aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/tcrypt.c1
-rw-r--r--crypto/testmgr.c15
-rw-r--r--crypto/testmgr.h226
3 files changed, 238 insertions, 4 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 91f3ab4e3a90..0c4e80f34651 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -788,6 +788,7 @@ static int do_test(int m)
788 case 8: 788 case 8:
789 ret += tcrypt_test("ecb(twofish)"); 789 ret += tcrypt_test("ecb(twofish)");
790 ret += tcrypt_test("cbc(twofish)"); 790 ret += tcrypt_test("cbc(twofish)");
791 ret += tcrypt_test("ctr(twofish)");
791 break; 792 break;
792 793
793 case 9: 794 case 9:
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 466f9c01e480..e91c1eb1722a 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1771,6 +1771,21 @@ static const struct alg_test_desc alg_test_descs[] = {
1771 } 1771 }
1772 } 1772 }
1773 }, { 1773 }, {
1774 .alg = "ctr(twofish)",
1775 .test = alg_test_skcipher,
1776 .suite = {
1777 .cipher = {
1778 .enc = {
1779 .vecs = tf_ctr_enc_tv_template,
1780 .count = TF_CTR_ENC_TEST_VECTORS
1781 },
1782 .dec = {
1783 .vecs = tf_ctr_dec_tv_template,
1784 .count = TF_CTR_DEC_TEST_VECTORS
1785 }
1786 }
1787 }
1788 }, {
1774 .alg = "cts(cbc(aes))", 1789 .alg = "cts(cbc(aes))",
1775 .test = alg_test_skcipher, 1790 .test = alg_test_skcipher,
1776 .suite = { 1791 .suite = {
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index a51902242261..37b4d8f45447 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -2711,10 +2711,12 @@ static struct cipher_testvec bf_ctr_dec_tv_template[] = {
2711/* 2711/*
2712 * Twofish test vectors. 2712 * Twofish test vectors.
2713 */ 2713 */
2714#define TF_ENC_TEST_VECTORS 3 2714#define TF_ENC_TEST_VECTORS 4
2715#define TF_DEC_TEST_VECTORS 3 2715#define TF_DEC_TEST_VECTORS 4
2716#define TF_CBC_ENC_TEST_VECTORS 4 2716#define TF_CBC_ENC_TEST_VECTORS 5
2717#define TF_CBC_DEC_TEST_VECTORS 4 2717#define TF_CBC_DEC_TEST_VECTORS 5
2718#define TF_CTR_ENC_TEST_VECTORS 2
2719#define TF_CTR_DEC_TEST_VECTORS 2
2718 2720
2719static struct cipher_testvec tf_enc_tv_template[] = { 2721static struct cipher_testvec tf_enc_tv_template[] = {
2720 { 2722 {
@@ -2746,6 +2748,30 @@ static struct cipher_testvec tf_enc_tv_template[] = {
2746 .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8" 2748 .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
2747 "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20", 2749 "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
2748 .rlen = 16, 2750 .rlen = 16,
2751 }, { /* Generated with Crypto++ */
2752 .key = "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C"
2753 "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D"
2754 "\x4A\x27\x04\xE1\x27\x04\xE1\xBE"
2755 "\x9B\x78\xBE\x9B\x78\x55\x32\x0F",
2756 .klen = 32,
2757 .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2758 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2759 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2760 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2761 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2762 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2763 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2764 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2765 .ilen = 64,
2766 .result = "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF"
2767 "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC"
2768 "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D"
2769 "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14"
2770 "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5"
2771 "\xDF\xFA\xC7\xE8\x09\x50\x76\x08"
2772 "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05"
2773 "\x89\xF6\x82\xF0\xD3\xDB\x06\x02",
2774 .rlen = 64,
2749 }, 2775 },
2750}; 2776};
2751 2777
@@ -2779,6 +2805,30 @@ static struct cipher_testvec tf_dec_tv_template[] = {
2779 .ilen = 16, 2805 .ilen = 16,
2780 .result = zeroed_string, 2806 .result = zeroed_string,
2781 .rlen = 16, 2807 .rlen = 16,
2808 }, { /* Generated with Crypto++ */
2809 .key = "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C"
2810 "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D"
2811 "\x4A\x27\x04\xE1\x27\x04\xE1\xBE"
2812 "\x9B\x78\xBE\x9B\x78\x55\x32\x0F",
2813 .klen = 32,
2814 .input = "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF"
2815 "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC"
2816 "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D"
2817 "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14"
2818 "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5"
2819 "\xDF\xFA\xC7\xE8\x09\x50\x76\x08"
2820 "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05"
2821 "\x89\xF6\x82\xF0\xD3\xDB\x06\x02",
2822 .ilen = 64,
2823 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2824 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2825 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2826 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2827 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2828 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2829 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2830 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2831 .rlen = 64,
2782 }, 2832 },
2783}; 2833};
2784 2834
@@ -2825,6 +2875,32 @@ static struct cipher_testvec tf_cbc_enc_tv_template[] = {
2825 "\x05\xef\x8c\x61\xa8\x11\x58\x26" 2875 "\x05\xef\x8c\x61\xa8\x11\x58\x26"
2826 "\x34\xba\x5c\xb7\x10\x6a\xa6\x41", 2876 "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
2827 .rlen = 48, 2877 .rlen = 48,
2878 }, { /* Generated with Crypto++ */
2879 .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2880 "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2881 "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2882 "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2883 .klen = 32,
2884 .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
2885 "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
2886 .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2887 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2888 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2889 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2890 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2891 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2892 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2893 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2894 .ilen = 64,
2895 .result = "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1"
2896 "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5"
2897 "\x26\x1B\x05\x0C\x05\x12\x3F\xC0"
2898 "\xF9\x1C\x02\x28\x40\x96\x6F\xD0"
2899 "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE"
2900 "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC"
2901 "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3"
2902 "\xB1\xD3\x44\x65\xDF\xE7\x63\x38",
2903 .rlen = 64,
2828 }, 2904 },
2829}; 2905};
2830 2906
@@ -2871,6 +2947,148 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = {
2871 .ilen = 48, 2947 .ilen = 48,
2872 .result = zeroed_string, 2948 .result = zeroed_string,
2873 .rlen = 48, 2949 .rlen = 48,
2950 }, { /* Generated with Crypto++ */
2951 .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2952 "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2953 "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2954 "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2955 .klen = 32,
2956 .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
2957 "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
2958 .input = "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1"
2959 "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5"
2960 "\x26\x1B\x05\x0C\x05\x12\x3F\xC0"
2961 "\xF9\x1C\x02\x28\x40\x96\x6F\xD0"
2962 "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE"
2963 "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC"
2964 "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3"
2965 "\xB1\xD3\x44\x65\xDF\xE7\x63\x38",
2966 .ilen = 64,
2967 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2968 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2969 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2970 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2971 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2972 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2973 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2974 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2975 .rlen = 64,
2976 },
2977};
2978
2979static struct cipher_testvec tf_ctr_enc_tv_template[] = {
2980 { /* Generated with Crypto++ */
2981 .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2982 "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2983 "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2984 "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2985 .klen = 32,
2986 .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
2987 "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
2988 .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2989 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2990 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2991 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2992 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2993 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2994 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2995 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2996 .ilen = 64,
2997 .result = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
2998 "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
2999 "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3000 "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3001 "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3002 "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3003 "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3004 "\x01\x41\x21\x12\x38\xAB\x52\x4F",
3005 .rlen = 64,
3006 }, { /* Generated with Crypto++ */
3007 .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3008 "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3009 "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3010 "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3011 .klen = 32,
3012 .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3013 "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3014 .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3015 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3016 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3017 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3018 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3019 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3020 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3021 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
3022 "\xC3\x37\xCE",
3023 .ilen = 67,
3024 .result = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3025 "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3026 "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3027 "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3028 "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3029 "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3030 "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3031 "\x01\x41\x21\x12\x38\xAB\x52\x4F"
3032 "\xA8\x57\x20",
3033 .rlen = 67,
3034 },
3035};
3036
3037static struct cipher_testvec tf_ctr_dec_tv_template[] = {
3038 { /* Generated with Crypto++ */
3039 .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3040 "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3041 "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3042 "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3043 .klen = 32,
3044 .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3045 "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3046 .input = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3047 "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3048 "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3049 "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3050 "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3051 "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3052 "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3053 "\x01\x41\x21\x12\x38\xAB\x52\x4F",
3054 .ilen = 64,
3055 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3056 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3057 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3058 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3059 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3060 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3061 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3062 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
3063 .rlen = 64,
3064 }, { /* Generated with Crypto++ */
3065 .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3066 "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3067 "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3068 "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3069 .klen = 32,
3070 .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3071 "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3072 .input = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3073 "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3074 "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3075 "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3076 "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3077 "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3078 "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3079 "\x01\x41\x21\x12\x38\xAB\x52\x4F"
3080 "\xA8\x57\x20",
3081 .ilen = 67,
3082 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3083 "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3084 "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3085 "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3086 "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3087 "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3088 "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3089 "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
3090 "\xC3\x37\xCE",
3091 .rlen = 67,
2874 }, 3092 },
2875}; 3093};
2876 3094