summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authormarkus <>2002-09-14 11:18:04 +0000
committermarkus <>2002-09-14 11:18:04 +0000
commit3a3a489a756f2852d798376f20cc0d4ab609c866 (patch)
tree2a4277fc9b7635e82c33faa3bae9f9380bc639e8 /src/lib/libcrypto
parent82d2611e1bb67683df1bb201dcc2afbff4c76980 (diff)
downloadopenbsd-3a3a489a756f2852d798376f20cc0d4ab609c866.tar.gz
openbsd-3a3a489a756f2852d798376f20cc0d4ab609c866.tar.bz2
openbsd-3a3a489a756f2852d798376f20cc0d4ab609c866.zip
merge with openssl-0.9.7-stable-SNAP-20020911,
new minor for libcrypto (_X509_REQ_print_ex) tested by miod@, pb@
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/Makefile.ssl2
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c6
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c4
-rw-r--r--src/lib/libcrypto/asn1/t_req.c260
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c6
-rw-r--r--src/lib/libcrypto/bio/b_print.c2
-rw-r--r--src/lib/libcrypto/bn/bn.h2
-rw-r--r--src/lib/libcrypto/crypto-lib.com10
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl3
-rw-r--r--src/lib/libcrypto/des/des_ver.h4
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c1
-rw-r--r--src/lib/libcrypto/des/set_key.c2
-rw-r--r--src/lib/libcrypto/doc/DH_set_method.pod102
-rw-r--r--src/lib/libcrypto/doc/DSA_dup_DH.pod2
-rw-r--r--src/lib/libcrypto/doc/DSA_new.pod3
-rw-r--r--src/lib/libcrypto/doc/DSA_set_method.pod91
-rw-r--r--src/lib/libcrypto/doc/DSA_size.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_SealInit.pod2
-rw-r--r--src/lib/libcrypto/doc/RAND_set_rand_method.pod44
-rw-r--r--src/lib/libcrypto/doc/RSA_new.pod6
-rw-r--r--src/lib/libcrypto/doc/RSA_set_method.pod127
-rw-r--r--src/lib/libcrypto/doc/RSA_size.pod2
-rw-r--r--src/lib/libcrypto/doc/dh.pod31
-rw-r--r--src/lib/libcrypto/doc/dsa.pod38
-rw-r--r--src/lib/libcrypto/doc/evp.pod10
-rw-r--r--src/lib/libcrypto/doc/rsa.pod31
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca.c2
-rw-r--r--src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c10
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec.c8
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h12
-rw-r--r--src/lib/libcrypto/krb5/Makefile.ssl10
-rw-r--r--src/lib/libcrypto/mem.c3
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c2
-rw-r--r--src/lib/libcrypto/ocsp/Makefile.ssl10
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c7
-rw-r--r--src/lib/libcrypto/pkcs12/p12_asn.c6
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_lib.c7
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c2
-rw-r--r--src/lib/libcrypto/util/libeay.num1
-rw-r--r--src/lib/libcrypto/x509/x509.h2
40 files changed, 543 insertions, 332 deletions
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
index 2489b614c6..db8baf385e 100644
--- a/src/lib/libcrypto/Makefile.ssl
+++ b/src/lib/libcrypto/Makefile.ssl
@@ -98,7 +98,7 @@ lib: $(LIBOBJ)
98 98
99shared: 99shared:
100 if [ -n "$(SHARED_LIBS)" ]; then \ 100 if [ -n "$(SHARED_LIBS)" ]; then \
101 (cd ..; make $(SHARED_LIB)); \ 101 (cd ..; $(MAKE) $(SHARED_LIB)); \
102 fi 102 fi
103 103
104libs: 104libs:
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index ed0bdfbde1..e0265f69d2 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -120,6 +120,12 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
120 unsigned char *p,*s; 120 unsigned char *p,*s;
121 int i; 121 int i;
122 122
123 if (len < 1)
124 {
125 i=ASN1_R_STRING_TOO_SHORT;
126 goto err;
127 }
128
123 if ((a == NULL) || ((*a) == NULL)) 129 if ((a == NULL) || ((*a) == NULL))
124 { 130 {
125 if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL); 131 if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL);
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index 8dab29dca1..7ddb7662f1 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -544,7 +544,7 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
544{ 544{
545 ASN1_STRING stmp, *str = &stmp; 545 ASN1_STRING stmp, *str = &stmp;
546 int mbflag, type, ret; 546 int mbflag, type, ret;
547 if(!*out || !in) return -1; 547 if(!in) return -1;
548 type = in->type; 548 type = in->type;
549 if((type < 0) || (type > 30)) return -1; 549 if((type < 0) || (type > 30)) return -1;
550 mbflag = tag2nbyte[type]; 550 mbflag = tag2nbyte[type];
@@ -553,6 +553,6 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
553 stmp.data = NULL; 553 stmp.data = NULL;
554 ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); 554 ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
555 if(ret < 0) return ret; 555 if(ret < 0) return ret;
556 if(out) *out = stmp.data; 556 *out = stmp.data;
557 return stmp.length; 557 return stmp.length;
558} 558}
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index 848c29a2dd..739f272ecf 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -82,7 +82,7 @@ int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
82 } 82 }
83#endif 83#endif
84 84
85int X509_REQ_print(BIO *bp, X509_REQ *x) 85int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long cflag)
86 { 86 {
87 unsigned long l; 87 unsigned long l;
88 int i; 88 int i;
@@ -92,143 +92,185 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
92 STACK_OF(X509_ATTRIBUTE) *sk; 92 STACK_OF(X509_ATTRIBUTE) *sk;
93 STACK_OF(X509_EXTENSION) *exts; 93 STACK_OF(X509_EXTENSION) *exts;
94 char str[128]; 94 char str[128];
95 char mlch = ' ';
96 int nmindent = 0;
97
98 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
99 mlch = '\n';
100 nmindent = 12;
101 }
102
103 if(nmflags == X509_FLAG_COMPAT)
104 nmindent = 16;
105
95 106
96 ri=x->req_info; 107 ri=x->req_info;
97 sprintf(str,"Certificate Request:\n"); 108 if(!(cflag & X509_FLAG_NO_HEADER))
98 if (BIO_puts(bp,str) <= 0) goto err;
99 sprintf(str,"%4sData:\n","");
100 if (BIO_puts(bp,str) <= 0) goto err;
101
102 neg=(ri->version->type == V_ASN1_NEG_INTEGER)?"-":"";
103 l=0;
104 for (i=0; i<ri->version->length; i++)
105 { l<<=8; l+=ri->version->data[i]; }
106 sprintf(str,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg,l);
107 if (BIO_puts(bp,str) <= 0) goto err;
108 sprintf(str,"%8sSubject: ","");
109 if (BIO_puts(bp,str) <= 0) goto err;
110
111 X509_NAME_print(bp,ri->subject,16);
112 sprintf(str,"\n%8sSubject Public Key Info:\n","");
113 if (BIO_puts(bp,str) <= 0) goto err;
114 i=OBJ_obj2nid(ri->pubkey->algor->algorithm);
115 sprintf(str,"%12sPublic Key Algorithm: %s\n","",
116 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
117 if (BIO_puts(bp,str) <= 0) goto err;
118
119 pkey=X509_REQ_get_pubkey(x);
120#ifndef OPENSSL_NO_RSA
121 if (pkey != NULL && pkey->type == EVP_PKEY_RSA)
122 { 109 {
123 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","", 110 if (BIO_write(bp,"Certificate Request:\n",21) <= 0) goto err;
124 BN_num_bits(pkey->pkey.rsa->n)); 111 if (BIO_write(bp," Data:\n",10) <= 0) goto err;
125 RSA_print(bp,pkey->pkey.rsa,16);
126 } 112 }
127 else 113 if(!(cflag & X509_FLAG_NO_VERSION))
128#endif
129#ifndef OPENSSL_NO_DSA
130 if (pkey != NULL && pkey->type == EVP_PKEY_DSA)
131 { 114 {
132 BIO_printf(bp,"%12sDSA Public Key:\n",""); 115 neg=(ri->version->type == V_ASN1_NEG_INTEGER)?"-":"";
133 DSA_print(bp,pkey->pkey.dsa,16); 116 l=0;
117 for (i=0; i<ri->version->length; i++)
118 { l<<=8; l+=ri->version->data[i]; }
119 sprintf(str,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg,l);
120 if (BIO_puts(bp,str) <= 0) goto err;
134 } 121 }
135 else 122 if(!(cflag & X509_FLAG_NO_SUBJECT))
136#endif 123 {
137 BIO_printf(bp,"%12sUnknown Public Key:\n",""); 124 if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err;
125 if (X509_NAME_print_ex(bp,ri->subject,nmindent, nmflags) < 0) goto err;
126 if (BIO_write(bp,"\n",1) <= 0) goto err;
127 }
128 if(!(cflag & X509_FLAG_NO_PUBKEY))
129 {
130 if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0)
131 goto err;
132 if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0)
133 goto err;
134 if (i2a_ASN1_OBJECT(bp, ri->pubkey->algor->algorithm) <= 0)
135 goto err;
136 if (BIO_puts(bp, "\n") <= 0)
137 goto err;
138 138
139 if (pkey != NULL) 139 pkey=X509_REQ_get_pubkey(x);
140 EVP_PKEY_free(pkey); 140 if (pkey == NULL)
141 {
142 BIO_printf(bp,"%12sUnable to load Public Key\n","");
143 ERR_print_errors(bp);
144 }
145 else
146#ifndef OPENSSL_NO_RSA
147 if (pkey->type == EVP_PKEY_RSA)
148 {
149 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
150 BN_num_bits(pkey->pkey.rsa->n));
151 RSA_print(bp,pkey->pkey.rsa,16);
152 }
153 else
154#endif
155#ifndef OPENSSL_NO_DSA
156 if (pkey->type == EVP_PKEY_DSA)
157 {
158 BIO_printf(bp,"%12sDSA Public Key:\n","");
159 DSA_print(bp,pkey->pkey.dsa,16);
160 }
161 else
162#endif
163 BIO_printf(bp,"%12sUnknown Public Key:\n","");
141 164
142 /* may not be */ 165 EVP_PKEY_free(pkey);
143 sprintf(str,"%8sAttributes:\n",""); 166 }
144 if (BIO_puts(bp,str) <= 0) goto err;
145 167
146 sk=x->req_info->attributes; 168 if(!(cflag & X509_FLAG_NO_ATTRIBUTES))
147 if (sk_X509_ATTRIBUTE_num(sk) == 0)
148 { 169 {
149 sprintf(str,"%12sa0:00\n",""); 170 /* may not be */
171 sprintf(str,"%8sAttributes:\n","");
150 if (BIO_puts(bp,str) <= 0) goto err; 172 if (BIO_puts(bp,str) <= 0) goto err;
151 } 173
152 else 174 sk=x->req_info->attributes;
153 { 175 if (sk_X509_ATTRIBUTE_num(sk) == 0)
154 for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
155 { 176 {
156 ASN1_TYPE *at; 177 sprintf(str,"%12sa0:00\n","");
157 X509_ATTRIBUTE *a;
158 ASN1_BIT_STRING *bs=NULL;
159 ASN1_TYPE *t;
160 int j,type=0,count=1,ii=0;
161
162 a=sk_X509_ATTRIBUTE_value(sk,i);
163 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
164 continue;
165 sprintf(str,"%12s","");
166 if (BIO_puts(bp,str) <= 0) goto err; 178 if (BIO_puts(bp,str) <= 0) goto err;
167 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 179 }
180 else
168 { 181 {
169 if (a->single) 182 for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
170 { 183 {
171 t=a->value.single; 184 ASN1_TYPE *at;
172 type=t->type; 185 X509_ATTRIBUTE *a;
173 bs=t->value.bit_string; 186 ASN1_BIT_STRING *bs=NULL;
174 } 187 ASN1_TYPE *t;
175 else 188 int j,type=0,count=1,ii=0;
189
190 a=sk_X509_ATTRIBUTE_value(sk,i);
191 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
192 continue;
193 sprintf(str,"%12s","");
194 if (BIO_puts(bp,str) <= 0) goto err;
195 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
176 { 196 {
177 ii=0; 197 if (a->single)
178 count=sk_ASN1_TYPE_num(a->value.set); 198 {
199 t=a->value.single;
200 type=t->type;
201 bs=t->value.bit_string;
202 }
203 else
204 {
205 ii=0;
206 count=sk_ASN1_TYPE_num(a->value.set);
179get_next: 207get_next:
180 at=sk_ASN1_TYPE_value(a->value.set,ii); 208 at=sk_ASN1_TYPE_value(a->value.set,ii);
181 type=at->type; 209 type=at->type;
182 bs=at->value.asn1_string; 210 bs=at->value.asn1_string;
211 }
212 }
213 for (j=25-j; j>0; j--)
214 if (BIO_write(bp," ",1) != 1) goto err;
215 if (BIO_puts(bp,":") <= 0) goto err;
216 if ( (type == V_ASN1_PRINTABLESTRING) ||
217 (type == V_ASN1_T61STRING) ||
218 (type == V_ASN1_IA5STRING))
219 {
220 if (BIO_write(bp,(char *)bs->data,bs->length)
221 != bs->length)
222 goto err;
223 BIO_puts(bp,"\n");
224 }
225 else
226 {
227 BIO_puts(bp,"unable to print attribute\n");
228 }
229 if (++ii < count) goto get_next;
183 } 230 }
184 } 231 }
185 for (j=25-j; j>0; j--) 232 }
186 if (BIO_write(bp," ",1) != 1) goto err; 233 if(!(cflag & X509_FLAG_NO_ATTRIBUTES))
187 if (BIO_puts(bp,":") <= 0) goto err; 234 {
188 if ( (type == V_ASN1_PRINTABLESTRING) || 235 exts = X509_REQ_get_extensions(x);
189 (type == V_ASN1_T61STRING) || 236 if(exts)
190 (type == V_ASN1_IA5STRING)) 237 {
238 BIO_printf(bp,"%8sRequested Extensions:\n","");
239 for (i=0; i<sk_X509_EXTENSION_num(exts); i++)
191 { 240 {
192 if (BIO_write(bp,(char *)bs->data,bs->length) 241 ASN1_OBJECT *obj;
193 != bs->length) 242 X509_EXTENSION *ex;
243 int j;
244 ex=sk_X509_EXTENSION_value(exts, i);
245 if (BIO_printf(bp,"%12s","") <= 0) goto err;
246 obj=X509_EXTENSION_get_object(ex);
247 i2a_ASN1_OBJECT(bp,obj);
248 j=X509_EXTENSION_get_critical(ex);
249 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
194 goto err; 250 goto err;
195 BIO_puts(bp,"\n"); 251 if(!X509V3_EXT_print(bp, ex, 0, 16))
196 } 252 {
197 else 253 BIO_printf(bp, "%16s", "");
198 { 254 M_ASN1_OCTET_STRING_print(bp,ex->value);
199 BIO_puts(bp,"unable to print attribute\n"); 255 }
256 if (BIO_write(bp,"\n",1) <= 0) goto err;
200 } 257 }
201 if (++ii < count) goto get_next; 258 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
202 } 259 }
203 } 260 }
204 261
205 exts = X509_REQ_get_extensions(x); 262 if(!(cflag & X509_FLAG_NO_SIGDUMP))
206 if(exts) { 263 {
207 BIO_printf(bp,"%8sRequested Extensions:\n",""); 264 if(!X509_signature_print(bp, x->sig_alg, x->signature)) goto err;
208 for (i=0; i<sk_X509_EXTENSION_num(exts); i++) {
209 ASN1_OBJECT *obj;
210 X509_EXTENSION *ex;
211 int j;
212 ex=sk_X509_EXTENSION_value(exts, i);
213 if (BIO_printf(bp,"%12s","") <= 0) goto err;
214 obj=X509_EXTENSION_get_object(ex);
215 i2a_ASN1_OBJECT(bp,obj);
216 j=X509_EXTENSION_get_critical(ex);
217 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
218 goto err;
219 if(!X509V3_EXT_print(bp, ex, 0, 16)) {
220 BIO_printf(bp, "%16s", "");
221 M_ASN1_OCTET_STRING_print(bp,ex->value);
222 }
223 if (BIO_write(bp,"\n",1) <= 0) goto err;
224 } 265 }
225 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
226 }
227
228 if(!X509_signature_print(bp, x->sig_alg, x->signature)) goto err;
229 266
230 return(1); 267 return(1);
231err: 268err:
232 X509err(X509_F_X509_REQ_PRINT,ERR_R_BUF_LIB); 269 X509err(X509_F_X509_REQ_PRINT,ERR_R_BUF_LIB);
233 return(0); 270 return(0);
234 } 271 }
272
273int X509_REQ_print(BIO *bp, X509_REQ *x)
274 {
275 return X509_REQ_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
276 }
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 0fc1f421e2..f87c08793a 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -913,10 +913,10 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *i
913 ctx->ptag = ptag; 913 ctx->ptag = ptag;
914 ctx->hdrlen = p - q; 914 ctx->hdrlen = p - q;
915 ctx->valid = 1; 915 ctx->valid = 1;
916 /* If definite length, length + header can't exceed total 916 /* If definite length, and no error, length +
917 * amount of data available. 917 * header can't exceed total amount of data available.
918 */ 918 */
919 if(!(i & 1) && ((plen + ctx->hdrlen) > len)) { 919 if(!(i & 0x81) && ((plen + ctx->hdrlen) > len)) {
920 ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG); 920 ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG);
921 asn1_tlc_clear(ctx); 921 asn1_tlc_clear(ctx);
922 return 0; 922 return 0;
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 3ce1290772..80c9cb69db 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -109,7 +109,7 @@
109 * o ... (for OpenSSL) 109 * o ... (for OpenSSL)
110 */ 110 */
111 111
112#if HAVE_LONG_DOUBLE 112#ifdef HAVE_LONG_DOUBLE
113#define LDOUBLE long double 113#define LDOUBLE long double
114#else 114#else
115#define LDOUBLE double 115#define LDOUBLE double
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 1eaf879553..b40682f831 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -430,7 +430,7 @@ int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
430int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, 430int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
431 BN_MONT_CTX *mont, BN_CTX *ctx); 431 BN_MONT_CTX *mont, BN_CTX *ctx);
432void BN_MONT_CTX_free(BN_MONT_CTX *mont); 432void BN_MONT_CTX_free(BN_MONT_CTX *mont);
433int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx); 433int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
434BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); 434BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
435 435
436BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod); 436BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod);
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
index 4847a69a71..dfcff11860 100644
--- a/src/lib/libcrypto/crypto-lib.com
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -231,7 +231,7 @@ $ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
231 "rand_vms" 231 "rand_vms"
232$ LIB_ERR = "err,err_all,err_prn" 232$ LIB_ERR = "err,err_all,err_prn"
233$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err" 233$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
234$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ - 234$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,"+ -
235 "e_des,e_bf,e_idea,e_des3,"+ - 235 "e_des,e_bf,e_idea,e_des3,"+ -
236 "e_rc4,e_aes,names,"+ - 236 "e_rc4,e_aes,names,"+ -
237 "e_xcbc_d,e_rc2,e_cast,e_rc5" 237 "e_xcbc_d,e_rc2,e_cast,e_rc5"
@@ -265,14 +265,14 @@ $ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
265 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ - 265 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
266 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info,"+ - 266 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info,"+ -
267 "v3_ocsp,v3_akeya" 267 "v3_ocsp,v3_akeya"
268$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall" 268$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall,conf_sap"
269$ LIB_TXT_DB = "txt_db" 269$ LIB_TXT_DB = "txt_db"
270$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ - 270$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ -
271 "pk7_mime" 271 "pk7_mime"
272$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ - 272$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ -
273 "p12_init,p12_key,p12_kiss,p12_mutl,"+ - 273 "p12_init,p12_key,p12_kiss,p12_mutl,"+ -
274 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e" 274 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e"
275$ LIB_COMP = "comp_lib,"+ - 275$ LIB_COMP = "comp_lib,comp_err,"+ -
276 "c_rle,c_zlib" 276 "c_rle,c_zlib"
277$ LIB_OCSP = "ocsp_asn,ocsp_ext,ocsp_ht,ocsp_lib,ocsp_cl,"+ - 277$ LIB_OCSP = "ocsp_asn,ocsp_ext,ocsp_ht,ocsp_lib,ocsp_cl,"+ -
278 "ocsp_srv,ocsp_prn,ocsp_vfy,ocsp_err" 278 "ocsp_srv,ocsp_prn,ocsp_vfy,ocsp_err"
@@ -1325,7 +1325,7 @@ $ CC4 = CC - CCDISABLEWARNINGS + CC4DISABLEWARNINGS
1325$! 1325$!
1326$! Show user the result 1326$! Show user the result
1327$! 1327$!
1328$ WRITE SYS$OUTPUT "Main C Compiling Command: ",CC 1328$ WRITE/SYMBOL SYS$OUTPUT "Main C Compiling Command: ",CC
1329$! 1329$!
1330$! Else The User Entered An Invalid Arguement. 1330$! Else The User Entered An Invalid Arguement.
1331$! 1331$!
@@ -1356,7 +1356,7 @@ $ IF ARCH .EQS. "AXP" THEN MACRO = "MACRO/MIGRATION/''DEBUGGER'/''MACRO_OPTIMIZE
1356$! 1356$!
1357$! Show user the result 1357$! Show user the result
1358$! 1358$!
1359$ WRITE SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO 1359$ WRITE/SYMBOL SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO
1360$! 1360$!
1361$! Time to check the contents, and to make sure we get the correct library. 1361$! Time to check the contents, and to make sure we get the correct library.
1362$! 1362$!
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
index ee5849d8fa..826ffcc58c 100644
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -207,7 +207,8 @@ ecb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
207ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 207ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
208ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 208ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 209ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
210ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ecb_enc.c spr.h 210ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h ecb_enc.c
211ecb_enc.o: spr.h
211ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 212ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
212ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h 213ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
213ede_cbcm_enc.o: ../../include/openssl/opensslconf.h 214ede_cbcm_enc.o: ../../include/openssl/opensslconf.h
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h
index 0fa94d5368..ec9cc736e3 100644
--- a/src/lib/libcrypto/des/des_ver.h
+++ b/src/lib/libcrypto/des/des_ver.h
@@ -63,5 +63,5 @@
63# define OPENSSL_EXTERN OPENSSL_EXPORT 63# define OPENSSL_EXTERN OPENSSL_EXPORT
64#endif 64#endif
65 65
66OPENSSL_EXTERN char *DES_version; /* SSLeay version string */ 66OPENSSL_EXTERN const char *DES_version; /* SSLeay version string */
67OPENSSL_EXTERN char *libdes_version; /* old libdes version string */ 67OPENSSL_EXTERN const char *libdes_version; /* old libdes version string */
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index 4650f2fa0f..1b70f68806 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "des_ver.h"
60#include "spr.h" 61#include "spr.h"
61#include <openssl/opensslv.h> 62#include <openssl/opensslv.h>
62 63
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index 683916e71b..143008ed9c 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -342,7 +342,7 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
342 register DES_LONG *k; 342 register DES_LONG *k;
343 register int i; 343 register int i;
344 344
345#if OPENBSD_DEV_CRYPTO 345#ifdef OPENBSD_DEV_CRYPTO
346 memcpy(schedule->key,key,sizeof schedule->key); 346 memcpy(schedule->key,key,sizeof schedule->key);
347 schedule->session=NULL; 347 schedule->session=NULL;
348#endif 348#endif
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod
index d990bf8786..73261fc467 100644
--- a/src/lib/libcrypto/doc/DH_set_method.pod
+++ b/src/lib/libcrypto/doc/DH_set_method.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5DH_set_default_openssl_method, DH_get_default_openssl_method, 5DH_set_default_method, DH_get_default_method,
6DH_set_method, DH_new_method, DH_OpenSSL - select DH method 6DH_set_method, DH_new_method, DH_OpenSSL - select DH method
7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
@@ -10,45 +10,47 @@ DH_set_method, DH_new_method, DH_OpenSSL - select DH method
10 #include <openssl/dh.h> 10 #include <openssl/dh.h>
11 #include <openssl/engine.h> 11 #include <openssl/engine.h>
12 12
13 void DH_set_default_openssl_method(DH_METHOD *meth); 13 void DH_set_default_method(const DH_METHOD *meth);
14 14
15 DH_METHOD *DH_get_default_openssl_method(void); 15 const DH_METHOD *DH_get_default_method(void);
16 16
17 int DH_set_method(DH *dh, ENGINE *engine); 17 int DH_set_method(DH *dh, const DH_METHOD *meth);
18 18
19 DH *DH_new_method(ENGINE *engine); 19 DH *DH_new_method(ENGINE *engine);
20 20
21 DH_METHOD *DH_OpenSSL(void); 21 const DH_METHOD *DH_OpenSSL(void);
22 22
23=head1 DESCRIPTION 23=head1 DESCRIPTION
24 24
25A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman 25A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman
26operations. By modifying the method, alternative implementations 26operations. By modifying the method, alternative implementations
27such as hardware accelerators may be used. 27such as hardware accelerators may be used. IMPORTANT: See the NOTES section for
28 28important information about how these DH API functions are affected by the use
29Initially, the default is to use the OpenSSL internal implementation. 29of B<ENGINE> API calls.
30DH_OpenSSL() returns a pointer to that method. 30
31 31Initially, the default DH_METHOD is the OpenSSL internal implementation, as
32DH_set_default_openssl_method() makes B<meth> the default method for all DH 32returned by DH_OpenSSL().
33structures created later. B<NB:> This is true only whilst the default engine 33
34for Diffie-Hellman operations remains as "openssl". ENGINEs provide an 34DH_set_default_method() makes B<meth> the default method for all DH
35encapsulation for implementations of one or more algorithms, and all the DH 35structures created later. B<NB>: This is true only whilst no ENGINE has been set
36functions mentioned here operate within the scope of the default 36as a default for DH, so this function is no longer recommended.
37"openssl" engine. 37
38 38DH_get_default_method() returns a pointer to the current default DH_METHOD.
39DH_get_default_openssl_method() returns a pointer to the current default 39However, the meaningfulness of this result is dependant on whether the ENGINE
40method for the "openssl" engine. 40API is being used, so this function is no longer recommended.
41 41
42DH_set_method() selects B<engine> as the engine that will be responsible for 42DH_set_method() selects B<meth> to perform all operations using the key B<dh>.
43all operations using the structure B<dh>. If this function completes successfully, 43This will replace the DH_METHOD used by the DH key and if the previous method
44then the B<dh> structure will have its own functional reference of B<engine>, so 44was supplied by an ENGINE, the handle to that ENGINE will be released during the
45the caller should remember to free their own reference to B<engine> when they are 45change. It is possible to have DH keys that only work with certain DH_METHOD
46finished with it. NB: An ENGINE's DH_METHOD can be retrieved (or set) by 46implementations (eg. from an ENGINE module that supports embedded
47ENGINE_get_DH() or ENGINE_set_DH(). 47hardware-protected keys), and in such cases attempting to change the DH_METHOD
48 48for the key can have unexpected results.
49DH_new_method() allocates and initializes a DH structure so that 49
50B<engine> will be used for the DH operations. If B<engine> is NULL, 50DH_new_method() allocates and initializes a DH structure so that B<engine> will
51the default engine for Diffie-Hellman opertaions is used. 51be used for the DH operations. If B<engine> is NULL, the default ENGINE for DH
52operations is used, and if no default ENGINE is set, the DH_METHOD controlled by
53DH_set_default_method() is used.
52 54
53=head1 THE DH_METHOD STRUCTURE 55=head1 THE DH_METHOD STRUCTURE
54 56
@@ -82,17 +84,28 @@ the default engine for Diffie-Hellman opertaions is used.
82 84
83=head1 RETURN VALUES 85=head1 RETURN VALUES
84 86
85DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the 87DH_OpenSSL() and DH_get_default_method() return pointers to the respective
86respective B<DH_METHOD>s. 88B<DH_METHOD>s.
89
90DH_set_default_method() returns no value.
91
92DH_set_method() returns non-zero if the provided B<meth> was successfully set as
93the method for B<dh> (including unloading the ENGINE handle if the previous
94method was supplied by an ENGINE).
87 95
88DH_set_default_openssl_method() returns no value. 96DH_new_method() returns NULL and sets an error code that can be obtained by
97L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
98returns a pointer to the newly allocated structure.
89 99
90DH_set_method() returns non-zero if the ENGINE associated with B<dh> 100=head1 NOTES
91was successfully changed to B<engine>.
92 101
93DH_new_method() returns NULL and sets an error code that can be 102As of version 0.9.7, DH_METHOD implementations are grouped together with other
94obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. 103algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
95Otherwise it returns a pointer to the newly allocated structure. 104default ENGINE is specified for DH functionality using an ENGINE API function,
105that will override any DH defaults set using the DH API (ie.
106DH_set_default_method()). For this reason, the ENGINE API is the recommended way
107to control default implementations for use in DH and other cryptographic
108algorithms.
96 109
97=head1 SEE ALSO 110=head1 SEE ALSO
98 111
@@ -103,9 +116,14 @@ L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
103DH_set_default_method(), DH_get_default_method(), DH_set_method(), 116DH_set_default_method(), DH_get_default_method(), DH_set_method(),
104DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4. 117DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.
105 118
106DH_set_default_openssl_method() and DH_get_default_openssl_method() 119DH_set_default_openssl_method() and DH_get_default_openssl_method() replaced
107replaced DH_set_default_method() and DH_get_default_method() respectively, 120DH_set_default_method() and DH_get_default_method() respectively, and
108and DH_set_method() and DH_new_method() were altered to use B<ENGINE>s 121DH_set_method() and DH_new_method() were altered to use B<ENGINE>s rather than
109rather than B<DH_METHOD>s during development of OpenSSL 0.9.6. 122B<DH_METHOD>s during development of the engine version of OpenSSL 0.9.6. For
1230.9.7, the handling of defaults in the ENGINE API was restructured so that this
124change was reversed, and behaviour of the other functions resembled more closely
125the previous behaviour. The behaviour of defaults in the ENGINE API now
126transparently overrides the behaviour of defaults in the DH API without
127requiring changing these function prototypes.
110 128
111=cut 129=cut
diff --git a/src/lib/libcrypto/doc/DSA_dup_DH.pod b/src/lib/libcrypto/doc/DSA_dup_DH.pod
index 695f99a13b..7f6f0d1115 100644
--- a/src/lib/libcrypto/doc/DSA_dup_DH.pod
+++ b/src/lib/libcrypto/doc/DSA_dup_DH.pod
@@ -8,7 +8,7 @@ DSA_dup_DH - create a DH structure out of DSA structure
8 8
9 #include <openssl/dsa.h> 9 #include <openssl/dsa.h>
10 10
11 DH * DSA_dup_DH(DSA *r); 11 DH * DSA_dup_DH(const DSA *r);
12 12
13=head1 DESCRIPTION 13=head1 DESCRIPTION
14 14
diff --git a/src/lib/libcrypto/doc/DSA_new.pod b/src/lib/libcrypto/doc/DSA_new.pod
index 301af912dd..48e9b82a09 100644
--- a/src/lib/libcrypto/doc/DSA_new.pod
+++ b/src/lib/libcrypto/doc/DSA_new.pod
@@ -14,7 +14,8 @@ DSA_new, DSA_free - allocate and free DSA objects
14 14
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17DSA_new() allocates and initializes a B<DSA> structure. 17DSA_new() allocates and initializes a B<DSA> structure. It is equivalent to
18calling DSA_new_method(NULL).
18 19
19DSA_free() frees the B<DSA> structure and its components. The values are 20DSA_free() frees the B<DSA> structure and its components. The values are
20erased before the memory is returned to the system. 21erased before the memory is returned to the system.
diff --git a/src/lib/libcrypto/doc/DSA_set_method.pod b/src/lib/libcrypto/doc/DSA_set_method.pod
index 36a1052d27..bc3cfb1f0a 100644
--- a/src/lib/libcrypto/doc/DSA_set_method.pod
+++ b/src/lib/libcrypto/doc/DSA_set_method.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5DSA_set_default_openssl_method, DSA_get_default_openssl_method, 5DSA_set_default_method, DSA_get_default_method,
6DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method 6DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
@@ -10,11 +10,11 @@ DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
10 #include <openssl/dsa.h> 10 #include <openssl/dsa.h>
11 #include <openssl/engine.h> 11 #include <openssl/engine.h>
12 12
13 void DSA_set_default_openssl_method(DSA_METHOD *meth); 13 void DSA_set_default_method(const DSA_METHOD *meth);
14 14
15 DSA_METHOD *DSA_get_default_openssl_method(void); 15 const DSA_METHOD *DSA_get_default_method(void);
16 16
17 int DSA_set_method(DSA *dsa, ENGINE *engine); 17 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth);
18 18
19 DSA *DSA_new_method(ENGINE *engine); 19 DSA *DSA_new_method(ENGINE *engine);
20 20
@@ -24,26 +24,35 @@ DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
24 24
25A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA 25A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA
26operations. By modifying the method, alternative implementations 26operations. By modifying the method, alternative implementations
27such as hardware accelerators may be used. 27such as hardware accelerators may be used. IMPORTANT: See the NOTES section for
28 28important information about how these DSA API functions are affected by the use
29Initially, the default is to use the OpenSSL internal implementation. 29of B<ENGINE> API calls.
30DSA_OpenSSL() returns a pointer to that method. 30
31 31Initially, the default DSA_METHOD is the OpenSSL internal implementation,
32DSA_set_default_openssl_method() makes B<meth> the default method for 32as returned by DSA_OpenSSL().
33all DSA structures created later. B<NB:> This is true only whilst the 33
34default engine for DSA operations remains as "openssl". ENGINEs 34DSA_set_default_method() makes B<meth> the default method for all DSA
35provide an encapsulation for implementations of one or more algorithms at a 35structures created later. B<NB>: This is true only whilst no ENGINE has
36time, and all the DSA functions mentioned here operate within the scope 36been set as a default for DSA, so this function is no longer recommended.
37of the default "openssl" engine. 37
38 38DSA_get_default_method() returns a pointer to the current default
39DSA_get_default_openssl_method() returns a pointer to the current default 39DSA_METHOD. However, the meaningfulness of this result is dependant on
40method for the "openssl" engine. 40whether the ENGINE API is being used, so this function is no longer
41 41recommended.
42DSA_set_method() selects B<engine> for all operations using the structure B<dsa>. 42
43 43DSA_set_method() selects B<meth> to perform all operations using the key
44DSA_new_method() allocates and initializes a DSA structure so that 44B<rsa>. This will replace the DSA_METHOD used by the DSA key and if the
45B<engine> will be used for the DSA operations. If B<engine> is NULL, 45previous method was supplied by an ENGINE, the handle to that ENGINE will
46the default engine for DSA operations is used. 46be released during the change. It is possible to have DSA keys that only
47work with certain DSA_METHOD implementations (eg. from an ENGINE module
48that supports embedded hardware-protected keys), and in such cases
49attempting to change the DSA_METHOD for the key can have unexpected
50results.
51
52DSA_new_method() allocates and initializes a DSA structure so that B<engine>
53will be used for the DSA operations. If B<engine> is NULL, the default engine
54for DSA operations is used, and if no default ENGINE is set, the DSA_METHOD
55controlled by DSA_set_default_method() is used.
47 56
48=head1 THE DSA_METHOD STRUCTURE 57=head1 THE DSA_METHOD STRUCTURE
49 58
@@ -89,18 +98,29 @@ struct
89 98
90=head1 RETURN VALUES 99=head1 RETURN VALUES
91 100
92DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the 101DSA_OpenSSL() and DSA_get_default_method() return pointers to the respective
93respective B<DSA_METHOD>s. 102B<DSA_METHOD>s.
94 103
95DSA_set_default_openssl_method() returns no value. 104DSA_set_default_method() returns no value.
96 105
97DSA_set_method() returns non-zero if the ENGINE associated with B<dsa> 106DSA_set_method() returns non-zero if the provided B<meth> was successfully set as
98was successfully changed to B<engine>. 107the method for B<dsa> (including unloading the ENGINE handle if the previous
108method was supplied by an ENGINE).
99 109
100DSA_new_method() returns NULL and sets an error code that can be 110DSA_new_method() returns NULL and sets an error code that can be
101obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation 111obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
102fails. Otherwise it returns a pointer to the newly allocated structure. 112fails. Otherwise it returns a pointer to the newly allocated structure.
103 113
114=head1 NOTES
115
116As of version 0.9.7, DSA_METHOD implementations are grouped together with other
117algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
118default ENGINE is specified for DSA functionality using an ENGINE API function,
119that will override any DSA defaults set using the DSA API (ie.
120DSA_set_default_method()). For this reason, the ENGINE API is the recommended way
121to control default implementations for use in DSA and other cryptographic
122algorithms.
123
104=head1 SEE ALSO 124=head1 SEE ALSO
105 125
106L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)> 126L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
@@ -110,9 +130,14 @@ L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
110DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(), 130DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
111DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4. 131DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
112 132
113DSA_set_default_openssl_method() and DSA_get_default_openssl_method() 133DSA_set_default_openssl_method() and DSA_get_default_openssl_method() replaced
114replaced DSA_set_default_method() and DSA_get_default_method() respectively, 134DSA_set_default_method() and DSA_get_default_method() respectively, and
115and DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s 135DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s rather than
116rather than B<DSA_METHOD>s during development of OpenSSL 0.9.6. 136B<DSA_METHOD>s during development of the engine version of OpenSSL 0.9.6. For
1370.9.7, the handling of defaults in the ENGINE API was restructured so that this
138change was reversed, and behaviour of the other functions resembled more closely
139the previous behaviour. The behaviour of defaults in the ENGINE API now
140transparently overrides the behaviour of defaults in the DSA API without
141requiring changing these function prototypes.
117 142
118=cut 143=cut
diff --git a/src/lib/libcrypto/doc/DSA_size.pod b/src/lib/libcrypto/doc/DSA_size.pod
index 23b6320a4d..ba4f650361 100644
--- a/src/lib/libcrypto/doc/DSA_size.pod
+++ b/src/lib/libcrypto/doc/DSA_size.pod
@@ -8,7 +8,7 @@ DSA_size - get DSA signature size
8 8
9 #include <openssl/dsa.h> 9 #include <openssl/dsa.h>
10 10
11 int DSA_size(DSA *dsa); 11 int DSA_size(const DSA *dsa);
12 12
13=head1 DESCRIPTION 13=head1 DESCRIPTION
14 14
diff --git a/src/lib/libcrypto/doc/EVP_SealInit.pod b/src/lib/libcrypto/doc/EVP_SealInit.pod
index 0451eb648a..25ef07f7c7 100644
--- a/src/lib/libcrypto/doc/EVP_SealInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SealInit.pod
@@ -73,4 +73,6 @@ L<EVP_OpenInit(3)|EVP_OpenInit(3)>
73 73
74=head1 HISTORY 74=head1 HISTORY
75 75
76EVP_SealFinal() did not return a value before OpenSSL 0.9.7.
77
76=cut 78=cut
diff --git a/src/lib/libcrypto/doc/RAND_set_rand_method.pod b/src/lib/libcrypto/doc/RAND_set_rand_method.pod
index 464eba416d..c9bb6d9f27 100644
--- a/src/lib/libcrypto/doc/RAND_set_rand_method.pod
+++ b/src/lib/libcrypto/doc/RAND_set_rand_method.pod
@@ -8,22 +8,30 @@ RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method
8 8
9 #include <openssl/rand.h> 9 #include <openssl/rand.h>
10 10
11 void RAND_set_rand_method(RAND_METHOD *meth); 11 void RAND_set_rand_method(const RAND_METHOD *meth);
12 12
13 RAND_METHOD *RAND_get_rand_method(void); 13 const RAND_METHOD *RAND_get_rand_method(void);
14 14
15 RAND_METHOD *RAND_SSLeay(void); 15 RAND_METHOD *RAND_SSLeay(void);
16 16
17=head1 DESCRIPTION 17=head1 DESCRIPTION
18 18
19A B<RAND_METHOD> specifies the functions that OpenSSL uses for random 19A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number
20number generation. By modifying the method, alternative 20generation. By modifying the method, alternative implementations such as
21implementations such as hardware RNGs may be used. Initially, the 21hardware RNGs may be used. IMPORTANT: See the NOTES section for important
22default is to use the OpenSSL internal implementation. RAND_SSLeay() 22information about how these RAND API functions are affected by the use of
23returns a pointer to that method. 23B<ENGINE> API calls.
24 24
25RAND_set_rand_method() sets the RAND method to B<meth>. 25Initially, the default RAND_METHOD is the OpenSSL internal implementation, as
26RAND_get_rand_method() returns a pointer to the current method. 26returned by RAND_SSLeay().
27
28RAND_set_default_method() makes B<meth> the method for PRNG use. B<NB>: This is
29true only whilst no ENGINE has been set as a default for RAND, so this function
30is no longer recommended.
31
32RAND_get_default_method() returns a pointer to the current RAND_METHOD.
33However, the meaningfulness of this result is dependant on whether the ENGINE
34API is being used, so this function is no longer recommended.
27 35
28=head1 THE RAND_METHOD STRUCTURE 36=head1 THE RAND_METHOD STRUCTURE
29 37
@@ -47,13 +55,29 @@ Each component may be NULL if the function is not implemented.
47RAND_set_rand_method() returns no value. RAND_get_rand_method() and 55RAND_set_rand_method() returns no value. RAND_get_rand_method() and
48RAND_SSLeay() return pointers to the respective methods. 56RAND_SSLeay() return pointers to the respective methods.
49 57
58=head1 NOTES
59
60As of version 0.9.7, RAND_METHOD implementations are grouped together with other
61algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
62default ENGINE is specified for RAND functionality using an ENGINE API function,
63that will override any RAND defaults set using the RAND API (ie.
64RAND_set_rand_method()). For this reason, the ENGINE API is the recommended way
65to control default implementations for use in RAND and other cryptographic
66algorithms.
67
50=head1 SEE ALSO 68=head1 SEE ALSO
51 69
52L<rand(3)|rand(3)> 70L<rand(3)|rand(3)>, L<engine(3)|engine(3)>
53 71
54=head1 HISTORY 72=head1 HISTORY
55 73
56RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are 74RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are
57available in all versions of OpenSSL. 75available in all versions of OpenSSL.
58 76
77In the engine version of version 0.9.6, RAND_set_rand_method() was altered to
78take an ENGINE pointer as its argument. As of version 0.9.7, that has been
79reverted as the ENGINE API transparently overrides RAND defaults if used,
80otherwise RAND API functions work as before. RAND_set_rand_engine() was also
81introduced in version 0.9.7.
82
59=cut 83=cut
diff --git a/src/lib/libcrypto/doc/RSA_new.pod b/src/lib/libcrypto/doc/RSA_new.pod
index 299047f31f..3d15b92824 100644
--- a/src/lib/libcrypto/doc/RSA_new.pod
+++ b/src/lib/libcrypto/doc/RSA_new.pod
@@ -14,7 +14,8 @@ RSA_new, RSA_free - allocate and free RSA objects
14 14
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17RSA_new() allocates and initializes an B<RSA> structure. 17RSA_new() allocates and initializes an B<RSA> structure. It is equivalent to
18calling RSA_new_method(NULL).
18 19
19RSA_free() frees the B<RSA> structure and its components. The key is 20RSA_free() frees the B<RSA> structure and its components. The key is
20erased before the memory is returned to the system. 21erased before the memory is returned to the system.
@@ -30,7 +31,8 @@ RSA_free() returns no value.
30=head1 SEE ALSO 31=head1 SEE ALSO
31 32
32L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>, 33L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>,
33L<RSA_generate_key(3)|RSA_generate_key(3)> 34L<RSA_generate_key(3)|RSA_generate_key(3)>,
35L<RSA_new_method(3)|RSA_new_method(3)>
34 36
35=head1 HISTORY 37=head1 HISTORY
36 38
diff --git a/src/lib/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod
index 14917dd35f..0687c2242a 100644
--- a/src/lib/libcrypto/doc/RSA_set_method.pod
+++ b/src/lib/libcrypto/doc/RSA_set_method.pod
@@ -11,52 +11,64 @@ RSA_null_method, RSA_flags, RSA_new_method - select RSA method
11 #include <openssl/rsa.h> 11 #include <openssl/rsa.h>
12 #include <openssl/engine.h> 12 #include <openssl/engine.h>
13 13
14 void RSA_set_default_openssl_method(RSA_METHOD *meth); 14 void RSA_set_default_method(const RSA_METHOD *meth);
15 15
16 RSA_METHOD *RSA_get_default_openssl_method(void); 16 RSA_METHOD *RSA_get_default_method(void);
17 17
18 int RSA_set_method(RSA *rsa, ENGINE *engine); 18 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
19 19
20 RSA_METHOD *RSA_get_method(RSA *rsa); 20 RSA_METHOD *RSA_get_method(const RSA *rsa);
21 21
22 RSA_METHOD *RSA_PKCS1_SSLeay(void); 22 RSA_METHOD *RSA_PKCS1_SSLeay(void);
23 23
24 RSA_METHOD *RSA_null_method(void); 24 RSA_METHOD *RSA_null_method(void);
25 25
26 int RSA_flags(RSA *rsa); 26 int RSA_flags(const RSA *rsa);
27 27
28 RSA *RSA_new_method(ENGINE *engine); 28 RSA *RSA_new_method(ENGINE *engine);
29 29
30=head1 DESCRIPTION 30=head1 DESCRIPTION
31 31
32An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA 32An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
33operations. By modifying the method, alternative implementations 33operations. By modifying the method, alternative implementations such as
34such as hardware accelerators may be used. 34hardware accelerators may be used. IMPORTANT: See the NOTES section for
35 35important information about how these RSA API functions are affected by the
36Initially, the default is to use the OpenSSL internal implementation. 36use of B<ENGINE> API calls.
37RSA_PKCS1_SSLeay() returns a pointer to that method. 37
38 38Initially, the default RSA_METHOD is the OpenSSL internal implementation,
39RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA> 39as returned by RSA_PKCS1_SSLeay().
40structures created later. B<NB:> This is true only whilst the default engine 40
41for RSA operations remains as "openssl". ENGINEs provide an 41RSA_set_default_method() makes B<meth> the default method for all RSA
42encapsulation for implementations of one or more algorithms at a time, and all 42structures created later. B<NB>: This is true only whilst no ENGINE has
43the RSA functions mentioned here operate within the scope of the default 43been set as a default for RSA, so this function is no longer recommended.
44"openssl" engine. 44
45 45RSA_get_default_method() returns a pointer to the current default
46RSA_get_default_openssl_method() returns a pointer to the current default 46RSA_METHOD. However, the meaningfulness of this result is dependant on
47method for the "openssl" engine. 47whether the ENGINE API is being used, so this function is no longer
48 48recommended.
49RSA_set_method() selects B<engine> for all operations using the key 49
50B<rsa>. 50RSA_set_method() selects B<meth> to perform all operations using the key
51 51B<rsa>. This will replace the RSA_METHOD used by the RSA key and if the
52RSA_get_method() returns a pointer to the RSA_METHOD from the currently 52previous method was supplied by an ENGINE, the handle to that ENGINE will
53selected ENGINE for B<rsa>. 53be released during the change. It is possible to have RSA keys that only
54 54work with certain RSA_METHOD implementations (eg. from an ENGINE module
55RSA_flags() returns the B<flags> that are set for B<rsa>'s current method. 55that supports embedded hardware-protected keys), and in such cases
56attempting to change the RSA_METHOD for the key can have unexpected
57results.
58
59RSA_get_method() returns a pointer to the RSA_METHOD being used by B<rsa>.
60This method may or may not be supplied by an ENGINE implementation, but if
61it is, the return value can only be guaranteed to be valid as long as the
62RSA key itself is valid and does not have its implementation changed by
63RSA_set_method().
64
65RSA_flags() returns the B<flags> that are set for B<rsa>'s current
66RSA_METHOD. See the BUGS section.
56 67
57RSA_new_method() allocates and initializes an RSA structure so that 68RSA_new_method() allocates and initializes an RSA structure so that
58B<engine> will be used for the RSA operations. If B<engine> is NULL, 69B<engine> will be used for the RSA operations. If B<engine> is NULL, the
59the default engine for RSA operations is used. 70default ENGINE for RSA operations is used, and if no default ENGINE is set,
71the RSA_METHOD controlled by RSA_set_default_method() is used.
60 72
61=head1 THE RSA_METHOD STRUCTURE 73=head1 THE RSA_METHOD STRUCTURE
62 74
@@ -121,22 +133,45 @@ the default engine for RSA operations is used.
121 133
122=head1 RETURN VALUES 134=head1 RETURN VALUES
123 135
124RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method() 136RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_method()
125and RSA_get_method() return pointers to the respective RSA_METHODs. 137and RSA_get_method() return pointers to the respective RSA_METHODs.
126 138
127RSA_set_default_openssl_method() returns no value. 139RSA_set_default_method() returns no value.
128 140
129RSA_set_method() selects B<engine> as the engine that will be responsible for 141RSA_set_method() returns a pointer to the old RSA_METHOD implementation
130all operations using the structure B<rsa>. If this function completes successfully, 142that was replaced. However, this return value should probably be ignored
131then the B<rsa> structure will have its own functional reference of B<engine>, so 143because if it was supplied by an ENGINE, the pointer could be invalidated
132the caller should remember to free their own reference to B<engine> when they are 144at any time if the ENGINE is unloaded (in fact it could be unloaded as a
133finished with it. NB: An ENGINE's RSA_METHOD can be retrieved (or set) by 145result of the RSA_set_method() function releasing its handle to the
134ENGINE_get_RSA() or ENGINE_set_RSA(). 146ENGINE). For this reason, the return type may be replaced with a B<void>
147declaration in a future release.
135 148
136RSA_new_method() returns NULL and sets an error code that can be 149RSA_new_method() returns NULL and sets an error code that can be obtained
137obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise 150by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise
138it returns a pointer to the newly allocated structure. 151it returns a pointer to the newly allocated structure.
139 152
153=head1 NOTES
154
155As of version 0.9.7, RSA_METHOD implementations are grouped together with
156other algorithmic APIs (eg. DSA_METHOD, EVP_CIPHER, etc) into B<ENGINE>
157modules. If a default ENGINE is specified for RSA functionality using an
158ENGINE API function, that will override any RSA defaults set using the RSA
159API (ie. RSA_set_default_method()). For this reason, the ENGINE API is the
160recommended way to control default implementations for use in RSA and other
161cryptographic algorithms.
162
163=head1 BUGS
164
165The behaviour of RSA_flags() is a mis-feature that is left as-is for now
166to avoid creating compatibility problems. RSA functionality, such as the
167encryption functions, are controlled by the B<flags> value in the RSA key
168itself, not by the B<flags> value in the RSA_METHOD attached to the RSA key
169(which is what this function returns). If the flags element of an RSA key
170is changed, the changes will be honoured by RSA functionality but will not
171be reflected in the return value of the RSA_flags() function - in effect
172RSA_flags() behaves more like an RSA_default_flags() function (which does
173not currently exist).
174
140=head1 SEE ALSO 175=head1 SEE ALSO
141 176
142L<rsa(3)|rsa(3)>, L<RSA_new(3)|RSA_new(3)> 177L<rsa(3)|rsa(3)>, L<RSA_new(3)|RSA_new(3)>
@@ -149,8 +184,14 @@ well as the rsa_sign and rsa_verify components of RSA_METHOD were
149added in OpenSSL 0.9.4. 184added in OpenSSL 0.9.4.
150 185
151RSA_set_default_openssl_method() and RSA_get_default_openssl_method() 186RSA_set_default_openssl_method() and RSA_get_default_openssl_method()
152replaced RSA_set_default_method() and RSA_get_default_method() respectively, 187replaced RSA_set_default_method() and RSA_get_default_method()
153and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s 188respectively, and RSA_set_method() and RSA_new_method() were altered to use
154rather than B<RSA_METHOD>s during development of OpenSSL 0.9.6. 189B<ENGINE>s rather than B<RSA_METHOD>s during development of the engine
190version of OpenSSL 0.9.6. For 0.9.7, the handling of defaults in the ENGINE
191API was restructured so that this change was reversed, and behaviour of the
192other functions resembled more closely the previous behaviour. The
193behaviour of defaults in the ENGINE API now transparently overrides the
194behaviour of defaults in the RSA API without requiring changing these
195function prototypes.
155 196
156=cut 197=cut
diff --git a/src/lib/libcrypto/doc/RSA_size.pod b/src/lib/libcrypto/doc/RSA_size.pod
index b36b4d58d5..5b7f835f95 100644
--- a/src/lib/libcrypto/doc/RSA_size.pod
+++ b/src/lib/libcrypto/doc/RSA_size.pod
@@ -8,7 +8,7 @@ RSA_size - get RSA modulus size
8 8
9 #include <openssl/rsa.h> 9 #include <openssl/rsa.h>
10 10
11 int RSA_size(RSA *rsa); 11 int RSA_size(const RSA *rsa);
12 12
13=head1 DESCRIPTION 13=head1 DESCRIPTION
14 14
diff --git a/src/lib/libcrypto/doc/dh.pod b/src/lib/libcrypto/doc/dh.pod
index b4be4be405..c3ccd06207 100644
--- a/src/lib/libcrypto/doc/dh.pod
+++ b/src/lib/libcrypto/doc/dh.pod
@@ -12,20 +12,20 @@ dh - Diffie-Hellman key agreement
12 DH * DH_new(void); 12 DH * DH_new(void);
13 void DH_free(DH *dh); 13 void DH_free(DH *dh);
14 14
15 int DH_size(DH *dh); 15 int DH_size(const DH *dh);
16 16
17 DH * DH_generate_parameters(int prime_len, int generator, 17 DH * DH_generate_parameters(int prime_len, int generator,
18 void (*callback)(int, int, void *), void *cb_arg); 18 void (*callback)(int, int, void *), void *cb_arg);
19 int DH_check(DH *dh, int *codes); 19 int DH_check(const DH *dh, int *codes);
20 20
21 int DH_generate_key(DH *dh); 21 int DH_generate_key(DH *dh);
22 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); 22 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
23 23
24 void DH_set_default_openssl_method(DH_METHOD *meth); 24 void DH_set_default_method(const DH_METHOD *meth);
25 DH_METHOD *DH_get_default_openssl_method(void); 25 const DH_METHOD *DH_get_default_method(void);
26 int DH_set_method(DH *dh, ENGINE *engine); 26 int DH_set_method(DH *dh, const DH_METHOD *meth);
27 DH *DH_new_method(ENGINE *engine); 27 DH *DH_new_method(ENGINE *engine);
28 DH_METHOD *DH_OpenSSL(void); 28 const DH_METHOD *DH_OpenSSL(void);
29 29
30 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(), 30 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(),
31 int (*dup_func)(), void (*free_func)()); 31 int (*dup_func)(), void (*free_func)());
@@ -33,10 +33,10 @@ dh - Diffie-Hellman key agreement
33 char *DH_get_ex_data(DH *d, int idx); 33 char *DH_get_ex_data(DH *d, int idx);
34 34
35 DH * d2i_DHparams(DH **a, unsigned char **pp, long length); 35 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
36 int i2d_DHparams(DH *a, unsigned char **pp); 36 int i2d_DHparams(const DH *a, unsigned char **pp);
37 37
38 int DHparams_print_fp(FILE *fp, DH *x); 38 int DHparams_print_fp(FILE *fp, const DH *x);
39 int DHparams_print(BIO *bp, DH *x); 39 int DHparams_print(BIO *bp, const DH *x);
40 40
41=head1 DESCRIPTION 41=head1 DESCRIPTION
42 42
@@ -57,11 +57,20 @@ The B<DH> structure consists of several BIGNUM components.
57 }; 57 };
58 DH 58 DH
59 59
60Note that DH keys may use non-standard B<DH_METHOD> implementations,
61either directly or by the use of B<ENGINE> modules. In some cases (eg. an
62ENGINE providing support for hardware-embedded keys), these BIGNUM values
63will not be used by the implementation or may be used for alternative data
64storage. For this reason, applications should generally avoid using DH
65structure elements directly and instead use API functions to query or
66modify keys.
67
60=head1 SEE ALSO 68=head1 SEE ALSO
61 69
62L<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, 70L<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
63L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<DH_set_method(3)|DH_set_method(3)>, 71L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<engine(3)|engine(3)>,
64L<DH_new(3)|DH_new(3)>, L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>, 72L<DH_set_method(3)|DH_set_method(3)>, L<DH_new(3)|DH_new(3)>,
73L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>,
65L<DH_generate_parameters(3)|DH_generate_parameters(3)>, 74L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
66L<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>, 75L<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>,
67L<RSA_print(3)|RSA_print(3)> 76L<RSA_print(3)|RSA_print(3)>
diff --git a/src/lib/libcrypto/doc/dsa.pod b/src/lib/libcrypto/doc/dsa.pod
index 573500204b..ae2e5d81f9 100644
--- a/src/lib/libcrypto/doc/dsa.pod
+++ b/src/lib/libcrypto/doc/dsa.pod
@@ -12,13 +12,13 @@ dsa - Digital Signature Algorithm
12 DSA * DSA_new(void); 12 DSA * DSA_new(void);
13 void DSA_free(DSA *dsa); 13 void DSA_free(DSA *dsa);
14 14
15 int DSA_size(DSA *dsa); 15 int DSA_size(const DSA *dsa);
16 16
17 DSA * DSA_generate_parameters(int bits, unsigned char *seed, 17 DSA * DSA_generate_parameters(int bits, unsigned char *seed,
18 int seed_len, int *counter_ret, unsigned long *h_ret, 18 int seed_len, int *counter_ret, unsigned long *h_ret,
19 void (*callback)(int, int, void *), void *cb_arg); 19 void (*callback)(int, int, void *), void *cb_arg);
20 20
21 DH * DSA_dup_DH(DSA *r); 21 DH * DSA_dup_DH(const DSA *r);
22 22
23 int DSA_generate_key(DSA *dsa); 23 int DSA_generate_key(DSA *dsa);
24 24
@@ -27,13 +27,13 @@ dsa - Digital Signature Algorithm
27 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, 27 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
28 BIGNUM **rp); 28 BIGNUM **rp);
29 int DSA_verify(int dummy, const unsigned char *dgst, int len, 29 int DSA_verify(int dummy, const unsigned char *dgst, int len,
30 unsigned char *sigbuf, int siglen, DSA *dsa); 30 const unsigned char *sigbuf, int siglen, DSA *dsa);
31 31
32 void DSA_set_default_openssl_method(DSA_METHOD *meth); 32 void DSA_set_default_method(const DSA_METHOD *meth);
33 DSA_METHOD *DSA_get_default_openssl_method(void); 33 const DSA_METHOD *DSA_get_default_method(void);
34 int DSA_set_method(DSA *dsa, ENGINE *engine); 34 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth);
35 DSA *DSA_new_method(ENGINE *engine); 35 DSA *DSA_new_method(ENGINE *engine);
36 DSA_METHOD *DSA_OpenSSL(void); 36 const DSA_METHOD *DSA_OpenSSL(void);
37 37
38 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), 38 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
39 int (*dup_func)(), void (*free_func)()); 39 int (*dup_func)(), void (*free_func)());
@@ -42,7 +42,7 @@ dsa - Digital Signature Algorithm
42 42
43 DSA_SIG *DSA_SIG_new(void); 43 DSA_SIG *DSA_SIG_new(void);
44 void DSA_SIG_free(DSA_SIG *a); 44 void DSA_SIG_free(DSA_SIG *a);
45 int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp); 45 int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
46 DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length); 46 DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length);
47 47
48 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); 48 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
@@ -52,14 +52,14 @@ dsa - Digital Signature Algorithm
52 DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length); 52 DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
53 DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length); 53 DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
54 DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); 54 DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
55 int i2d_DSAPublicKey(DSA *a, unsigned char **pp); 55 int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
56 int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); 56 int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
57 int i2d_DSAparams(DSA *a,unsigned char **pp); 57 int i2d_DSAparams(const DSA *a,unsigned char **pp);
58 58
59 int DSAparams_print(BIO *bp, DSA *x); 59 int DSAparams_print(BIO *bp, const DSA *x);
60 int DSAparams_print_fp(FILE *fp, DSA *x); 60 int DSAparams_print_fp(FILE *fp, const DSA *x);
61 int DSA_print(BIO *bp, DSA *x, int off); 61 int DSA_print(BIO *bp, const DSA *x, int off);
62 int DSA_print_fp(FILE *bp, DSA *x, int off); 62 int DSA_print_fp(FILE *bp, const DSA *x, int off);
63 63
64=head1 DESCRIPTION 64=head1 DESCRIPTION
65 65
@@ -85,6 +85,14 @@ The B<DSA> structure consists of several BIGNUM components.
85 85
86In public keys, B<priv_key> is NULL. 86In public keys, B<priv_key> is NULL.
87 87
88Note that DSA keys may use non-standard B<DSA_METHOD> implementations,
89either directly or by the use of B<ENGINE> modules. In some cases (eg. an
90ENGINE providing support for hardware-embedded keys), these BIGNUM values
91will not be used by the implementation or may be used for alternative data
92storage. For this reason, applications should generally avoid using DSA
93structure elements directly and instead use API functions to query or
94modify keys.
95
88=head1 CONFORMING TO 96=head1 CONFORMING TO
89 97
90US Federal Information Processing Standard FIPS 186 (Digital Signature 98US Federal Information Processing Standard FIPS 186 (Digital Signature
diff --git a/src/lib/libcrypto/doc/evp.pod b/src/lib/libcrypto/doc/evp.pod
index edf47dbde6..b3ca14314f 100644
--- a/src/lib/libcrypto/doc/evp.pod
+++ b/src/lib/libcrypto/doc/evp.pod
@@ -24,6 +24,13 @@ functions. The B<EVP_Digest>I<...> functions provide message digests.
24 24
25Algorithms are loaded with OpenSSL_add_all_algorithms(3). 25Algorithms are loaded with OpenSSL_add_all_algorithms(3).
26 26
27All the symmetric algorithms (ciphers) and digests can be replaced by ENGINE
28modules providing alternative implementations. If ENGINE implementations of
29ciphers or digests are registered as defaults, then the various EVP functions
30will automatically use those implementations automatically in preference to
31built in software implementations. For more information, consult the engine(3)
32man page.
33
27=head1 SEE ALSO 34=head1 SEE ALSO
28 35
29L<EVP_DigestInit(3)|EVP_DigestInit(3)>, 36L<EVP_DigestInit(3)|EVP_DigestInit(3)>,
@@ -32,6 +39,7 @@ L<EVP_OpenInit(3)|EVP_OpenInit(3)>,
32L<EVP_SealInit(3)|EVP_SealInit(3)>, 39L<EVP_SealInit(3)|EVP_SealInit(3)>,
33L<EVP_SignInit(3)|EVP_SignInit(3)>, 40L<EVP_SignInit(3)|EVP_SignInit(3)>,
34L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>, 41L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>,
35L<OpenSSL_add_all_algorithms(3)|OpenSSL_add_all_algorithms(3)> 42L<OpenSSL_add_all_algorithms(3)|OpenSSL_add_all_algorithms(3)>,
43L<engine(3)|engine(3)>
36 44
37=cut 45=cut
diff --git a/src/lib/libcrypto/doc/rsa.pod b/src/lib/libcrypto/doc/rsa.pod
index 2b93a12b65..45ac53ffc1 100644
--- a/src/lib/libcrypto/doc/rsa.pod
+++ b/src/lib/libcrypto/doc/rsa.pod
@@ -16,13 +16,17 @@ rsa - RSA public key cryptosystem
16 unsigned char *to, RSA *rsa, int padding); 16 unsigned char *to, RSA *rsa, int padding);
17 int RSA_private_decrypt(int flen, unsigned char *from, 17 int RSA_private_decrypt(int flen, unsigned char *from,
18 unsigned char *to, RSA *rsa, int padding); 18 unsigned char *to, RSA *rsa, int padding);
19 int RSA_private_encrypt(int flen, unsigned char *from,
20 unsigned char *to, RSA *rsa,int padding);
21 int RSA_public_decrypt(int flen, unsigned char *from,
22 unsigned char *to, RSA *rsa,int padding);
19 23
20 int RSA_sign(int type, unsigned char *m, unsigned int m_len, 24 int RSA_sign(int type, unsigned char *m, unsigned int m_len,
21 unsigned char *sigret, unsigned int *siglen, RSA *rsa); 25 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
22 int RSA_verify(int type, unsigned char *m, unsigned int m_len, 26 int RSA_verify(int type, unsigned char *m, unsigned int m_len,
23 unsigned char *sigbuf, unsigned int siglen, RSA *rsa); 27 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
24 28
25 int RSA_size(RSA *rsa); 29 int RSA_size(const RSA *rsa);
26 30
27 RSA *RSA_generate_key(int num, unsigned long e, 31 RSA *RSA_generate_key(int num, unsigned long e,
28 void (*callback)(int,int,void *), void *cb_arg); 32 void (*callback)(int,int,void *), void *cb_arg);
@@ -32,13 +36,13 @@ rsa - RSA public key cryptosystem
32 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); 36 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
33 void RSA_blinding_off(RSA *rsa); 37 void RSA_blinding_off(RSA *rsa);
34 38
35 void RSA_set_default_openssl_method(RSA_METHOD *meth); 39 void RSA_set_default_method(const RSA_METHOD *meth);
36 RSA_METHOD *RSA_get_default_openssl_method(void); 40 const RSA_METHOD *RSA_get_default_method(void);
37 int RSA_set_method(RSA *rsa, ENGINE *engine); 41 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
38 RSA_METHOD *RSA_get_method(RSA *rsa); 42 const RSA_METHOD *RSA_get_method(const RSA *rsa);
39 RSA_METHOD *RSA_PKCS1_SSLeay(void); 43 RSA_METHOD *RSA_PKCS1_SSLeay(void);
40 RSA_METHOD *RSA_null_method(void); 44 RSA_METHOD *RSA_null_method(void);
41 int RSA_flags(RSA *rsa); 45 int RSA_flags(const RSA *rsa);
42 RSA *RSA_new_method(ENGINE *engine); 46 RSA *RSA_new_method(ENGINE *engine);
43 47
44 int RSA_print(BIO *bp, RSA *x, int offset); 48 int RSA_print(BIO *bp, RSA *x, int offset);
@@ -49,11 +53,6 @@ rsa - RSA public key cryptosystem
49 int RSA_set_ex_data(RSA *r,int idx,char *arg); 53 int RSA_set_ex_data(RSA *r,int idx,char *arg);
50 char *RSA_get_ex_data(RSA *r, int idx); 54 char *RSA_get_ex_data(RSA *r, int idx);
51 55
52 int RSA_private_encrypt(int flen, unsigned char *from,
53 unsigned char *to, RSA *rsa,int padding);
54 int RSA_public_decrypt(int flen, unsigned char *from,
55 unsigned char *to, RSA *rsa,int padding);
56
57 int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m, 56 int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m,
58 unsigned int m_len, unsigned char *sigret, unsigned int *siglen, 57 unsigned int m_len, unsigned char *sigret, unsigned int *siglen,
59 RSA *rsa); 58 RSA *rsa);
@@ -90,6 +89,14 @@ B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private
90keys, but the RSA operations are much faster when these values are 89keys, but the RSA operations are much faster when these values are
91available. 90available.
92 91
92Note that RSA keys may use non-standard B<RSA_METHOD> implementations,
93either directly or by the use of B<ENGINE> modules. In some cases (eg. an
94ENGINE providing support for hardware-embedded keys), these BIGNUM values
95will not be used by the implementation or may be used for alternative data
96storage. For this reason, applications should generally avoid using RSA
97structure elements directly and instead use API functions to query or
98modify keys.
99
93=head1 CONFORMING TO 100=head1 CONFORMING TO
94 101
95SSL, PKCS #1 v2.0 102SSL, PKCS #1 v2.0
@@ -101,7 +108,7 @@ RSA was covered by a US patent which expired in September 2000.
101=head1 SEE ALSO 108=head1 SEE ALSO
102 109
103L<rsa(1)|rsa(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>, 110L<rsa(1)|rsa(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>,
104L<rand(3)|rand(3)>, L<RSA_new(3)|RSA_new(3)>, 111L<rand(3)|rand(3)>, L<engine(3)|engine(3)>, L<RSA_new(3)|RSA_new(3)>,
105L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>, 112L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>,
106L<RSA_sign(3)|RSA_sign(3)>, L<RSA_size(3)|RSA_size(3)>, 113L<RSA_sign(3)|RSA_sign(3)>, L<RSA_size(3)|RSA_size(3)>,
107L<RSA_generate_key(3)|RSA_generate_key(3)>, 114L<RSA_generate_key(3)|RSA_generate_key(3)>,
diff --git a/src/lib/libcrypto/engine/hw_4758_cca.c b/src/lib/libcrypto/engine/hw_4758_cca.c
index f404b1a3b8..6d41b9ed2a 100644
--- a/src/lib/libcrypto/engine/hw_4758_cca.c
+++ b/src/lib/libcrypto/engine/hw_4758_cca.c
@@ -953,7 +953,7 @@ static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
953#ifdef ENGINE_DYNAMIC_SUPPORT 953#ifdef ENGINE_DYNAMIC_SUPPORT
954static int bind_fn(ENGINE *e, const char *id) 954static int bind_fn(ENGINE *e, const char *id)
955 { 955 {
956 if(id && (strcmp(id, engine_cswift_id) != 0)) 956 if(id && (strcmp(id, engine_4758_cca_id) != 0))
957 return 0; 957 return 0;
958 if(!bind_helper(e)) 958 if(!bind_helper(e))
959 return 0; 959 return 0;
diff --git a/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c b/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c
index f946389b8a..b8aab545db 100644
--- a/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c
+++ b/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c
@@ -408,7 +408,7 @@ static int do_digest(int ses,unsigned char *md,const void *data,int len)
408 cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */ 408 cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */
409 cryp.len=len; 409 cryp.len=len;
410 cryp.src=(caddr_t)data; 410 cryp.src=(caddr_t)data;
411 cryp.dst=(caddr_t)data; // FIXME!!! 411 cryp.dst=(caddr_t)data; /* FIXME!!! */
412 cryp.mac=(caddr_t)md; 412 cryp.mac=(caddr_t)md;
413 413
414 if(ioctl(fd, CIOCCRYPT, &cryp) == -1) 414 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
@@ -420,7 +420,7 @@ static int do_digest(int ses,unsigned char *md,const void *data,int len)
420 dcopy=OPENSSL_malloc(len); 420 dcopy=OPENSSL_malloc(len);
421 memcpy(dcopy,data,len); 421 memcpy(dcopy,data,len);
422 cryp.src=dcopy; 422 cryp.src=dcopy;
423 cryp.dst=cryp.src; // FIXME!!! 423 cryp.dst=cryp.src; /* FIXME!!! */
424 424
425 if(ioctl(fd, CIOCCRYPT, &cryp) == -1) 425 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
426 { 426 {
@@ -437,7 +437,7 @@ static int do_digest(int ses,unsigned char *md,const void *data,int len)
437 return 0; 437 return 0;
438 } 438 }
439 } 439 }
440 // printf("done\n"); 440 /* printf("done\n"); */
441 441
442 return 1; 442 return 1;
443 } 443 }
@@ -483,7 +483,7 @@ static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
483 const MD_DATA *from_md=from->md_data; 483 const MD_DATA *from_md=from->md_data;
484 MD_DATA *to_md=to->md_data; 484 MD_DATA *to_md=to->md_data;
485 485
486 // How do we copy sessions? 486 /* How do we copy sessions? */
487 assert(from->digest->flags&EVP_MD_FLAG_ONESHOT); 487 assert(from->digest->flags&EVP_MD_FLAG_ONESHOT);
488 488
489 to_md->data=OPENSSL_malloc(from_md->len); 489 to_md->data=OPENSSL_malloc(from_md->len);
@@ -530,7 +530,7 @@ static const EVP_MD md5_md=
530 NID_md5, 530 NID_md5,
531 NID_md5WithRSAEncryption, 531 NID_md5WithRSAEncryption,
532 MD5_DIGEST_LENGTH, 532 MD5_DIGEST_LENGTH,
533 EVP_MD_FLAG_ONESHOT, // XXX: set according to device info... 533 EVP_MD_FLAG_ONESHOT, /* XXX: set according to device info... */
534 dev_crypto_md5_init, 534 dev_crypto_md5_init,
535 dev_crypto_md5_update, 535 dev_crypto_md5_update,
536 dev_crypto_md5_final, 536 dev_crypto_md5_final,
diff --git a/src/lib/libcrypto/engine/hw_ubsec.c b/src/lib/libcrypto/engine/hw_ubsec.c
index 63397f868c..ed8401ec16 100644
--- a/src/lib/libcrypto/engine/hw_ubsec.c
+++ b/src/lib/libcrypto/engine/hw_ubsec.c
@@ -93,7 +93,7 @@ static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
93static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 93static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
94 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 94 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
95#ifndef OPENSSL_NO_DSA 95#ifndef OPENSSL_NO_DSA
96#if NOT_USED 96#ifdef NOT_USED
97static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, 97static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
98 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, 98 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
99 BN_CTX *ctx, BN_MONT_CTX *in_mont); 99 BN_CTX *ctx, BN_MONT_CTX *in_mont);
@@ -113,7 +113,7 @@ static int ubsec_dh_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh)
113static int ubsec_dh_generate_key(DH *dh); 113static int ubsec_dh_generate_key(DH *dh);
114#endif 114#endif
115 115
116#if NOT_USED 116#ifdef NOT_USED
117static int ubsec_rand_bytes(unsigned char *buf, int num); 117static int ubsec_rand_bytes(unsigned char *buf, int num);
118static int ubsec_rand_status(void); 118static int ubsec_rand_status(void);
119#endif 119#endif
@@ -663,7 +663,7 @@ static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
663} 663}
664 664
665#ifndef OPENSSL_NO_DSA 665#ifndef OPENSSL_NO_DSA
666#if NOT_USED 666#ifdef NOT_USED
667static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, 667static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
668 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, 668 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
669 BN_CTX *ctx, BN_MONT_CTX *in_mont) 669 BN_CTX *ctx, BN_MONT_CTX *in_mont)
@@ -987,7 +987,7 @@ err:
987 } 987 }
988#endif 988#endif
989 989
990#if NOT_USED 990#ifdef NOT_USED
991static int ubsec_rand_bytes(unsigned char * buf, 991static int ubsec_rand_bytes(unsigned char * buf,
992 int num) 992 int num)
993 { 993 {
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index 7b088b4848..4d81a3bf4c 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -124,17 +124,17 @@ const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
124BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ 124BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
125 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) 125 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
126 126
127#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, block_size, key_len, \ 127#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
128 iv_len, cbits, flags, init_key, cleanup, \ 128 iv_len, cbits, flags, init_key, cleanup, \
129 set_asn1, get_asn1, ctrl) \ 129 set_asn1, get_asn1, ctrl) \
130BLOCK_CIPHER_def1(cname, cfb##cbits, cfb, CFB, kstruct, nid, block_size, \ 130BLOCK_CIPHER_def1(cname, cfb##cbits, cfb, CFB, kstruct, nid, 1, \
131 key_len, iv_len, flags, init_key, cleanup, set_asn1, \ 131 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
132 get_asn1, ctrl) 132 get_asn1, ctrl)
133 133
134#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, block_size, key_len, \ 134#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
135 iv_len, cbits, flags, init_key, cleanup, \ 135 iv_len, cbits, flags, init_key, cleanup, \
136 set_asn1, get_asn1, ctrl) \ 136 set_asn1, get_asn1, ctrl) \
137BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, block_size, \ 137BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
138 key_len, iv_len, flags, init_key, cleanup, set_asn1, \ 138 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
139 get_asn1, ctrl) 139 get_asn1, ctrl)
140 140
@@ -149,9 +149,9 @@ BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
149 init_key, cleanup, set_asn1, get_asn1, ctrl) \ 149 init_key, cleanup, set_asn1, get_asn1, ctrl) \
150BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ 150BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
151 init_key, cleanup, set_asn1, get_asn1, ctrl) \ 151 init_key, cleanup, set_asn1, get_asn1, ctrl) \
152BLOCK_CIPHER_def_cfb(cname, kstruct, nid, block_size, key_len, iv_len, cbits, \ 152BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
153 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ 153 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
154BLOCK_CIPHER_def_ofb(cname, kstruct, nid, block_size, key_len, iv_len, cbits, \ 154BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
155 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ 155 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
156BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ 156BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
157 init_key, cleanup, set_asn1, get_asn1, ctrl) 157 init_key, cleanup, set_asn1, get_asn1, ctrl)
diff --git a/src/lib/libcrypto/krb5/Makefile.ssl b/src/lib/libcrypto/krb5/Makefile.ssl
index caf111be8d..7ad0cbb0bc 100644
--- a/src/lib/libcrypto/krb5/Makefile.ssl
+++ b/src/lib/libcrypto/krb5/Makefile.ssl
@@ -45,13 +45,13 @@ lib: $(LIBOBJ)
45 @touch lib 45 @touch lib
46 46
47files: 47files:
48 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 48 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49 49
50links: 50links:
51 @sh $(TOP)/util/point.sh Makefile.ssl Makefile 51 @sh $(TOP)/util/point.sh Makefile.ssl Makefile ;
52 $(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) 52 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
53 $(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) 53 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
54 $(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 54 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
55 55
56install: 56install:
57 @for i in $(EXHEADER) ; \ 57 @for i in $(EXHEADER) ; \
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index effec714e8..a7826908e6 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -303,6 +303,9 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
303 { 303 {
304 void *ret = NULL; 304 void *ret = NULL;
305 305
306 if (str == NULL)
307 return CRYPTO_malloc(num, file, line);
308
306 if (realloc_debug_func != NULL) 309 if (realloc_debug_func != NULL)
307 realloc_debug_func(str, NULL, num, file, line, 0); 310 realloc_debug_func(str, NULL, num, file, line, 0);
308 ret = realloc_ex_func(str,num,file,line); 311 ret = realloc_ex_func(str,num,file,line);
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 02c3719f04..ce779dc1b5 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -425,7 +425,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
425 a2d_ASN1_OBJECT(p,i,s,-1); 425 a2d_ASN1_OBJECT(p,i,s,-1);
426 426
427 p=buf; 427 p=buf;
428 op=d2i_ASN1_OBJECT(NULL,&p,i); 428 op=d2i_ASN1_OBJECT(NULL,&p,j);
429 OPENSSL_free(buf); 429 OPENSSL_free(buf);
430 return op; 430 return op;
431 } 431 }
diff --git a/src/lib/libcrypto/ocsp/Makefile.ssl b/src/lib/libcrypto/ocsp/Makefile.ssl
index 44eacbbb13..2be98179ae 100644
--- a/src/lib/libcrypto/ocsp/Makefile.ssl
+++ b/src/lib/libcrypto/ocsp/Makefile.ssl
@@ -47,13 +47,13 @@ lib: $(LIBOBJ)
47 @touch lib 47 @touch lib
48 48
49files: 49files:
50 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51 51
52links: 52links:
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile 53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile ;
54 $(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) 54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 $(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) 55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 $(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57 57
58install: 58install:
59 @for i in $(EXHEADER) ; \ 59 @for i in $(EXHEADER) ; \
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 18b751a91a..a8db6ffbf5 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -366,8 +366,11 @@ err:
366 memset(iv,0,sizeof(iv)); 366 memset(iv,0,sizeof(iv));
367 memset((char *)&ctx,0,sizeof(ctx)); 367 memset((char *)&ctx,0,sizeof(ctx));
368 memset(buf,0,PEM_BUFSIZE); 368 memset(buf,0,PEM_BUFSIZE);
369 memset(data,0,(unsigned int)dsize); 369 if (data != NULL)
370 OPENSSL_free(data); 370 {
371 memset(data,0,(unsigned int)dsize);
372 OPENSSL_free(data);
373 }
371 return(ret); 374 return(ret);
372 } 375 }
373 376
diff --git a/src/lib/libcrypto/pkcs12/p12_asn.c b/src/lib/libcrypto/pkcs12/p12_asn.c
index c327bdba03..a3739fee1a 100644
--- a/src/lib/libcrypto/pkcs12/p12_asn.c
+++ b/src/lib/libcrypto/pkcs12/p12_asn.c
@@ -83,8 +83,8 @@ ASN1_ADB_TEMPLATE(bag_default) = ASN1_EXP(PKCS12_BAGS, value.other, ASN1_ANY, 0)
83 83
84ASN1_ADB(PKCS12_BAGS) = { 84ASN1_ADB(PKCS12_BAGS) = {
85 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509cert, ASN1_OCTET_STRING, 0)), 85 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509cert, ASN1_OCTET_STRING, 0)),
86 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509crl, ASN1_OCTET_STRING, 0)), 86 ADB_ENTRY(NID_x509Crl, ASN1_EXP(PKCS12_BAGS, value.x509crl, ASN1_OCTET_STRING, 0)),
87 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.sdsicert, ASN1_IA5STRING, 0)), 87 ADB_ENTRY(NID_sdsiCertificate, ASN1_EXP(PKCS12_BAGS, value.sdsicert, ASN1_IA5STRING, 0)),
88} ASN1_ADB_END(PKCS12_BAGS, 0, type, 0, &bag_default_tt, NULL); 88} ASN1_ADB_END(PKCS12_BAGS, 0, type, 0, &bag_default_tt, NULL);
89 89
90ASN1_SEQUENCE(PKCS12_BAGS) = { 90ASN1_SEQUENCE(PKCS12_BAGS) = {
@@ -98,7 +98,7 @@ ASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_
98 98
99ASN1_ADB(PKCS12_SAFEBAG) = { 99ASN1_ADB(PKCS12_SAFEBAG) = {
100 ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)), 100 ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)),
101 ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, X509_SIG, 0)), 101 ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.shkeybag, X509_SIG, 0)),
102 ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SET_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)), 102 ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SET_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)),
103 ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), 103 ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
104 ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), 104 ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c
index c00ed6833a..985b07245c 100644
--- a/src/lib/libcrypto/pkcs7/pk7_lib.c
+++ b/src/lib/libcrypto/pkcs7/pk7_lib.c
@@ -74,6 +74,13 @@ long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
74 if (nid == NID_pkcs7_signed) 74 if (nid == NID_pkcs7_signed)
75 { 75 {
76 ret=p7->detached=(int)larg; 76 ret=p7->detached=(int)larg;
77 if (ret && PKCS7_type_is_data(p7->d.sign->contents))
78 {
79 ASN1_OCTET_STRING *os;
80 os=p7->d.sign->contents->d.data;
81 ASN1_OCTET_STRING_free(os);
82 p7->d.sign->contents->d.data = NULL;
83 }
77 } 84 }
78 else 85 else
79 { 86 {
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
index 19e9741db2..be1fb8b1f6 100644
--- a/src/lib/libcrypto/ripemd/rmdtest.c
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62#include <openssl/ripemd.h>
63 62
64#ifdef OPENSSL_NO_RIPEMD 63#ifdef OPENSSL_NO_RIPEMD
65int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
@@ -68,6 +67,7 @@ int main(int argc, char *argv[])
68 return(0); 67 return(0);
69} 68}
70#else 69#else
70#include <openssl/ripemd.h>
71#include <openssl/evp.h> 71#include <openssl/evp.h>
72 72
73#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index 512185e257..7e5728495f 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -2792,3 +2792,4 @@ ASN1_UNIVERSALSTRING_it 3234 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA
2792ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: 2792ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2793d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION: 2793d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION:
2794EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES 2794EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES
2795X509_REQ_print_ex 3237 EXIST::FUNCTION:BIO
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index c75aa0c717..7095440d36 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -331,6 +331,7 @@ DECLARE_STACK_OF(X509_TRUST)
331#define X509_FLAG_NO_EXTENSIONS (1L << 8) 331#define X509_FLAG_NO_EXTENSIONS (1L << 8)
332#define X509_FLAG_NO_SIGDUMP (1L << 9) 332#define X509_FLAG_NO_SIGDUMP (1L << 9)
333#define X509_FLAG_NO_AUX (1L << 10) 333#define X509_FLAG_NO_AUX (1L << 10)
334#define X509_FLAG_NO_ATTRIBUTES (1L << 11)
334 335
335/* Flags specific to X509_NAME_print_ex() */ 336/* Flags specific to X509_NAME_print_ex() */
336 337
@@ -1015,6 +1016,7 @@ int X509_print(BIO *bp,X509 *x);
1015int X509_ocspid_print(BIO *bp,X509 *x); 1016int X509_ocspid_print(BIO *bp,X509 *x);
1016int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); 1017int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
1017int X509_CRL_print(BIO *bp,X509_CRL *x); 1018int X509_CRL_print(BIO *bp,X509_CRL *x);
1019int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
1018int X509_REQ_print(BIO *bp,X509_REQ *req); 1020int X509_REQ_print(BIO *bp,X509_REQ *req);
1019#endif 1021#endif
1020 1022