aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2015-06-01 07:43:59 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-04 03:04:51 -0400
commiteee9dc6162c537641a9259ae595193fa3c68c96e (patch)
tree8eb5a24eaba51d85dcdb98c1ad5ff399d7aca895 /crypto
parentf979e014c50ce3f7467f133898dbea2243247a91 (diff)
crypto: testmgr - Add Poly1305 test vectors from RFC7539
Signed-off-by: Martin Willi <martin@strongswan.org> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/testmgr.c9
-rw-r--r--crypto/testmgr.h259
2 files changed, 268 insertions, 0 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index abd09c2489fa..faf93a6696e2 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3315,6 +3315,15 @@ static const struct alg_test_desc alg_test_descs[] = {
3315 } 3315 }
3316 } 3316 }
3317 }, { 3317 }, {
3318 .alg = "poly1305",
3319 .test = alg_test_hash,
3320 .suite = {
3321 .hash = {
3322 .vecs = poly1305_tv_template,
3323 .count = POLY1305_TEST_VECTORS
3324 }
3325 }
3326 }, {
3318 .alg = "rfc3686(ctr(aes))", 3327 .alg = "rfc3686(ctr(aes))",
3319 .test = alg_test_skcipher, 3328 .test = alg_test_skcipher,
3320 .fips_allowed = 1, 3329 .fips_allowed = 1,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 6e7b902eb6e0..0cbb7184af17 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -3026,6 +3026,265 @@ static struct hash_testvec hmac_sha512_tv_template[] = {
3026}; 3026};
3027 3027
3028/* 3028/*
3029 * Poly1305 test vectors from RFC7539 A.3.
3030 */
3031
3032#define POLY1305_TEST_VECTORS 11
3033
3034static struct hash_testvec poly1305_tv_template[] = {
3035 { /* Test Vector #1 */
3036 .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
3037 "\x00\x00\x00\x00\x00\x00\x00\x00"
3038 "\x00\x00\x00\x00\x00\x00\x00\x00"
3039 "\x00\x00\x00\x00\x00\x00\x00\x00",
3040 .ksize = 32,
3041 .plaintext = "\x00\x00\x00\x00\x00\x00\x00\x00"
3042 "\x00\x00\x00\x00\x00\x00\x00\x00"
3043 "\x00\x00\x00\x00\x00\x00\x00\x00"
3044 "\x00\x00\x00\x00\x00\x00\x00\x00"
3045 "\x00\x00\x00\x00\x00\x00\x00\x00"
3046 "\x00\x00\x00\x00\x00\x00\x00\x00"
3047 "\x00\x00\x00\x00\x00\x00\x00\x00"
3048 "\x00\x00\x00\x00\x00\x00\x00\x00",
3049 .psize = 64,
3050 .digest = "\x00\x00\x00\x00\x00\x00\x00\x00"
3051 "\x00\x00\x00\x00\x00\x00\x00\x00",
3052 }, { /* Test Vector #2 */
3053 .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
3054 "\x00\x00\x00\x00\x00\x00\x00\x00"
3055 "\x36\xe5\xf6\xb5\xc5\xe0\x60\x70"
3056 "\xf0\xef\xca\x96\x22\x7a\x86\x3e",
3057 .ksize = 32,
3058 .plaintext = "\x41\x6e\x79\x20\x73\x75\x62\x6d"
3059 "\x69\x73\x73\x69\x6f\x6e\x20\x74"
3060 "\x6f\x20\x74\x68\x65\x20\x49\x45"
3061 "\x54\x46\x20\x69\x6e\x74\x65\x6e"
3062 "\x64\x65\x64\x20\x62\x79\x20\x74"
3063 "\x68\x65\x20\x43\x6f\x6e\x74\x72"
3064 "\x69\x62\x75\x74\x6f\x72\x20\x66"
3065 "\x6f\x72\x20\x70\x75\x62\x6c\x69"
3066 "\x63\x61\x74\x69\x6f\x6e\x20\x61"
3067 "\x73\x20\x61\x6c\x6c\x20\x6f\x72"
3068 "\x20\x70\x61\x72\x74\x20\x6f\x66"
3069 "\x20\x61\x6e\x20\x49\x45\x54\x46"
3070 "\x20\x49\x6e\x74\x65\x72\x6e\x65"
3071 "\x74\x2d\x44\x72\x61\x66\x74\x20"
3072 "\x6f\x72\x20\x52\x46\x43\x20\x61"
3073 "\x6e\x64\x20\x61\x6e\x79\x20\x73"
3074 "\x74\x61\x74\x65\x6d\x65\x6e\x74"
3075 "\x20\x6d\x61\x64\x65\x20\x77\x69"
3076 "\x74\x68\x69\x6e\x20\x74\x68\x65"
3077 "\x20\x63\x6f\x6e\x74\x65\x78\x74"
3078 "\x20\x6f\x66\x20\x61\x6e\x20\x49"
3079 "\x45\x54\x46\x20\x61\x63\x74\x69"
3080 "\x76\x69\x74\x79\x20\x69\x73\x20"
3081 "\x63\x6f\x6e\x73\x69\x64\x65\x72"
3082 "\x65\x64\x20\x61\x6e\x20\x22\x49"
3083 "\x45\x54\x46\x20\x43\x6f\x6e\x74"
3084 "\x72\x69\x62\x75\x74\x69\x6f\x6e"
3085 "\x22\x2e\x20\x53\x75\x63\x68\x20"
3086 "\x73\x74\x61\x74\x65\x6d\x65\x6e"
3087 "\x74\x73\x20\x69\x6e\x63\x6c\x75"
3088 "\x64\x65\x20\x6f\x72\x61\x6c\x20"
3089 "\x73\x74\x61\x74\x65\x6d\x65\x6e"
3090 "\x74\x73\x20\x69\x6e\x20\x49\x45"
3091 "\x54\x46\x20\x73\x65\x73\x73\x69"
3092 "\x6f\x6e\x73\x2c\x20\x61\x73\x20"
3093 "\x77\x65\x6c\x6c\x20\x61\x73\x20"
3094 "\x77\x72\x69\x74\x74\x65\x6e\x20"
3095 "\x61\x6e\x64\x20\x65\x6c\x65\x63"
3096 "\x74\x72\x6f\x6e\x69\x63\x20\x63"
3097 "\x6f\x6d\x6d\x75\x6e\x69\x63\x61"
3098 "\x74\x69\x6f\x6e\x73\x20\x6d\x61"
3099 "\x64\x65\x20\x61\x74\x20\x61\x6e"
3100 "\x79\x20\x74\x69\x6d\x65\x20\x6f"
3101 "\x72\x20\x70\x6c\x61\x63\x65\x2c"
3102 "\x20\x77\x68\x69\x63\x68\x20\x61"
3103 "\x72\x65\x20\x61\x64\x64\x72\x65"
3104 "\x73\x73\x65\x64\x20\x74\x6f",
3105 .psize = 375,
3106 .digest = "\x36\xe5\xf6\xb5\xc5\xe0\x60\x70"
3107 "\xf0\xef\xca\x96\x22\x7a\x86\x3e",
3108 }, { /* Test Vector #3 */
3109 .key = "\x36\xe5\xf6\xb5\xc5\xe0\x60\x70"
3110 "\xf0\xef\xca\x96\x22\x7a\x86\x3e"
3111 "\x00\x00\x00\x00\x00\x00\x00\x00"
3112 "\x00\x00\x00\x00\x00\x00\x00\x00",
3113 .ksize = 32,
3114 .plaintext = "\x41\x6e\x79\x20\x73\x75\x62\x6d"
3115 "\x69\x73\x73\x69\x6f\x6e\x20\x74"
3116 "\x6f\x20\x74\x68\x65\x20\x49\x45"
3117 "\x54\x46\x20\x69\x6e\x74\x65\x6e"
3118 "\x64\x65\x64\x20\x62\x79\x20\x74"
3119 "\x68\x65\x20\x43\x6f\x6e\x74\x72"
3120 "\x69\x62\x75\x74\x6f\x72\x20\x66"
3121 "\x6f\x72\x20\x70\x75\x62\x6c\x69"
3122 "\x63\x61\x74\x69\x6f\x6e\x20\x61"
3123 "\x73\x20\x61\x6c\x6c\x20\x6f\x72"
3124 "\x20\x70\x61\x72\x74\x20\x6f\x66"
3125 "\x20\x61\x6e\x20\x49\x45\x54\x46"
3126 "\x20\x49\x6e\x74\x65\x72\x6e\x65"
3127 "\x74\x2d\x44\x72\x61\x66\x74\x20"
3128 "\x6f\x72\x20\x52\x46\x43\x20\x61"
3129 "\x6e\x64\x20\x61\x6e\x79\x20\x73"
3130 "\x74\x61\x74\x65\x6d\x65\x6e\x74"
3131 "\x20\x6d\x61\x64\x65\x20\x77\x69"
3132 "\x74\x68\x69\x6e\x20\x74\x68\x65"
3133 "\x20\x63\x6f\x6e\x74\x65\x78\x74"
3134 "\x20\x6f\x66\x20\x61\x6e\x20\x49"
3135 "\x45\x54\x46\x20\x61\x63\x74\x69"
3136 "\x76\x69\x74\x79\x20\x69\x73\x20"
3137 "\x63\x6f\x6e\x73\x69\x64\x65\x72"
3138 "\x65\x64\x20\x61\x6e\x20\x22\x49"
3139 "\x45\x54\x46\x20\x43\x6f\x6e\x74"
3140 "\x72\x69\x62\x75\x74\x69\x6f\x6e"
3141 "\x22\x2e\x20\x53\x75\x63\x68\x20"
3142 "\x73\x74\x61\x74\x65\x6d\x65\x6e"
3143 "\x74\x73\x20\x69\x6e\x63\x6c\x75"
3144 "\x64\x65\x20\x6f\x72\x61\x6c\x20"
3145 "\x73\x74\x61\x74\x65\x6d\x65\x6e"
3146 "\x74\x73\x20\x69\x6e\x20\x49\x45"
3147 "\x54\x46\x20\x73\x65\x73\x73\x69"
3148 "\x6f\x6e\x73\x2c\x20\x61\x73\x20"
3149 "\x77\x65\x6c\x6c\x20\x61\x73\x20"
3150 "\x77\x72\x69\x74\x74\x65\x6e\x20"
3151 "\x61\x6e\x64\x20\x65\x6c\x65\x63"
3152 "\x74\x72\x6f\x6e\x69\x63\x20\x63"
3153 "\x6f\x6d\x6d\x75\x6e\x69\x63\x61"
3154 "\x74\x69\x6f\x6e\x73\x20\x6d\x61"
3155 "\x64\x65\x20\x61\x74\x20\x61\x6e"
3156 "\x79\x20\x74\x69\x6d\x65\x20\x6f"
3157 "\x72\x20\x70\x6c\x61\x63\x65\x2c"
3158 "\x20\x77\x68\x69\x63\x68\x20\x61"
3159 "\x72\x65\x20\x61\x64\x64\x72\x65"
3160 "\x73\x73\x65\x64\x20\x74\x6f",
3161 .psize = 375,
3162 .digest = "\xf3\x47\x7e\x7c\xd9\x54\x17\xaf"
3163 "\x89\xa6\xb8\x79\x4c\x31\x0c\xf0",
3164 }, { /* Test Vector #4 */
3165 .key = "\x1c\x92\x40\xa5\xeb\x55\xd3\x8a"
3166 "\xf3\x33\x88\x86\x04\xf6\xb5\xf0"
3167 "\x47\x39\x17\xc1\x40\x2b\x80\x09"
3168 "\x9d\xca\x5c\xbc\x20\x70\x75\xc0",
3169 .ksize = 32,
3170 .plaintext = "\x27\x54\x77\x61\x73\x20\x62\x72"
3171 "\x69\x6c\x6c\x69\x67\x2c\x20\x61"
3172 "\x6e\x64\x20\x74\x68\x65\x20\x73"
3173 "\x6c\x69\x74\x68\x79\x20\x74\x6f"
3174 "\x76\x65\x73\x0a\x44\x69\x64\x20"
3175 "\x67\x79\x72\x65\x20\x61\x6e\x64"
3176 "\x20\x67\x69\x6d\x62\x6c\x65\x20"
3177 "\x69\x6e\x20\x74\x68\x65\x20\x77"
3178 "\x61\x62\x65\x3a\x0a\x41\x6c\x6c"
3179 "\x20\x6d\x69\x6d\x73\x79\x20\x77"
3180 "\x65\x72\x65\x20\x74\x68\x65\x20"
3181 "\x62\x6f\x72\x6f\x67\x6f\x76\x65"
3182 "\x73\x2c\x0a\x41\x6e\x64\x20\x74"
3183 "\x68\x65\x20\x6d\x6f\x6d\x65\x20"
3184 "\x72\x61\x74\x68\x73\x20\x6f\x75"
3185 "\x74\x67\x72\x61\x62\x65\x2e",
3186 .psize = 127,
3187 .digest = "\x45\x41\x66\x9a\x7e\xaa\xee\x61"
3188 "\xe7\x08\xdc\x7c\xbc\xc5\xeb\x62",
3189 }, { /* Test Vector #5 */
3190 .key = "\x02\x00\x00\x00\x00\x00\x00\x00"
3191 "\x00\x00\x00\x00\x00\x00\x00\x00"
3192 "\x00\x00\x00\x00\x00\x00\x00\x00"
3193 "\x00\x00\x00\x00\x00\x00\x00\x00",
3194 .ksize = 32,
3195 .plaintext = "\xff\xff\xff\xff\xff\xff\xff\xff"
3196 "\xff\xff\xff\xff\xff\xff\xff\xff",
3197 .psize = 16,
3198 .digest = "\x03\x00\x00\x00\x00\x00\x00\x00"
3199 "\x00\x00\x00\x00\x00\x00\x00\x00",
3200 }, { /* Test Vector #6 */
3201 .key = "\x02\x00\x00\x00\x00\x00\x00\x00"
3202 "\x00\x00\x00\x00\x00\x00\x00\x00"
3203 "\xff\xff\xff\xff\xff\xff\xff\xff"
3204 "\xff\xff\xff\xff\xff\xff\xff\xff",
3205 .ksize = 32,
3206 .plaintext = "\x02\x00\x00\x00\x00\x00\x00\x00"
3207 "\x00\x00\x00\x00\x00\x00\x00\x00",
3208 .psize = 16,
3209 .digest = "\x03\x00\x00\x00\x00\x00\x00\x00"
3210 "\x00\x00\x00\x00\x00\x00\x00\x00",
3211 }, { /* Test Vector #7 */
3212 .key = "\x01\x00\x00\x00\x00\x00\x00\x00"
3213 "\x00\x00\x00\x00\x00\x00\x00\x00"
3214 "\x00\x00\x00\x00\x00\x00\x00\x00"
3215 "\x00\x00\x00\x00\x00\x00\x00\x00",
3216 .ksize = 32,
3217 .plaintext = "\xff\xff\xff\xff\xff\xff\xff\xff"
3218 "\xff\xff\xff\xff\xff\xff\xff\xff"
3219 "\xf0\xff\xff\xff\xff\xff\xff\xff"
3220 "\xff\xff\xff\xff\xff\xff\xff\xff"
3221 "\x11\x00\x00\x00\x00\x00\x00\x00"
3222 "\x00\x00\x00\x00\x00\x00\x00\x00",
3223 .psize = 48,
3224 .digest = "\x05\x00\x00\x00\x00\x00\x00\x00"
3225 "\x00\x00\x00\x00\x00\x00\x00\x00",
3226 }, { /* Test Vector #8 */
3227 .key = "\x01\x00\x00\x00\x00\x00\x00\x00"
3228 "\x00\x00\x00\x00\x00\x00\x00\x00"
3229 "\x00\x00\x00\x00\x00\x00\x00\x00"
3230 "\x00\x00\x00\x00\x00\x00\x00\x00",
3231 .ksize = 32,
3232 .plaintext = "\xff\xff\xff\xff\xff\xff\xff\xff"
3233 "\xff\xff\xff\xff\xff\xff\xff\xff"
3234 "\xfb\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
3235 "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
3236 "\x01\x01\x01\x01\x01\x01\x01\x01"
3237 "\x01\x01\x01\x01\x01\x01\x01\x01",
3238 .psize = 48,
3239 .digest = "\x00\x00\x00\x00\x00\x00\x00\x00"
3240 "\x00\x00\x00\x00\x00\x00\x00\x00",
3241 }, { /* Test Vector #9 */
3242 .key = "\x02\x00\x00\x00\x00\x00\x00\x00"
3243 "\x00\x00\x00\x00\x00\x00\x00\x00"
3244 "\x00\x00\x00\x00\x00\x00\x00\x00"
3245 "\x00\x00\x00\x00\x00\x00\x00\x00",
3246 .ksize = 32,
3247 .plaintext = "\xfd\xff\xff\xff\xff\xff\xff\xff"
3248 "\xff\xff\xff\xff\xff\xff\xff\xff",
3249 .psize = 16,
3250 .digest = "\xfa\xff\xff\xff\xff\xff\xff\xff"
3251 "\xff\xff\xff\xff\xff\xff\xff\xff",
3252 }, { /* Test Vector #10 */
3253 .key = "\x01\x00\x00\x00\x00\x00\x00\x00"
3254 "\x04\x00\x00\x00\x00\x00\x00\x00"
3255 "\x00\x00\x00\x00\x00\x00\x00\x00"
3256 "\x00\x00\x00\x00\x00\x00\x00\x00",
3257 .ksize = 32,
3258 .plaintext = "\xe3\x35\x94\xd7\x50\x5e\x43\xb9"
3259 "\x00\x00\x00\x00\x00\x00\x00\x00"
3260 "\x33\x94\xd7\x50\x5e\x43\x79\xcd"
3261 "\x01\x00\x00\x00\x00\x00\x00\x00"
3262 "\x00\x00\x00\x00\x00\x00\x00\x00"
3263 "\x00\x00\x00\x00\x00\x00\x00\x00"
3264 "\x01\x00\x00\x00\x00\x00\x00\x00"
3265 "\x00\x00\x00\x00\x00\x00\x00\x00",
3266 .psize = 64,
3267 .digest = "\x14\x00\x00\x00\x00\x00\x00\x00"
3268 "\x55\x00\x00\x00\x00\x00\x00\x00",
3269 }, { /* Test Vector #11 */
3270 .key = "\x01\x00\x00\x00\x00\x00\x00\x00"
3271 "\x04\x00\x00\x00\x00\x00\x00\x00"
3272 "\x00\x00\x00\x00\x00\x00\x00\x00"
3273 "\x00\x00\x00\x00\x00\x00\x00\x00",
3274 .ksize = 32,
3275 .plaintext = "\xe3\x35\x94\xd7\x50\x5e\x43\xb9"
3276 "\x00\x00\x00\x00\x00\x00\x00\x00"
3277 "\x33\x94\xd7\x50\x5e\x43\x79\xcd"
3278 "\x01\x00\x00\x00\x00\x00\x00\x00"
3279 "\x00\x00\x00\x00\x00\x00\x00\x00"
3280 "\x00\x00\x00\x00\x00\x00\x00\x00",
3281 .psize = 48,
3282 .digest = "\x13\x00\x00\x00\x00\x00\x00\x00"
3283 "\x00\x00\x00\x00\x00\x00\x00\x00",
3284 },
3285};
3286
3287/*
3029 * DES test vectors. 3288 * DES test vectors.
3030 */ 3289 */
3031#define DES_ENC_TEST_VECTORS 11 3290#define DES_ENC_TEST_VECTORS 11