CmCalculateSignature
Description
CmCalculateSignature() calculates a signature using the ECDSA algorithm of the given digest directly via a CmContainer entry.
|
Triple Mode Redundancy-related information (TMR)
|
Syntax
int CMAPIENTRY CmCalculateSignature(HCMSysEntry hcmse, CMAUTHENTICATE *pcmAuth, CMBYTE *pbSignature, CMUINT cbSignature);
The digest is available as mabDigest of the structure
CMAUTHENTICATE.
|
CMAUTHENTICATE contains all information needed for an authentication process. Syntax
Parameter mflCtrl contains one of the following commands:
This commands can be or'ed with one of the following flags:
mulKeyExtType contains the extended type of the Hidden Data or Secret Data PIO, if in mflCtrl CM_AUTH_HIDDENDATA or CM_AUTH_SECRETDATA is specified. Otherwise this member must be set to 0. mulFirmCode contains the Firm Code used for the authentication process. mulProductCode contains the Product Code used for the authentication process. mulEncryptionCodeOptions contains the Encryption Code Options, this are the higher 32 bits of the Encryption Code. This value is only used, if mflCtrl has set the CM_AUTH_EXTENDED, CM_AUTH_EXTENDED, CM_AUTH_EXTENDED2 or CM_AUTH_SERIAL option. Otherwise it must be set to 0. mulFeatureCode contains the used Feature Code, which must match the used Feature Map. This value is only used, if mflCtrl has set the CM_AUTH_EXTENDED, CM_AUTH_EXTENDED, CM_AUTH_EXTENDED2 option. Otherwise it must be set to 0. mcmBoxInfo contains the CmContainer information used for the authentication process. mabDigest contains the 32-byte res. 256-bit digest which is signed.
|
hcmse contains a handle opened with CmAccess / CmAccess2 (can be a Box Access or an Entry Access).
pcmAuth contains all information needed for the authentication process (see structure CMAUTHENTICATE.
pbSignature contains the buffer for the signature.
cbSignature contains the length of the buffer of pbSignature. The length has to be CM_PUBLIC_KEY_LEN which is 64.
Return
True (1), if the signature was calculated successful. If an error occurs, 0 is returned and an error code is set.
Notes
•The hash value used for the signature must always be set into pcmAuth->mabDigest.
•The value pcmAuth->mflCtrl has to be a combination of signature method and key source. The values are or'ed together.
•Signature method is one of CM_AUTH_DIRECT, CM_AUTH_EXTENDED, CM_AUTH_EXTENDED2 or CM_AUTH_SERIAL.
•Key source is one of CM_AUTH_HIDDENDATA, CM_AUTH_SECRETDATA, CM_AUTH_SERIALKEY, CM_AUTH_BOXKEY or CM_AUTH_FIRMKEY.
•In the case of Hidden Data or Secret Data, the extended type must be set as pcmAuth->mulKeyExtType. Otherwise this value should be 0.
•CM_AUTH_DIRECT: All other values are ignored and should be set to 0.
•CM_AUTH_EXTENDED(2): pcmAuth->mulEncryptionCodeOptions has to have the same value as for CmValidateSignature. pcmAuth->mulFeatureCode can be set to a specific value. The value will be integrated into the signature but the signature will only be calculated, if the requested Feature Code conforms with the current Feature Map. The signature incorporates the serial number of the signing CodeMeter and the Firm Code / Product Code values used for CmAccess / CmAccess2. These values have to be remembered to correctly verify the signature later using CmValidateSignature.
The flag has been introduced with CodeMeter Version 5.10. Please note that using CM_AUTH_EXTENDED2 requires at least hardware version 2.03.
•CM_AUTH_SERIAL: pcmAuth->mulEncryptionCodeOptions has to have the same value as for CmValidateSignature. All other values should be set to 0. The signature incorporates the serial number of the signing CodeMeter and the Firm Code / Product Code values used for CmAccess / CmAccess2. These values have to be remembered to correctly verify the signature later using CmValidateSignature.
•CM_AUTH_PISK (Product Item Secret Key) has been introduced with CodeMeter Version 6.0 (License Transfer).
Syntax
public bool CmCalculateSignature(HCMSysEntry hcmse, CmAuthenticate Auth, out byte[] Signature) |
The digest is available as Digest of the class
CmAuthenticate.
|
CmAuthenticate contains all information needed for an authentication process. Syntax
Parameter BoxInfo contains the CmContainer information used for the authentication process. CmAuthenticate.Option contains one of the following commands:
KeyExtType contains the extended type of the Hidden Data or Secret Data PIO, if in Option HiddenData or SecretData is specified. Otherwise this member must be set to 0. FirmCode contains the Firm Code used for the authentication process. ProductCode contains the Product Code used for the authentication process. EncryptionCodeOptions contains the Encryption Code Options, this are the higher 32 bits of the Encryption Code. This value is only used, if Option has been set the Extended, Extended2 or Serial option. Otherwise it must be set to 0. Extended2 has been introduced with CodeMeter Version 5.10. Please note that using Extended2 requires at least hardware version 2.03. FeatureCode contains the used Feature Code, which must match the used Feature Map. This value is only used, if Option has been set the Extended, Extended2 option. Otherwise it must be set to 0. Digest contains the 32-byte res. 256-bit digest which is signed.
|
hcmse contains a handle opened with CmAccess / CmAccess2 (can be a Box Access or an Entry Access).
Auth contains all information needed for the authentication process (see class CmAuthenticate).
Signature receives the calculated signature.
Return
true, if the signature was calculated successful. If an error occurs, false is returned and an error code is set.
Notes
•The hash value used for the signature must always be set into Auth->Digest.
•The value Auth->Option has to be a combination of signature method and key source. The values are or'ed together.
•Signature method is one of Direct, Extended, Extended, Extended2 or Serial.
•Key source is one of HiddenData, SecretData, SerialKey, Pisk, BoxKey or FirmKey.
•In the case of Hidden Data or Secret Data, the extended type must be set as Auth->KeyExtType. Otherwise this value should be 0.
•Direct: All other values are ignored and should be set to 0.
•Extended, Extended2: Auth->EncryptionCodeOptions has to have the same value as for CmValidateSignature. Auth->FeatureCode can be set to a specific value. The value will be integrated into the signature but the signature will only be calculated, if the requested Feature Code conforms with the current Feature Map. The signature incorporates the serial number of the signing CodeMeter and the Firm Code / Product Code values used for CmAccess / CmAccess2. These values have to be remembered to correctly verify the signature later using CmValidateSignature.
Extended2 has been introduced with CodeMeter Version 5.10. Please note that using Extended2 requires at least hardware version 2.03.
•Serial: Auth->EncryptionCodeOptions has to have the same value as for CmValidateSignature. All other values should be set to 0. The signature incorporates the serial number of the signing CodeMeter and the Firm Code / Product Code values used for CmAccess / CmAccess2. These values have to be remembered to correctly verify the signature later using CmValidateSignature.
Syntax
import cmapi
handle.CmCalculateSignature(pcmAuth: CMAUTHENTICATE) -> bytes
throws CodeMeterApiFailedException()
The digest is available as mabDigest of the class
cmapi.CMAUTHENTICATE.
|
CMAUTHENTICATE contains all information needed for an authentication process. Syntax
Parameter mflCtrl contains one of the following commands:
This commands can be or'ed with one of the following flags:
mulKeyExtType contains the extended type of the Hidden Data or Secret Data PIO, if in mflCtrl cmapi.CM_AUTH_HIDDENDATA or cmapi.CM_AUTH_SECRETDATA is specified. Otherwise this member must be set to 0. mulFirmCode contains the Firm Code used for the authentication process. mulProductCode contains the Product Code used for the authentication process. mulEncryptionCodeOptions contains the Encryption Code Options, this are the higher 32 bits of the Encryption Code. This value is only used, if mflCtrl has set the cmapi.CM_AUTH_EXTENDED, cmapi.CM_AUTH_EXTENDED, cmapi.CM_AUTH_EXTENDED2 or cmapi.CM_AUTH_SERIAL option. Otherwise it must be set to 0. mulFeatureCode contains the used Feature Code, which must match the used Feature Map. This value is only used, if mflCtrl has set the cmapi.CM_AUTH_EXTENDED, CM_AUTH_EXTENDED, cmapi.CM_AUTH_EXTENDED2 option. Otherwise it must be set to 0. mcmBoxInfo contains the CmContainer information used for the authentication process. mabDigest contains the 32-byte res. 256-bit digest which is signed.
|
handle is the handle opened with CmAccess2 (can be a Box Access or an Entry Access).
pcmAuth contains all information needed for the authentication process (see class cmapi.CMAUTHENTICATE.
Return
The buffer for the signature if the signature was calculated successful. If an error occurs, a CodeMeterApiFailedException is thrown and an error code is set.
Notes
•The hash value used for the signature must always be set into pcmAuth->mabDigest.
•The value pcmAuth->mflCtrl has to be a combination of signature method and key source. The values are or'ed together.
•Signature method is one of cmapi.CM_AUTH_DIRECT, cmapi.CM_AUTH_EXTENDED, cmapi.CM_AUTH_EXTENDED2 or cmapi.CM_AUTH_SERIAL.
•Key source is one of cmapi.CM_AUTH_HIDDENDATA, cmapi.CM_AUTH_SECRETDATA, cmapi.CM_AUTH_SERIALKEY, cmapi.CM_AUTH_BOXKEY or cmapi.CM_AUTH_FIRMKEY.
•In the case of Hidden Data or Secret Data, the extended type must be set as pcmAuth->mulKeyExtType. Otherwise this value should be 0.
•cmapi.CM_AUTH_DIRECT: All other values are ignored and should be set to 0.
•cmapi.CM_AUTH_EXTENDED(2): pcmAuth->mulEncryptionCodeOptions has to have the same value as for CmValidateSignature. pcmAuth->mulFeatureCode can be set to a specific value. The value will be integrated into the signature but the signature will only be calculated, if the requested Feature Code conforms with the current Feature Map. The signature incorporates the serial number of the signing CodeMeter and the Firm Code / Product Code values used for CmAccess / CmAccess2. These values have to be remembered to correctly verify the signature later using CmValidateSignature.
The flag has been introduced with CodeMeter Version 5.10. Please note that using CM_AUTH_EXTENDED2 requires at least hardware version 2.03.
•cmapi.CM_AUTH_SERIAL: pcmAuth->mulEncryptionCodeOptions has to have the same value as for CmValidateSignature. All other values should be set to 0. The signature incorporates the serial number of the signing CodeMeter and the Firm Code / Product Code values used for CmAccess / CmAccess2. These values have to be remembered to correctly verify the signature later using CmValidateSignature.
•cmapi.CM_AUTH_PISK (Product Item Secret Key) has been introduced with CodeMeter Version 6.0 (License Transfer).