diff options
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
-rw-r--r-- | src/lib/libcrypto/evp/evp_lib.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c index 69784eb555..3f9bf55828 100644 --- a/src/lib/libcrypto/evp/evp_lib.c +++ b/src/lib/libcrypto/evp/evp_lib.c | |||
@@ -58,12 +58,10 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "evp.h" | 61 | #include <openssl/evp.h> |
62 | #include "objects.h" | 62 | #include <openssl/objects.h> |
63 | 63 | ||
64 | int EVP_CIPHER_param_to_asn1(c,type) | 64 | int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) |
65 | EVP_CIPHER_CTX *c; | ||
66 | ASN1_TYPE *type; | ||
67 | { | 65 | { |
68 | int ret; | 66 | int ret; |
69 | 67 | ||
@@ -74,9 +72,7 @@ ASN1_TYPE *type; | |||
74 | return(ret); | 72 | return(ret); |
75 | } | 73 | } |
76 | 74 | ||
77 | int EVP_CIPHER_asn1_to_param(c,type) | 75 | int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) |
78 | EVP_CIPHER_CTX *c; | ||
79 | ASN1_TYPE *type; | ||
80 | { | 76 | { |
81 | int ret; | 77 | int ret; |
82 | 78 | ||
@@ -87,9 +83,7 @@ ASN1_TYPE *type; | |||
87 | return(ret); | 83 | return(ret); |
88 | } | 84 | } |
89 | 85 | ||
90 | int EVP_CIPHER_get_asn1_iv(c,type) | 86 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) |
91 | EVP_CIPHER_CTX *c; | ||
92 | ASN1_TYPE *type; | ||
93 | { | 87 | { |
94 | int i=0,l; | 88 | int i=0,l; |
95 | 89 | ||
@@ -97,14 +91,15 @@ ASN1_TYPE *type; | |||
97 | { | 91 | { |
98 | l=EVP_CIPHER_CTX_iv_length(c); | 92 | l=EVP_CIPHER_CTX_iv_length(c); |
99 | i=ASN1_TYPE_get_octetstring(type,c->oiv,l); | 93 | i=ASN1_TYPE_get_octetstring(type,c->oiv,l); |
100 | memcpy(c->iv,c->oiv,l); | 94 | if (i != l) |
95 | return(-1); | ||
96 | else if (i > 0) | ||
97 | memcpy(c->iv,c->oiv,l); | ||
101 | } | 98 | } |
102 | return(i); | 99 | return(i); |
103 | } | 100 | } |
104 | 101 | ||
105 | int EVP_CIPHER_set_asn1_iv(c,type) | 102 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) |
106 | EVP_CIPHER_CTX *c; | ||
107 | ASN1_TYPE *type; | ||
108 | { | 103 | { |
109 | int i=0,j; | 104 | int i=0,j; |
110 | 105 | ||
@@ -115,3 +110,29 @@ ASN1_TYPE *type; | |||
115 | } | 110 | } |
116 | return(i); | 111 | return(i); |
117 | } | 112 | } |
113 | |||
114 | /* Convert the various cipher NIDs and dummies to a proper OID NID */ | ||
115 | int EVP_CIPHER_type(const EVP_CIPHER *ctx) | ||
116 | { | ||
117 | int nid; | ||
118 | nid = EVP_CIPHER_nid(ctx); | ||
119 | |||
120 | switch(nid) { | ||
121 | |||
122 | case NID_rc2_cbc: | ||
123 | case NID_rc2_64_cbc: | ||
124 | case NID_rc2_40_cbc: | ||
125 | |||
126 | return NID_rc2_cbc; | ||
127 | |||
128 | case NID_rc4: | ||
129 | case NID_rc4_40: | ||
130 | |||
131 | return NID_rc4; | ||
132 | |||
133 | default: | ||
134 | |||
135 | return nid; | ||
136 | } | ||
137 | } | ||
138 | |||