-/* $OpenBSD: sha512.c,v 1.18 2023/03/26 17:06:14 jsing Exp $ */
+/* $OpenBSD: sha512.c,v 1.19 2023/03/26 17:52:07 jsing Exp $ */
/* ====================================================================
* Copyright (c) 2004 The OpenSSL Project. All rights reserved
* according to the OpenSSL license [found in ../../LICENSE].
p[n]=0x80; /* There always is a room for one */
n++;
- if (n > (sizeof(c->u) - 16))
- memset (p + n, 0, sizeof(c->u) - n), n = 0,
- sha512_block_data_order (c, p, 1);
+ if (n > (sizeof(c->u) - 16)) {
+ memset(p + n, 0, sizeof(c->u) - n);
+ n = 0;
+ sha512_block_data_order(c, p, 1);
+ }
memset (p + n, 0, sizeof(c->u) - 16 - n);
#if BYTE_ORDER == BIG_ENDIAN
p[sizeof(c->u) - 16] = (unsigned char)(c->Nh >> 56);
#endif
- sha512_block_data_order (c, p, 1);
+ sha512_block_data_order(c, p, 1);
if (md == 0)
return 0;
size_t n = sizeof(c->u) - c->num;
if (len < n) {
- memcpy (p + c->num, data, len), c->num += (unsigned int)len;
+ memcpy(p + c->num, data, len);
+ c->num += (unsigned int)len;
return 1;
- }
- else {
- memcpy (p + c->num, data, n), c->num = 0;
- len -= n, data += n;
- sha512_block_data_order (c, p, 1);
+ } else{
+ memcpy(p + c->num, data, n);
+ c->num = 0;
+ len -= n;
+ data += n;
+ sha512_block_data_order(c, p, 1);
}
}
if (len >= sizeof(c->u)) {
#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
- if ((size_t)data % sizeof(c->u.d[0]) != 0)
- while (len >= sizeof(c->u))
- memcpy (p, data, sizeof(c->u)),
- sha512_block_data_order (c, p, 1),
- len -= sizeof(c->u),
- data += sizeof(c->u);
- else
+ if ((size_t)data % sizeof(c->u.d[0]) != 0) {
+ while (len >= sizeof(c->u)) {
+ memcpy(p, data, sizeof(c->u));
+ sha512_block_data_order(c, p, 1);
+ len -= sizeof(c->u);
+ data += sizeof(c->u);
+ }
+ } else
#endif
- sha512_block_data_order (c, data, len/sizeof(c->u)),
- data += len,
- len %= sizeof(c->u),
- data -= len;
+ {
+ sha512_block_data_order(c, data, len/sizeof(c->u));
+ data += len;
+ len %= sizeof(c->u);
+ data -= len;
+ }
}
- if (len != 0)
- memcpy (p, data, len), c->num = (int)len;
+ if (len != 0) {
+ memcpy(p, data, len);
+ c->num = (int)len;
+ }
return 1;
}