X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/SecurityTests/clxutils/p12/p12GetPassKey.cpp diff --git a/SecurityTests/clxutils/p12/p12GetPassKey.cpp b/SecurityTests/clxutils/p12/p12GetPassKey.cpp new file mode 100644 index 00000000..59ae25c9 --- /dev/null +++ b/SecurityTests/clxutils/p12/p12GetPassKey.cpp @@ -0,0 +1,132 @@ +/* + * p12GetPassKey.h - get a CSSM_ALGID_SECURE_PASSPHRASE key for encode/decode + */ + +#include +#include +#include "p12GetPassKey.h" +#include +#include +#include + +/* when true, simulate secure passphrase in CSPDL */ +#define SIMULATE_PASSPHRASE 1 + +/* + * Safe gets(). + * -- guaranteed no buffer overflow + * -- guaranteed NULL-terminated string + * -- handles empty string (i.e., response is just CR) properly + */ +void getString( + char *buf, + unsigned bufSize) +{ + unsigned dex; + char c; + char *cp = buf; + + for(dex=0; dex