aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2013-08-05 15:40:50 +0100
committerDr. Stephen Henson <steve@openssl.org>2013-08-05 15:45:00 +0100
commite61f5d55bc0072e75023be8971ae6e849643f466 (patch)
tree9c96e22f61f15a98eb5d1bf448f2d1ecd97ae6bf /crypto/evp
parenta59f43629583b4a73c3d28ddac2c3d5a49127ece (diff)
downloadopenssl-e61f5d55bc0072e75023be8971ae6e849643f466.tar.gz
Algorithm parameter support.
Check and set AlgorithmIdenfier parameters for key wrap algorithms. Currently these just set parameters to NULL.
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/e_aes.c2
-rw-r--r--crypto/evp/e_des3.c3
-rw-r--r--crypto/evp/evp_lib.c14
3 files changed, 16 insertions, 3 deletions
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index fbf47ac2cb..d1972a77e6 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -1943,7 +1943,7 @@ static int aes_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
#define WRAP_FLAGS (EVP_CIPH_WRAP_MODE \
| EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \
- | EVP_CIPH_ALWAYS_CALL_INIT)
+ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_FLAG_DEFAULT_ASN1)
static const EVP_CIPHER aes_128_wrap = {
NID_id_aes128_wrap,
diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c
index cfd49bbe7f..dd44ac325c 100644
--- a/crypto/evp/e_des3.c
+++ b/crypto/evp/e_des3.c
@@ -468,7 +468,8 @@ static int des_ede3_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
static const EVP_CIPHER des3_wrap = {
NID_id_smime_alg_CMS3DESwrap,
8, 24, 0,
- EVP_CIPH_WRAP_MODE|EVP_CIPH_CUSTOM_IV|EVP_CIPH_FLAG_CUSTOM_CIPHER,
+ EVP_CIPH_WRAP_MODE|EVP_CIPH_CUSTOM_IV|EVP_CIPH_FLAG_CUSTOM_CIPHER
+ |EVP_CIPH_FLAG_DEFAULT_ASN1,
des_ede3_init_key, des_ede3_wrap_cipher,
NULL,
sizeof(DES_EDE_KEY),
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
index b180e4828a..2a87570b9e 100644
--- a/crypto/evp/evp_lib.c
+++ b/crypto/evp/evp_lib.c
@@ -68,7 +68,15 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
if (c->cipher->set_asn1_parameters != NULL)
ret=c->cipher->set_asn1_parameters(c,type);
else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
- ret=EVP_CIPHER_set_asn1_iv(c, type);
+ {
+ if (EVP_CIPHER_CTX_mode(c) == EVP_CIPH_WRAP_MODE)
+ {
+ ASN1_TYPE_set(type, V_ASN1_NULL, NULL);
+ ret = 1;
+ }
+ else
+ ret=EVP_CIPHER_set_asn1_iv(c, type);
+ }
else
ret=-1;
return(ret);
@@ -81,7 +89,11 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
if (c->cipher->get_asn1_parameters != NULL)
ret=c->cipher->get_asn1_parameters(c,type);
else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
+ {
+ if (EVP_CIPHER_CTX_mode(c) == EVP_CIPH_WRAP_MODE)
+ return 1;
ret=EVP_CIPHER_get_asn1_iv(c, type);
+ }
else
ret=-1;
return(ret);