summaryrefslogtreecommitdiffstats
path: root/security/nss/lib/freebl/chacha20poly1305.c
diff options
context:
space:
mode:
authorKevin Jacobs <kjacobs@mozilla.com>2019-10-24 16:47:28 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-10-24 22:43:18 +0200
commit820d6ea6a43590a9bbd9b908154f2632c290107c (patch)
tree2b6d4bf7018343b86533664a8812fbcbc3cab20f /security/nss/lib/freebl/chacha20poly1305.c
parentc6f4af2c515f81e5baa0423442c4b1a0355f1b70 (diff)
downloadUXP-820d6ea6a43590a9bbd9b908154f2632c290107c.tar
UXP-820d6ea6a43590a9bbd9b908154f2632c290107c.tar.gz
UXP-820d6ea6a43590a9bbd9b908154f2632c290107c.tar.lz
UXP-820d6ea6a43590a9bbd9b908154f2632c290107c.tar.xz
UXP-820d6ea6a43590a9bbd9b908154f2632c290107c.zip
Add length checks for cryptographic primitives
This rollup patch adds additional length checks around cryptographic primitives.
Diffstat (limited to 'security/nss/lib/freebl/chacha20poly1305.c')
-rw-r--r--security/nss/lib/freebl/chacha20poly1305.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/security/nss/lib/freebl/chacha20poly1305.c b/security/nss/lib/freebl/chacha20poly1305.c
index 302f0db9e..8fdaf3fec 100644
--- a/security/nss/lib/freebl/chacha20poly1305.c
+++ b/security/nss/lib/freebl/chacha20poly1305.c
@@ -234,6 +234,11 @@ ChaCha20Poly1305_Open(const ChaCha20Poly1305Context *ctx, unsigned char *output,
PORT_SetError(SEC_ERROR_OUTPUT_LEN);
return SECFailure;
}
+ // ChaCha has a 64 octet block, with a 32-bit block counter.
+ if (inputLen >= (1ULL << (6 + 32)) + ctx->tagLen) {
+ PORT_SetError(SEC_ERROR_INPUT_LEN);
+ return SECFailure;
+ }
PORT_Memset(block, 0, sizeof(block));
// Generate a block of keystream. The first 32 bytes will be the poly1305