From 08d5782520453340940c3c3d711745b0dd745d9c Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sun, 13 Sep 2015 15:33:48 +0000 Subject: [PATCH] Wrap so that calls go direct and the symbols are all weak. Hide bcrypt_autorounds(), prefixing with an underbar for static builds. --- src/lib/libc/crypt/bcrypt.c | 7 +++++-- src/lib/libc/crypt/cryptutil.c | 8 +++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c index 0e6b00f1..a8c1b9e7 100644 --- a/src/lib/libc/crypt/bcrypt.c +++ b/src/lib/libc/crypt/bcrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcrypt.c,v 1.54 2015/09/13 12:42:39 millert Exp $ */ +/* $OpenBSD: bcrypt.c,v 1.55 2015/09/13 15:33:48 guenther Exp $ */ /* * Copyright (c) 2014 Ted Unangst @@ -215,6 +215,7 @@ bcrypt_newhash(const char *pass, int log_rounds, char *hash, size_t hashlen) explicit_bzero(salt, sizeof(salt)); return 0; } +DEF_WEAK(bcrypt_newhash); int bcrypt_checkpass(const char *pass, const char *goodhash) @@ -232,13 +233,14 @@ bcrypt_checkpass(const char *pass, const char *goodhash) explicit_bzero(hash, sizeof(hash)); return 0; } +DEF_WEAK(bcrypt_checkpass); /* * Measure this system's performance by measuring the time for 8 rounds. * We are aiming for something that takes around 0.1s, but not too much over. */ int -bcrypt_autorounds(void) +_bcrypt_autorounds(void) { struct timespec before, after; int r = 8; @@ -391,3 +393,4 @@ bcrypt(const char *pass, const char *salt) return gencrypted; } +DEF_WEAK(bcrypt); diff --git a/src/lib/libc/crypt/cryptutil.c b/src/lib/libc/crypt/cryptutil.c index 20d68b3f..f48ba1af 100644 --- a/src/lib/libc/crypt/cryptutil.c +++ b/src/lib/libc/crypt/cryptutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptutil.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */ +/* $OpenBSD: cryptutil.c,v 1.12 2015/09/13 15:33:48 guenther Exp $ */ /* * Copyright (c) 2014 Ted Unangst * @@ -21,8 +21,6 @@ #include #include -int bcrypt_autorounds(void); - int crypt_checkpass(const char *pass, const char *goodhash) { @@ -70,12 +68,12 @@ crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen) const char *choice = choices[i]; size_t len = strlen(choice); if (strcmp(pref, choice) == 0) { - rounds = bcrypt_autorounds(); + rounds = _bcrypt_autorounds(); break; } else if (strncmp(pref, choice, len) == 0 && pref[len] == ',') { if (strcmp(pref + len + 1, "a") == 0) { - rounds = bcrypt_autorounds(); + rounds = _bcrypt_autorounds(); } else { rounds = strtonum(pref + len + 1, 4, 31, &errstr); if (errstr) {