in platform/posix/transport/src/mbedtls_pkcs11_posix.c [932:971]
int32_t Mbedtls_Pkcs11_Send( NetworkContext_t * pNetworkContext,
const void * pBuffer,
size_t bytesToSend )
{
MbedtlsPkcs11Context_t * pMbedtlsPkcs11Context = NULL;
int32_t tlsStatus = 0;
assert( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) );
pMbedtlsPkcs11Context = pNetworkContext->pParams;
tlsStatus = ( int32_t ) mbedtls_ssl_write( &( pMbedtlsPkcs11Context->context ),
pBuffer,
bytesToSend );
if( ( tlsStatus == MBEDTLS_ERR_SSL_TIMEOUT ) ||
( tlsStatus == MBEDTLS_ERR_SSL_WANT_READ ) ||
( tlsStatus == MBEDTLS_ERR_SSL_WANT_WRITE ) )
{
LogDebug( ( "Failed to send data. However, send can be retried on this error. "
"mbedTLSError= %s : %s.",
mbedtlsHighLevelCodeOrDefault( tlsStatus ),
mbedtlsLowLevelCodeOrDefault( tlsStatus ) ) );
/* Mark these set of errors as a timeout. The libraries may retry send
* on these errors. */
tlsStatus = 0;
}
else if( tlsStatus < 0 )
{
LogError( ( "Failed to send data: mbedTLSError= %s : %s.",
mbedtlsHighLevelCodeOrDefault( tlsStatus ),
mbedtlsLowLevelCodeOrDefault( tlsStatus ) ) );
}
else
{
/* Empty else marker. */
}
return tlsStatus;
}