summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c125
1 files changed, 7 insertions, 118 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index edb28ef38e..a63ba19317 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -68,7 +68,7 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
68 if (c->cipher->set_asn1_parameters != NULL) 68 if (c->cipher->set_asn1_parameters != NULL)
69 ret=c->cipher->set_asn1_parameters(c,type); 69 ret=c->cipher->set_asn1_parameters(c,type);
70 else 70 else
71 ret=-1; 71 return -1;
72 return(ret); 72 return(ret);
73 } 73 }
74 74
@@ -79,21 +79,20 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
79 if (c->cipher->get_asn1_parameters != NULL) 79 if (c->cipher->get_asn1_parameters != NULL)
80 ret=c->cipher->get_asn1_parameters(c,type); 80 ret=c->cipher->get_asn1_parameters(c,type);
81 else 81 else
82 ret=-1; 82 return -1;
83 return(ret); 83 return(ret);
84 } 84 }
85 85
86int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) 86int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
87 { 87 {
88 int i=0; 88 int i=0,l;
89 unsigned int l;
90 89
91 if (type != NULL) 90 if (type != NULL)
92 { 91 {
93 l=EVP_CIPHER_CTX_iv_length(c); 92 l=EVP_CIPHER_CTX_iv_length(c);
94 OPENSSL_assert(l <= sizeof(c->iv)); 93 OPENSSL_assert(l <= sizeof c->iv);
95 i=ASN1_TYPE_get_octetstring(type,c->oiv,l); 94 i=ASN1_TYPE_get_octetstring(type,c->oiv,l);
96 if (i != (int)l) 95 if (i != l)
97 return(-1); 96 return(-1);
98 else if (i > 0) 97 else if (i > 0)
99 memcpy(c->iv,c->oiv,l); 98 memcpy(c->iv,c->oiv,l);
@@ -103,13 +102,12 @@ int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
103 102
104int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) 103int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
105 { 104 {
106 int i=0; 105 int i=0,j;
107 unsigned int j;
108 106
109 if (type != NULL) 107 if (type != NULL)
110 { 108 {
111 j=EVP_CIPHER_CTX_iv_length(c); 109 j=EVP_CIPHER_CTX_iv_length(c);
112 OPENSSL_assert(j <= sizeof(c->iv)); 110 OPENSSL_assert(j <= sizeof c->iv);
113 i=ASN1_TYPE_set_octetstring(type,c->oiv,j); 111 i=ASN1_TYPE_set_octetstring(type,c->oiv,j);
114 } 112 }
115 return(i); 113 return(i);
@@ -168,112 +166,3 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx)
168 } 166 }
169} 167}
170 168
171int EVP_CIPHER_block_size(const EVP_CIPHER *e)
172 {
173 return e->block_size;
174 }
175
176int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
177 {
178 return ctx->cipher->block_size;
179 }
180
181int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl)
182 {
183 return ctx->cipher->do_cipher(ctx,out,in,inl);
184 }
185
186const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx)
187 {
188 return ctx->cipher;
189 }
190
191unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher)
192 {
193 return cipher->flags;
194 }
195
196unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
197 {
198 return ctx->cipher->flags;
199 }
200
201void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx)
202 {
203 return ctx->app_data;
204 }
205
206void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data)
207 {
208 ctx->app_data = data;
209 }
210
211int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher)
212 {
213 return cipher->iv_len;
214 }
215
216int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
217 {
218 return ctx->cipher->iv_len;
219 }
220
221int EVP_CIPHER_key_length(const EVP_CIPHER *cipher)
222 {
223 return cipher->key_len;
224 }
225
226int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx)
227 {
228 return ctx->key_len;
229 }
230
231int EVP_CIPHER_nid(const EVP_CIPHER *cipher)
232 {
233 return cipher->nid;
234 }
235
236int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
237 {
238 return ctx->cipher->nid;
239 }
240
241int EVP_MD_block_size(const EVP_MD *md)
242 {
243 return md->block_size;
244 }
245
246int EVP_MD_type(const EVP_MD *md)
247 {
248 return md->type;
249 }
250
251int EVP_MD_pkey_type(const EVP_MD *md)
252 {
253 return md->pkey_type;
254 }
255
256int EVP_MD_size(const EVP_MD *md)
257 {
258 return md->md_size;
259 }
260
261const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
262 {
263 return ctx->digest;
264 }
265
266void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
267 {
268 ctx->flags |= flags;
269 }
270
271void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags)
272 {
273 ctx->flags &= ~flags;
274 }
275
276int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags)
277 {
278 return (ctx->flags & flags);
279 }