diff options
author | Aleksey Sanin <aleksey@src.gnome.org> | 2003-06-08 03:39:01 +0000 |
---|---|---|
committer | Aleksey Sanin <aleksey@src.gnome.org> | 2003-06-08 03:39:01 +0000 |
commit | 4f295fb2b1d58bda13d30dcc5919087b45ea099e (patch) | |
tree | 3a3207fcc5b9bb652c440f13726f15a7d3d0b170 /apps | |
parent | 24fe484b72bcd6d44542200e364ec7b3221f8f73 (diff) | |
download | xmlsec1-4f295fb2b1d58bda13d30dcc5919087b45ea099e.tar.gz xmlsec1-4f295fb2b1d58bda13d30dcc5919087b45ea099e.tar.bz2 xmlsec1-4f295fb2b1d58bda13d30dcc5919087b45ea099e.zip |
added PKCS#8 support (based on Tej's patch)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/crypto.c | 20 | ||||
-rw-r--r-- | apps/crypto.h | 9 | ||||
-rw-r--r-- | apps/xmlsec.c | 79 |
3 files changed, 75 insertions, 33 deletions
diff --git a/apps/crypto.c b/apps/crypto.c index 86d93301..ff4f581f 100644 --- a/apps/crypto.c +++ b/apps/crypto.c @@ -100,7 +100,7 @@ xmlSecAppCryptoSimpleKeysMngrCertLoad(xmlSecKeysMngrPtr mngr, const char *filena #endif /* XMLSEC_NO_X509 */ } -static int +int xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(xmlSecKeysMngrPtr mngr, const char* files, const char* pwd, const char* name, @@ -179,24 +179,6 @@ xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(xmlSecKeysMngrPtr mngr, int -xmlSecAppCryptoSimpleKeysMngrPemKeyAndCertsLoad(xmlSecKeysMngrPtr mngr, - const char* files, const char* pwd, - const char* name) { - - return xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(mngr, files, pwd, name, - xmlSecKeyDataFormatPem); -} - -int -xmlSecAppCryptoSimpleKeysMngrDerKeyAndCertsLoad(xmlSecKeysMngrPtr mngr, - const char* files, const char* pwd, - const char* name) { - - return xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(mngr, files, pwd, name, - xmlSecKeyDataFormatDer); -} - -int xmlSecAppCryptoSimpleKeysMngrPkcs12KeyLoad(xmlSecKeysMngrPtr mngr, const char *filename, const char* pwd, const char *name) { xmlSecKeyPtr key; char buf[1024] = ""; diff --git a/apps/crypto.h b/apps/crypto.h index e0a2dfad..29571d32 100644 --- a/apps/crypto.h +++ b/apps/crypto.h @@ -42,14 +42,11 @@ int xmlSecAppCryptoSimpleKeysMngrCertLoad (xmlSecKeysMngrPtr mngr, const char *filename, xmlSecKeyDataFormat format, xmlSecKeyDataType type); -int xmlSecAppCryptoSimpleKeysMngrPemKeyAndCertsLoad (xmlSecKeysMngrPtr mngr, +int xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad (xmlSecKeysMngrPtr mngr, const char *files, const char* pwd, - const char* name); -int xmlSecAppCryptoSimpleKeysMngrDerKeyAndCertsLoad (xmlSecKeysMngrPtr mngr, - const char *files, - const char* pwd, - const char* name); + const char* name, + xmlSecKeyDataFormat format); int xmlSecAppCryptoSimpleKeysMngrPkcs12KeyLoad (xmlSecKeysMngrPtr mngr, const char *filename, const char* pwd, diff --git a/apps/xmlsec.c b/apps/xmlsec.c index c2ea09de..3e1e554d 100644 --- a/apps/xmlsec.c +++ b/apps/xmlsec.c @@ -254,6 +254,31 @@ static xmlSecAppCmdLineParam privkeyDerParam = { xmlSecAppCmdLineParamFlagParamNameValue | xmlSecAppCmdLineParamFlagMultipleValues, NULL }; + +static xmlSecAppCmdLineParam pkcs8PemParam = { + xmlSecAppCmdLineTopicKeysMngr, + "--pkcs8-pem", + "--privkey-p8-pem", + "--pkcs-pem[:<name>] <file>[,<cafile>[,<cafile>[...]]]" + "\n\tload private key from PKCS8 PEM file and PEM certificates" + "\n\tthat verify this key", + xmlSecAppCmdLineParamTypeStringList, + xmlSecAppCmdLineParamFlagParamNameValue | xmlSecAppCmdLineParamFlagMultipleValues, + NULL +}; + +static xmlSecAppCmdLineParam pkcs8DerParam = { + xmlSecAppCmdLineTopicKeysMngr, + "--pkcs8-der", + "--privkey-p8-der", + "--pkcs8-der[:<name>] <file>[,<cafile>[,<cafile>[...]]]" + "\n\tload private key from PKCS8 DER file and DER certificates" + "\n\tthat verify this key", + xmlSecAppCmdLineParamTypeStringList, + xmlSecAppCmdLineParamFlagParamNameValue | xmlSecAppCmdLineParamFlagMultipleValues, + NULL +}; + static xmlSecAppCmdLineParam pubkeyParam = { xmlSecAppCmdLineTopicKeysMngr, "--pubkey-pem", @@ -678,6 +703,8 @@ static xmlSecAppCmdLineParamPtr parameters[] = { &keysFileParam, &privkeyParam, &privkeyDerParam, + &pkcs8PemParam, + &pkcs8DerParam, &pubkeyParam, &pubkeyDerParam, #ifndef XMLSEC_NO_AES @@ -1912,10 +1939,11 @@ xmlSecAppLoadKeys(void) { fprintf(stderr, "Error: invalid value for option \"%s\".\n", privkeyParam.fullName); return(-1); - } else if(xmlSecAppCryptoSimpleKeysMngrPemKeyAndCertsLoad(gKeysMngr, + } else if(xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(gKeysMngr, value->strListValue, xmlSecAppCmdLineParamGetString(&pwdParam), - value->paramNameValue) < 0) { + value->paramNameValue, + xmlSecKeyDataFormatPem) < 0) { fprintf(stderr, "Error: failed to load private key from \"%s\".\n", value->strListValue); return(-1); @@ -1927,10 +1955,43 @@ xmlSecAppLoadKeys(void) { fprintf(stderr, "Error: invalid value for option \"%s\".\n", privkeyDerParam.fullName); return(-1); - } else if(xmlSecAppCryptoSimpleKeysMngrDerKeyAndCertsLoad(gKeysMngr, + } else if(xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(gKeysMngr, value->strListValue, xmlSecAppCmdLineParamGetString(&pwdParam), - value->paramNameValue) < 0) { + value->paramNameValue, + xmlSecKeyDataFormatDer) < 0) { + fprintf(stderr, "Error: failed to load private key from \"%s\".\n", + value->strListValue); + return(-1); + } + } + + for(value = pkcs8PemParam.value; value != NULL; value = value->next) { + if(value->strValue == NULL) { + fprintf(stderr, "Error: invalid value for option \"%s\".\n", + pkcs8PemParam.fullName); + return(-1); + } else if(xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(gKeysMngr, + value->strListValue, + xmlSecAppCmdLineParamGetString(&pwdParam), + value->paramNameValue, + xmlSecKeyDataFormatPkcs8Pem) < 0) { + fprintf(stderr, "Error: failed to load private key from \"%s\".\n", + value->strListValue); + return(-1); + } + } + + for(value = pkcs8DerParam.value; value != NULL; value = value->next) { + if(value->strValue == NULL) { + fprintf(stderr, "Error: invalid value for option \"%s\".\n", + pkcs8DerParam.fullName); + return(-1); + } else if(xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(gKeysMngr, + value->strListValue, + xmlSecAppCmdLineParamGetString(&pwdParam), + value->paramNameValue, + xmlSecKeyDataFormatPkcs8Der) < 0) { fprintf(stderr, "Error: failed to load private key from \"%s\".\n", value->strListValue); return(-1); @@ -1943,10 +2004,11 @@ xmlSecAppLoadKeys(void) { fprintf(stderr, "Error: invalid value for option \"%s\".\n", pubkeyParam.fullName); return(-1); - } else if(xmlSecAppCryptoSimpleKeysMngrPemKeyAndCertsLoad(gKeysMngr, + } else if(xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(gKeysMngr, value->strListValue, xmlSecAppCmdLineParamGetString(&pwdParam), - value->paramNameValue) < 0) { + value->paramNameValue, + xmlSecKeyDataFormatPem) < 0) { fprintf(stderr, "Error: failed to load public key from \"%s\".\n", value->strListValue); return(-1); @@ -1958,10 +2020,11 @@ xmlSecAppLoadKeys(void) { fprintf(stderr, "Error: invalid value for option \"%s\".\n", pubkeyDerParam.fullName); return(-1); - } else if(xmlSecAppCryptoSimpleKeysMngrDerKeyAndCertsLoad(gKeysMngr, + } else if(xmlSecAppCryptoSimpleKeysMngrKeyAndCertsLoad(gKeysMngr, value->strListValue, xmlSecAppCmdLineParamGetString(&pwdParam), - value->paramNameValue) < 0) { + value->paramNameValue, + xmlSecKeyDataFormatDer) < 0) { fprintf(stderr, "Error: failed to load public key from \"%s\".\n", value->strListValue); return(-1); |