I'm currently trying to verify a signature with ECDSA (ECC public key P256) as part of the UDS security service.
Any suggestion would be welcome. Thank you.
Std_ReturnType SEC_VerifySignatureSecurityAccess(uint32_t u32KeyId, /*KeyId*/
uint8_t * pData, /* Seed*/
uint32_t u32DataSz, /* Seed Size */
uint8_t * pTag, /*signature */
uint32_t u32TagLength, /* signature size */
Crypto_VerifyResultType * pVerifyResult)
{
Std_ReturnType retVal = E_NOT_OK;
/** Crypto job-structures for UDS Security Access signature verification */
Crypto_PrimitiveInfoType App_SignatureVerifyPrimitiveInfo = {
u32TagLength, /* resultLength */
CRYPTO_SIGNATUREVERIFY, /* service*/
{CRYPTO_ALGOFAM_ECCNIST, CRYPTO_ALGOFAM_SHA2_256, (ECC_PUB_KEY_SZ), CRYPTO_ALGOMODE_NOT_SET}
};
Crypto_JobPrimitiveInfoType App_JobSignaturePrimitiveInfo = {0U, /* callbackId */
&App_SignatureVerifyPrimitiveInfo, /* primitiveInfo */
0U, /* cryIfKeyId*/
CRYPTO_PROCESSING_SYNC, /* Crypto_ProcessingType*/
FALSE /* callbackUpdateNotification*/};
/** Job SignatureVerify ID and priority*/
const Crypto_JobInfoType App_JobSignatureVerifyInfo = {JOB_SIGNATURE_VERIFY_ID, JOB_SIGNATURE_VERIFY_PRIORITY};
/** Structure of the job to be passed to Crypto driver, requesting Signature Verify */
Crypto_JobType App_JobSignatureVerify = {
JOB_SIGNATURE_VERIFY_ID, /* jobId - Identifier for the job structure */
CRYPTO_JOBSTATE_IDLE, /* jobState - Determines the current job state */
{
pData, /* inputPtr - Pointer to the input data. */
u32DataSz, /* inputLength - Contains the input length in bytes. */
pTag, /* secondaryInputPtr - Pointer to the secondary input data (for MacVerify, SignatureVerify). */
u32TagLength, /* secondaryInputLength - Contains the secondary input length in bytes. */
NULL_PTR, /* tertiaryInputPtr - Pointer to the tertiary input data (for MacVerify, SignatureVerify). */
0U, /* tertiaryInputLength - Contains the tertiary input length in bytes. */
NULL_PTR, /* outputPtr - Pointer to the output data. */
NULL_PTR, /* outputLengthPtr - Holds a pointer to a memory location containing the output length in bytes. */
NULL_PTR, /* secondaryOutputPtr - Pointer to the secondary output data. */
NULL_PTR, /* secondaryOutputLengthPtr - Holds a pointer to a memory location containing the secondary output length in bytes. */
0U, /* input64 - Versatile input parameter */
pVerifyResult, /* verifyPtr - Output pointer to a memory location holding a Crypto_VerifyResultType */
NULL_PTR, /* output64Ptr - Output pointer to a memory location holding an uint64. */
CRYPTO_OPERATIONMODE_SINGLECALL, /* mode - Indicator of the mode(s)/operation(s) to be performed */
0U, /* cryIfKeyId - Holds the CryIf key id for key operation services. */
0U, /* targetCryIfKeyId - Holds the target CryIf key id for key operation services. */
},
&App_JobSignaturePrimitiveInfo, /* jobPrimitiveInfo - Pointer to a structure containing further information, which depends on the job and the
crypto primitive */
&App_JobSignatureVerifyInfo, /* jobInfo - Pointer to a structure containing further information, which depends on the job and the
crypto primitive */
NULL_PTR, /* jobRedirectionInfoRef - Pointer to a structure containing further information on the usage of keys as input and output for jobs. */
u32KeyId /* cryptoKeyId - Identifier of the Crypto Driver key. The identifier shall be written by the Crypto Interface */
};
retVal = Crypto_ProcessJob(CryptoConf_CryptoDriverObject_CryptoDriverObject_0, &App_JobSignatureVerify);
return retVal;
}