diff options
author | Sverker Eriksson <[email protected]> | 2012-07-04 17:26:29 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2012-07-04 17:33:50 +0200 |
commit | 6faad239766accdcc007540f0b8b38d4709cd435 (patch) | |
tree | ae52b182816078c3fede13e65483b12d24e0a207 /lib/crypto/test/crypto_SUITE.erl | |
parent | 14f6a66f6410e1665ad39e95158420b0a45634d6 (diff) | |
download | otp-6faad239766accdcc007540f0b8b38d4709cd435.tar.gz otp-6faad239766accdcc007540f0b8b38d4709cd435.tar.bz2 otp-6faad239766accdcc007540f0b8b38d4709cd435.zip |
crypto: Allow aes_cfb_128_{en|de}crypt to accept unaligned data
Remove the need for padding up to 16-byte multiple.
Diffstat (limited to 'lib/crypto/test/crypto_SUITE.erl')
-rw-r--r-- | lib/crypto/test/crypto_SUITE.erl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/crypto/test/crypto_SUITE.erl b/lib/crypto/test/crypto_SUITE.erl index 627c966dfb..196f00da5d 100644 --- a/lib/crypto/test/crypto_SUITE.erl +++ b/lib/crypto/test/crypto_SUITE.erl @@ -717,10 +717,19 @@ aes_cfb(Config) when is_list(Config) -> ?line Key = hexstr2bin("2b7e151628aed2a6abf7158809cf4f3c"), ?line IVec = hexstr2bin("000102030405060708090a0b0c0d0e0f"), ?line Plain = hexstr2bin("6bc1bee22e409f96e93d7e117393172a"), - ?line Cipher = crypto:aes_cfb_128_encrypt(Key, IVec, Plain), - ?line m(Cipher, hexstr2bin("3b3fd92eb72dad20333449f8e83cfb4a")), - ?line m(Plain, - crypto:aes_cfb_128_decrypt(Key, IVec, Cipher)). + ?line Cipher = hexstr2bin("3b3fd92eb72dad20333449f8e83cfb4a"), + + %% Try all prefixes of plain and cipher. + aes_cfb_do(byte_size(Plain), Plain, Cipher, Key, IVec). + +aes_cfb_do(N, Plain, Cipher, Key, IVec) when N >= 0 -> + <<P:N/binary, _/binary>> = Plain, + <<C:N/binary, _/binary>> = Cipher, + ?line C = crypto:aes_cfb_128_encrypt(Key, IVec, P), + ?line P = crypto:aes_cfb_128_decrypt(Key, IVec, C), + aes_cfb_do(N-1, Plain, Cipher, Key, IVec); +aes_cfb_do(_, _, _, _, _) -> ok. + %% %% |