summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/t_pkey.c
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:50 +0000
committermarkus <>2002-09-05 12:51:50 +0000
commit15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch)
treebf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/asn1/t_pkey.c
parent027351f729b9e837200dae6e1520cda6577ab930 (diff)
downloadopenbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/asn1/t_pkey.c')
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c117
1 files changed, 43 insertions, 74 deletions
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index bc518d59a2..8060115202 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -58,35 +58,23 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "buffer.h" 61#include <openssl/buffer.h>
62#include "bn.h" 62#include <openssl/bn.h>
63#ifndef NO_RSA 63#ifndef OPENSSL_NO_RSA
64#include "rsa.h" 64#include <openssl/rsa.h>
65#endif 65#endif
66#ifndef NO_DH 66#ifndef OPENSSL_NO_DH
67#include "dh.h" 67#include <openssl/dh.h>
68#endif 68#endif
69#ifndef NO_DSA 69#ifndef OPENSSL_NO_DSA
70#include "dsa.h" 70#include <openssl/dsa.h>
71#endif 71#endif
72 72
73/* DHerr(DH_F_DHPARAMS_PRINT,ERR_R_MALLOC_FAILURE); 73static int print(BIO *fp,const char *str,BIGNUM *num,
74 * DSAerr(DSA_F_DSAPARAMS_PRINT,ERR_R_MALLOC_FAILURE);
75 */
76
77#ifndef NOPROTO
78static int print(BIO *fp,char *str,BIGNUM *num,
79 unsigned char *buf,int off); 74 unsigned char *buf,int off);
80#else 75#ifndef OPENSSL_NO_RSA
81static int print(); 76#ifndef OPENSSL_NO_FP_API
82#endif 77int RSA_print_fp(FILE *fp, const RSA *x, int off)
83
84#ifndef NO_RSA
85#ifndef NO_FP_API
86int RSA_print_fp(fp,x,off)
87FILE *fp;
88RSA *x;
89int off;
90 { 78 {
91 BIO *b; 79 BIO *b;
92 int ret; 80 int ret;
@@ -103,17 +91,15 @@ int off;
103 } 91 }
104#endif 92#endif
105 93
106int RSA_print(bp,x,off) 94int RSA_print(BIO *bp, const RSA *x, int off)
107BIO *bp;
108RSA *x;
109int off;
110 { 95 {
111 char str[128],*s; 96 char str[128];
97 const char *s;
112 unsigned char *m=NULL; 98 unsigned char *m=NULL;
113 int i,ret=0; 99 int i,ret=0;
114 100
115 i=RSA_size(x); 101 i=RSA_size(x);
116 m=(unsigned char *)Malloc((unsigned int)i+10); 102 m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
117 if (m == NULL) 103 if (m == NULL)
118 { 104 {
119 RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE); 105 RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE);
@@ -147,17 +133,14 @@ int off;
147 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err; 133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err;
148 ret=1; 134 ret=1;
149err: 135err:
150 if (m != NULL) Free((char *)m); 136 if (m != NULL) OPENSSL_free(m);
151 return(ret); 137 return(ret);
152 } 138 }
153#endif /* NO_RSA */ 139#endif /* OPENSSL_NO_RSA */
154 140
155#ifndef NO_DSA 141#ifndef OPENSSL_NO_DSA
156#ifndef NO_FP_API 142#ifndef OPENSSL_NO_FP_API
157int DSA_print_fp(fp,x,off) 143int DSA_print_fp(FILE *fp, const DSA *x, int off)
158FILE *fp;
159DSA *x;
160int off;
161 { 144 {
162 BIO *b; 145 BIO *b;
163 int ret; 146 int ret;
@@ -174,10 +157,7 @@ int off;
174 } 157 }
175#endif 158#endif
176 159
177int DSA_print(bp,x,off) 160int DSA_print(BIO *bp, const DSA *x, int off)
178BIO *bp;
179DSA *x;
180int off;
181 { 161 {
182 char str[128]; 162 char str[128];
183 unsigned char *m=NULL; 163 unsigned char *m=NULL;
@@ -196,7 +176,7 @@ int off;
196 i=BN_num_bytes(bn)*2; 176 i=BN_num_bytes(bn)*2;
197 else 177 else
198 i=256; 178 i=256;
199 m=(unsigned char *)Malloc((unsigned int)i+10); 179 m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
200 if (m == NULL) 180 if (m == NULL)
201 { 181 {
202 DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE); 182 DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE);
@@ -224,20 +204,17 @@ int off;
224 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err; 204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err;
225 ret=1; 205 ret=1;
226err: 206err:
227 if (m != NULL) Free((char *)m); 207 if (m != NULL) OPENSSL_free(m);
228 return(ret); 208 return(ret);
229 } 209 }
230#endif /* !NO_DSA */ 210#endif /* !OPENSSL_NO_DSA */
231 211
232static int print(bp,number,num,buf,off) 212static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
233BIO *bp; 213 int off)
234char *number;
235BIGNUM *num;
236unsigned char *buf;
237int off;
238 { 214 {
239 int n,i; 215 int n,i;
240 char str[128],*neg; 216 char str[128];
217 const char *neg;
241 218
242 if (num == NULL) return(1); 219 if (num == NULL) return(1);
243 neg=(num->neg)?"-":""; 220 neg=(num->neg)?"-":"";
@@ -282,11 +259,9 @@ int off;
282 return(1); 259 return(1);
283 } 260 }
284 261
285#ifndef NO_DH 262#ifndef OPENSSL_NO_DH
286#ifndef NO_FP_API 263#ifndef OPENSSL_NO_FP_API
287int DHparams_print_fp(fp,x) 264int DHparams_print_fp(FILE *fp, const DH *x)
288FILE *fp;
289DH *x;
290 { 265 {
291 BIO *b; 266 BIO *b;
292 int ret; 267 int ret;
@@ -303,15 +278,13 @@ DH *x;
303 } 278 }
304#endif 279#endif
305 280
306int DHparams_print(bp,x) 281int DHparams_print(BIO *bp, const DH *x)
307BIO *bp;
308DH *x;
309 { 282 {
310 unsigned char *m=NULL; 283 unsigned char *m=NULL;
311 int reason=ERR_R_BUF_LIB,i,ret=0; 284 int reason=ERR_R_BUF_LIB,i,ret=0;
312 285
313 i=BN_num_bytes(x->p); 286 i=BN_num_bytes(x->p);
314 m=(unsigned char *)Malloc((unsigned int)i+10); 287 m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
315 if (m == NULL) 288 if (m == NULL)
316 { 289 {
317 reason=ERR_R_MALLOC_FAILURE; 290 reason=ERR_R_MALLOC_FAILURE;
@@ -325,7 +298,7 @@ DH *x;
325 if (!print(bp,"generator:",x->g,m,4)) goto err; 298 if (!print(bp,"generator:",x->g,m,4)) goto err;
326 if (x->length != 0) 299 if (x->length != 0)
327 { 300 {
328 if (BIO_printf(bp," recomented-private-length: %d bits\n", 301 if (BIO_printf(bp," recommended-private-length: %d bits\n",
329 (int)x->length) <= 0) goto err; 302 (int)x->length) <= 0) goto err;
330 } 303 }
331 ret=1; 304 ret=1;
@@ -334,16 +307,14 @@ DH *x;
334err: 307err:
335 DHerr(DH_F_DHPARAMS_PRINT,reason); 308 DHerr(DH_F_DHPARAMS_PRINT,reason);
336 } 309 }
337 if (m != NULL) Free((char *)m); 310 if (m != NULL) OPENSSL_free(m);
338 return(ret); 311 return(ret);
339 } 312 }
340#endif 313#endif
341 314
342#ifndef NO_DSA 315#ifndef OPENSSL_NO_DSA
343#ifndef NO_FP_API 316#ifndef OPENSSL_NO_FP_API
344int DSAparams_print_fp(fp,x) 317int DSAparams_print_fp(FILE *fp, const DSA *x)
345FILE *fp;
346DSA *x;
347 { 318 {
348 BIO *b; 319 BIO *b;
349 int ret; 320 int ret;
@@ -360,15 +331,13 @@ DSA *x;
360 } 331 }
361#endif 332#endif
362 333
363int DSAparams_print(bp,x) 334int DSAparams_print(BIO *bp, const DSA *x)
364BIO *bp;
365DSA *x;
366 { 335 {
367 unsigned char *m=NULL; 336 unsigned char *m=NULL;
368 int reason=ERR_R_BUF_LIB,i,ret=0; 337 int reason=ERR_R_BUF_LIB,i,ret=0;
369 338
370 i=BN_num_bytes(x->p); 339 i=BN_num_bytes(x->p);
371 m=(unsigned char *)Malloc((unsigned int)i+10); 340 m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
372 if (m == NULL) 341 if (m == NULL)
373 { 342 {
374 reason=ERR_R_MALLOC_FAILURE; 343 reason=ERR_R_MALLOC_FAILURE;
@@ -383,10 +352,10 @@ DSA *x;
383 if (!print(bp,"g:",x->g,m,4)) goto err; 352 if (!print(bp,"g:",x->g,m,4)) goto err;
384 ret=1; 353 ret=1;
385err: 354err:
386 if (m != NULL) Free((char *)m); 355 if (m != NULL) OPENSSL_free(m);
387 DSAerr(DSA_F_DSAPARAMS_PRINT,reason); 356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason);
388 return(ret); 357 return(ret);
389 } 358 }
390 359
391#endif /* !NO_DSA */ 360#endif /* !OPENSSL_NO_DSA */
392 361