6.3.4 Crypto_DigiSign_Ecdsa_VerifyData

crypto_DigiSign_Status_E Crypto_DigiSign_Ecdsa_VerifyData(
    crypto_HandlerType_E ecdsaHandlerType_en, 
    uint8_t ptr_inputData, 
    uint32_t hashLen, 
    uint8_t *ptr_inputSig, 
    uint32_t sigLen, 
    uint8_t *ptr_pubKey, 
    uint32_t pubKeyLen, 
    int8_t *ptr_hashVerifyStat, 
    crypto_Hash_Algo_E hashType_en,
    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 TypeArgument NameTypeDescription
1crypto_HandlerType_EecdsaHandlerType_enInputEnum for crypto operation handler i.e., SW, HW
2uint8_t*ptr_inputDataInputPointer which holds data to verify
3uint32_thashLenInputLength of the hash in bytes
4uint8_t*ptr_inputSigInputPointer holds the signatures of hash
5uint32_tsigLenInputLength of signature in bytes
6uint8_t*ptr_pubKeyInputPointer to hold public key x9.63 format
7uint32_tpubKeyLenInputLength of ECC public key in bytes
8int8_t*ptr_hashVerifyStatOutputStatus of signature verification 1 valid signature and 0 invalid signature
8crypto_Hash_Algo_EhashType_enInputHash algo type to use
9crypto_EccCurveType_EeccCurveType_enInputCurve type used for the ECC keys
10uint32_tecdsaSessionIdInputIt defines the session ID, must be more than zero

Returns

Return TypeDescription
crypto_DigiSign_Status_EFunction 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;
crypto_Hash_Algo_E hashAlgoType = CRYPTO_HASH_SHA2_256;
uint8_t *hashVerifyStat = NULL;

status = Crypto_DigiSign_Ecdsa_SignData(
    handlerType_en,
    inputData,
    dataLen,
    outSig,
    sigLen,
    key,
    keyLen,
    hashAlgoType,
    eccCurveType_en,
    sessionID
    );

status = Crypto_DigiSign_Ecdsa_VerifyData(
    handlerType_en,
    inputData,
    dataLen,
    sig,
    sigLen,
    key,
    keyLen,
    &hashVerifyStat,
    eccCurveType_en,
    sessionID
    );

Remarks

This API does not support DER format of Keys.