update NSS as-of pm27 rev 7606140ee

This commit is contained in:
Roy Tam 2020-09-04 22:55:34 +08:00
commit 8015bb7004
24 changed files with 1005 additions and 1400 deletions

View file

@ -147,9 +147,8 @@ static SECStatus
blake2b_Begin(BLAKE2BContext* ctx, uint8_t outlen, const uint8_t* key,
size_t keylen)
{
PORT_Assert(ctx != NULL);
if (!ctx) {
goto failure;
goto failure_noclean;
}
if (outlen == 0 || outlen > BLAKE2B512_LENGTH) {
goto failure;
@ -181,6 +180,7 @@ blake2b_Begin(BLAKE2BContext* ctx, uint8_t outlen, const uint8_t* key,
failure:
PORT_Memset(ctx, 0, sizeof(*ctx));
failure_noclean:
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}
@ -218,17 +218,11 @@ SECStatus
BLAKE2B_Update(BLAKE2BContext* ctx, const unsigned char* in,
unsigned int inlen)
{
size_t left = ctx->buflen;
size_t fill = BLAKE2B_BLOCK_LENGTH - left;
/* Nothing to do if there's nothing. */
if (inlen == 0) {
return SECSuccess;
}
PORT_Assert(ctx != NULL);
PORT_Assert(in != NULL);
PORT_Assert(left <= BLAKE2B_BLOCK_LENGTH);
if (!ctx || !in) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
@ -240,6 +234,10 @@ BLAKE2B_Update(BLAKE2BContext* ctx, const unsigned char* in,
return SECFailure;
}
size_t left = ctx->buflen;
PORT_Assert(left <= BLAKE2B_BLOCK_LENGTH);
size_t fill = BLAKE2B_BLOCK_LENGTH - left;
if (inlen > fill) {
if (ctx->buflen) {
/* There's some remaining data in ctx->buf that we have to prepend