Sjcl.encrypt using AES or SHA256

I use the SJCL library to encrypt / decrypt messages. I have a question that I do not know what AES or SHA256 is used

Here is my code:

var h = sjcl.codec.hex, count = 2048 ; salt = h.fromBits(sjcl.random.randomWords('10','0')); var key = h.fromBits( sjcl.misc.pbkdf2(somePassword, h.toBits(salt), count) ) ; 

Further I can encrypt / decrypt, for example

 var encMessage = sjcl.encrypt(key, message) ; sjcl.decrypt(key, encMessage) ; 

AES or SHA256 or something else?

+1
source share
3 answers

pbkdf2 uses HMAC with SHA256 to generate keys. But the default encryption key size with sjcl for AES-CCM is only 128 bits. If you want AES-CCM-256 , I think you need to do the following: you also do not need to call pbkdf2 directly.

 var encMessage =sjcl.encrypt(somePassword,message,{count:2048,salt:salt,ks:256}); 
+5
source

SHA256 and AES are two different types of algorithms.

SHA256 is a hash function of cryptography: http://en.wikipedia.org/wiki/SHA-2

AES is an encryption algorithm: http://en.wikipedia.org/wiki/Advanced_Encryption_Standard

So, in your case, when using encryption, you are actually using AES.

+6
source

Based on a quick check of the source , I would suggest using AES in CCM mode .

The SJCL page explains the cryptographic methods used, although admittedly the documentation for each function does not explain at all.

+1
source

All Articles