nagenndrababu / crypto-js

Automatically exported from code.google.com/p/crypto-js
0 stars 0 forks source link

Add 8-bit CFB segment size support #92

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Encrypt data with OpenSSL, using 256-bit AES with 128-bit segment size, e.g.:
openssl enc -e -aes-256-cfb -in <(echo -n plaintext) -out /dev/stdout -K 
2c70e12b7a0646f92279f427c7b38e7334d8e5389cff167a1dc30e73f826b683 -iv 
0123456789abcdef0123456789abcdef -base64

2. Decrypt the ciphertext with CryptoJS
var ciphertext = "ztVRBx6+mY/u";
var key = 
CryptoJS.enc.Hex.parse("2c70e12b7a0646f92279f427c7b38e7334d8e5389cff167a1dc30e73
f826b683");
var iv = CryptoJS.enc.Hex.parse('0123456789abcdef0123456789abcdef');
var decrypted = CryptoJS.AES.decrypt(ciphertext, key, {
  mode: CryptoJS.mode.CFB,
  padding: CryptoJS.pad.NoPadding,
  iv: iv,
});
var plaintext = decrypted.toString(CryptoJS.enc.Utf8);

3. The above works. However, if you replace -aes-256-cfb (128 bit segment size) 
with -aes-256-cfb8 (8 bit segment size), the decryption fails.

CryptoJS should do one of the following:
1. Add support for 8 bit segment size. Some software libraries (e.g. PyCrypto) 
defaults to 8 bit segment size and their ciphertext can't be decrypted with 
CryptoJS.

2. If 8 bit segment size support is not possible or desirable, please document 
that CryptoJS only supports 128 bit segment size. The documentation currently 
does not state that.

What version of the product are you using? On what operating system?
CryptoJS v3.1.2
Ubuntu 12.04

Original issue reported on code.google.com by netv...@gmail.com on 24 Aug 2013 at 1:30