Remove inconsistent null pointer checks in cipher_update hooks None of the other cipher_update functions have this. They don't make sense here. The weird null special cases are handled in the wrapper layer. For empty slices, the check is wrong, because doing nothing should succeed. It's fine because the wrappers handle empty slices for you. That leaves people incorrectly passing a null pointer with a non-empty slice. But invalid slices are, in general, not something functions can handle. It's unlikely that anyone is relying on this to mask a bug since it is only applied to a couple obscure ciphers. This removes some of the few places where cipher_update is actually fallible. Change-Id: I335a0431370ffd0aa161c866b2fc9cfda2d845eb Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/99988 Auto-Submit: David Benjamin <davidben@google.com> Commit-Queue: Rudolf Polzer <rpolzer@google.com> Reviewed-by: Rudolf Polzer <rpolzer@google.com>
diff --git a/decrepit/cfb/cfb.cc b/decrepit/cfb/cfb.cc index c7b3f8f..21116a1 100644 --- a/decrepit/cfb/cfb.cc +++ b/decrepit/cfb/cfb.cc
@@ -38,16 +38,11 @@ static int aes_cfb128_cipher_update(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, size_t len) { - if (!out || !in) { - return 0; - } - EVP_CFB_CTX *cfb_ctx = reinterpret_cast<EVP_CFB_CTX *>(ctx->cipher_data); int num = ctx->num; AES_cfb128_encrypt(in, out, len, &cfb_ctx->ks, ctx->iv, &num, ctx->encrypt ? AES_ENCRYPT : AES_DECRYPT); ctx->num = num; - return 1; }
diff --git a/decrepit/xts/xts.cc b/decrepit/xts/xts.cc index 97b665e..b2f33a5 100644 --- a/decrepit/xts/xts.cc +++ b/decrepit/xts/xts.cc
@@ -164,8 +164,7 @@ static int aes_xts_cipher_update(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, size_t len) { EVP_AES_XTS_CTX *xctx = reinterpret_cast<EVP_AES_XTS_CTX *>(ctx->cipher_data); - if (!xctx->xts.key1 || !xctx->xts.key2 || !out || !in || - len < AES_BLOCK_SIZE || + if (!xctx->xts.key1 || !xctx->xts.key2 || len < AES_BLOCK_SIZE || !CRYPTO_xts128_encrypt(&xctx->xts, ctx->iv, in, out, len, ctx->encrypt)) { return 0; }