CryptoSys PKI
23.0.0
|
Create, read and analyze Cryptographic Message Syntax (CMS) objects. More...
Public Types | |
enum class | CipherAlg |
Content encryption algorithm. More... | |
enum | ComprDataOptions : unsigned int |
Advanced options for CMS compressed-data objects [BitFlags]. More... | |
enum | EnvDataOptions : unsigned int |
Advanced options for CMS enveloped-data objects [BitFlags]. More... | |
enum class | Format |
Output format. More... | |
enum class | HashAlg |
Hash algorithm for RSA-OEAP or ECDH KDF or RSA-KEM. More... | |
enum class | KeyEncrAlg |
Key encryption algorithm for key transport scheme (ktri) More... | |
enum class | SigAlg |
Signature algorithm. More... | |
enum | SigDataOptions : unsigned int |
Advanced options for CMS signed-data objects [BitFlags]. More... | |
Static Public Member Functions | |
static std::string | GetSigDataDigest (const std::string &inputFile, const std::string &certFile="") |
Extract the message digest from a signed-data CMS object file. More... | |
static int | MakeComprData (const std::string &outputFile, const std::string &inputFile) |
Create a CMS compressed-data file (.p7z) from an existing input file [binary file --> binary file]. More... | |
static int | MakeDetachedSig (const std::string &outputFile, const std::string &hexDigest, const std::string &certList, const std::string &privateKey, SigAlg sigAlg=SigAlg::Default, SigDataOptions opts=SigDataOptions::Default_SigDataOpt, Format format=Format::Default) |
Create a "detached signature" CMS signed-data object from a message digest of the content [hexdigest --> file]. More... | |
static int | MakeEnvData (const std::string &outputFile, const std::string &inputFile, const std::string &certList, CipherAlg cipherAlg=CipherAlg::Default, KeyEncrAlg keyEncrAlg=KeyEncrAlg::Default, HashAlg hashAlg=HashAlg::Default, EnvDataOptions advOpts=EnvDataOptions::Default_EnvDataOpt, Format format=Format::Default, bool bigFile=false, Kdf::KdfAlg kdfAlg=Kdf::KdfAlg::X963, Kdf::KeyWrapAlg keyWrapAlg=Kdf::KeyWrapAlg::Default, const std::string &keyString="", int count=0) |
Create a CMS enveloped-data object for one or more recipients [file --> file]. More... | |
static int | MakeEnvData (const std::string &outputFile, const std::string &inputFile, const std::string &schemeType, const std::string &keyString, CipherAlg cipherAlg=CipherAlg::Default, Kdf::KeyWrapAlg keyWrapAlg=Kdf::KeyWrapAlg::Default, EnvDataOptions advOpts=EnvDataOptions::Default_EnvDataOpt, Format format=Format::Default, HashAlg hashAlg=HashAlg::Default, int count=0) |
Create a CMS enveloped-data object using pwri or kekri scheme [file --> file]. More... | |
static int | MakeEnvDataFromBytes (const std::string &outputFile, const dipki::bvec_t &data, const std::string &certList, CipherAlg cipherAlg=CipherAlg::Default, KeyEncrAlg keyEncrAlg=KeyEncrAlg::Default, HashAlg hashAlg=HashAlg::Default, EnvDataOptions advOpts=EnvDataOptions::Default_EnvDataOpt, Format format=Format::Default, Kdf::KdfAlg kdfAlg=Kdf::KdfAlg::X963, Kdf::KeyWrapAlg keyWrapAlg=Kdf::KeyWrapAlg::Default, const std::string &keyString="") |
Create a CMS enveloped-data object for one or more recipients [bytes --> file]. More... | |
static int | MakeEnvDataFromString (const std::string &outputFile, const std::string &inputStr, const std::string &certList, CipherAlg cipherAlg=CipherAlg::Default, KeyEncrAlg keyEncrAlg=KeyEncrAlg::Default, HashAlg hashAlg=HashAlg::Default, EnvDataOptions advOpts=EnvDataOptions::Default_EnvDataOpt, Format format=Format::Default, Kdf::KdfAlg kdfAlg=Kdf::KdfAlg::X963, Kdf::KeyWrapAlg keyWrapAlg=Kdf::KeyWrapAlg::Default, const std::string &keyString="") |
Create a CMS enveloped-data object for one or more recipients [string --> file]. More... | |
static int | MakeSigData (const std::string &outputFile, const std::string &inputFile, const std::string &certList, const std::string &privateKey, SigAlg sigAlg=SigAlg::Default, SigDataOptions opts=SigDataOptions::Default_SigDataOpt, Format format=Format::Default, bool bigFile=false) |
Create a CMS signed-data object from a data file [file --> file]. More... | |
static int | MakeSigDataFromBytes (const std::string &outputFile, const dipki::bvec_t &data, const std::string &certList, const std::string &privateKey, SigAlg sigAlg=SigAlg::Default, SigDataOptions opts=SigDataOptions::Default_SigDataOpt, Format format=Format::Default) |
Create a CMS signed-data object from data [bytes --> file]. More... | |
static int | MakeSigDataFromPseudo (const std::string &outputFile, const std::string &inputPseudoFile, const dipki::bvec_t &sigValue, Format format=Format::Default) |
Create a SignedData object from a "pseudo" object. More... | |
static int | MakeSigDataFromSigValue (const std::string &outputFile, const dipki::bvec_t &sigValue, const dipki::bvec_t &data, const std::string &certList, SigAlg sigAlg=SigAlg::Default, SigDataOptions opts=SigDataOptions::Default_SigDataOpt, Format format=Format::Default) |
Create a CMS object of type SignedData using a pre-computed signature value [bytes --> file]. More... | |
static int | MakeSigDataFromString (const std::string &outputFile, const std::string &inputStr, const std::string &certList, const std::string &privateKey, SigAlg sigAlg=SigAlg::Default, SigDataOptions opts=SigDataOptions::Default_SigDataOpt, Format format=Format::Default) |
Create a CMS signed-data object from a string [string --> file]. More... | |
static std::string | QueryEnvData (const std::string &inputFile, const std::string &query) |
Query a CMS enveloped-data object for selected information. More... | |
static std::string | QuerySigData (const std::string &inputFile, const std::string &query) |
Query a CMS signed-data object for selected information. More... | |
static int | ReadComprData (const std::string &outputFile, const std::string &inputFile, ComprDataOptions opts=ComprDataOptions::Default_ComprDataOpt) |
Read and extract the decompressed contents of a CMS compressed-data file [binary file --> binary file]. More... | |
static bvec_t | ReadEnvDataToBytes (const std::string &inputFile, const std::string &privateKey, const std::string &certFile="") |
Read and decrypt a CMS enveloped-data object to a byte array [file --> bytes]. More... | |
static int | ReadEnvDataToFile (const std::string &outputFile, const std::string &inputFile, const std::string &privateKey, const std::string &certFile="", bool bigFile=false) |
Read and decrypt a CMS enveloped-data object to a file [file --> file]. More... | |
static bvec_t | ReadSigDataToBytes (const std::string &inputFile) |
Read and decrypt a CMS enveloped-data object to a byte array [file --> bytes]. More... | |
static int | ReadSigDataToFile (const std::string &outputFile, const std::string &inputFile, bool bigFile=false) |
Read the content from a CMS signed-data object file [file --> file]. More... | |
static bool | VerifySigData (const std::string &inputFile, const std::string &certFile="", const std::string &hexDigest="", bool bigFile=false) |
Verify the signature and content of a signed-data CMS object file. More... | |
Create, read and analyze Cryptographic Message Syntax (CMS) objects.
Supported CMS objects are signed-data, enveloped-data, and compressed-data.
|
strong |
Content encryption algorithm.
enum dipki::Cms::ComprDataOptions : unsigned int |
enum dipki::Cms::EnvDataOptions : unsigned int |
Advanced options for CMS enveloped-data objects [BitFlags].
|
strong |
|
strong |
Hash algorithm for RSA-OEAP or ECDH KDF or RSA-KEM.
Enumerator | |
---|---|
Default | Use default algorithm. |
Sha1 | SHA-1 (default) |
Sha224 | SHA-224. |
Sha256 | SHA-256 (default for RSA-KEM) |
Sha384 | SHA-384. |
Sha512 | SHA=512. |
|
strong |
Key encryption algorithm for key transport scheme (ktri)
|
strong |
Signature algorithm.
enum dipki::Cms::SigDataOptions : unsigned int |
Advanced options for CMS signed-data objects [BitFlags].
|
static |
Extract the message digest from a signed-data CMS object file.
inputFile | File containing CMS signed-data object (or a string with its PEM representation). |
certFile | an (optional) X.509 certificate file to be used to identify the signer. |
std::runtime_error | Exception if input data is invalid. |
|
static |
Create a CMS compressed-data file (.p7z) from an existing input file [binary file --> binary file].
outputFile | Name of output file to be created. |
inputFile | Input data file. |
zlibCompress
algorithm. It only works in file-to-file mode.
|
static |
Create a "detached signature" CMS signed-data object from a message digest of the content [hexdigest --> file].
outputFile | Name of output file to be created. |
hexDigest | String containing message digest in hex format. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
privateKey | Internal representation of private key for the sender. |
sigAlg | Signature algorithm to use when signing [default=rsa-sha1]. |
opts | Advanced option flags. |
format | Output format (default = binary). |
|
static |
Create a CMS enveloped-data object for one or more recipients [file --> file].
outputFile | Name of output file to be created. |
inputFile | Input data file. |
certList | list of one or more recipient X.509 certificate filenames, separated by semicolons (;). A certificate's representation in base64 or as a PEM string may be used instead of a filename. Alternatively, specify a single PKCS#7 certificate chain file (.p7c/.p7b). |
cipherAlg | Content encryption algorithm [default=AES128-CBC] |
keyEncrAlg | Key encryption algorithm for key transport scheme [default=RSAES-PKCS-v1_5 (rsaEncryption)]. |
hashAlg | Hash algorithm for RSAES-OAEP and ECDH KDF [default=SHA-1] or RSA-KEM [default=SHA-256] |
advOpts | Advanced option flags. |
format | Output format (default = binary). |
bigFile | Set as true for faster handling of a large input file (binary output only). |
kdfAlg | Key derivation function (KDF) for ECDH key agreement scheme (where applicable). |
keyWrapAlg | Key wrap algorithm for ECDH key agreement scheme or kekri type (default=match content encryption algorithm) |
keyString | Use to pass optional additional user key material (ukm) for KDF where KeyAgreement (kari) type is used. |
count | Optional tag length for AuthEnvelopedData (in range 12-16, default=16). Otherwise ignored |
|
static |
Create a CMS enveloped-data object using pwri or kekri scheme [file --> file].
outputFile | Name of output file to be created. |
inputFile | Input data file. |
schemeType | Set as "type=@pwri" to create a single recipientInfo of the PasswordRecipientInfo (pwri) type; or set as "type=@kekri,keyid=<string>" to create a single recipientInfo of the KEKRecipientInfo (kekri) type. |
keyString | Use to pass the password for a pwri type or the key encryption key (KEK) for a kekri type. Either pass a plain ASCII string, e.g. "abc" or use the format "#x<hex-digits>" to pass a string of arbitrary octet values, e.g. "#xdeadbeef01" to pass the 5 bytes 0xde,0xad,0xbe,0xef,0x01 . Required for pwri and kekri types. |
cipherAlg | Content encryption algorithm [default=AES128-CBC] |
keyWrapAlg | Key wrap algorithm for kekri type (default=match content encryption algorithm) |
advOpts | Advanced option flags. Add EnvDataOptions.Authenticated for authenticated encryption. |
format | Output format (default = binary). |
hashAlg | Hash algorithm for pwri PBKDF2 [default=SHA-1] |
count | Optional iteration count for KDF in pwri type (default=4096) or tag length for AuthEnvelopedData (in range 12-16, default=16). Otherwise ignored |
|
static |
Create a CMS enveloped-data object for one or more recipients [bytes --> file].
outputFile | Name of output file to be created. |
data | Input data. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
cipherAlg | Content encryption algorithm [default=AES128-CBC] |
keyEncrAlg | Key encryption algorithm [default=RSAES-PKCS-v1_5 (rsaEncryption)]. |
hashAlg | Hash algorithm for RSAES-OAEP and ECDH KDF [default=SHA-1] or RSA-KEM [default=SHA-256] |
advOpts | Advanced option flags. |
format | Output format (default = binary). |
kdfAlg | Key derivation function (KDF) for ECDH key agreement scheme (where applicable). |
keyWrapAlg | Key wrap algorithm for ECDH key agreement scheme. |
keyString | Optional user key material (ukm) for ECDH key agreement scheme |
|
static |
Create a CMS enveloped-data object for one or more recipients [string --> file].
outputFile | Name of output file to be created. |
inputStr | Input data string. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
cipherAlg | Content encryption algorithm [default=AES128-CBC] |
keyEncrAlg | Key encryption algorithm [default=RSAES-PKCS-v1_5 (rsaEncryption)]. |
hashAlg | Hash algorithm for RSAES-OAEP and ECDH KDF [default=SHA-1] or RSA-KEM [default=SHA-256] |
advOpts | Advanced option flags. |
kdfAlg | Key derivation function (KDF) for ECDH key agreement scheme (where applicable). |
keyWrapAlg | Key wrap algorithm for ECDH key agreement scheme. |
keyString | Optional user key material (ukm) for ECDH key agreement scheme |
format | Output format (default = binary). |
|
static |
Create a CMS signed-data object from a data file [file --> file].
outputFile | Name of output file to be created. |
inputFile | File containing message data to be signed. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
privateKey | Internal representation of private key for the sender. |
sigAlg | Signature algorithm to use when signing [default=rsa-sha1]. |
opts | Advanced option flags. |
format | Output format options [default=binary]. |
bigFile | Set as true for faster handling of a large input file (binary output only). |
|
static |
Create a CMS signed-data object from data [bytes --> file].
outputFile | Name of output file to be created. |
data | Message data to be signed. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
privateKey | Internal representation of private key for the sender. |
sigAlg | Signature algorithm to use when signing [default=rsa-sha1]. |
opts | Advanced option flags. |
format | Output format options [default=binary]. |
|
static |
Create a SignedData object from a "pseudo" object.
outputFile | Name of output file to be created. |
inputPseudoFile | Input "pseudo" file with dummy placeholder signature. |
sigValue | Signature value computed by external service. |
format | Output format (default = binary). |
|
static |
Create a CMS object of type SignedData using a pre-computed signature value [bytes --> file].
outputFile | Name of output file to be created. |
sigValue | Signature value. |
data | Message data to be signed. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
sigAlg | Signature algorithm to use when signing [default=rsa-sha1]. RSA-PKCS1V1_5 only. |
opts | Advanced option flags. |
format | Output format options [default=binary]. |
|
static |
Create a CMS signed-data object from a string [string --> file].
outputFile | Name of output file to be created. |
inputStr | String containing message data to be signed. |
certList | Filename of the signer's certificate (or a string with its base64 or PEM representation) and (optionally) a list of other certificates to be included in the output, separated by semi-colons(; ). Alternatively specify a single PKCS#7 certificate chain file (.p7c/.p7b) containing the signer's certificate. |
privateKey | Internal representation of private key for the sender. |
sigAlg | Signature algorithm to use when signing [default=rsa-sha1]. |
opts | Advanced option flags. |
format | Output format options [default=binary]. |
|
static |
Query a CMS enveloped-data object for selected information.
inputFile | File containing CMS enveloped-data object (or a string with its PEM representation). |
query | Query string (case insensitive). See remarks. |
"1"
. Use std::stoi(s)
to convert to an integer. Query String | Returns |
---|---|
version | envelopedData CMSVersion (edVer ) value, e.g. "0" . |
recipientInfoVersion | recipientInfo version (riVer ) value |
recipientInfoType | Type of recipientInfo: ktri , kari , kekri , pwri |
countOfRecipientInfos | Number of RecipientInfos included in the data |
recipientIssuerName | Distinguished Name of recipient's certificate issuer |
recipientSerialNumber | serialNumber of recipient's certificate in hex format |
keyEncryptionAlgorithm | keyEncryptionAlgorithm, e.g. "rsaEncryption" |
keyEncryptionFlags | Bit flags used for the key encryption algorithm (ktri only) |
sizeofEncryptedKey | Size (in bytes) of the EncryptedKey |
encryptedKey | EncryptedKey value encoded in hex |
oaepParams | Parameters used for RSA-OAEP (if applicable). |
keyWrapAlgorithm | Key wrap algorithm, e.g. "aes128-wrap" (if applicable) |
originatorKeyAlgorithm | OriginatorPublicKey algorithm, e.g. "ecPublicKey" |
originatorPublicKey | OriginatorPublicKey publicKey value encoded in hex |
keyid | keyIdentifier for KEKRecipientInfo (kekri) type |
contentEncryptionAlgorithm | contentEncryptionAlgorithm, e.g. "des-EDE3-CBC" |
sizeofEncryptedContent | Size (in bytes) of the EncryptedContent |
encryptedContent | EncryptedContent encoded in hex |
iv | Initialization vector encoded in hex |
N
th recipientInfo append "/N"
to the query string, e.g. "recipientInfoVersion/2"
to find the version number of the second recipientInfo in the file. std::runtime_error | Exception with error code if input data or query is invalid. |
|
static |
Query a CMS signed-data object for selected information.
inputFile | File containing CMS signed-data object (or a string with its PEM representation). |
query | Query string (case insensitive). See remarks. |
"1"
. Use std::stoi(s)
to convert to an integer. Query String | Returns |
---|---|
version | signedData version (sdVer ) value, e.g. "1" . |
eContentType | ContentType of the EncapsulatedContentInfo, e.g. "data" |
HASeContent | "1" if eContent is present; "0" if not |
CountOfCertificates | Number of certificates included in the data |
CountOfSignerInfos | Number of SignerInfos included in the data |
signerInfoVersion | signerInfo version (siVer ) value |
digestAlgorithm | digestAlgorithm, e.g. "sha1" |
signatureAlgorithm | signatureAlgorithm, e.g. "rsaEncryption" |
signatureValue | Signature value encoded in hex |
HASsignedAttributes | "1" if signedAttributes (authenticatedAttributes) are present; "0" if not |
DigestOfSignedAttrs | Computed digest over signed attributes, if present, using digestAlgorithm |
DigestOfeContent | Computed digest over eContent, if present, using digestAlgorithm |
signingTime | signingTime attribute in format "2005-12-31 23:30:59" |
messageDigest | messageDigest attribute in hexadecimal format, if present |
pssParams | Parameters used for RSA-PSS (if applicable). |
HASsigningCertificate | "1" if an ESS signingCertificate is present; "0" if not. |
signingCertHash | certHash value of ESS signing certificate, if present, encoded in hex |
HASalgorithmProtection | "1" if a cmsAlgorithmProtection attribute is present; "0" if not. |
N
th signerInfo append "/N"
to the query string, e.g. "signerInfoVersion/2"
to find the version number of the second signerInfo in the file. std::runtime_error | Exception with error code if input data or query is invalid. |
|
static |
Read and extract the decompressed contents of a CMS compressed-data file [binary file --> binary file].
outputFile | Name of output file to be created. |
inputFile | Input data file. |
opts | Options [default=inflate contents]. |
|
static |
Read and decrypt a CMS enveloped-data object to a byte array [file --> bytes].
inputFile | Input data file. |
privateKey | Internal representation of private key. |
certFile | (optional) recipient's X.509 certificate. |
|
static |
Read and decrypt a CMS enveloped-data object to a file [file --> file].
outputFile | Name of output file to be created. |
inputFile | Input data file. |
privateKey | Internal representation of private key. |
certFile | (optional) recipient's X.509 certificate. |
bigFile | Set as true for faster handling of a large input file (binary only). |
|
static |
Read and decrypt a CMS enveloped-data object to a byte array [file --> bytes].
inputFile | Input data file. |
std::runtime_error | Exception if input data is invalid. |
|
static |
Read the content from a CMS signed-data object file [file --> file].
outputFile | Name of output file to be created. |
inputFile | Name of file containing CMS signed-data object (binary or base64-encoded) or the data as a base64 or PEM string. |
bigFile | Set as true for faster handling of a large input file (binary only). |
std::runtime_error | Exception if input data is invalid. |
|
static |
Verify the signature and content of a signed-data CMS object file.
inputFile | File containing CMS signed-data object (or a string with its PEM representation). |
certFile | (optional) X.509 certificate file of the signer (or its base64 or PEM representation). |
hexDigest | (optional) digest of eContent to be verified (use for "detached-signature" form). |
bigFile | Set as true for faster handling of a large input file. |
certFile
then the public key from that certificate will be used and a matching signerInfo
field will be searched for in the SignedData file. Otherwise the first matching pair of certificate and signerInfo
found in the SignedData file will be used. For a "detached-signature" file where the signed content has been passed to the user by other means, compute a separate message digest of the data and pass it to the function in the hexDigest
parameter. std::runtime_error | Exception if file is missing or corrupt, or parameters are bad, etc. |