From b0404dc3aed5b42933d7f9650d2a9f6e0620f34c Mon Sep 17 00:00:00 2001 From: guenther <> Date: Fri, 11 Sep 2015 09:18:27 +0000 Subject: Wrap blowfish, sha*, md5, and rmd160 so that internal calls go direct ok deraadt@ --- src/lib/libc/crypt/blowfish.c | 15 ++++++++++++++- src/lib/libc/include/namespace.h | 11 ++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'src') 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 @@ -/* $OpenBSD: blowfish.c,v 1.18 2004/11/02 17:23:26 hshoexer Exp $ */ +/* $OpenBSD: blowfish.c,v 1.19 2015/09/11 09:18:27 guenther Exp $ */ /* * Blowfish block cipher for OpenBSD * Copyright 1997 Niels Provos @@ -87,6 +87,7 @@ Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr) *xl = Xr ^ p[17]; *xr = Xl; } +DEF_WEAK(Blowfish_encipher); void 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) *xl = Xr ^ p[0]; *xr = Xl; } +DEF_WEAK(Blowfish_decipher); void Blowfish_initstate(blf_ctx *c) @@ -391,6 +393,7 @@ Blowfish_initstate(blf_ctx *c) *c = initstate; } +DEF_WEAK(Blowfish_initstate); u_int32_t 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, *current = j; return temp; } +DEF_WEAK(Blowfish_stream2word); void 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) } } } +DEF_WEAK(Blowfish_expand0state); void @@ -493,6 +498,7 @@ Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes, } } +DEF_WEAK(Blowfish_expandstate); void 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) /* Transform S-boxes and subkeys with key */ Blowfish_expand0state(c, k, len); } +DEF_WEAK(blf_key); void 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) d += 2; } } +DEF_WEAK(blf_enc); void 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) d += 2; } } +DEF_WEAK(blf_dec); void 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) data += 8; } } +DEF_WEAK(blf_ecb_encrypt); void 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) data += 8; } } +DEF_WEAK(blf_ecb_decrypt); void 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) data += 8; } } +DEF_WEAK(blf_cbc_encrypt); void 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) for (j = 0; j < 8; j++) data[j] ^= iva[j]; } +DEF_WEAK(blf_cbc_decrypt); #if 0 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 @@ -/* $OpenBSD: namespace.h,v 1.6 2015/09/10 18:13:46 guenther Exp $ */ +/* $OpenBSD: namespace.h,v 1.7 2015/09/11 09:18:27 guenther Exp $ */ #ifndef _LIBC_NAMESPACE_H_ #define _LIBC_NAMESPACE_H_ @@ -124,6 +124,12 @@ * only be needed for syscalls that have C instead of asm stubs. * Matches with PROTO_NORMAL(), PROTO_CANCEL(), or PROTO_WRAP() * ex: DEF_SYS(pread) + * + * MAKE_CLONE(dst, src) Symbols that are exact clones of other symbols + * This declares _libc_dst as being the same type as dst, and makes + * _libc_dst a strong, hidden alias for _libc_src. You still need to + * DEF_STRONG(dst) or DEF_WEAK(dst) to alias dst itself + * ex: MAKE_CLONE(SHA224Pad, SHA256Pad) */ #include /* for __dso_hidden and __{weak,strong}_alias */ @@ -146,6 +152,9 @@ #define DEF_WRAP(x) __weak_alias(x, WRAP(x)) #define DEF_SYS(x) __strong_alias(_thread_sys_##x, HIDDEN(x)) +#define MAKE_CLONE(dst, src) __dso_hidden typeof(dst) HIDDEN(dst) \ + __attribute__((alias (HIDDEN_STRING(src)))) + /* * gcc will generate calls to the functions below. -- cgit v1.2.3-55-g6feb