summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/sha/sha512.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/lib/libcrypto/sha/sha512.c b/src/lib/libcrypto/sha/sha512.c
index 8c78f826c8..d923a8e2af 100644
--- a/src/lib/libcrypto/sha/sha512.c
+++ b/src/lib/libcrypto/sha/sha512.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sha512.c,v 1.28 2023/04/11 10:35:21 jsing Exp $ */ 1/* $OpenBSD: sha512.c,v 1.29 2023/04/11 13:03:03 tb 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 *
@@ -546,9 +546,28 @@ SHA512_Final(unsigned char *md, SHA512_CTX *c)
546 sha512_block_data_order(c, p, 1); 546 sha512_block_data_order(c, p, 1);
547 } 547 }
548 548
549 memset(p + n, 0, sizeof(c->u) - 16 - n); 549 memset (p + n, 0, sizeof(c->u) - 16 - n);
550 c->u.d[SHA_LBLOCK - 2] = htobe64(c->Nh); 550#if BYTE_ORDER == BIG_ENDIAN
551 c->u.d[SHA_LBLOCK - 1] = htobe64(c->Nl); 551 c->u.d[SHA_LBLOCK - 2] = c->Nh;
552 c->u.d[SHA_LBLOCK - 1] = c->Nl;
553#else
554 p[sizeof(c->u) - 1] = (unsigned char)(c->Nl);
555 p[sizeof(c->u) - 2] = (unsigned char)(c->Nl >> 8);
556 p[sizeof(c->u) - 3] = (unsigned char)(c->Nl >> 16);
557 p[sizeof(c->u) - 4] = (unsigned char)(c->Nl >> 24);
558 p[sizeof(c->u) - 5] = (unsigned char)(c->Nl >> 32);
559 p[sizeof(c->u) - 6] = (unsigned char)(c->Nl >> 40);
560 p[sizeof(c->u) - 7] = (unsigned char)(c->Nl >> 48);
561 p[sizeof(c->u) - 8] = (unsigned char)(c->Nl >> 56);
562 p[sizeof(c->u) - 9] = (unsigned char)(c->Nh);
563 p[sizeof(c->u) - 10] = (unsigned char)(c->Nh >> 8);
564 p[sizeof(c->u) - 11] = (unsigned char)(c->Nh >> 16);
565 p[sizeof(c->u) - 12] = (unsigned char)(c->Nh >> 24);
566 p[sizeof(c->u) - 13] = (unsigned char)(c->Nh >> 32);
567 p[sizeof(c->u) - 14] = (unsigned char)(c->Nh >> 40);
568 p[sizeof(c->u) - 15] = (unsigned char)(c->Nh >> 48);
569 p[sizeof(c->u) - 16] = (unsigned char)(c->Nh >> 56);
570#endif
552 571
553 sha512_block_data_order(c, p, 1); 572 sha512_block_data_order(c, p, 1);
554 573