Navigation Menu

Skip to content

Commit

Permalink
Bug 1307472 - ChaCha20/Poly1305 should work with AAD=null r=ekr
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Taubert committed Oct 4, 2016
1 parent b087bfc commit 8f45f4c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/softoken/pkcs11c.c
Expand Up @@ -692,6 +692,9 @@ sftk_ChaCha20Poly1305_CreateContext(const unsigned char *key,

PORT_Memcpy(ctx->nonce, params->pNonce, sizeof(ctx->nonce));

/* AAD data and length must both be null, or both non-null. */
PORT_Assert((params->pAAD == NULL) == (params->ulAADLen == 0));

if (params->ulAADLen > sizeof(ctx->ad)) {
/* Need to allocate an overflow buffer for the additional data. */
ctx->adOverflow = (unsigned char *)PORT_Alloc(params->ulAADLen);
Expand All @@ -702,7 +705,9 @@ sftk_ChaCha20Poly1305_CreateContext(const unsigned char *key,
PORT_Memcpy(ctx->adOverflow, params->pAAD, params->ulAADLen);
} else {
ctx->adOverflow = NULL;
PORT_Memcpy(ctx->ad, params->pAAD, params->ulAADLen);
if (params->pAAD) {
PORT_Memcpy(ctx->ad, params->pAAD, params->ulAADLen);
}
}
ctx->adLen = params->ulAADLen;

Expand Down

0 comments on commit 8f45f4c

Please sign in to comment.