]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/parseCrl/parseCrl.cpp
Security-57031.30.12.tar.gz
[apple/security.git] / SecurityTests / clxutils / parseCrl / parseCrl.cpp
1 /*
2 * parseCrl.cpp - CL-based cert parser.
3 *
4 * See oidParser.h for info on config file.
5 */
6 #include <security_cdsa_utils/cuPrintCert.h>
7 #include <security_cdsa_utils/cuFileIo.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11
12 static void usage(char **argv)
13 {
14 printf("Usage: %s crlFile [l=loops]\n", argv[0]);
15 exit(1);
16 }
17
18 int main(int argc, char **argv)
19 {
20 unsigned char *rawCrl = NULL;
21 unsigned rawCrlSize;
22 int rtn;
23 int loops = 1;
24 int loop;
25 CSSM_BOOL verbose = CSSM_FALSE;
26
27 if(argc < 2) {
28 usage(argv);
29 }
30
31 for(int arg=2; arg<argc; arg++) {
32 switch(argv[arg][0]) {
33 case 'l':
34 loops = atoi(&argv[arg][2]);
35 break;
36 case 'v':
37 verbose = CSSM_TRUE;
38 break;
39 default:
40 usage(argv);
41 }
42 }
43
44 rtn = readFile(argv[1], &rawCrl, &rawCrlSize);
45 if(rtn) {
46 printf("Error reading %s; %s\n", argv[1], strerror(rtn));
47 exit(1);
48 }
49
50 /* optional loop for malloc debug */
51 for(loop=0; loop<loops; loop++) {
52 printCrl(rawCrl, rawCrlSize, verbose);
53 if(loops != 1) {
54 fpurge(stdin);
55 printf("CR to continue, q to quit: ");
56 char c = getchar();
57 if(c == 'q') {
58 break;
59 }
60 }
61 }
62 return 0;
63 }
64