aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/tcrypt.c42
-rw-r--r--crypto/tcrypt.h165
2 files changed, 206 insertions, 1 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 8c8e2f95dc7e..f5e9da319ece 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -73,7 +73,7 @@ static char *check[] = {
73 "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 73 "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
74 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 74 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
75 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", 75 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
76 NULL 76 "camellia", NULL
77}; 77};
78 78
79static void hexdump(unsigned char *buf, unsigned int len) 79static void hexdump(unsigned char *buf, unsigned int len)
@@ -972,6 +972,20 @@ static void do_test(void)
972 test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template, 972 test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
973 FCRYPT_DEC_TEST_VECTORS); 973 FCRYPT_DEC_TEST_VECTORS);
974 974
975 //CAMELLIA
976 test_cipher("ecb(camellia)", ENCRYPT,
977 camellia_enc_tv_template,
978 CAMELLIA_ENC_TEST_VECTORS);
979 test_cipher("ecb(camellia)", DECRYPT,
980 camellia_dec_tv_template,
981 CAMELLIA_DEC_TEST_VECTORS);
982 test_cipher("cbc(camellia)", ENCRYPT,
983 camellia_cbc_enc_tv_template,
984 CAMELLIA_CBC_ENC_TEST_VECTORS);
985 test_cipher("cbc(camellia)", DECRYPT,
986 camellia_cbc_dec_tv_template,
987 CAMELLIA_CBC_DEC_TEST_VECTORS);
988
975 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); 989 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
976 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); 990 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
977 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS); 991 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
@@ -1196,6 +1210,21 @@ static void do_test(void)
1196 FCRYPT_DEC_TEST_VECTORS); 1210 FCRYPT_DEC_TEST_VECTORS);
1197 break; 1211 break;
1198 1212
1213 case 32:
1214 test_cipher("ecb(camellia)", ENCRYPT,
1215 camellia_enc_tv_template,
1216 CAMELLIA_ENC_TEST_VECTORS);
1217 test_cipher("ecb(camellia)", DECRYPT,
1218 camellia_dec_tv_template,
1219 CAMELLIA_DEC_TEST_VECTORS);
1220 test_cipher("cbc(camellia)", ENCRYPT,
1221 camellia_cbc_enc_tv_template,
1222 CAMELLIA_CBC_ENC_TEST_VECTORS);
1223 test_cipher("cbc(camellia)", DECRYPT,
1224 camellia_cbc_dec_tv_template,
1225 CAMELLIA_CBC_DEC_TEST_VECTORS);
1226 break;
1227
1199 case 100: 1228 case 100:
1200 test_hash("hmac(md5)", hmac_md5_tv_template, 1229 test_hash("hmac(md5)", hmac_md5_tv_template,
1201 HMAC_MD5_TEST_VECTORS); 1230 HMAC_MD5_TEST_VECTORS);
@@ -1289,6 +1318,17 @@ static void do_test(void)
1289 des_speed_template); 1318 des_speed_template);
1290 break; 1319 break;
1291 1320
1321 case 205:
1322 test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1323 camellia_speed_template);
1324 test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1325 camellia_speed_template);
1326 test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1327 camellia_speed_template);
1328 test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1329 camellia_speed_template);
1330 break;
1331
1292 case 300: 1332 case 300:
1293 /* fall through */ 1333 /* fall through */
1294 1334
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index ec77814d104e..887527bd5bc6 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -3688,6 +3688,150 @@ static struct cipher_testvec fcrypt_pcbc_dec_tv_template[] = {
3688}; 3688};
3689 3689
3690/* 3690/*
3691 * CAMELLIA test vectors.
3692 */
3693#define CAMELLIA_ENC_TEST_VECTORS 3
3694#define CAMELLIA_DEC_TEST_VECTORS 3
3695#define CAMELLIA_CBC_ENC_TEST_VECTORS 2
3696#define CAMELLIA_CBC_DEC_TEST_VECTORS 2
3697
3698static struct cipher_testvec camellia_enc_tv_template[] = {
3699 {
3700 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3701 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3702 .klen = 16,
3703 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3704 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3705 .ilen = 16,
3706 .result = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
3707 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
3708 .rlen = 16,
3709 }, {
3710 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3711 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3712 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
3713 .klen = 24,
3714 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3715 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3716 .ilen = 16,
3717 .result = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
3718 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
3719 .rlen = 16,
3720 }, {
3721 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3722 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3723 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3724 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
3725 .klen = 32,
3726 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3727 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3728 .ilen = 16,
3729 .result = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
3730 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
3731 .rlen = 16,
3732 },
3733};
3734
3735static struct cipher_testvec camellia_dec_tv_template[] = {
3736 {
3737 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3738 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3739 .klen = 16,
3740 .input = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
3741 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
3742 .ilen = 16,
3743 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3744 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3745 .rlen = 16,
3746 }, {
3747 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3748 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3749 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
3750 .klen = 24,
3751 .input = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
3752 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
3753 .ilen = 16,
3754 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3755 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3756 .rlen = 16,
3757 }, {
3758 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3759 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3760 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3761 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
3762 .klen = 32,
3763 .input = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
3764 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
3765 .ilen = 16,
3766 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3767 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3768 .rlen = 16,
3769 },
3770};
3771
3772static struct cipher_testvec camellia_cbc_enc_tv_template[] = {
3773 {
3774 .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
3775 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
3776 .klen = 16,
3777 .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
3778 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
3779 .input = { "Single block msg" },
3780 .ilen = 16,
3781 .result = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
3782 0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
3783 .rlen = 16,
3784 }, {
3785 .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
3786 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
3787 .klen = 16,
3788 .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
3789 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
3790 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3791 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3792 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3793 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
3794 .ilen = 32,
3795 .result = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
3796 0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
3797 0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
3798 0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
3799 .rlen = 32,
3800 },
3801};
3802
3803static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
3804 {
3805 .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
3806 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
3807 .klen = 16,
3808 .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
3809 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
3810 .input = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
3811 0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
3812 .ilen = 16,
3813 .result = { "Single block msg" },
3814 .rlen = 16,
3815 }, {
3816 .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
3817 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
3818 .klen = 16,
3819 .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
3820 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
3821 .input = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
3822 0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
3823 0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
3824 0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
3825 .ilen = 32,
3826 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3827 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3828 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3829 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
3830 .rlen = 32,
3831 },
3832};
3833
3834/*
3691 * Compression stuff. 3835 * Compression stuff.
3692 */ 3836 */
3693#define COMP_BUF_SIZE 512 3837#define COMP_BUF_SIZE 512
@@ -4140,4 +4284,25 @@ static struct hash_speed generic_hash_speed_template[] = {
4140 { .blen = 0, .plen = 0, } 4284 { .blen = 0, .plen = 0, }
4141}; 4285};
4142 4286
4287static struct cipher_speed camellia_speed_template[] = {
4288 { .klen = 16, .blen = 16, },
4289 { .klen = 16, .blen = 64, },
4290 { .klen = 16, .blen = 256, },
4291 { .klen = 16, .blen = 1024, },
4292 { .klen = 16, .blen = 8192, },
4293 { .klen = 24, .blen = 16, },
4294 { .klen = 24, .blen = 64, },
4295 { .klen = 24, .blen = 256, },
4296 { .klen = 24, .blen = 1024, },
4297 { .klen = 24, .blen = 8192, },
4298 { .klen = 32, .blen = 16, },
4299 { .klen = 32, .blen = 64, },
4300 { .klen = 32, .blen = 256, },
4301 { .klen = 32, .blen = 1024, },
4302 { .klen = 32, .blen = 8192, },
4303
4304 /* End marker */
4305 { .klen = 0, .blen = 0, }
4306};
4307
4143#endif /* _CRYPTO_TCRYPT_H */ 4308#endif /* _CRYPTO_TCRYPT_H */