/** * XML Security standards test: XMLDSig * * See Copyright for the status of this software. * * Author: Aleksey Sanin */ #include #include #include #if defined(_MSC_VER) #define snprintf _snprintf #endif #include #include #include #include #include #include #ifndef XMLSEC_NO_XSLT #include #include #include #include #include #endif /* XMLSEC_NO_XSLT */ #include #include #include #include #include #include #include #include #include static const char copyright[] = "Written by Aleksey Sanin .\n" "Copyright (C) 2002 Aleksey Sanin.\n" "This is free software: see the source for copying information.\n"; static const char bugs[] = "To report bugs or get some help check XML Security Library home page:\n" " http://www.aleksey.com/xmlsec\n"; static const char usage[] = "Usage: xmlsec %s [] [ [ ... ]]\n"; static const char helpCommands[] = "XMLSec commands are:\n" " help display this help information and exit\n" " help- display help information for and exit\n" " version print version information and exit\n" " keys keys XML file manipulation\n" #ifndef XMLSEC_NO_XMLDSIG " sign sign data and output XML document\n" " verify verify signed document\n" #endif /* XMLSEC_NO_XMLDSIG */ #ifndef XMLSEC_NO_XMLENC " encrypt encrypt data and output XML document\n" " decrypt decrypt data from XML document\n" #endif /* XMLSEC_NO_XMLENC */ "\n"; static const char helpVersion[] = "Usage: xmlsec version\n" "\n" "Prints version information and exits.\n" "\n"; static const char helpKeys[] = "Keys XML file manipulation. The result keys set is written to the file.\n" "\n" "Keys generation options:\n" " --gen-hmac generate new 24 bytes HMAC key and set the key name\n" " --gen-rsa generate new RSA key and set the key name\n" " --gen-dsa generate new DSA key and set the key name\n" " --gen-des3 generate new DES key and set the key name\n" " --gen-aes128 generate new AES 128 key and set the key name\n" " --gen-aes192 generate new AES 192 key and set the key name\n" " --gen-aes256 generate new AES 256 key and set the key name\n" "\n"; static const char helpKeySelect[] = "Key selection options:\n" " --session-key-hmac generate and use session 24 bytes HMAC key\n" " --session-key-rsa generate and use session RSA key\n" " --session-key-dsa generate and use session DSA key\n" " --session-key-des3 generate and use session DES key\n" " --session-key-aes128 generate and use session AES 128 key\n" " --session-key-aes192 generate and use session AES 192 key\n" " --session-key-aes256 generate and use session AES 256 key\n" "\n"; static const char helpSign[] = "Signs data in the file and outputs document in \"XML Signature\" format.\n" "\n" #ifndef XMLSEC_NO_XMLDSIG "Signature options:\n" " --output write signed document to file \n" " --ignore-manifests do not process elements\n" " --fake-signatures disable actual signature calc for perf tests\n" #else /* XMLSEC_NO_XMLDSIG */ "XML Digital Signatures support was disabled during compilation\n" #endif /* XMLSEC_NO_XMLDSIG */ "\n"; static const char helpVerify[] = "Verifies signed XML document in the file.\n" "\n" #ifndef XMLSEC_NO_XMLDSIG "Verification options:\n" " --ignore-manifests do not process elements\n" " --print-result print the result information\n" " --print-references store and print the pre-digested\n" " signature references\n" " --print-manifests store and print the pre-digested\n" " manifests references\n" " --print-signature store and print the pre-signated\n" " data ( element)\n" " --print-all combination of the all \"--print-*\" options\n" " --print-xml print the result information in XML format\n" " --print-to-file print the result to file \n" " --fake-signatures disable actual signature calc for perf tests\n" #else /* XMLSEC_NO_XMLDSIG */ "XML Digital Signatures support was disabled during compilation\n" #endif /* XMLSEC_NO_XMLDSIG */ "\n"; static const char helpEncrypt[] = "Encrypts data and outputs document in \"XML Encryption\" format.\n" "\n" #ifndef XMLSEC_NO_XMLENC "Encryption options:\n" " --output write encrypted document to file \n" " --binary binary file to encrypt\n" " --xml XML file to encrypt\n" #else /* XMLSEC_NO_XMLENC */ "XML Encryption support was disabled during compilation\n" #endif /* XMLSEC_NO_XMLENC */ "\n"; static const char helpDecrypt[] = "Decrypts data from document in \"XML Encryption\" format.\n" #ifndef XMLSEC_NO_XMLENC " --output write decrypted document to file \n" #else /* XMLSEC_NO_XMLENC */ "\n" "XML Encryption support was disabled during compilation\n" #endif /* XMLSEC_NO_XMLENC */ "\n"; static const char helpNodeSelection[] = "Start node selection options:\n" " --node-id set the operation start point to the node \n" " with given \n" " --node-name [:]\n" " set the operation start point to the first node \n" " with given and URI\n" " --node-xpath set the operation start point to the first node \n" " selected by the specified XPath expression\n" " --dtdfile Load the specified file as the DTD\n" "\n"; static const char helpKeysMngmt[] = "Keys management options:\n" " --keys load keys from XML file\n" " --privkey[:] [,[,[...]]]\n" " load private key from PEM file and certificates\n" " that verify this key\n" " --pubkey[:] \n" " load public key from PEM file\n" #ifndef XMLSEC_NO_X509 " --pkcs12[:] \n" " load private key from pkcs12 file\n" #endif /* XMLSEC_NO_X509 */ #ifndef XMLSEC_NO_HMAC " --hmackey[:] \n" " load hmac key from binary file\n" #endif /* XMLSEC_NO_HMAC */ " --allowed specify the set of the allowed key origins\n" " for signature verification or decryption;\n" " is a comma separated collection of\n" " the following values:\n" " \"keymanager\", \"keyname\", \"keyvalue\",\n" " \"retrieval-doc\", \"retrieval-remote\",\n" " \"enc-key\", \"x509\", \"pgp\"\n" " by default, all key origins are allowed\n" " --pwd the password to use for reading keys and certs\n" "\n"; static const char helpX509[] = #ifndef XMLSEC_NO_X509 "X509 certificates options:\n" " --trusted load trusted (root) certificate from PEM file\n" " --untrusted load un-trusted certificate from PEM file\n" " --pwd the password to use for reading keys and certs\n" " --verification-time