-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
Lines 5 to 11 in c77c2d7
| function encrypt(data, key) { | |
| return CryptoJS.AES.encrypt(data, key).toString(); | |
| } | |
| function decrypt(data, key) { | |
| return CryptoJS.AES.decrypt(data, key).toString(CryptoJS.enc.Utf8); | |
| } |
You're using unauthenticated AES-CBC. https://paragonie.com/blog/2015/05/using-encryption-and-authentication-correctly
Your About section says:
Since nobody can modify the code, and nobody can view the key unless you show it to them, nobody without the key can either read the plaintext or ship a malicious viewer which would exfiltrate the plaintext (or key).
...but this is strictly not true with unauthenticated encryption. In fact, you can recover the plaintext with a padding oracle attack.
Also, your RNG is biased.
Lines 13 to 25 in c77c2d7
| function generate_key() { | |
| var alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| var randombytes = new Uint8Array(32); | |
| crypto.getRandomValues(randombytes); | |
| var k = ''; | |
| for (var i = 0; i < 32; i++) { | |
| var idx = Math.floor(randombytes[i] * alphabet.length / 256); | |
| k += alphabet.charAt(idx); | |
| } | |
| return k; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels