]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/p12/p12Encode.cpp
2 * Decode P12 PFX using P12Coder, reencode to file
5 #include <security_pkcs12/pkcs12Coder.h>
8 #include <Security/cssmtype.h>
9 #include <security_cdsa_utils/cuPrintCert.h>
10 #include <security_cdsa_utils/cuFileIo.h>
12 /* decode --> encode */
15 CSSM_CSP_HANDLE cspHand
,
16 CFStringRef pwd
, // explicit passphrase, mutually exclusive with...
22 for(unsigned loop
=0; loop
<loops
; loop
++) {
24 /* localize scope of coder for malloc test */
26 CFDataRef cfd
= CFDataCreate(NULL
, pfx
.Data
, pfx
.Length
);
29 printf("...decoding...\n");
31 coder
.setCsp(cspHand
);
32 coder
.setMacPassPhrase(pwd
);
36 printf("***decode error\n");
41 /* should just be able to re-encode it */
42 printf("...encoding...\n");
45 coder
.encode(&encPfx
);
48 printf("***encode error\n");
51 writeFile("encoded.p12", CFDataGetBytePtr(encPfx
),
52 CFDataGetLength(encPfx
));
53 printf("...wrote %u bytes to encoded.p12\n",
54 (unsigned)CFDataGetLength(encPfx
));
59 printf("CR to continue: ");