in ports/mbedTLS/azure_iot_jws_mbedtls.c [472:525]
static AzureIoTResult_t prvBase64DecodeJWK( prvJWSValidationContext_t * pxManifestContext )
{
az_result xCoreResult;
xCoreResult = az_base64_url_decode( az_span_create( pxManifestContext->ucJWKHeader, azureiotjwsJWK_HEADER_SIZE ),
az_span_create( pxManifestContext->pucJWKBase64EncodedHeader, pxManifestContext->ulJWKBase64EncodedHeaderLength ),
&pxManifestContext->outJWKHeaderLength );
if( az_result_failed( xCoreResult ) )
{
AZLogError( ( "[JWS] az_base64_url_decode failed: result 0x%08x", ( uint16_t ) xCoreResult ) );
if( xCoreResult == AZ_ERROR_NOT_ENOUGH_SPACE )
{
AZLogError( ( "[JWS] Decode buffer was too small: %i bytes", azureiotjwsJWK_HEADER_SIZE ) );
}
return eAzureIoTErrorFailed;
}
xCoreResult = az_base64_url_decode( az_span_create( pxManifestContext->ucJWKPayload, azureiotjwsJWK_PAYLOAD_SIZE ),
az_span_create( pxManifestContext->pucJWKBase64EncodedPayload, pxManifestContext->ulJWKBase64EncodedPayloadLength ),
&pxManifestContext->outJWKPayloadLength );
if( az_result_failed( xCoreResult ) )
{
AZLogError( ( "[JWS] az_base64_url_decode failed: result 0x%08x", ( uint16_t ) xCoreResult ) );
if( xCoreResult == AZ_ERROR_NOT_ENOUGH_SPACE )
{
AZLogError( ( "[JWS] Decode buffer was too small: %i bytes", azureiotjwsJWK_PAYLOAD_SIZE ) );
}
return eAzureIoTErrorFailed;
}
xCoreResult = az_base64_url_decode( az_span_create( pxManifestContext->ucJWKSignature, azureiotjwsSIGNATURE_SIZE ),
az_span_create( pxManifestContext->pucJWKBase64EncodedSignature, pxManifestContext->ulJWKBase64EncodedSignatureLength ),
&pxManifestContext->outJWKSignatureLength );
if( az_result_failed( xCoreResult ) )
{
AZLogError( ( "[JWS] az_base64_url_decode failed: result 0x%08x", ( uint16_t ) xCoreResult ) );
if( xCoreResult == AZ_ERROR_NOT_ENOUGH_SPACE )
{
AZLogError( ( "[JWS] Decode buffer was too small: %i bytes", azureiotjwsSIGNATURE_SIZE ) );
}
return eAzureIoTErrorFailed;
}
return eAzureIoTSuccess;
}