diff options
| author | markus <> | 2002-09-05 12:51:50 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:50 +0000 |
| commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
| tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/evp/evp_lib.c | |
| parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
| download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip | |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_lib.c | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c index 69784eb555..a431945ef5 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,33 @@ 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 | ASN1_OBJECT *otmp; | ||
| 119 | nid = EVP_CIPHER_nid(ctx); | ||
| 120 | |||
| 121 | switch(nid) { | ||
| 122 | |||
| 123 | case NID_rc2_cbc: | ||
| 124 | case NID_rc2_64_cbc: | ||
| 125 | case NID_rc2_40_cbc: | ||
| 126 | |||
| 127 | return NID_rc2_cbc; | ||
| 128 | |||
| 129 | case NID_rc4: | ||
| 130 | case NID_rc4_40: | ||
| 131 | |||
| 132 | return NID_rc4; | ||
| 133 | |||
| 134 | default: | ||
| 135 | /* Check it has an OID and it is valid */ | ||
| 136 | otmp = OBJ_nid2obj(nid); | ||
| 137 | if(!otmp || !otmp->data) nid = NID_undef; | ||
| 138 | ASN1_OBJECT_free(otmp); | ||
| 139 | return nid; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
