Match padding macro values and restore EVP non-AES-GCM

This commit is contained in:
Tesfa Mael
2019-08-28 15:45:07 -07:00
parent a76f719aac
commit 87e876d8c6
2 changed files with 19 additions and 24 deletions

View File

@ -383,23 +383,21 @@ WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx,
*outl = 0;
if (inl == 0) return WOLFSSL_SUCCESS;
#if defined(HAVE_AESGCM)
#if !defined(NO_AES) && defined(HAVE_AESGCM)
switch (ctx->cipherType) {
#if !defined(NO_AES)
#if defined(HAVE_AESGCM)
case AES_128_GCM_TYPE:
case AES_192_GCM_TYPE:
case AES_256_GCM_TYPE:
/* if out == NULL, in/inl contains the additional authenticated data for GCM */
return wolfSSL_EVP_CipherUpdate_GCM(ctx, out, outl, in, inl);
#endif
default:
/* fall-through*/
/* fall-through */
break;
}
#endif /* !defined(NO_AES) && defined(HAVE_AESGCM) */
if (out == NULL)
return BAD_FUNC_ARG;
}
#endif /* !NO_AES */
#endif /* HAVE_AESGCM */
if (ctx->bufUsed > 0) { /* concatinate them if there is anything */
fill = fillBuff(ctx, in, inl);
@ -496,10 +494,8 @@ WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
WOLFSSL_ENTER("wolfSSL_EVP_CipherFinal");
#if defined(HAVE_AESGCM)
#if !defined(NO_AES) && defined(HAVE_AESGCM)
switch (ctx->cipherType) {
#if !defined(NO_AES)
#if defined(HAVE_AESGCM)
case AES_128_GCM_TYPE:
case AES_192_GCM_TYPE:
case AES_256_GCM_TYPE:
@ -507,18 +503,17 @@ WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
/* Clear IV, since IV reuse is not recommended for AES GCM. */
XMEMSET(ctx->iv, 0, AES_BLOCK_SIZE);
return WOLFSSL_SUCCESS;
#endif
default:
/* fall-through*/
/* fall-through */
break;
}
#endif /* !NO_AES && HAVE_AESGCM */
if (ctx->flags & WOLFSSL_EVP_CIPH_NO_PADDING) {
if (ctx->bufUsed != 0) return WOLFSSL_FAILURE;
*outl = 0;
return WOLFSSL_SUCCESS;
}
}
#endif /* !NO_AES */
#endif /* HAVE_AESGCM */
if (ctx->enc) {
if (ctx->block_size == 1) {
*outl = 0;

View File

@ -35,8 +35,8 @@
/* Padding types */
#define RSA_PKCS1_PADDING 0
#define RSA_PKCS1_OAEP_PADDING 1
#define RSA_NO_PADDING 2
#define RSA_PKCS1_PSS_PADDING 3
#define RSA_PKCS1_PSS_PADDING 2
#define RSA_NO_PADDING 3
#ifndef WOLFSSL_RSA_TYPE_DEFINED /* guard on redeclaration */
typedef struct WOLFSSL_RSA WOLFSSL_RSA;