diff options
author | jsing <> | 2023-03-29 05:27:02 +0000 |
---|---|---|
committer | jsing <> | 2023-03-29 05:27:02 +0000 |
commit | 1d5a5e65f7e7b2e03db5d9b866ee8cc652eaa182 (patch) | |
tree | 65b0cf6de00d5a053131966323b97041d1ef4b9a /src | |
parent | f8ba5010990dd811db416b2bd3faa3de528187eb (diff) | |
download | openbsd-1d5a5e65f7e7b2e03db5d9b866ee8cc652eaa182.tar.gz openbsd-1d5a5e65f7e7b2e03db5d9b866ee8cc652eaa182.tar.bz2 openbsd-1d5a5e65f7e7b2e03db5d9b866ee8cc652eaa182.zip |
Whitespace fixes.
Mechanically replace "a,b" with "a, b", followed with some manual
indentation clean up.
No change in generated assembly.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/sha/sha512.c | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/src/lib/libcrypto/sha/sha512.c b/src/lib/libcrypto/sha/sha512.c index 5dfe61b4a5..980d50d656 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.23 2023/03/29 05:11:37 jsing Exp $ */ | 1 | /* $OpenBSD: sha512.c,v 1.24 2023/03/29 05:27:02 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 | * |
@@ -153,7 +153,7 @@ static const SHA_LONG64 K512[80] = { | |||
153 | 153 | ||
154 | #if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) | 154 | #if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) |
155 | # if defined(__x86_64) || defined(__x86_64__) | 155 | # if defined(__x86_64) || defined(__x86_64__) |
156 | # define ROTR(a,n) ({ SHA_LONG64 ret; \ | 156 | # define ROTR(a, n) ({ SHA_LONG64 ret; \ |
157 | asm ("rorq %1,%0" \ | 157 | asm ("rorq %1,%0" \ |
158 | : "=r"(ret) \ | 158 | : "=r"(ret) \ |
159 | : "J"(n),"0"(a) \ | 159 | : "J"(n),"0"(a) \ |
@@ -170,7 +170,7 @@ static const SHA_LONG64 K512[80] = { | |||
170 | : "0"(lo),"1"(hi)); \ | 170 | : "0"(lo),"1"(hi)); \ |
171 | ((SHA_LONG64)hi)<<32|lo; }) | 171 | ((SHA_LONG64)hi)<<32|lo; }) |
172 | # elif (defined(_ARCH_PPC) && defined(__64BIT__)) || defined(_ARCH_PPC64) | 172 | # elif (defined(_ARCH_PPC) && defined(__64BIT__)) || defined(_ARCH_PPC64) |
173 | # define ROTR(a,n) ({ SHA_LONG64 ret; \ | 173 | # define ROTR(a, n) ({ SHA_LONG64 ret; \ |
174 | asm ("rotrdi %0,%1,%2" \ | 174 | asm ("rotrdi %0,%1,%2" \ |
175 | : "=r"(ret) \ | 175 | : "=r"(ret) \ |
176 | : "r"(a),"K"(n)); ret; }) | 176 | : "r"(a),"K"(n)); ret; }) |
@@ -178,12 +178,12 @@ static const SHA_LONG64 K512[80] = { | |||
178 | #endif | 178 | #endif |
179 | 179 | ||
180 | #ifndef PULL64 | 180 | #ifndef PULL64 |
181 | #define B(x,j) (((SHA_LONG64)(*(((const unsigned char *)(&x))+j)))<<((7-j)*8)) | 181 | #define B(x, j) (((SHA_LONG64)(*(((const unsigned char *)(&x))+j)))<<((7-j)*8)) |
182 | #define PULL64(x) (B(x,0)|B(x,1)|B(x,2)|B(x,3)|B(x,4)|B(x,5)|B(x,6)|B(x,7)) | 182 | #define PULL64(x) (B(x,0)|B(x,1)|B(x,2)|B(x,3)|B(x,4)|B(x,5)|B(x,6)|B(x,7)) |
183 | #endif | 183 | #endif |
184 | 184 | ||
185 | #ifndef ROTR | 185 | #ifndef ROTR |
186 | #define ROTR(x,s) (((x)>>s) | (x)<<(64-s)) | 186 | #define ROTR(x, s) (((x)>>s) | (x)<<(64-s)) |
187 | #endif | 187 | #endif |
188 | 188 | ||
189 | #define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) | 189 | #define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) |
@@ -191,8 +191,8 @@ static const SHA_LONG64 K512[80] = { | |||
191 | #define sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) | 191 | #define sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) |
192 | #define sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) | 192 | #define sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) |
193 | 193 | ||
194 | #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) | 194 | #define Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) |
195 | #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) | 195 | #define Maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) |
196 | 196 | ||
197 | 197 | ||
198 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) | 198 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) |
@@ -204,8 +204,8 @@ static void | |||
204 | sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) | 204 | sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) |
205 | { | 205 | { |
206 | const SHA_LONG64 *W = in; | 206 | const SHA_LONG64 *W = in; |
207 | SHA_LONG64 A, E, T; | 207 | SHA_LONG64 A, E, T; |
208 | SHA_LONG64 X[9 + 80], *F; | 208 | SHA_LONG64 X[9 + 80], *F; |
209 | int i; | 209 | int i; |
210 | 210 | ||
211 | while (num--) { | 211 | while (num--) { |
@@ -262,8 +262,8 @@ static void | |||
262 | sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) | 262 | sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) |
263 | { | 263 | { |
264 | const SHA_LONG64 *W = in; | 264 | const SHA_LONG64 *W = in; |
265 | SHA_LONG64 a, b,c, d,e, f,g, h,s0, s1, T1, T2; | 265 | SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1, T2; |
266 | SHA_LONG64 X[16]; | 266 | SHA_LONG64 X[16]; |
267 | int i; | 267 | int i; |
268 | 268 | ||
269 | while (num--) { | 269 | while (num--) { |
@@ -329,23 +329,23 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) | |||
329 | 329 | ||
330 | #else | 330 | #else |
331 | 331 | ||
332 | #define ROUND_00_15(i,a,b,c,d,e,f,g,h) do { \ | 332 | #define ROUND_00_15(i, a, b, c, d, e, f, g, h) do { \ |
333 | T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i]; \ | 333 | T1 += h + Sigma1(e) + Ch(e, f, g) + K512[i]; \ |
334 | h = Sigma0(a) + Maj(a,b,c); \ | 334 | h = Sigma0(a) + Maj(a, b, c); \ |
335 | d += T1; h += T1; } while (0) | 335 | d += T1; h += T1; } while (0) |
336 | 336 | ||
337 | #define ROUND_16_80(i,j,a,b,c,d,e,f,g,h,X) do { \ | 337 | #define ROUND_16_80(i, j, a, b, c, d, e, f, g, h, X) do { \ |
338 | s0 = X[(j+1)&0x0f]; s0 = sigma0(s0); \ | 338 | s0 = X[(j+1)&0x0f]; s0 = sigma0(s0); \ |
339 | s1 = X[(j+14)&0x0f]; s1 = sigma1(s1); \ | 339 | s1 = X[(j+14)&0x0f]; s1 = sigma1(s1); \ |
340 | T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f]; \ | 340 | T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f]; \ |
341 | ROUND_00_15(i+j,a,b,c,d,e,f,g,h); } while (0) | 341 | ROUND_00_15(i+j, a, b, c, d, e, f, g, h); } while (0) |
342 | 342 | ||
343 | static void | 343 | static void |
344 | sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) | 344 | sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) |
345 | { | 345 | { |
346 | const SHA_LONG64 *W = in; | 346 | const SHA_LONG64 *W = in; |
347 | SHA_LONG64 a, b,c, d,e, f,g, h,s0, s1, T1; | 347 | SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1; |
348 | SHA_LONG64 X[16]; | 348 | SHA_LONG64 X[16]; |
349 | int i; | 349 | int i; |
350 | 350 | ||
351 | while (num--) { | 351 | while (num--) { |
@@ -361,89 +361,89 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) | |||
361 | 361 | ||
362 | #if BYTE_ORDER == BIG_ENDIAN | 362 | #if BYTE_ORDER == BIG_ENDIAN |
363 | T1 = X[0] = W[0]; | 363 | T1 = X[0] = W[0]; |
364 | ROUND_00_15(0, a,b, c,d, e,f, g, h); | 364 | ROUND_00_15(0, a, b, c, d, e, f, g, h); |
365 | T1 = X[1] = W[1]; | 365 | T1 = X[1] = W[1]; |
366 | ROUND_00_15(1, h,a, b,c, d,e, f, g); | 366 | ROUND_00_15(1, h, a, b, c, d, e, f, g); |
367 | T1 = X[2] = W[2]; | 367 | T1 = X[2] = W[2]; |
368 | ROUND_00_15(2, g,h, a,b, c,d, e, f); | 368 | ROUND_00_15(2, g, h, a, b, c, d, e, f); |
369 | T1 = X[3] = W[3]; | 369 | T1 = X[3] = W[3]; |
370 | ROUND_00_15(3, f,g, h,a, b,c, d, e); | 370 | ROUND_00_15(3, f, g, h, a, b, c, d, e); |
371 | T1 = X[4] = W[4]; | 371 | T1 = X[4] = W[4]; |
372 | ROUND_00_15(4, e,f, g,h, a,b, c, d); | 372 | ROUND_00_15(4, e, f, g, h, a, b, c, d); |
373 | T1 = X[5] = W[5]; | 373 | T1 = X[5] = W[5]; |
374 | ROUND_00_15(5, d,e, f,g, h,a, b, c); | 374 | ROUND_00_15(5, d, e, f, g, h, a, b, c); |
375 | T1 = X[6] = W[6]; | 375 | T1 = X[6] = W[6]; |
376 | ROUND_00_15(6, c,d, e,f, g,h, a, b); | 376 | ROUND_00_15(6, c, d, e, f, g, h, a, b); |
377 | T1 = X[7] = W[7]; | 377 | T1 = X[7] = W[7]; |
378 | ROUND_00_15(7, b,c, d,e, f,g, h, a); | 378 | ROUND_00_15(7, b, c, d, e, f, g, h, a); |
379 | T1 = X[8] = W[8]; | 379 | T1 = X[8] = W[8]; |
380 | ROUND_00_15(8, a,b, c,d, e,f, g, h); | 380 | ROUND_00_15(8, a, b, c, d, e, f, g, h); |
381 | T1 = X[9] = W[9]; | 381 | T1 = X[9] = W[9]; |
382 | ROUND_00_15(9, h,a, b,c, d,e, f, g); | 382 | ROUND_00_15(9, h, a, b, c, d, e, f, g); |
383 | T1 = X[10] = W[10]; | 383 | T1 = X[10] = W[10]; |
384 | ROUND_00_15(10, g,h, a,b, c,d, e, f); | 384 | ROUND_00_15(10, g, h, a, b, c, d, e, f); |
385 | T1 = X[11] = W[11]; | 385 | T1 = X[11] = W[11]; |
386 | ROUND_00_15(11, f,g, h,a, b,c, d, e); | 386 | ROUND_00_15(11, f, g, h, a, b, c, d, e); |
387 | T1 = X[12] = W[12]; | 387 | T1 = X[12] = W[12]; |
388 | ROUND_00_15(12, e,f, g,h, a,b, c, d); | 388 | ROUND_00_15(12, e, f, g, h, a, b, c, d); |
389 | T1 = X[13] = W[13]; | 389 | T1 = X[13] = W[13]; |
390 | ROUND_00_15(13, d,e, f,g, h,a, b, c); | 390 | ROUND_00_15(13, d, e, f, g, h, a, b, c); |
391 | T1 = X[14] = W[14]; | 391 | T1 = X[14] = W[14]; |
392 | ROUND_00_15(14, c,d, e,f, g,h, a, b); | 392 | ROUND_00_15(14, c, d, e, f, g, h, a, b); |
393 | T1 = X[15] = W[15]; | 393 | T1 = X[15] = W[15]; |
394 | ROUND_00_15(15, b,c, d,e, f,g, h, a); | 394 | ROUND_00_15(15, b, c, d, e, f, g, h, a); |
395 | #else | 395 | #else |
396 | T1 = X[0] = PULL64(W[0]); | 396 | T1 = X[0] = PULL64(W[0]); |
397 | ROUND_00_15(0, a,b, c,d, e,f, g, h); | 397 | ROUND_00_15(0, a, b, c, d, e, f, g, h); |
398 | T1 = X[1] = PULL64(W[1]); | 398 | T1 = X[1] = PULL64(W[1]); |
399 | ROUND_00_15(1, h,a, b,c, d,e, f, g); | 399 | ROUND_00_15(1, h, a, b, c, d, e, f, g); |
400 | T1 = X[2] = PULL64(W[2]); | 400 | T1 = X[2] = PULL64(W[2]); |
401 | ROUND_00_15(2, g,h, a,b, c,d, e, f); | 401 | ROUND_00_15(2, g, h, a, b, c, d, e, f); |
402 | T1 = X[3] = PULL64(W[3]); | 402 | T1 = X[3] = PULL64(W[3]); |
403 | ROUND_00_15(3, f,g, h,a, b,c, d, e); | 403 | ROUND_00_15(3, f, g, h, a, b, c, d, e); |
404 | T1 = X[4] = PULL64(W[4]); | 404 | T1 = X[4] = PULL64(W[4]); |
405 | ROUND_00_15(4, e,f, g,h, a,b, c, d); | 405 | ROUND_00_15(4, e, f, g, h, a, b, c, d); |
406 | T1 = X[5] = PULL64(W[5]); | 406 | T1 = X[5] = PULL64(W[5]); |
407 | ROUND_00_15(5, d,e, f,g, h,a, b, c); | 407 | ROUND_00_15(5, d, e, f, g, h, a, b, c); |
408 | T1 = X[6] = PULL64(W[6]); | 408 | T1 = X[6] = PULL64(W[6]); |
409 | ROUND_00_15(6, c,d, e,f, g,h, a, b); | 409 | ROUND_00_15(6, c, d, e, f, g, h, a, b); |
410 | T1 = X[7] = PULL64(W[7]); | 410 | T1 = X[7] = PULL64(W[7]); |
411 | ROUND_00_15(7, b,c, d,e, f,g, h, a); | 411 | ROUND_00_15(7, b, c, d, e, f, g, h, a); |
412 | T1 = X[8] = PULL64(W[8]); | 412 | T1 = X[8] = PULL64(W[8]); |
413 | ROUND_00_15(8, a,b, c,d, e,f, g, h); | 413 | ROUND_00_15(8, a, b, c, d, e, f, g, h); |
414 | T1 = X[9] = PULL64(W[9]); | 414 | T1 = X[9] = PULL64(W[9]); |
415 | ROUND_00_15(9, h,a, b,c, d,e, f, g); | 415 | ROUND_00_15(9, h, a, b, c, d, e, f, g); |
416 | T1 = X[10] = PULL64(W[10]); | 416 | T1 = X[10] = PULL64(W[10]); |
417 | ROUND_00_15(10, g,h, a,b, c,d, e, f); | 417 | ROUND_00_15(10, g, h, a, b, c, d, e, f); |
418 | T1 = X[11] = PULL64(W[11]); | 418 | T1 = X[11] = PULL64(W[11]); |
419 | ROUND_00_15(11, f,g, h,a, b,c, d, e); | 419 | ROUND_00_15(11, f, g, h, a, b, c, d, e); |
420 | T1 = X[12] = PULL64(W[12]); | 420 | T1 = X[12] = PULL64(W[12]); |
421 | ROUND_00_15(12, e,f, g,h, a,b, c, d); | 421 | ROUND_00_15(12, e, f, g, h, a, b, c, d); |
422 | T1 = X[13] = PULL64(W[13]); | 422 | T1 = X[13] = PULL64(W[13]); |
423 | ROUND_00_15(13, d,e, f,g, h,a, b, c); | 423 | ROUND_00_15(13, d, e, f, g, h, a, b, c); |
424 | T1 = X[14] = PULL64(W[14]); | 424 | T1 = X[14] = PULL64(W[14]); |
425 | ROUND_00_15(14, c,d, e,f, g,h, a, b); | 425 | ROUND_00_15(14, c, d, e, f, g, h, a, b); |
426 | T1 = X[15] = PULL64(W[15]); | 426 | T1 = X[15] = PULL64(W[15]); |
427 | ROUND_00_15(15, b,c, d,e, f,g, h, a); | 427 | ROUND_00_15(15, b, c, d, e, f, g, h, a); |
428 | #endif | 428 | #endif |
429 | 429 | ||
430 | for (i = 16; i < 80; i += 16) { | 430 | for (i = 16; i < 80; i += 16) { |
431 | ROUND_16_80(i, 0, a,b, c,d, e,f, g,h, X); | 431 | ROUND_16_80(i, 0, a, b, c, d, e, f, g, h, X); |
432 | ROUND_16_80(i, 1, h,a, b,c, d,e, f,g, X); | 432 | ROUND_16_80(i, 1, h, a, b, c, d, e, f, g, X); |
433 | ROUND_16_80(i, 2, g,h, a,b, c,d, e,f, X); | 433 | ROUND_16_80(i, 2, g, h, a, b, c, d, e, f, X); |
434 | ROUND_16_80(i, 3, f,g, h,a, b,c, d,e, X); | 434 | ROUND_16_80(i, 3, f, g, h, a, b, c, d, e, X); |
435 | ROUND_16_80(i, 4, e,f, g,h, a,b, c,d, X); | 435 | ROUND_16_80(i, 4, e, f, g, h, a, b, c, d, X); |
436 | ROUND_16_80(i, 5, d,e, f,g, h,a, b,c, X); | 436 | ROUND_16_80(i, 5, d, e, f, g, h, a, b, c, X); |
437 | ROUND_16_80(i, 6, c,d, e,f, g,h, a,b, X); | 437 | ROUND_16_80(i, 6, c, d, e, f, g, h, a, b, X); |
438 | ROUND_16_80(i, 7, b,c, d,e, f,g, h,a, X); | 438 | ROUND_16_80(i, 7, b, c, d, e, f, g, h, a, X); |
439 | ROUND_16_80(i, 8, a,b, c,d, e,f, g,h, X); | 439 | ROUND_16_80(i, 8, a, b, c, d, e, f, g, h, X); |
440 | ROUND_16_80(i, 9, h,a, b,c, d,e, f,g, X); | 440 | ROUND_16_80(i, 9, h, a, b, c, d, e, f, g, X); |
441 | ROUND_16_80(i, 10, g,h, a,b, c,d, e,f, X); | 441 | ROUND_16_80(i, 10, g, h, a, b, c, d, e, f, X); |
442 | ROUND_16_80(i, 11, f,g, h,a, b,c, d,e, X); | 442 | ROUND_16_80(i, 11, f, g, h, a, b, c, d, e, X); |
443 | ROUND_16_80(i, 12, e,f, g,h, a,b, c,d, X); | 443 | ROUND_16_80(i, 12, e, f, g, h, a, b, c, d, X); |
444 | ROUND_16_80(i, 13, d,e, f,g, h,a, b,c, X); | 444 | ROUND_16_80(i, 13, d, e, f, g, h, a, b, c, X); |
445 | ROUND_16_80(i, 14, c,d, e,f, g,h, a,b, X); | 445 | ROUND_16_80(i, 14, c, d, e, f, g, h, a, b, X); |
446 | ROUND_16_80(i, 15, b,c, d,e, f,g, h,a, X); | 446 | ROUND_16_80(i, 15, b, c, d, e, f, g, h, a, X); |
447 | } | 447 | } |
448 | 448 | ||
449 | ctx->h[0] += a; | 449 | ctx->h[0] += a; |