Revert "re-factor size checks in blake2 implementations"

This reverts commit af38b1830e.
This commit is contained in:
Steffen Jaeckel 2017-06-27 12:33:40 +02:00
parent af38b1830e
commit 1a3880fda5
2 changed files with 4 additions and 4 deletions

View File

@ -333,14 +333,14 @@ int blake2b_process(hash_state *md, const unsigned char *in, unsigned long inlen
LTC_ARGCHK(md != NULL); LTC_ARGCHK(md != NULL);
LTC_ARGCHK(in != NULL); LTC_ARGCHK(in != NULL);
if (md->blake2b.curlen >= sizeof(md->blake2b.buf)) { if (md->blake2b.curlen > sizeof(md->blake2b.buf)) {
return CRYPT_INVALID_ARG; return CRYPT_INVALID_ARG;
} }
if (inlen > 0) { if (inlen > 0) {
unsigned long left = md->blake2b.curlen; unsigned long left = md->blake2b.curlen;
unsigned long fill = BLAKE2B_BLOCKBYTES - left; unsigned long fill = BLAKE2B_BLOCKBYTES - left;
if (inlen >= fill) { if (inlen > fill) {
md->blake2b.curlen = 0; md->blake2b.curlen = 0;
XMEMCPY(md->blake2b.buf + left, in, fill); /* Fill buffer */ XMEMCPY(md->blake2b.buf + left, in, fill); /* Fill buffer */
blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES); blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);

View File

@ -321,14 +321,14 @@ int blake2s_process(hash_state *md, const unsigned char *in, unsigned long inlen
LTC_ARGCHK(md != NULL); LTC_ARGCHK(md != NULL);
LTC_ARGCHK(in != NULL); LTC_ARGCHK(in != NULL);
if (md->blake2s.curlen >= sizeof(md->blake2s.buf)) { if (md->blake2s.curlen > sizeof(md->blake2s.buf)) {
return CRYPT_INVALID_ARG; return CRYPT_INVALID_ARG;
} }
if (inlen > 0) { if (inlen > 0) {
unsigned long left = md->blake2s.curlen; unsigned long left = md->blake2s.curlen;
unsigned long fill = BLAKE2S_BLOCKBYTES - left; unsigned long fill = BLAKE2S_BLOCKBYTES - left;
if (inlen >= fill) { if (inlen > fill) {
md->blake2s.curlen = 0; md->blake2s.curlen = 0;
XMEMCPY(md->blake2s.buf + left, in, fill); /* Fill buffer */ XMEMCPY(md->blake2s.buf + left, in, fill); /* Fill buffer */
blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES); blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES);