javascript - How can I decrypt AES CBC Mode in Hex String? -
my task decrypt aes-128 in cbc mode have encrypted hex string , key (also in hex). have tried simple code like:
function dodecrypt(){ var encrypteddata = "1d4c76364618b6efce62258353f89810" var key = "11112222333344445555666677778888"; encrypteddata = cryptojs.enc.hex.parse(encrypteddata); key = cryptojs.enc.hex.parse(key); var decrypted = cryptojs.aes.decrypt(encrypteddata, key); alert(cryptojs.enc.hex.stringify(decrypted)); }
the result blank word array (in "decrpyted"), can point out did wrong please?
do need additional info such iv, salt or not?
"aes-128 in cbc mode" not info format. there no universal way of writing encrypted info along required metadata. need know you've been handed , how generated. can work out how implement same cryptojs in cases. in particular, need know following:
what algorithm? "aes-128" ambiguous. mean "aes 128-bit key size" or mean "aes 128-block size , other key size." what key size (see above) what mode? (you've answered this: it's cbc.) what padding? mutual pkcs#7, there no padding. (for cbc mode, pkcs#7.) what iv? there always iv cbc. iv incorrectly set null (this makes cbc less secure). possible iv generated somehow password (this how openssl works). do have key, insecure key, or password. key series of random bytes size of key. insecure key when password treated key (by copying human-typed letters key buffer). insanely insecure, common. if have proper password, kdf , parameters used convert key? example, did utilize openssl kdf or pbkdf2 or bcrypt or scrypt? is there other metadata, such hmac? (an hmac required secure aes-cbc. without it, attacker can modify ciphertext decrypt desired plaintext.)when have these answers, can work out how implement cryptojs.
javascript aes cryptojs
No comments:
Post a Comment