aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/encrypt_object.js43
-rw-r--r--crypto/test-pem.js (renamed from crypto/test.js)0
2 files changed, 43 insertions, 0 deletions
diff --git a/crypto/encrypt_object.js b/crypto/encrypt_object.js
new file mode 100644
index 0000000..b2efa8b
--- /dev/null
+++ b/crypto/encrypt_object.js
@@ -0,0 +1,43 @@
+load('jsbn.js')
+load('jsbn2.js')
+load('rsa.js')
+load('rsa2.js')
+load('sjcl.js')
+load('prng4.js')
+load('rng.js')
+
+var root = '/var/lib/alias'
+var priv_key_string = read(root + '/guillaume@alias.im/privkey/object')
+var pub_key_string1 = read(root + '/guillaume@alias.im/pubkey/object')
+var pub_key_string2 = read(root + '/thrasibule@alias.im/pubkey/object')
+var pub_key1 = new RSAKey()
+var pub_key1_json = JSON.parse(pub_key_string1)
+pub_key1.setPublic(pub_key1_json.n,pub_key1_json.e)
+var pub_key2 = new RSAKey()
+var pub_key2_json = JSON.parse(pub_key_string2)
+pub_key2.setPublic(pub_key2_json.n,pub_key2_json.e)
+
+
+varpriv_key = sjcl.decrypt("Mvdujq06",priv_key_string)
+
+var profile = '<h2><span id="firstname">John</span> <span id="lastname">Doe</span></h2>\
+<ul>\
+<li><span class="description">Sex:</span> <span id="sex" class="editable">Male</span></li>\
+<li><span class="description">Born:</span> <span id="birthdate" class="editable">02/02/1980</span></li>\
+<li><span class="description">Email:</span> <span id="email" class="editable">john.doe@alias.im</li>\
+<li><span class="description">Adress:</span> <span id="adress" class="editable">450 W. 33 Street</span>\
+<span id="city" class="editable">New York City</span> </li>\
+<ul>'
+
+//sjcl.random.startCollectors()
+var aeskey = sjcl.random.randomWords(4,0)
+var aeskeyb64 = sjcl.codec.base64.fromBits(aeskey)
+var object = sjcl.encrypt(aeskey,profile)
+var enckey1 = pub_key1.encrypt(aeskeyb64)
+var enckey2 = pub_key2.encrypt(aeskeyb64)
+print("This is the content of the encrypted object:")
+print(object)
+print("This is the encryption key encrypted with the public key of guillaume@alias.im")
+print(enckey1)
+print("This is the encryption key encrypted with the public key of thrasibule@alias.im")
+print(enckey2)
diff --git a/crypto/test.js b/crypto/test-pem.js
index 91c0dc4..91c0dc4 100644
--- a/crypto/test.js
+++ b/crypto/test-pem.js