Skip to content
Open
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
3 changes: 2 additions & 1 deletion wolfcrypt/src/chacha20_poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ int wc_ChaCha20Poly1305_Final(ChaChaPoly_Aead* aead,
if (aead == NULL || outAuthTag == NULL) {
return BAD_FUNC_ARG;
}
if (aead->state != CHACHA20_POLY1305_STATE_AAD &&
if (aead->state != CHACHA20_POLY1305_STATE_READY &&
aead->state != CHACHA20_POLY1305_STATE_AAD &&
aead->state != CHACHA20_POLY1305_STATE_DATA) {
return BAD_STATE_E;
}
Expand Down
19 changes: 16 additions & 3 deletions wolfcrypt/src/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -3354,7 +3354,15 @@ static int RsaPublicEncryptEx(const byte* in, word32 inLen, byte* out,
RsaPadding padding;
#endif

if (in == NULL || inLen == 0 || out == NULL || key == NULL) {
if (out == NULL || key == NULL) {
return BAD_FUNC_ARG;
}

/* For OAEP padding (RFC 8017, Section 7.1.1), zero-length messages are
* permitted: the spec requires mLen <= k - 2*hLen - 2, and mLen = 0
* satisfies this for all supported key sizes. For other padding types,
* a zero-length input is invalid. */
if (in == NULL || (inLen == 0 && pad_type != WC_RSA_OAEP_PAD)) {
return BAD_FUNC_ARG;
}

Expand Down Expand Up @@ -3752,8 +3760,13 @@ static int RsaPrivateDecryptEx(const byte* in, word32 inLen, byte* out,
ret = ctMaskSelInt(ctMaskLTE(ret, (int)outLen), ret,
WC_NO_ERR_TRACE(RSA_BUFFER_E));
#ifndef WOLFSSL_RSA_DECRYPT_TO_0_LEN
ret = ctMaskSelInt(ctMaskNotEq(ret, 0), ret,
WC_NO_ERR_TRACE(RSA_BUFFER_E));
/* RFC 8017 Section 7.1.2: OAEP decryption may produce a valid
* zero-length message. Only reject ret==0 for non-OAEP types. */
{
int zeroOk = ctMaskEq(pad_type, WC_RSA_OAEP_PAD);
ret = ctMaskSelInt(ctMaskNotEq(ret, 0) | zeroOk, ret,
WC_NO_ERR_TRACE(RSA_BUFFER_E));
}
#endif
#else
if (outLen < (word32)ret)
Expand Down
Loading