mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
One more time to quiet clang tidy
This commit is contained in:
@ -299,53 +299,55 @@ int wc_CmacFinalNoFree(Cmac* cmac, byte* out, word32* outSz)
|
|||||||
NULL);
|
NULL);
|
||||||
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
|
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Clear CRYPTOCB_UNAVAILABLE return code */
|
/* Clear CRYPTOCB_UNAVAILABLE return code */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
/* fall-through when unavailable */
|
/* fall-through when unavailable */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
switch (cmac->type) {
|
if (ret == 0) {
|
||||||
#if !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT)
|
switch (cmac->type) {
|
||||||
case WC_CMAC_AES:
|
#if !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT)
|
||||||
{
|
case WC_CMAC_AES:
|
||||||
const byte* subKey;
|
{
|
||||||
word32 remainder;
|
const byte* subKey;
|
||||||
|
word32 remainder;
|
||||||
|
|
||||||
if (cmac->bufferSz == AES_BLOCK_SIZE) {
|
if (cmac->bufferSz == AES_BLOCK_SIZE) {
|
||||||
subKey = cmac->k1;
|
subKey = cmac->k1;
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* ensure we will have a valid remainder value */
|
|
||||||
if (cmac->bufferSz > AES_BLOCK_SIZE) {
|
|
||||||
ret = BAD_STATE_E;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
remainder = AES_BLOCK_SIZE - cmac->bufferSz;
|
else {
|
||||||
|
/* ensure we will have a valid remainder value */
|
||||||
|
if (cmac->bufferSz > AES_BLOCK_SIZE) {
|
||||||
|
ret = BAD_STATE_E;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
remainder = AES_BLOCK_SIZE - cmac->bufferSz;
|
||||||
|
|
||||||
if (remainder == 0) {
|
if (remainder == 0) {
|
||||||
remainder = AES_BLOCK_SIZE;
|
remainder = AES_BLOCK_SIZE;
|
||||||
}
|
}
|
||||||
if (remainder > 1) {
|
if (remainder > 1) {
|
||||||
XMEMSET(cmac->buffer + AES_BLOCK_SIZE - remainder, 0,
|
XMEMSET(cmac->buffer + AES_BLOCK_SIZE - remainder, 0,
|
||||||
remainder);
|
remainder);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmac->buffer[AES_BLOCK_SIZE - remainder] = 0x80;
|
cmac->buffer[AES_BLOCK_SIZE - remainder] = 0x80;
|
||||||
subKey = cmac->k2;
|
subKey = cmac->k2;
|
||||||
|
}
|
||||||
|
xorbuf(cmac->buffer, cmac->digest, AES_BLOCK_SIZE);
|
||||||
|
xorbuf(cmac->buffer, subKey, AES_BLOCK_SIZE);
|
||||||
|
ret = wc_AesEncryptDirect(&cmac->aes, cmac->digest, cmac->buffer);
|
||||||
|
if (ret == 0) {
|
||||||
|
XMEMCPY(out, cmac->digest, *outSz);
|
||||||
|
}
|
||||||
|
}; break;
|
||||||
|
#endif /* !NO_AES && WOLFSSL_AES_DIRECT */
|
||||||
|
default :
|
||||||
|
ret = BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
xorbuf(cmac->buffer, cmac->digest, AES_BLOCK_SIZE);
|
|
||||||
xorbuf(cmac->buffer, subKey, AES_BLOCK_SIZE);
|
|
||||||
ret = wc_AesEncryptDirect(&cmac->aes, cmac->digest, cmac->buffer);
|
|
||||||
if (ret == 0) {
|
|
||||||
XMEMCPY(out, cmac->digest, *outSz);
|
|
||||||
}
|
|
||||||
}; break;
|
|
||||||
#endif /* !NO_AES && WOLFSSL_AES_DIRECT */
|
|
||||||
default :
|
|
||||||
ret = BAD_FUNC_ARG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user