summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/t_req.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/t_req.c')
-rw-r--r--src/lib/libcrypto/asn1/t_req.c112
1 files changed, 60 insertions, 52 deletions
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index 7df749a48f..848c29a2dd 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -58,15 +58,14 @@
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#include "objects.h" 63#include <openssl/objects.h>
64#include "x509.h" 64#include <openssl/x509.h>
65#include <openssl/x509v3.h>
65 66
66#ifndef NO_FP_API 67#ifndef OPENSSL_NO_FP_API
67int X509_REQ_print_fp(fp,x) 68int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
68FILE *fp;
69X509_REQ *x;
70 { 69 {
71 BIO *b; 70 BIO *b;
72 int ret; 71 int ret;
@@ -83,16 +82,15 @@ X509_REQ *x;
83 } 82 }
84#endif 83#endif
85 84
86int X509_REQ_print(bp,x) 85int X509_REQ_print(BIO *bp, X509_REQ *x)
87BIO *bp;
88X509_REQ *x;
89 { 86 {
90 unsigned long l; 87 unsigned long l;
91 int i,n; 88 int i;
92 char *s,*neg; 89 const char *neg;
93 X509_REQ_INFO *ri; 90 X509_REQ_INFO *ri;
94 EVP_PKEY *pkey; 91 EVP_PKEY *pkey;
95 STACK *sk; 92 STACK_OF(X509_ATTRIBUTE) *sk;
93 STACK_OF(X509_EXTENSION) *exts;
96 char str[128]; 94 char str[128];
97 95
98 ri=x->req_info; 96 ri=x->req_info;
@@ -119,8 +117,8 @@ X509_REQ *x;
119 if (BIO_puts(bp,str) <= 0) goto err; 117 if (BIO_puts(bp,str) <= 0) goto err;
120 118
121 pkey=X509_REQ_get_pubkey(x); 119 pkey=X509_REQ_get_pubkey(x);
122#ifndef NO_RSA 120#ifndef OPENSSL_NO_RSA
123 if (pkey->type == EVP_PKEY_RSA) 121 if (pkey != NULL && pkey->type == EVP_PKEY_RSA)
124 { 122 {
125 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","", 123 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
126 BN_num_bits(pkey->pkey.rsa->n)); 124 BN_num_bits(pkey->pkey.rsa->n));
@@ -128,8 +126,8 @@ X509_REQ *x;
128 } 126 }
129 else 127 else
130#endif 128#endif
131#ifndef NO_DSA 129#ifndef OPENSSL_NO_DSA
132 if (pkey->type == EVP_PKEY_DSA) 130 if (pkey != NULL && pkey->type == EVP_PKEY_DSA)
133 { 131 {
134 BIO_printf(bp,"%12sDSA Public Key:\n",""); 132 BIO_printf(bp,"%12sDSA Public Key:\n","");
135 DSA_print(bp,pkey->pkey.dsa,16); 133 DSA_print(bp,pkey->pkey.dsa,16);
@@ -138,22 +136,22 @@ X509_REQ *x;
138#endif 136#endif
139 BIO_printf(bp,"%12sUnknown Public Key:\n",""); 137 BIO_printf(bp,"%12sUnknown Public Key:\n","");
140 138
139 if (pkey != NULL)
140 EVP_PKEY_free(pkey);
141
141 /* may not be */ 142 /* may not be */
142 sprintf(str,"%8sAttributes:\n",""); 143 sprintf(str,"%8sAttributes:\n","");
143 if (BIO_puts(bp,str) <= 0) goto err; 144 if (BIO_puts(bp,str) <= 0) goto err;
144 145
145 sk=x->req_info->attributes; 146 sk=x->req_info->attributes;
146 if ((sk == NULL) || (sk_num(sk) == 0)) 147 if (sk_X509_ATTRIBUTE_num(sk) == 0)
147 { 148 {
148 if (!x->req_info->req_kludge) 149 sprintf(str,"%12sa0:00\n","");
149 { 150 if (BIO_puts(bp,str) <= 0) goto err;
150 sprintf(str,"%12sa0:00\n","");
151 if (BIO_puts(bp,str) <= 0) goto err;
152 }
153 } 151 }
154 else 152 else
155 { 153 {
156 for (i=0; i<sk_num(sk); i++) 154 for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
157 { 155 {
158 ASN1_TYPE *at; 156 ASN1_TYPE *at;
159 X509_ATTRIBUTE *a; 157 X509_ATTRIBUTE *a;
@@ -161,26 +159,29 @@ X509_REQ *x;
161 ASN1_TYPE *t; 159 ASN1_TYPE *t;
162 int j,type=0,count=1,ii=0; 160 int j,type=0,count=1,ii=0;
163 161
164 a=(X509_ATTRIBUTE *)sk_value(sk,i); 162 a=sk_X509_ATTRIBUTE_value(sk,i);
163 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
164 continue;
165 sprintf(str,"%12s",""); 165 sprintf(str,"%12s","");
166 if (BIO_puts(bp,str) <= 0) goto err; 166 if (BIO_puts(bp,str) <= 0) goto err;
167 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 167 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
168 168 {
169 if (a->set) 169 if (a->single)
170 {
171 t=a->value.single;
172 type=t->type;
173 bs=t->value.bit_string;
174 }
175 else
170 { 176 {
171 ii=0; 177 ii=0;
172 count=sk_num(a->value.set); 178 count=sk_ASN1_TYPE_num(a->value.set);
173get_next: 179get_next:
174 at=(ASN1_TYPE *)sk_value(a->value.set,ii); 180 at=sk_ASN1_TYPE_value(a->value.set,ii);
175 type=at->type; 181 type=at->type;
176 bs=at->value.asn1_string; 182 bs=at->value.asn1_string;
177 } 183 }
178 else 184 }
179 {
180 t=a->value.single;
181 type=t->type;
182 bs=t->value.bit_string;
183 }
184 for (j=25-j; j>0; j--) 185 for (j=25-j; j>0; j--)
185 if (BIO_write(bp," ",1) != 1) goto err; 186 if (BIO_write(bp," ",1) != 1) goto err;
186 if (BIO_puts(bp,":") <= 0) goto err; 187 if (BIO_puts(bp,":") <= 0) goto err;
@@ -201,24 +202,31 @@ get_next:
201 } 202 }
202 } 203 }
203 204
204 i=OBJ_obj2nid(x->sig_alg->algorithm); 205 exts = X509_REQ_get_extensions(x);
205 sprintf(str,"%4sSignature Algorithm: %s","", 206 if(exts) {
206 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); 207 BIO_printf(bp,"%8sRequested Extensions:\n","");
207 if (BIO_puts(bp,str) <= 0) goto err; 208 for (i=0; i<sk_X509_EXTENSION_num(exts); i++) {
208 209 ASN1_OBJECT *obj;
209 n=x->signature->length; 210 X509_EXTENSION *ex;
210 s=(char *)x->signature->data; 211 int j;
211 for (i=0; i<n; i++) 212 ex=sk_X509_EXTENSION_value(exts, i);
212 { 213 if (BIO_printf(bp,"%12s","") <= 0) goto err;
213 if ((i%18) == 0) 214 obj=X509_EXTENSION_get_object(ex);
214 { 215 i2a_ASN1_OBJECT(bp,obj);
215 sprintf(str,"\n%8s",""); 216 j=X509_EXTENSION_get_critical(ex);
216 if (BIO_puts(bp,str) <= 0) goto err; 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);
217 } 222 }
218 sprintf(str,"%02x%s",(unsigned char)s[i],((i+1) == n)?"":":"); 223 if (BIO_write(bp,"\n",1) <= 0) goto err;
219 if (BIO_puts(bp,str) <= 0) goto err;
220 } 224 }
221 if (BIO_puts(bp,"\n") <= 0) goto err; 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
222 return(1); 230 return(1);
223err: 231err:
224 X509err(X509_F_X509_REQ_PRINT,ERR_R_BUF_LIB); 232 X509err(X509_F_X509_REQ_PRINT,ERR_R_BUF_LIB);