]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/p12Parse/main.cpp
Security-57336.1.9.tar.gz
[apple/security.git] / SecurityTests / clxutils / p12Parse / main.cpp
1 /*
2 * standalone pkcs12 parser.
3 */
4 #include <security_cdsa_utils/cuFileIo.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <CoreFoundation/CoreFoundation.h>
8 #include "p12Parse.h"
9 #include <security_cdsa_utils/cuCdsaUtils.h>
10
11 static void usage(char **argv)
12 {
13 printf("Usage: %s infile password [v(erbose)\n", argv[0]);
14 exit(1);
15 }
16
17 int main(int argc, char **argv)
18 {
19 char *inFile;
20 CFStringRef pwd = NULL;
21 bool verbose = false;
22
23 if(argc < 3) {
24 usage(argv);
25 }
26 for(int arg=3; arg<argc; arg++) {
27 char *argp = argv[arg];
28 switch(argp[0]) {
29 case 'v':
30 verbose = true;
31 break;
32 default:
33 usage(argv);
34 }
35 }
36
37 inFile = argv[1];
38 CSSM_DATA rawBlob;
39 unsigned len;
40 if(readFile(inFile, &rawBlob.Data, &len)) {
41 printf("***Error reading %s. Aborting.\n", inFile);
42 exit(1);
43 }
44 rawBlob.Length = len;
45 pwd = CFStringCreateWithCString(NULL, argv[2], kCFStringEncodingASCII);
46
47 CSSM_CSP_HANDLE cspHand = cuCspStartup(CSSM_TRUE);
48 int rtn = p12ParseTop(rawBlob, cspHand, pwd, verbose);
49 return rtn;
50 }