diff options
| author | Jarod Wilson <jarod@redhat.com> | 2009-05-06 05:29:17 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-06-02 00:04:46 -0400 |
| commit | f7cb80f2b9fa06730be20d17c80b12e511a36c1c (patch) | |
| tree | 09bf6f66a518adbceb32b8821b671af3f2f216ac /crypto | |
| parent | f8b0d4d09dc9d0a73fcdcf6c2724650529ec417d (diff) | |
crypto: testmgr - Add ctr(aes) test vectors
Now with multi-block test vectors, all from SP800-38A, Appendix F.5.
Also added ctr(aes) to case 10 in tcrypt.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/tcrypt.c | 1 | ||||
| -rw-r--r-- | crypto/testmgr.c | 23 | ||||
| -rw-r--r-- | crypto/testmgr.h | 166 |
3 files changed, 183 insertions, 7 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index ea3b8a8db721..9e4974eb7825 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
| @@ -526,6 +526,7 @@ static void do_test(int m) | |||
| 526 | tcrypt_test("cbc(aes)"); | 526 | tcrypt_test("cbc(aes)"); |
| 527 | tcrypt_test("lrw(aes)"); | 527 | tcrypt_test("lrw(aes)"); |
| 528 | tcrypt_test("xts(aes)"); | 528 | tcrypt_test("xts(aes)"); |
| 529 | tcrypt_test("ctr(aes)"); | ||
| 529 | tcrypt_test("rfc3686(ctr(aes))"); | 530 | tcrypt_test("rfc3686(ctr(aes))"); |
| 530 | break; | 531 | break; |
| 531 | 532 | ||
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index c5550943411d..f4cc1780aee2 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
| @@ -1568,6 +1568,21 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 1568 | } | 1568 | } |
| 1569 | } | 1569 | } |
| 1570 | }, { | 1570 | }, { |
| 1571 | .alg = "ctr(aes)", | ||
| 1572 | .test = alg_test_skcipher, | ||
| 1573 | .suite = { | ||
| 1574 | .cipher = { | ||
| 1575 | .enc = { | ||
| 1576 | .vecs = aes_ctr_enc_tv_template, | ||
| 1577 | .count = AES_CTR_ENC_TEST_VECTORS | ||
| 1578 | }, | ||
| 1579 | .dec = { | ||
| 1580 | .vecs = aes_ctr_dec_tv_template, | ||
| 1581 | .count = AES_CTR_DEC_TEST_VECTORS | ||
| 1582 | } | ||
| 1583 | } | ||
| 1584 | } | ||
| 1585 | }, { | ||
| 1571 | .alg = "cts(cbc(aes))", | 1586 | .alg = "cts(cbc(aes))", |
| 1572 | .test = alg_test_skcipher, | 1587 | .test = alg_test_skcipher, |
| 1573 | .suite = { | 1588 | .suite = { |
| @@ -2017,12 +2032,12 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 2017 | .suite = { | 2032 | .suite = { |
| 2018 | .cipher = { | 2033 | .cipher = { |
| 2019 | .enc = { | 2034 | .enc = { |
| 2020 | .vecs = aes_ctr_enc_tv_template, | 2035 | .vecs = aes_ctr_rfc3686_enc_tv_template, |
| 2021 | .count = AES_CTR_ENC_TEST_VECTORS | 2036 | .count = AES_CTR_3686_ENC_TEST_VECTORS |
| 2022 | }, | 2037 | }, |
| 2023 | .dec = { | 2038 | .dec = { |
| 2024 | .vecs = aes_ctr_dec_tv_template, | 2039 | .vecs = aes_ctr_rfc3686_dec_tv_template, |
| 2025 | .count = AES_CTR_DEC_TEST_VECTORS | 2040 | .count = AES_CTR_3686_DEC_TEST_VECTORS |
| 2026 | } | 2041 | } |
| 2027 | } | 2042 | } |
| 2028 | } | 2043 | } |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index c1c709b57ddb..69316228fc19 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
| @@ -2854,8 +2854,10 @@ static struct cipher_testvec cast6_dec_tv_template[] = { | |||
| 2854 | #define AES_LRW_DEC_TEST_VECTORS 8 | 2854 | #define AES_LRW_DEC_TEST_VECTORS 8 |
| 2855 | #define AES_XTS_ENC_TEST_VECTORS 4 | 2855 | #define AES_XTS_ENC_TEST_VECTORS 4 |
| 2856 | #define AES_XTS_DEC_TEST_VECTORS 4 | 2856 | #define AES_XTS_DEC_TEST_VECTORS 4 |
| 2857 | #define AES_CTR_ENC_TEST_VECTORS 7 | 2857 | #define AES_CTR_ENC_TEST_VECTORS 3 |
| 2858 | #define AES_CTR_DEC_TEST_VECTORS 6 | 2858 | #define AES_CTR_DEC_TEST_VECTORS 3 |
| 2859 | #define AES_CTR_3686_ENC_TEST_VECTORS 7 | ||
| 2860 | #define AES_CTR_3686_DEC_TEST_VECTORS 6 | ||
| 2859 | #define AES_GCM_ENC_TEST_VECTORS 9 | 2861 | #define AES_GCM_ENC_TEST_VECTORS 9 |
| 2860 | #define AES_GCM_DEC_TEST_VECTORS 8 | 2862 | #define AES_GCM_DEC_TEST_VECTORS 8 |
| 2861 | #define AES_CCM_ENC_TEST_VECTORS 7 | 2863 | #define AES_CCM_ENC_TEST_VECTORS 7 |
| @@ -3998,6 +4000,164 @@ static struct cipher_testvec aes_xts_dec_tv_template[] = { | |||
| 3998 | 4000 | ||
| 3999 | 4001 | ||
| 4000 | static struct cipher_testvec aes_ctr_enc_tv_template[] = { | 4002 | static struct cipher_testvec aes_ctr_enc_tv_template[] = { |
| 4003 | { /* From NIST Special Publication 800-38A, Appendix F.5 */ | ||
| 4004 | .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" | ||
| 4005 | "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", | ||
| 4006 | .klen = 16, | ||
| 4007 | .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
| 4008 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
| 4009 | .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" | ||
| 4010 | "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" | ||
| 4011 | "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" | ||
| 4012 | "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" | ||
| 4013 | "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" | ||
| 4014 | "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" | ||
| 4015 | "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" | ||
| 4016 | "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", | ||
| 4017 | .ilen = 64, | ||
| 4018 | .result = "\x87\x4d\x61\x91\xb6\x20\xe3\x26" | ||
| 4019 | "\x1b\xef\x68\x64\x99\x0d\xb6\xce" | ||
| 4020 | "\x98\x06\xf6\x6b\x79\x70\xfd\xff" | ||
| 4021 | "\x86\x17\x18\x7b\xb9\xff\xfd\xff" | ||
| 4022 | "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e" | ||
| 4023 | "\x5b\x4f\x09\x02\x0d\xb0\x3e\xab" | ||
| 4024 | "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1" | ||
| 4025 | "\x79\x21\x70\xa0\xf3\x00\x9c\xee", | ||
| 4026 | .rlen = 64, | ||
| 4027 | }, { | ||
| 4028 | .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" | ||
| 4029 | "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" | ||
| 4030 | "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", | ||
| 4031 | .klen = 24, | ||
| 4032 | .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
| 4033 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
| 4034 | .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" | ||
| 4035 | "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" | ||
| 4036 | "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" | ||
| 4037 | "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" | ||
| 4038 | "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" | ||
| 4039 | "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" | ||
| 4040 | "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" | ||
| 4041 | "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", | ||
| 4042 | .ilen = 64, | ||
| 4043 | .result = "\x1a\xbc\x93\x24\x17\x52\x1c\xa2" | ||
| 4044 | "\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b" | ||
| 4045 | "\x09\x03\x39\xec\x0a\xa6\xfa\xef" | ||
| 4046 | "\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94" | ||
| 4047 | "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70" | ||
| 4048 | "\xd1\xbd\x1d\x66\x56\x20\xab\xf7" | ||
| 4049 | "\x4f\x78\xa7\xf6\xd2\x98\x09\x58" | ||
| 4050 | "\x5a\x97\xda\xec\x58\xc6\xb0\x50", | ||
| 4051 | .rlen = 64, | ||
| 4052 | }, { | ||
| 4053 | .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" | ||
| 4054 | "\x2b\x73\xae\xf0\x85\x7d\x77\x81" | ||
| 4055 | "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" | ||
| 4056 | "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", | ||
| 4057 | .klen = 32, | ||
| 4058 | .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
| 4059 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
| 4060 | .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" | ||
| 4061 | "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" | ||
| 4062 | "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" | ||
| 4063 | "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" | ||
| 4064 | "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" | ||
| 4065 | "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" | ||
| 4066 | "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" | ||
| 4067 | "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", | ||
| 4068 | .ilen = 64, | ||
| 4069 | .result = "\x60\x1e\xc3\x13\x77\x57\x89\xa5" | ||
| 4070 | "\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28" | ||
| 4071 | "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a" | ||
| 4072 | "\xca\x84\xe9\x90\xca\xca\xf5\xc5" | ||
| 4073 | "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c" | ||
| 4074 | "\xe8\x70\x17\xba\x2d\x84\x98\x8d" | ||
| 4075 | "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6" | ||
| 4076 | "\x13\xc2\xdd\x08\x45\x79\x41\xa6", | ||
| 4077 | .rlen = 64, | ||
| 4078 | } | ||
| 4079 | }; | ||
| 4080 | |||
| 4081 | static struct cipher_testvec aes_ctr_dec_tv_template[] = { | ||
| 4082 | { /* From NIST Special Publication 800-38A, Appendix F.5 */ | ||
| 4083 | .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" | ||
| 4084 | "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", | ||
| 4085 | .klen = 16, | ||
| 4086 | .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
| 4087 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
| 4088 | .input = "\x87\x4d\x61\x91\xb6\x20\xe3\x26" | ||
| 4089 | "\x1b\xef\x68\x64\x99\x0d\xb6\xce" | ||
| 4090 | "\x98\x06\xf6\x6b\x79\x70\xfd\xff" | ||
| 4091 | "\x86\x17\x18\x7b\xb9\xff\xfd\xff" | ||
| 4092 | "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e" | ||
| 4093 | "\x5b\x4f\x09\x02\x0d\xb0\x3e\xab" | ||
| 4094 | "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1" | ||
| 4095 | "\x79\x21\x70\xa0\xf3\x00\x9c\xee", | ||
| 4096 | .ilen = 64, | ||
| 4097 | .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" | ||
| 4098 | "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" | ||
| 4099 | "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" | ||
| 4100 | "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" | ||
| 4101 | "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" | ||
| 4102 | "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" | ||
| 4103 | "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" | ||
| 4104 | "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", | ||
| 4105 | .rlen = 64, | ||
| 4106 | }, { | ||
| 4107 | .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" | ||
| 4108 | "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" | ||
| 4109 | "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", | ||
| 4110 | .klen = 24, | ||
| 4111 | .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
| 4112 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
| 4113 | .input = "\x1a\xbc\x93\x24\x17\x52\x1c\xa2" | ||
| 4114 | "\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b" | ||
| 4115 | "\x09\x03\x39\xec\x0a\xa6\xfa\xef" | ||
| 4116 | "\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94" | ||
| 4117 | "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70" | ||
| 4118 | "\xd1\xbd\x1d\x66\x56\x20\xab\xf7" | ||
| 4119 | "\x4f\x78\xa7\xf6\xd2\x98\x09\x58" | ||
| 4120 | "\x5a\x97\xda\xec\x58\xc6\xb0\x50", | ||
| 4121 | .ilen = 64, | ||
| 4122 | .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" | ||
| 4123 | "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" | ||
| 4124 | "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" | ||
| 4125 | "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" | ||
| 4126 | "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" | ||
| 4127 | "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" | ||
| 4128 | "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" | ||
| 4129 | "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", | ||
| 4130 | .rlen = 64, | ||
| 4131 | }, { | ||
| 4132 | .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" | ||
| 4133 | "\x2b\x73\xae\xf0\x85\x7d\x77\x81" | ||
| 4134 | "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" | ||
| 4135 | "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", | ||
| 4136 | .klen = 32, | ||
| 4137 | .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
| 4138 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
| 4139 | .input = "\x60\x1e\xc3\x13\x77\x57\x89\xa5" | ||
| 4140 | "\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28" | ||
| 4141 | "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a" | ||
| 4142 | "\xca\x84\xe9\x90\xca\xca\xf5\xc5" | ||
| 4143 | "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c" | ||
| 4144 | "\xe8\x70\x17\xba\x2d\x84\x98\x8d" | ||
| 4145 | "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6" | ||
| 4146 | "\x13\xc2\xdd\x08\x45\x79\x41\xa6", | ||
| 4147 | .ilen = 64, | ||
| 4148 | .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" | ||
| 4149 | "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" | ||
| 4150 | "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" | ||
| 4151 | "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" | ||
| 4152 | "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" | ||
| 4153 | "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" | ||
| 4154 | "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" | ||
| 4155 | "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", | ||
| 4156 | .rlen = 64, | ||
| 4157 | } | ||
| 4158 | }; | ||
| 4159 | |||
| 4160 | static struct cipher_testvec aes_ctr_rfc3686_enc_tv_template[] = { | ||
| 4001 | { /* From RFC 3686 */ | 4161 | { /* From RFC 3686 */ |
| 4002 | .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc" | 4162 | .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc" |
| 4003 | "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e" | 4163 | "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e" |
| @@ -5129,7 +5289,7 @@ static struct cipher_testvec aes_ctr_enc_tv_template[] = { | |||
| 5129 | }, | 5289 | }, |
| 5130 | }; | 5290 | }; |
| 5131 | 5291 | ||
| 5132 | static struct cipher_testvec aes_ctr_dec_tv_template[] = { | 5292 | static struct cipher_testvec aes_ctr_rfc3686_dec_tv_template[] = { |
| 5133 | { /* From RFC 3686 */ | 5293 | { /* From RFC 3686 */ |
| 5134 | .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc" | 5294 | .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc" |
| 5135 | "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e" | 5295 | "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e" |
