Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: openssl/demos/cms/cms_ver.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/demos/cms/cms_uncomp.c ('k') | openssl/demos/cms/comp.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Simple S/MIME verification example */
2 #include <openssl/pem.h>
3 #include <openssl/cms.h>
4 #include <openssl/err.h>
5
6 int main(int argc, char **argv)
7 {
8 BIO *in = NULL, *out = NULL, *tbio = NULL, *cont = NULL;
9 X509_STORE *st = NULL;
10 X509 *cacert = NULL;
11 CMS_ContentInfo *cms = NULL;
12
13 int ret = 1;
14
15 OpenSSL_add_all_algorithms();
16 ERR_load_crypto_strings();
17
18 /* Set up trusted CA certificate store */
19
20 st = X509_STORE_new();
21
22 /* Read in CA certificate */
23 tbio = BIO_new_file("cacert.pem", "r");
24
25 if (!tbio)
26 goto err;
27
28 cacert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
29
30 if (!cacert)
31 goto err;
32
33 if (!X509_STORE_add_cert(st, cacert))
34 goto err;
35
36 /* Open message being verified */
37
38 in = BIO_new_file("smout.txt", "r");
39
40 if (!in)
41 goto err;
42
43 /* parse message */
44 cms = SMIME_read_CMS(in, &cont);
45
46 if (!cms)
47 goto err;
48
49 /* File to output verified content to */
50 out = BIO_new_file("smver.txt", "w");
51 if (!out)
52 goto err;
53
54 if (!CMS_verify(cms, NULL, st, cont, out, 0))
55 {
56 fprintf(stderr, "Verification Failure\n");
57 goto err;
58 }
59
60 fprintf(stderr, "Verification Successful\n");
61
62 ret = 0;
63
64 err:
65
66 if (ret)
67 {
68 fprintf(stderr, "Error Verifying Data\n");
69 ERR_print_errors_fp(stderr);
70 }
71
72 if (cms)
73 CMS_ContentInfo_free(cms);
74
75 if (cacert)
76 X509_free(cacert);
77
78 if (in)
79 BIO_free(in);
80 if (out)
81 BIO_free(out);
82 if (tbio)
83 BIO_free(tbio);
84
85 return ret;
86
87 }
OLDNEW
« no previous file with comments | « openssl/demos/cms/cms_uncomp.c ('k') | openssl/demos/cms/comp.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698