]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/p12/p12.cpp
2 * multipurpose pkcs12 tool.
4 #include <security_cdsa_utils/cuFileIo.h>
7 #include <CoreFoundation/CoreFoundation.h>
9 #include <security_cdsa_utils/cuCdsaUtils.h>
11 static void usage(char **argv
)
14 printf(" %s p infile [options] parse\n", argv
[0]);
15 printf(" %s d infile [options] decode\n", argv
[0]);
16 printf(" %s e infile [options] decode-->encode\n", argv
[0]);
17 printf(" %s i infile keychain import to keychain\n", argv
[0]);
18 printf(" %s x outfile keychain export from keychain\n", argv
[0]);
21 printf(" p=password\n");
22 printf(" z=keychainPassword\n");
23 printf(" P (use secure passphrase)\n");
24 printf(" k=keychain\n");
26 printf(" n(o prompt; export only)\n");
27 printf(" v(erbose)\n");
40 int main(int argc
, char **argv
)
45 CFStringRef pwd
= NULL
;
49 bool noPrompt
= false;
51 bool usePassKey
= false;
83 for(int arg
=minArgs
; arg
<argc
; arg
++) {
84 char *argp
= argv
[arg
];
87 pwd
= CFStringCreateWithCString(NULL
, &argp
[2],
88 kCFStringEncodingASCII
);
103 loops
= atoi(&argp
[2]);
114 /* import/export - ready to go right now */
117 return p12Import(argv
[2], argv
[3], pwd
, usePassKey
, kcPwd
);
119 return p12Export(argv
[2], argv
[3], pwd
, usePassKey
, kcPwd
, noPrompt
);
124 /* all other ops: read infile */
128 if(readFile(inFile
, &rawBlob
.Data
, &len
)) {
129 printf("***Error reading %s. Aborting.\n", inFile
);
132 rawBlob
.Length
= len
;
134 CSSM_CSP_HANDLE cspHand
= cuCspStartup(CSSM_TRUE
);
138 rtn
= p12Decode(rawBlob
, cspHand
, pwd
, usePassKey
, verbose
, loops
);
141 rtn
= p12Reencode(rawBlob
, cspHand
, pwd
, verbose
, loops
);
144 rtn
= p12ParseTop(rawBlob
, cspHand
, pwd
, verbose
);