in ports/mbedTLS/azure_iot_jws_mbedtls.c [87:140]
static AzureIoTResult_t prvSplitJWS( uint8_t * pucJWS,
uint32_t ulJWSLength,
uint8_t ** ppucHeader,
uint32_t * pulHeaderLength,
uint8_t ** ppucPayload,
uint32_t * pulPayloadLength,
uint8_t ** ppucSignature,
uint32_t * pulSignatureLength )
{
uint8_t * pucFirstDot;
uint8_t * pucSecondDot;
uint32_t ulDotCount = 0;
uint32_t ulIndex = 0;
*ppucHeader = pucJWS;
while( ulIndex < ulJWSLength )
{
if( *pucJWS == '.' )
{
ulDotCount++;
if( ulDotCount == 1 )
{
pucFirstDot = pucJWS;
}
else if( ulDotCount == 2 )
{
pucSecondDot = pucJWS;
}
else if( ulDotCount > 2 )
{
AZLogError( ( "JWS had more '.' than required (2)" ) );
return eAzureIoTErrorFailed;
}
}
pucJWS++;
ulIndex++;
}
if( ( ulDotCount != 2 ) || ( pucSecondDot >= ( *ppucHeader + ulJWSLength - 1 ) ) )
{
return eAzureIoTErrorFailed;
}
*pulHeaderLength = pucFirstDot - *ppucHeader;
*ppucPayload = pucFirstDot + 1;
*pulPayloadLength = pucSecondDot - *ppucPayload;
*ppucSignature = pucSecondDot + 1;
*pulSignatureLength = *ppucHeader + ulJWSLength - *ppucSignature;
return eAzureIoTSuccess;
}