diff options
| author | jsing <> | 2026-05-09 07:08:43 +0000 |
|---|---|---|
| committer | jsing <> | 2026-05-09 07:08:43 +0000 |
| commit | b6077f1a28e4087c661209654a7fc1deabd9067b (patch) | |
| tree | 119083215db165e41fca1b10163dfc85194a83f9 | |
| parent | 7ddc619ceef43c35386d776c57d6979124df6da8 (diff) | |
| download | openbsd-b6077f1a28e4087c661209654a7fc1deabd9067b.tar.gz openbsd-b6077f1a28e4087c661209654a7fc1deabd9067b.tar.bz2 openbsd-b6077f1a28e4087c661209654a7fc1deabd9067b.zip | |
Use crypto_add_u32dw_u64() to increment SHA-256 message bit counter.
ok kenjiro@ tb@
| -rw-r--r-- | src/lib/libcrypto/sha/sha256.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/lib/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c index f60073bf76..f03475e86d 100644 --- a/src/lib/libcrypto/sha/sha256.c +++ b/src/lib/libcrypto/sha/sha256.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha256.c,v 1.34 2026/04/25 05:47:03 jsing Exp $ */ | 1 | /* $OpenBSD: sha256.c,v 1.35 2026/05/09 07:08:43 jsing Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -365,19 +365,13 @@ SHA256_Update(SHA256_CTX *c, const void *data_, size_t len) | |||
| 365 | { | 365 | { |
| 366 | const unsigned char *data = data_; | 366 | const unsigned char *data = data_; |
| 367 | unsigned char *p; | 367 | unsigned char *p; |
| 368 | SHA_LONG l; | ||
| 369 | size_t n; | 368 | size_t n; |
| 370 | 369 | ||
| 371 | if (len == 0) | 370 | if (len == 0) |
| 372 | return 1; | 371 | return 1; |
| 373 | 372 | ||
| 374 | l = (c->Nl + (((SHA_LONG)len) << 3)) & 0xffffffffUL; | 373 | /* Update message bit counter. */ |
| 375 | /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to | 374 | crypto_add_u32dw_u64(&c->Nh, &c->Nl, (uint64_t)len << 3); |
| 376 | * Wei Dai <weidai@eskimo.com> for pointing it out. */ | ||
| 377 | if (l < c->Nl) /* overflow */ | ||
| 378 | c->Nh++; | ||
| 379 | c->Nh += (SHA_LONG)(len >> 29); /* might cause compiler warning on 16-bit */ | ||
| 380 | c->Nl = l; | ||
| 381 | 375 | ||
| 382 | n = c->num; | 376 | n = c->num; |
| 383 | if (n != 0) { | 377 | if (n != 0) { |
