ruby - Why don't I need a 32 bit key, or initialization vector for NodeJS crypto? -


i working interchangeably node's crypto library , ruby's openssl library.

the challenge coming across encrypt usingaes256 in both libraries.

however, in node using crypto.createdecipher('aes256', key) have key less 32 bits long, ruby throw error saying key not long enough when using:

cipher = openssl::cipher.new 'aes256' cipher.encrypt key = 'geeses' 

i don't have set initialization vector node, ruby seems set 1 under covers. i'm pretty new crypto stuff, what's going on here?

when use crypto.createdecipher(), value pass second argument password key , iv derived (using 1 iteration of md5 hashing). accomplished using evp_bytestokey() create 2 values. openssl knows correct lengths both values need because cipher passed evp_bytestokey().

so ruby function more analogous node's crypto.createdecipheriv() accepts both key , iv (which need right lengths cipher).


Comments