diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/n_pkey.c')
-rw-r--r-- | src/lib/libcrypto/asn1/n_pkey.c | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c index 5110c91bec..cdc0d8b7c4 100644 --- a/src/lib/libcrypto/asn1/n_pkey.c +++ b/src/lib/libcrypto/asn1/n_pkey.c | |||
@@ -56,13 +56,14 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef NO_RSA | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | #include "rsa.h" | 62 | #include <openssl/rsa.h> |
62 | #include "objects.h" | 63 | #include <openssl/objects.h> |
63 | #include "asn1_mac.h" | 64 | #include <openssl/asn1_mac.h> |
64 | #include "evp.h" | 65 | #include <openssl/evp.h> |
65 | #include "x509.h" | 66 | #include <openssl/x509.h> |
66 | 67 | ||
67 | 68 | ||
68 | #ifndef NO_RC4 | 69 | #ifndef NO_RC4 |
@@ -74,28 +75,12 @@ typedef struct netscape_pkey_st | |||
74 | ASN1_OCTET_STRING *private_key; | 75 | ASN1_OCTET_STRING *private_key; |
75 | } NETSCAPE_PKEY; | 76 | } NETSCAPE_PKEY; |
76 | 77 | ||
77 | /* | ||
78 | * ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_LENGTH_MISMATCH); | ||
79 | * ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_DECODING_ERROR); | ||
80 | * ASN1err(ASN1_F_D2I_NETSCAPE_PKEY,ASN1_R_DECODING_ERROR); | ||
81 | * ASN1err(ASN1_F_NETSCAPE_PKEY_NEW,ASN1_R_DECODING_ERROR); | ||
82 | */ | ||
83 | #ifndef NOPROTO | ||
84 | static int i2d_NETSCAPE_PKEY(NETSCAPE_PKEY *a, unsigned char **pp); | 78 | static int i2d_NETSCAPE_PKEY(NETSCAPE_PKEY *a, unsigned char **pp); |
85 | static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(NETSCAPE_PKEY **a,unsigned char **pp, long length); | 79 | static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(NETSCAPE_PKEY **a,unsigned char **pp, long length); |
86 | static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void); | 80 | static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void); |
87 | static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *); | 81 | static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *); |
88 | #else | ||
89 | static int i2d_NETSCAPE_PKEY(); | ||
90 | static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(); | ||
91 | static NETSCAPE_PKEY *NETSCAPE_PKEY_new(); | ||
92 | static void NETSCAPE_PKEY_free(); | ||
93 | #endif | ||
94 | 82 | ||
95 | int i2d_Netscape_RSA(a,pp,cb) | 83 | int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()) |
96 | RSA *a; | ||
97 | unsigned char **pp; | ||
98 | int (*cb)(); | ||
99 | { | 84 | { |
100 | int i,j,l[6]; | 85 | int i,j,l[6]; |
101 | NETSCAPE_PKEY *pkey; | 86 | NETSCAPE_PKEY *pkey; |
@@ -138,7 +123,9 @@ int (*cb)(); | |||
138 | l[2]=i2d_X509_ALGOR(alg,NULL); | 123 | l[2]=i2d_X509_ALGOR(alg,NULL); |
139 | l[3]=ASN1_object_size(1,l[2]+l[1],V_ASN1_SEQUENCE); | 124 | l[3]=ASN1_object_size(1,l[2]+l[1],V_ASN1_SEQUENCE); |
140 | 125 | ||
126 | #ifndef CONST_STRICT | ||
141 | os.data=(unsigned char *)"private-key"; | 127 | os.data=(unsigned char *)"private-key"; |
128 | #endif | ||
142 | os.length=11; | 129 | os.length=11; |
143 | l[4]=i2d_ASN1_OCTET_STRING(&os,NULL); | 130 | l[4]=i2d_ASN1_OCTET_STRING(&os,NULL); |
144 | 131 | ||
@@ -195,18 +182,14 @@ int (*cb)(); | |||
195 | i2d_ASN1_OCTET_STRING(&os2,&p); | 182 | i2d_ASN1_OCTET_STRING(&os2,&p); |
196 | ret=l[5]; | 183 | ret=l[5]; |
197 | err: | 184 | err: |
198 | if (os2.data != NULL) Free((char *)os2.data); | 185 | if (os2.data != NULL) Free(os2.data); |
199 | if (alg != NULL) X509_ALGOR_free(alg); | 186 | if (alg != NULL) X509_ALGOR_free(alg); |
200 | if (pkey != NULL) NETSCAPE_PKEY_free(pkey); | 187 | if (pkey != NULL) NETSCAPE_PKEY_free(pkey); |
201 | r=r; | 188 | r=r; |
202 | return(ret); | 189 | return(ret); |
203 | } | 190 | } |
204 | 191 | ||
205 | RSA *d2i_Netscape_RSA(a,pp,length,cb) | 192 | RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()) |
206 | RSA **a; | ||
207 | unsigned char **pp; | ||
208 | long length; | ||
209 | int (*cb)(); | ||
210 | { | 193 | { |
211 | RSA *ret=NULL; | 194 | RSA *ret=NULL; |
212 | ASN1_OCTET_STRING *os=NULL; | 195 | ASN1_OCTET_STRING *os=NULL; |
@@ -233,11 +216,8 @@ int (*cb)(); | |||
233 | M_ASN1_D2I_Finish(a,RSA_free,ASN1_F_D2I_NETSCAPE_RSA); | 216 | M_ASN1_D2I_Finish(a,RSA_free,ASN1_F_D2I_NETSCAPE_RSA); |
234 | } | 217 | } |
235 | 218 | ||
236 | RSA *d2i_Netscape_RSA_2(a,pp,length,cb) | 219 | RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length, |
237 | RSA **a; | 220 | int (*cb)()) |
238 | unsigned char **pp; | ||
239 | long length; | ||
240 | int (*cb)(); | ||
241 | { | 221 | { |
242 | NETSCAPE_PKEY *pkey=NULL; | 222 | NETSCAPE_PKEY *pkey=NULL; |
243 | RSA *ret=NULL; | 223 | RSA *ret=NULL; |
@@ -249,7 +229,7 @@ int (*cb)(); | |||
249 | ASN1_OCTET_STRING *os=NULL; | 229 | ASN1_OCTET_STRING *os=NULL; |
250 | ASN1_CTX c; | 230 | ASN1_CTX c; |
251 | 231 | ||
252 | c.error=ASN1_R_ERROR_STACK; | 232 | c.error=ERR_R_NESTED_ASN1_ERROR; |
253 | c.pp=pp; | 233 | c.pp=pp; |
254 | 234 | ||
255 | M_ASN1_D2I_Init(); | 235 | M_ASN1_D2I_Init(); |
@@ -304,9 +284,7 @@ err: | |||
304 | return(ret); | 284 | return(ret); |
305 | } | 285 | } |
306 | 286 | ||
307 | static int i2d_NETSCAPE_PKEY(a,pp) | 287 | static int i2d_NETSCAPE_PKEY(NETSCAPE_PKEY *a, unsigned char **pp) |
308 | NETSCAPE_PKEY *a; | ||
309 | unsigned char **pp; | ||
310 | { | 288 | { |
311 | M_ASN1_I2D_vars(a); | 289 | M_ASN1_I2D_vars(a); |
312 | 290 | ||
@@ -324,10 +302,8 @@ unsigned char **pp; | |||
324 | M_ASN1_I2D_finish(); | 302 | M_ASN1_I2D_finish(); |
325 | } | 303 | } |
326 | 304 | ||
327 | static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(a,pp,length) | 305 | static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(NETSCAPE_PKEY **a, unsigned char **pp, |
328 | NETSCAPE_PKEY **a; | 306 | long length) |
329 | unsigned char **pp; | ||
330 | long length; | ||
331 | { | 307 | { |
332 | M_ASN1_D2I_vars(a,NETSCAPE_PKEY *,NETSCAPE_PKEY_new); | 308 | M_ASN1_D2I_vars(a,NETSCAPE_PKEY *,NETSCAPE_PKEY_new); |
333 | 309 | ||
@@ -339,9 +315,10 @@ long length; | |||
339 | M_ASN1_D2I_Finish(a,NETSCAPE_PKEY_free,ASN1_F_D2I_NETSCAPE_PKEY); | 315 | M_ASN1_D2I_Finish(a,NETSCAPE_PKEY_free,ASN1_F_D2I_NETSCAPE_PKEY); |
340 | } | 316 | } |
341 | 317 | ||
342 | static NETSCAPE_PKEY *NETSCAPE_PKEY_new() | 318 | static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void) |
343 | { | 319 | { |
344 | NETSCAPE_PKEY *ret=NULL; | 320 | NETSCAPE_PKEY *ret=NULL; |
321 | ASN1_CTX c; | ||
345 | 322 | ||
346 | M_ASN1_New_Malloc(ret,NETSCAPE_PKEY); | 323 | M_ASN1_New_Malloc(ret,NETSCAPE_PKEY); |
347 | M_ASN1_New(ret->version,ASN1_INTEGER_new); | 324 | M_ASN1_New(ret->version,ASN1_INTEGER_new); |
@@ -351,8 +328,7 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new() | |||
351 | M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW); | 328 | M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW); |
352 | } | 329 | } |
353 | 330 | ||
354 | static void NETSCAPE_PKEY_free(a) | 331 | static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a) |
355 | NETSCAPE_PKEY *a; | ||
356 | { | 332 | { |
357 | if (a == NULL) return; | 333 | if (a == NULL) return; |
358 | ASN1_INTEGER_free(a->version); | 334 | ASN1_INTEGER_free(a->version); |
@@ -362,4 +338,4 @@ NETSCAPE_PKEY *a; | |||
362 | } | 338 | } |
363 | 339 | ||
364 | #endif /* NO_RC4 */ | 340 | #endif /* NO_RC4 */ |
365 | 341 | #endif | |