This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Difference between Container Encryption and Item Encryption | |
// (Short answer: Item Encryption & decryption is identical to container encryoption and decryoption, just 1 step & simpler with no diffs, etc) | |
// Containers Encryption: | |
// https://github.com/SpiderOak/crypton/blob/a7e6a76f0c099ef2762c27f85f474bfb1c62727b/client/src/session.js#L663-L699 | |
var selfPeer = new crypton.Peer({ | |
session: this, | |
pubKey: this.account.pubKey, | |
signKeyPub: this.account.signKeyPub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: | |
Date/Time: | |
Kloak Version: | |
1. Install Kloak from Apple Test Flight | |
* Bugs, Problems: | |
--- |