diff options
author | guenther <> | 2015-09-11 09:18:27 +0000 |
---|---|---|
committer | guenther <> | 2015-09-11 09:18:27 +0000 |
commit | b0404dc3aed5b42933d7f9650d2a9f6e0620f34c (patch) | |
tree | 54b7815c87b1e17a76f16279310a2867b9a1ef00 | |
parent | c041f863310ba8ab2a1bce7605887f1deff68a38 (diff) | |
download | openbsd-b0404dc3aed5b42933d7f9650d2a9f6e0620f34c.tar.gz openbsd-b0404dc3aed5b42933d7f9650d2a9f6e0620f34c.tar.bz2 openbsd-b0404dc3aed5b42933d7f9650d2a9f6e0620f34c.zip |
Wrap blowfish, sha*, md5, and rmd160 so that internal calls go direct
ok deraadt@
-rw-r--r-- | src/lib/libc/crypt/blowfish.c | 15 | ||||
-rw-r--r-- | src/lib/libc/include/namespace.h | 11 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/lib/libc/crypt/blowfish.c b/src/lib/libc/crypt/blowfish.c index c337df8a0a..a658e602d2 100644 --- a/src/lib/libc/crypt/blowfish.c +++ b/src/lib/libc/crypt/blowfish.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: blowfish.c,v 1.18 2004/11/02 17:23:26 hshoexer Exp $ */ | 1 | /* $OpenBSD: blowfish.c,v 1.19 2015/09/11 09:18:27 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * Blowfish block cipher for OpenBSD | 3 | * Blowfish block cipher for OpenBSD |
4 | * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> | 4 | * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> |
@@ -87,6 +87,7 @@ Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr) | |||
87 | *xl = Xr ^ p[17]; | 87 | *xl = Xr ^ p[17]; |
88 | *xr = Xl; | 88 | *xr = Xl; |
89 | } | 89 | } |
90 | DEF_WEAK(Blowfish_encipher); | ||
90 | 91 | ||
91 | void | 92 | void |
92 | Blowfish_decipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr) | 93 | Blowfish_decipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr) |
@@ -112,6 +113,7 @@ Blowfish_decipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr) | |||
112 | *xl = Xr ^ p[0]; | 113 | *xl = Xr ^ p[0]; |
113 | *xr = Xl; | 114 | *xr = Xl; |
114 | } | 115 | } |
116 | DEF_WEAK(Blowfish_decipher); | ||
115 | 117 | ||
116 | void | 118 | void |
117 | Blowfish_initstate(blf_ctx *c) | 119 | Blowfish_initstate(blf_ctx *c) |
@@ -391,6 +393,7 @@ Blowfish_initstate(blf_ctx *c) | |||
391 | 393 | ||
392 | *c = initstate; | 394 | *c = initstate; |
393 | } | 395 | } |
396 | DEF_WEAK(Blowfish_initstate); | ||
394 | 397 | ||
395 | u_int32_t | 398 | u_int32_t |
396 | Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, | 399 | Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, |
@@ -412,6 +415,7 @@ Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, | |||
412 | *current = j; | 415 | *current = j; |
413 | return temp; | 416 | return temp; |
414 | } | 417 | } |
418 | DEF_WEAK(Blowfish_stream2word); | ||
415 | 419 | ||
416 | void | 420 | void |
417 | Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes) | 421 | Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes) |
@@ -449,6 +453,7 @@ Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes) | |||
449 | } | 453 | } |
450 | } | 454 | } |
451 | } | 455 | } |
456 | DEF_WEAK(Blowfish_expand0state); | ||
452 | 457 | ||
453 | 458 | ||
454 | void | 459 | void |
@@ -493,6 +498,7 @@ Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes, | |||
493 | } | 498 | } |
494 | 499 | ||
495 | } | 500 | } |
501 | DEF_WEAK(Blowfish_expandstate); | ||
496 | 502 | ||
497 | void | 503 | void |
498 | blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len) | 504 | blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len) |
@@ -503,6 +509,7 @@ blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len) | |||
503 | /* Transform S-boxes and subkeys with key */ | 509 | /* Transform S-boxes and subkeys with key */ |
504 | Blowfish_expand0state(c, k, len); | 510 | Blowfish_expand0state(c, k, len); |
505 | } | 511 | } |
512 | DEF_WEAK(blf_key); | ||
506 | 513 | ||
507 | void | 514 | void |
508 | blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks) | 515 | blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks) |
@@ -516,6 +523,7 @@ blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks) | |||
516 | d += 2; | 523 | d += 2; |
517 | } | 524 | } |
518 | } | 525 | } |
526 | DEF_WEAK(blf_enc); | ||
519 | 527 | ||
520 | void | 528 | void |
521 | blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks) | 529 | blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks) |
@@ -529,6 +537,7 @@ blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks) | |||
529 | d += 2; | 537 | d += 2; |
530 | } | 538 | } |
531 | } | 539 | } |
540 | DEF_WEAK(blf_dec); | ||
532 | 541 | ||
533 | void | 542 | void |
534 | blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) | 543 | blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) |
@@ -551,6 +560,7 @@ blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) | |||
551 | data += 8; | 560 | data += 8; |
552 | } | 561 | } |
553 | } | 562 | } |
563 | DEF_WEAK(blf_ecb_encrypt); | ||
554 | 564 | ||
555 | void | 565 | void |
556 | blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) | 566 | blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) |
@@ -573,6 +583,7 @@ blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) | |||
573 | data += 8; | 583 | data += 8; |
574 | } | 584 | } |
575 | } | 585 | } |
586 | DEF_WEAK(blf_ecb_decrypt); | ||
576 | 587 | ||
577 | void | 588 | void |
578 | blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len) | 589 | blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len) |
@@ -598,6 +609,7 @@ blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len) | |||
598 | data += 8; | 609 | data += 8; |
599 | } | 610 | } |
600 | } | 611 | } |
612 | DEF_WEAK(blf_cbc_encrypt); | ||
601 | 613 | ||
602 | void | 614 | void |
603 | blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len) | 615 | blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len) |
@@ -639,6 +651,7 @@ blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len) | |||
639 | for (j = 0; j < 8; j++) | 651 | for (j = 0; j < 8; j++) |
640 | data[j] ^= iva[j]; | 652 | data[j] ^= iva[j]; |
641 | } | 653 | } |
654 | DEF_WEAK(blf_cbc_decrypt); | ||
642 | 655 | ||
643 | #if 0 | 656 | #if 0 |
644 | void | 657 | void |
diff --git a/src/lib/libc/include/namespace.h b/src/lib/libc/include/namespace.h index c8c864a266..cfdb95ad02 100644 --- a/src/lib/libc/include/namespace.h +++ b/src/lib/libc/include/namespace.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: namespace.h,v 1.6 2015/09/10 18:13:46 guenther Exp $ */ | 1 | /* $OpenBSD: namespace.h,v 1.7 2015/09/11 09:18:27 guenther Exp $ */ |
2 | 2 | ||
3 | #ifndef _LIBC_NAMESPACE_H_ | 3 | #ifndef _LIBC_NAMESPACE_H_ |
4 | #define _LIBC_NAMESPACE_H_ | 4 | #define _LIBC_NAMESPACE_H_ |
@@ -124,6 +124,12 @@ | |||
124 | * only be needed for syscalls that have C instead of asm stubs. | 124 | * only be needed for syscalls that have C instead of asm stubs. |
125 | * Matches with PROTO_NORMAL(), PROTO_CANCEL(), or PROTO_WRAP() | 125 | * Matches with PROTO_NORMAL(), PROTO_CANCEL(), or PROTO_WRAP() |
126 | * ex: DEF_SYS(pread) | 126 | * ex: DEF_SYS(pread) |
127 | * | ||
128 | * MAKE_CLONE(dst, src) Symbols that are exact clones of other symbols | ||
129 | * This declares _libc_dst as being the same type as dst, and makes | ||
130 | * _libc_dst a strong, hidden alias for _libc_src. You still need to | ||
131 | * DEF_STRONG(dst) or DEF_WEAK(dst) to alias dst itself | ||
132 | * ex: MAKE_CLONE(SHA224Pad, SHA256Pad) | ||
127 | */ | 133 | */ |
128 | 134 | ||
129 | #include <sys/cdefs.h> /* for __dso_hidden and __{weak,strong}_alias */ | 135 | #include <sys/cdefs.h> /* for __dso_hidden and __{weak,strong}_alias */ |
@@ -146,6 +152,9 @@ | |||
146 | #define DEF_WRAP(x) __weak_alias(x, WRAP(x)) | 152 | #define DEF_WRAP(x) __weak_alias(x, WRAP(x)) |
147 | #define DEF_SYS(x) __strong_alias(_thread_sys_##x, HIDDEN(x)) | 153 | #define DEF_SYS(x) __strong_alias(_thread_sys_##x, HIDDEN(x)) |
148 | 154 | ||
155 | #define MAKE_CLONE(dst, src) __dso_hidden typeof(dst) HIDDEN(dst) \ | ||
156 | __attribute__((alias (HIDDEN_STRING(src)))) | ||
157 | |||
149 | 158 | ||
150 | /* | 159 | /* |
151 | * gcc will generate calls to the functions below. | 160 | * gcc will generate calls to the functions below. |