Skip to content

Update code to remove constness related warnings for lates ESP-IDF v5.4 (CA-354) #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ static CK_RV prvGetCertificate( const char * pcLabelName,
uint8_t ** ppucData,
uint32_t * pulDataSize );

static OtaPalStatus_t asn1_to_raw_ecdsa( uint8_t * signature,
static OtaPalStatus_t asn1_to_raw_ecdsa( const uint8_t * signature,
uint16_t sig_len,
uint8_t * out_signature )
{
int ret = 0;
const unsigned char * end = signature + sig_len;
unsigned char * local_signature_ptr = ( unsigned char * ) signature;
const unsigned char * end = local_signature_ptr + sig_len;
size_t len;
mbedtls_mpi r = { 0 };
mbedtls_mpi s = { 0 };
Expand All @@ -125,21 +126,21 @@ static OtaPalStatus_t asn1_to_raw_ecdsa( uint8_t * signature,
mbedtls_mpi_init( &r );
mbedtls_mpi_init( &s );

if( ( ret = mbedtls_asn1_get_tag( &signature, end, &len,
if( ( ret = mbedtls_asn1_get_tag( &local_signature_ptr, end, &len,
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
{
LogError( ( "Bad Input Signature" ) );
goto cleanup;
}

if( signature + len != end )
if( local_signature_ptr + len != end )
{
LogError( ( "Incorrect ASN1 Signature Length" ) );
goto cleanup;
}

if( ( ( ret = mbedtls_asn1_get_mpi( &signature, end, &r ) ) != 0 ) ||
( ( ret = mbedtls_asn1_get_mpi( &signature, end, &s ) ) != 0 ) )
if( ( ( ret = mbedtls_asn1_get_mpi( &local_signature_ptr, end, &r ) ) != 0 ) ||
( ( ret = mbedtls_asn1_get_mpi( &local_signature_ptr, end, &s ) ) != 0 ) )
{
LogError( ( "ASN1 parsing failed" ) );
goto cleanup;
Expand Down Expand Up @@ -475,7 +476,7 @@ OtaPalStatus_t otaPal_CheckFileSignature( AfrOtaJobDocumentFields_t * const pFil
}

if( CRYPTO_SignatureVerificationFinal( pvSigVerifyContext, ( char * ) pucSignerCert, ulSignerCertSize,
pFileContext->signature, pFileContext->signatureLen ) == pdFALSE )
( const uint8_t * ) pFileContext->signature, pFileContext->signatureLen ) == pdFALSE )
{
LogError( ( "Signature verification failed." ) );
result = OtaPalSignatureCheckFailed;
Expand Down Expand Up @@ -529,7 +530,7 @@ OtaPalStatus_t otaPal_CloseFile( AfrOtaJobDocumentFields_t * const pFileContext
{
memset( sec_boot_sig->sec_ver, 0x00, sizeof( sec_boot_sig->sec_ver ) );
memset( sec_boot_sig->pad, 0xFF, sizeof( sec_boot_sig->pad ) );
mainErr = asn1_to_raw_ecdsa( pFileContext->signature, pFileContext->signatureLen, sec_boot_sig->raw_ecdsa_sig );
mainErr = asn1_to_raw_ecdsa( ( const uint8_t * ) pFileContext->signature, pFileContext->signatureLen, sec_boot_sig->raw_ecdsa_sig );

if( mainErr == OtaPalSuccess )
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/corePKCS11/port/iot_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static BaseType_t prvVerifySignature( char * pcSignerCertificate,
BaseType_t xHashAlgorithm,
uint8_t * pucHash,
size_t xHashLength,
uint8_t * pucSignature,
const uint8_t * pucSignature,
size_t xSignatureLength )
{
BaseType_t xResult = pdTRUE;
Expand Down Expand Up @@ -255,7 +255,7 @@ void CRYPTO_SignatureVerificationUpdate( void * pvContext,
BaseType_t CRYPTO_SignatureVerificationFinal( void * pvContext,
char * pcSignerCertificate,
size_t xSignerCertificateLength,
uint8_t * pucSignature,
const uint8_t * pucSignature,
size_t xSignatureLength )
{
BaseType_t xResult = pdFALSE;
Expand Down
2 changes: 1 addition & 1 deletion libraries/corePKCS11/port/iot_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void CRYPTO_SignatureVerificationUpdate( void * pvContext,
BaseType_t CRYPTO_SignatureVerificationFinal( void * pvContext,
char * pcSignerCertificate,
size_t xSignerCertificateLength,
uint8_t * pucSignature,
const uint8_t * pucSignature,
size_t xSignatureLength );
#ifdef __cplusplus
}
Expand Down