diff options
Diffstat (limited to 'src/lib/libcrypto/pkcs7/verify.c')
-rw-r--r-- | src/lib/libcrypto/pkcs7/verify.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/src/lib/libcrypto/pkcs7/verify.c b/src/lib/libcrypto/pkcs7/verify.c index 0e1c1b26dc..32d9783e45 100644 --- a/src/lib/libcrypto/pkcs7/verify.c +++ b/src/lib/libcrypto/pkcs7/verify.c | |||
@@ -56,41 +56,41 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | #include <stdio.h> | 58 | #include <stdio.h> |
59 | #include "asn1.h" | 59 | #include <openssl/bio.h> |
60 | #include "bio.h" | 60 | #include <openssl/asn1.h> |
61 | #include "x509.h" | 61 | #include <openssl/x509.h> |
62 | #include "pem.h" | 62 | #include <openssl/pem.h> |
63 | #include <openssl/err.h> | ||
64 | #include "example.h" | ||
63 | 65 | ||
64 | int verify_callback(int ok, X509_STORE_CTX *ctx); | 66 | int verify_callback(int ok, X509_STORE_CTX *ctx); |
65 | 67 | ||
66 | BIO *bio_err=NULL; | 68 | BIO *bio_err=NULL; |
69 | BIO *bio_out=NULL; | ||
67 | 70 | ||
68 | main(argc,argv) | 71 | int main(argc,argv) |
69 | int argc; | 72 | int argc; |
70 | char *argv[]; | 73 | char *argv[]; |
71 | { | 74 | { |
72 | X509 *x509,*x; | ||
73 | PKCS7 *p7; | 75 | PKCS7 *p7; |
74 | PKCS7_SIGNED *s; | ||
75 | PKCS7_SIGNER_INFO *si; | 76 | PKCS7_SIGNER_INFO *si; |
76 | PKCS7_ISSUER_AND_SERIAL *ias; | ||
77 | X509_STORE_CTX cert_ctx; | 77 | X509_STORE_CTX cert_ctx; |
78 | X509_STORE *cert_store=NULL; | 78 | X509_STORE *cert_store=NULL; |
79 | X509_LOOKUP *lookup=NULL; | ||
80 | BIO *data,*detached=NULL,*p7bio=NULL; | 79 | BIO *data,*detached=NULL,*p7bio=NULL; |
81 | char buf[1024*4]; | 80 | char buf[1024*4]; |
82 | unsigned char *p,*pp; | 81 | char *pp; |
83 | int i,j,printit=0; | 82 | int i,printit=0; |
84 | STACK *sk; | 83 | STACK_OF(PKCS7_SIGNER_INFO) *sk; |
85 | 84 | ||
86 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | 85 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); |
86 | bio_out=BIO_new_fp(stdout,BIO_NOCLOSE); | ||
87 | EVP_add_digest(EVP_md2()); | 87 | EVP_add_digest(EVP_md2()); |
88 | EVP_add_digest(EVP_md5()); | 88 | EVP_add_digest(EVP_md5()); |
89 | EVP_add_digest(EVP_sha1()); | 89 | EVP_add_digest(EVP_sha1()); |
90 | EVP_add_digest(EVP_mdc2()); | 90 | EVP_add_digest(EVP_mdc2()); |
91 | 91 | ||
92 | data=BIO_new(BIO_s_file()); | 92 | data=BIO_new(BIO_s_file()); |
93 | again: | 93 | |
94 | pp=NULL; | 94 | pp=NULL; |
95 | while (argc > 1) | 95 | while (argc > 1) |
96 | { | 96 | { |
@@ -131,10 +131,10 @@ again: | |||
131 | X509_STORE_load_locations(cert_store,NULL,"../../certs"); | 131 | X509_STORE_load_locations(cert_store,NULL,"../../certs"); |
132 | X509_STORE_set_verify_cb_func(cert_store,verify_callback); | 132 | X509_STORE_set_verify_cb_func(cert_store,verify_callback); |
133 | 133 | ||
134 | ERR_clear_errors(); | 134 | ERR_clear_error(); |
135 | 135 | ||
136 | /* We need to process the data */ | 136 | /* We need to process the data */ |
137 | if (PKCS7_get_detached(p7)) | 137 | if ((PKCS7_get_detached(p7) || detached)) |
138 | { | 138 | { |
139 | if (detached == NULL) | 139 | if (detached == NULL) |
140 | { | 140 | { |
@@ -166,12 +166,29 @@ again: | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* Ok, first we need to, for each subject entry, see if we can verify */ | 168 | /* Ok, first we need to, for each subject entry, see if we can verify */ |
169 | for (i=0; i<sk_num(sk); i++) | 169 | for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sk); i++) |
170 | { | 170 | { |
171 | si=(PKCS7_SIGNER_INFO *)sk_value(sk,i); | 171 | ASN1_UTCTIME *tm; |
172 | char *str1,*str2; | ||
173 | |||
174 | si=sk_PKCS7_SIGNER_INFO_value(sk,i); | ||
172 | i=PKCS7_dataVerify(cert_store,&cert_ctx,p7bio,p7,si); | 175 | i=PKCS7_dataVerify(cert_store,&cert_ctx,p7bio,p7,si); |
173 | if (i <= 0) | 176 | if (i <= 0) |
174 | goto err; | 177 | goto err; |
178 | printf("signer info\n"); | ||
179 | if ((tm=get_signed_time(si)) != NULL) | ||
180 | { | ||
181 | BIO_printf(bio_out,"Signed time:"); | ||
182 | ASN1_UTCTIME_print(bio_out,tm); | ||
183 | ASN1_UTCTIME_free(tm); | ||
184 | BIO_printf(bio_out,"\n"); | ||
185 | } | ||
186 | if (get_signed_seq2string(si,&str1,&str2)) | ||
187 | { | ||
188 | BIO_printf(bio_out,"String 1 is %s\n",str1); | ||
189 | BIO_printf(bio_out,"String 2 is %s\n",str2); | ||
190 | } | ||
191 | |||
175 | } | 192 | } |
176 | 193 | ||
177 | X509_STORE_free(cert_store); | 194 | X509_STORE_free(cert_store); |
@@ -185,9 +202,7 @@ err: | |||
185 | } | 202 | } |
186 | 203 | ||
187 | /* should be X509 * but we can just have them as char *. */ | 204 | /* should be X509 * but we can just have them as char *. */ |
188 | int verify_callback(ok, ctx) | 205 | int verify_callback(int ok, X509_STORE_CTX *ctx) |
189 | int ok; | ||
190 | X509_STORE_CTX *ctx; | ||
191 | { | 206 | { |
192 | char buf[256]; | 207 | char buf[256]; |
193 | X509 *err_cert; | 208 | X509 *err_cert; |