summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-05-10 00:47:42 +0000
committerDr. Stephen Henson <steve@openssl.org>1999-05-10 00:47:42 +0000
commit884e8ec61533ee6361d72151066a808a0cfcd6d3 (patch)
tree45ea7a5baeef816089ea84b81e41e773762d0b9c /crypto/evp
parent9d5cceac6fb0eca8945f630afff1a2288aa6332a (diff)
Various PKCS#7 fixes to properly (maybe!) handle PKCS#7 enveloped data.
Containts elements of code by Sebastian Akerman <sak@parallelconsulting.com> and made a bit less "naughty" by Steve.
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/e_cbc_r2.c6
-rw-r--r--crypto/evp/evp.h3
-rw-r--r--crypto/evp/evp_lib.c26
3 files changed, 32 insertions, 3 deletions
diff --git a/crypto/evp/e_cbc_r2.c b/crypto/evp/e_cbc_r2.c
index d6a568f4b3..e7aa44d9af 100644
--- a/crypto/evp/e_cbc_r2.c
+++ b/crypto/evp/e_cbc_r2.c
@@ -155,9 +155,9 @@ static int rc2_meth_to_magic(const EVP_CIPHER *e)
int i;
i=EVP_CIPHER_key_length(e);
- if (i == 128) return(RC2_128_MAGIC);
- else if (i == 64) return(RC2_64_MAGIC);
- else if (i == 40) return(RC2_40_MAGIC);
+ if (i == 16) return(RC2_128_MAGIC);
+ else if (i == 8) return(RC2_64_MAGIC);
+ else if (i == 5) return(RC2_40_MAGIC);
else return(0);
}
diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h
index ccb7d51474..ac21717057 100644
--- a/crypto/evp/evp.h
+++ b/crypto/evp/evp.h
@@ -433,6 +433,7 @@ typedef int (EVP_PBE_KEYGEN)(const char *pass, int passlen,
#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
+#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
@@ -623,6 +624,8 @@ int EVP_PKEY_missing_parameters(EVP_PKEY *pkey);
int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b);
+int EVP_CIPHER_type(EVP_CIPHER *ctx);
+
/* calls methods */
int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
index 6b677fdf6f..d49ae90c77 100644
--- a/crypto/evp/evp_lib.c
+++ b/crypto/evp/evp_lib.c
@@ -110,3 +110,29 @@ int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
}
return(i);
}
+
+/* Convert the various cipher NIDs and dummies to a proper OID NID */
+int EVP_CIPHER_type(EVP_CIPHER *ctx)
+{
+ int nid;
+ nid = EVP_CIPHER_nid(ctx);
+
+ switch(nid) {
+
+ case NID_rc2_cbc:
+ case NID_rc2_64_cbc:
+ case NID_rc2_40_cbc:
+
+ return NID_rc2_cbc;
+
+ case NID_rc4:
+ case NID_rc4_40:
+
+ return NID_rc4;
+
+ default:
+
+ return nid;
+ }
+}
+