X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/SecurityTests/clxutils/extenGrab/extenGrab.cpp?ds=inline diff --git a/SecurityTests/clxutils/extenGrab/extenGrab.cpp b/SecurityTests/clxutils/extenGrab/extenGrab.cpp new file mode 100644 index 00000000..01410d34 --- /dev/null +++ b/SecurityTests/clxutils/extenGrab/extenGrab.cpp @@ -0,0 +1,124 @@ +/* + * extenGrab - write the unparsed extension blobs of a specified + * cert to files for external examination + */ +#include +#include +#include +#include +#include +#include +#include +#include + +static void usage(char **argv) +{ + printf("Usage: %s certFile outFileBase [r for CRL, default is cert]\n", + argv[0]); + exit(1); +} + +/* + * How many items in a NULL-terminated array of pointers? + */ +static unsigned nssArraySize( + const void **array) +{ + unsigned count = 0; + if (array) { + while (*array++) { + count++; + } + } + return count; +} + +int main(int argc, char **argv) +{ + if(argc < 3) { + usage(argv); + } + + bool doCert = true; + NSS_Certificate signedCert; + NSS_Crl signedCrl; + void *decodeTarget; + const SecAsn1Template *templ; + NSS_CertExtension ***extenp; + + for(int arg=3; argextnId.Data, exten->extnId.Length, oidStr); + printf("Extension %u : %s\n", dex, oidStr); + sprintf(outFileName, "%s_%u", outBase, dex); + if(writeFile(outFileName, exten->value.Data, exten->value.Length)) { + printf("***Error writing %s. Aborting.\n", + outFileName); + exit(1); + } + else { + printf("...wrote %lu bytes to %s\n", + exten->value.Length, outFileName); + } + } + SecAsn1CoderRelease(coder); + printf("..done.\n"); + return 0; +}