summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp_lib.c
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/evp/evp_lib.c
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c51
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
64int EVP_CIPHER_param_to_asn1(c,type) 64int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
65EVP_CIPHER_CTX *c;
66ASN1_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
77int EVP_CIPHER_asn1_to_param(c,type) 75int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
78EVP_CIPHER_CTX *c;
79ASN1_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
90int EVP_CIPHER_get_asn1_iv(c,type) 86int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
91EVP_CIPHER_CTX *c;
92ASN1_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
105int EVP_CIPHER_set_asn1_iv(c,type) 102int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
106EVP_CIPHER_CTX *c;
107ASN1_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 */
115int 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