6.3.2 Crypto_DigiSign_Ecdsa_Verify
crypto_DigiSign_Status_E Crypto_DigiSign_Ecdsa_Verify(
crypto_HandlerType_E ecdsaHandlerType_en,
uint8_t *ptr_inputHash,
uint32_t hashLen,
uint8_t *ptr_inputSig,
uint32_t sigLen,
uint8_t *ptr_pubKey,
uint32_t pubKeyLen,
int8_t *ptr_hashVerifyStat,
crypto_EccCurveType_E eccCurveType_en,
uint32_t ecdsaSessionId
);
Description
This API is designed for verifying the signature of a hash using the ECDSA algorithm. It utilizes the ECC public key to perform the verification. The public key should adhere to the ANSI X9.63 format. The first byte of the X9.63 formatted ECC public key indicates compression, which can be uncompressed, odd, or even.
For instance, an uncompressed ECC public key for secp256r1 is 65 bytes long, where the first byte indicates compression (0x04), followed by 64 bytes representing the X and Y components. If the public key is compressed and even (0x02) or odd (0x03), then the key's first byte represents compression, followed by 32 bytes representing the X component. Thus, a compressed public key for the secp256r1 curve is 33 bytes long.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|---|---|---|---|
1 | crypto_HandlerType_E | ecdsaHandlerType_en | Input | Enum for crypto operation handler i.e., SW, HW |
2 | uint8_t* | ptr_inputHash | Input | Pointer which holds hash to verify |
3 | uint32_t | hashLen | Input | Length of the hash in bytes |
4 | uint8_t* | ptr_inputSig | Input | Pointer holds the signatures of hash |
5 | uint32_t | sigLen | Input | Length of signature in bytes |
6 | uint8_t* | ptr_pubKey | Input | Pointer to hold public key x9.63 format |
7 | uint32_t | pubKeyLen | Input | Length of ECC public key in bytes |
8 | uint8_t* | ptr_hashVerifyStat | Output | Status of signature verification 1 valid signature and 0 invalid signature |
9 | crypto_EccCurveType_E | eccCurveType_en | Input | Curve type used for the ECC Keys |
10 | uint32_t | ecdsaSessionId | Input | It defines the session ID, must be more than zero |
Returns
Return Type | Description |
---|---|
crypto_DigiSign_Status_E | Function returns the status of the API. |
Example
#define sessionID 1
crypto_DigiSign_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_HW_INTERNAL
uint8_t inputData[32] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t key[32] = {/*data*/};
uint32_t keyLen = sizeof(key);
uint8_t outSig[64];
uint32_t sigLen = sizeof(outSig);
crypto_EccCurveType_E eccCurveType_en = CRYPTO_ECC_CURVE_SECP256R1;
status = Crypto_DigiSign_Ecdsa_Sign(
handlerType_en,
inputData,
dataLen,
outSig,
sigLen,
key,
keyLen,
eccCurveType_en,
sessionID
);
crypto_EccCurveType_E eccCurveType_en = CRYPTO_ECC_CURVE_SECP256R1;
uint8_t *hashVerifyStat = NULL;
status = Crypto_DigiSign_Ecdsa_Verify(
handlerType_en,
inputData,
dataLen,
outSig,
sigLen,
key,
keyLen,
&hashVerifyStat,
eccCurveType_en,
sessionID
);
Remarks
This API does not support DER format of Keys.