diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2019-03-17 18:33:02 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2019-03-17 18:33:02 +0000 |
commit | fc34b9f5a94b9bc76c14324ec799f2d1a056545e (patch) | |
tree | 5c930ab2c7cd3fe82f8d143b44c63f62030e07c1 /regress | |
parent | 409a7fe89ce80b6a77eb67cf322be761df559ea7 (diff) |
Add regress tests for the EVP_aes_*_wrap() API. Based on the tests in
OpenSSL 1.0.2r which is still freely licenced with a tweak by jsing.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libcrypto/evp/evptest.c | 14 | ||||
-rw-r--r-- | regress/lib/libcrypto/evp/evptests.txt | 9 |
2 files changed, 19 insertions, 4 deletions
diff --git a/regress/lib/libcrypto/evp/evptest.c b/regress/lib/libcrypto/evp/evptest.c index 1aa11d7b1ee..ac15a55aaaf 100644 --- a/regress/lib/libcrypto/evp/evptest.c +++ b/regress/lib/libcrypto/evp/evptest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evptest.c,v 1.7 2018/07/17 17:06:49 tb Exp $ */ +/* $OpenBSD: evptest.c,v 1.8 2019/03/17 18:33:01 tb Exp $ */ /* Written by Ben Laurie, 2001 */ /* * Copyright (c) 2001 The OpenSSL Project. All rights reserved. @@ -144,6 +144,7 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, { EVP_CIPHER_CTX ctx; unsigned char out[4096]; + const unsigned char *eiv; int outl, outl2; printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), @@ -160,8 +161,12 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, test1_exit(5); } EVP_CIPHER_CTX_init(&ctx); + EVP_CIPHER_CTX_set_flags(&ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW); if (encdec != 0) { - if (!EVP_EncryptInit_ex(&ctx, c,NULL, key, iv)) { + eiv = iv; + if (EVP_CIPHER_mode(c) == EVP_CIPH_WRAP_MODE && in == 0) + eiv = NULL; + if (!EVP_EncryptInit_ex(&ctx, c, NULL, key, eiv)) { fprintf(stderr, "EncryptInit failed\n"); ERR_print_errors_fp(stderr); test1_exit(10); @@ -194,7 +199,10 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, } if (encdec <= 0) { - if (!EVP_DecryptInit_ex(&ctx, c,NULL, key, iv)) { + eiv = iv; + if (EVP_CIPHER_mode(c) == EVP_CIPH_WRAP_MODE && in == 0) + eiv = NULL; + if (!EVP_DecryptInit_ex(&ctx, c,NULL, key, eiv)) { fprintf(stderr, "DecryptInit failed\n"); ERR_print_errors_fp(stderr); test1_exit(11); diff --git a/regress/lib/libcrypto/evp/evptests.txt b/regress/lib/libcrypto/evp/evptests.txt index fd2c6cdfd1e..3c133dba9cc 100644 --- a/regress/lib/libcrypto/evp/evptests.txt +++ b/regress/lib/libcrypto/evp/evptests.txt @@ -1,4 +1,4 @@ -# $OpenBSD: evptests.txt,v 1.5 2018/07/17 17:06:49 tb Exp $ +# $OpenBSD: evptests.txt,v 1.6 2019/03/17 18:33:01 tb Exp $ #cipher:key:iv:plaintext:ciphertext:0/1(decrypt/encrypt) #digest:::input:output @@ -184,6 +184,13 @@ aes-256-ctr:776BEFF2851DB06F4C8A0542C8696F6C6A81AF1EEC96B4D37FC1D689E6C1C104:000 aes-256-ctr:F6D66D6BD52D59BB0796365879EFF886C66DD51A5B6A99744B50590C87A23884:00FAAC24C1585EF15A43D87500000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:F05E231B3894612C49EE000B804EB2A9B8306B508F839D6A5530831D9344AF1C:1 aes-256-ctr:FF7A617CE69148E4F1726E2F43581DE2AA62D9F805532EDFF1EED687FB54153D:001CC5B751A51D70A1C1114800000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:EB6C52821D0BBBF7CE7594462ACA4FAAB407DF866569FD07F48CC0B583D6071F1EC0E6B8:1 +# AES wrap tests from RFC3394 +id-aes128-wrap:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5 +id-aes192-wrap:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:96778B25AE6CA435F92B5B97C050AED2468AB8A17AD84E5D +id-aes256-wrap:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:64E8C3F9CE0F5BA263E9777905818A2A93C8191E7D6E8AE7 +id-aes192-wrap:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF0001020304050607:031D33264E15D33268F24EC260743EDCE1C6C7DDEE725A936BA814915C6762D2 +id-aes256-wrap:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF0001020304050607:A8F9BC1612C68B3FF6E6F4FBE30E71E4769C8B80A32CB8958CD5D17D6B254DA1 +id-aes256-wrap:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F:28C9F404C4B810F4CBCCB35CFB87F8263F5786E2D80ED326CBC7F0E71A99F43BFB988B9B7A02DD21 # DES ECB tests (from destest) DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7 |