aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.c
diff options
context:
space:
mode:
authorJoy Latten <latten@austin.ibm.com>2007-11-07 09:59:47 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-10 16:16:08 -0500
commit41fdab3dd385dde36caae60ed2df82aecb7a32f0 (patch)
treeaed4c4e7630cebc8b66d33fa6e26ec20f564bbd8 /crypto/tcrypt.c
parentd3e7480572bf882dee5baa2891bccbfa3db0b1a1 (diff)
[CRYPTO] ctr: Add countersize
This patch adds countersize to CTR mode. The template is now ctr(algo,noncesize,ivsize,countersize). For example, ctr(aes,4,8,4) indicates the counterblock will be composed of a salt/nonce that is 4 bytes, an iv that is 8 bytes and the counter is 4 bytes. When noncesize + ivsize < blocksize, CTR initializes the last block - ivsize - noncesize portion of the block to zero. Otherwise the counter block is composed of the IV (and nonce if necessary). If noncesize + ivsize == blocksize, then this indicates that user is passing in entire counterblock. Thus countersize indicates the amount of bytes in counterblock to use as the counter for incrementing. CTR will increment counter portion by 1, and begin encryption with that value. Note that CTR assumes the counter portion of the block that will be incremented is stored in big endian. Signed-off-by: Joy Latten <latten@austin.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r--crypto/tcrypt.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 640cbcad32a1..aa84bc4f2313 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -969,9 +969,9 @@ static void do_test(void)
969 AES_XTS_ENC_TEST_VECTORS); 969 AES_XTS_ENC_TEST_VECTORS);
970 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template, 970 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
971 AES_XTS_DEC_TEST_VECTORS); 971 AES_XTS_DEC_TEST_VECTORS);
972 test_cipher("ctr(aes,4,8)", ENCRYPT, aes_ctr_enc_tv_template, 972 test_cipher("ctr(aes,4,8,4)", ENCRYPT, aes_ctr_enc_tv_template,
973 AES_CTR_ENC_TEST_VECTORS); 973 AES_CTR_ENC_TEST_VECTORS);
974 test_cipher("ctr(aes,4,8)", DECRYPT, aes_ctr_dec_tv_template, 974 test_cipher("ctr(aes,4,8,4)", DECRYPT, aes_ctr_dec_tv_template,
975 AES_CTR_DEC_TEST_VECTORS); 975 AES_CTR_DEC_TEST_VECTORS);
976 976
977 //CAST5 977 //CAST5
@@ -1160,9 +1160,9 @@ static void do_test(void)
1160 AES_XTS_ENC_TEST_VECTORS); 1160 AES_XTS_ENC_TEST_VECTORS);
1161 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template, 1161 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
1162 AES_XTS_DEC_TEST_VECTORS); 1162 AES_XTS_DEC_TEST_VECTORS);
1163 test_cipher("ctr(aes,4,8)", ENCRYPT, aes_ctr_enc_tv_template, 1163 test_cipher("ctr(aes,4,8,4)", ENCRYPT, aes_ctr_enc_tv_template,
1164 AES_CTR_ENC_TEST_VECTORS); 1164 AES_CTR_ENC_TEST_VECTORS);
1165 test_cipher("ctr(aes,4,8)", DECRYPT, aes_ctr_dec_tv_template, 1165 test_cipher("ctr(aes,4,8,4)", DECRYPT, aes_ctr_dec_tv_template,
1166 AES_CTR_DEC_TEST_VECTORS); 1166 AES_CTR_DEC_TEST_VECTORS);
1167 break; 1167 break;
1168 1168