Skip to content

Instantly share code, notes, and snippets.

View daviddahl's full-sized avatar
💭
burning the midnight oil

David Dahl daviddahl

💭
burning the midnight oil
View GitHub Profile
@daviddahl
daviddahl / tests-working
Created March 4, 2014 17:40
Crypton tests diff
diff --git a/server/Makefile b/server/Makefile
index ff9bdc7..210a5b5 100644
--- a/server/Makefile
+++ b/server/Makefile
@@ -3,6 +3,9 @@ test: test-unit
test-unit: clean node_modules
@NODE_ENV=test ./node_modules/.bin/mocha -R spec
+test-debug: clean node_modules
+ @NODE_ENV=test ./node_modules/.bin/mocha -R spec -d --debug-brk

Keybase proof

I hereby claim:

  • I am daviddahl on github.
  • I am ddahl (https://keybase.io/ddahl) on keybase.
  • I have a public key whose fingerprint is 0FF0 2B5E 7148 FA97 0A22 0C12 4BA5 2DBB 2ADE D0CD

To claim this, I am signing this object:

#define SALT_LENGTH 16
int generateKeyFromPassword(char* passphrase, struct keyItem* item)
{
int i;
unsigned char* salt = gcry_random_bytes(SALT_LENGTH, GCRY_STRONG_RANDOM);
char* keyBuffer;
size_t keySize = 32;
gpg_error_t err;
unsigned long iterations = 10000;
@daviddahl
daviddahl / wtf-fails.c
Created May 29, 2014 17:17
WTF-fails.c
int generateKeyFromPassword(char* passphrase, struct keyItem* item)
{
int i;
unsigned char* salt = gcry_random_bytes(16, GCRY_STRONG_RANDOM);
char* keyBuffer;
size_t saltLen = 16;
size_t keySize = 32;
gpg_error_t err;
unsigned long iterations = 10000;
(gdb) break gcry_kdf_derive
Breakpoint 3 at 0x7ffff7b65180
(gdb) r
Starting program: /home/ddahl/code/spideroak/daviddahl/crypton/client/native/src/./pbkdf
Breakpoint 3, 0x00007ffff7b65180 in gcry_kdf_derive () from /lib/x86_64-linux-gnu/libgcrypt.so.11
(gdb) s
Single stepping until exit from function gcry_kdf_derive,
which has no line number information.
generateKeyFromPassword (passphrase=0x401a5b "password", item=0x7fffffffe118) at pbkdf2.c:45
var app = {};
app.createUser = function(user, password) {
crypton.generateAccount(user, password, function (err, account){
if (err) { console.error(err); return;}
console.log(account);
})
};
app.auth = function (username, password) {
createItem("my-dossier9", {name: 'foo', address: 123, city: 'chicago'});
window.session.items;
Object {my-dossier8: Item, my-dossier9: Item}
window.session.items['my-dossier8'].value
Object {name: "foo", address: 123, city: "chicago"}
CREATE OR REPLACE FUNCTION notifyUpdatediItem() RETURNS TRIGGER AS $$
DECLARE
rec RECORD;
BEGIN
FOR rec IN (SELECT getSharedItemNotifees(NEW.item_id)) LOOP
PERFORM pg_notify('SharedItemUpdated', CAST(rec.to_account_id AS text)|| ' ' || CAST(NEW.name_hmac AS text));
END LOOP;
END;
$$ LANGUAGE PLPGSQL;
CREATE OR REPLACE FUNCTION notifyUpdatedItem() RETURNS TRIGGER AS $$
DECLARE
notify_row RECORD;
BEGIN
FOR notify_row IN
SELECT s.item_session_key_share_id,
s.account_id, s.to_account_id, k.item_id,
a.username as toUser, b.username AS fromUser
FROM item_session_key_share s
JOIN item_session_key k ON
@daviddahl
daviddahl / items-api.js
Last active August 29, 2015 14:17
Crypton Items API
// We use session.getOrCreateItem in order to create a new item that we can share with others
app.session.getOrCreateItem('myReport', function (err, report) {
if (err) {
callback(err);
return console.error(err);
}
// update the report
report.value = { updated: Date.now(), reportContent: app.reportContent };
// share this data: