]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: move crypto_hash_sha512() to be inline in crypto_api.h, saves
authordjm@openbsd.org <djm@openbsd.org>
Thu, 30 Oct 2025 23:19:33 +0000 (23:19 +0000)
committerDamien Miller <djm@mindrot.org>
Thu, 30 Oct 2025 23:29:11 +0000 (10:29 +1100)
about 0.5kb per binary and makes life easier for portable; with/ok dtucker@

OpenBSD-Commit-ID: 672d7390f78bb6581c12661d7f5adc8a9c6be564

.depend
Makefile.in
crypto_api.h
hash.c [deleted file]

diff --git a/.depend b/.depend
index cb8c28eac558f25b67f09b79f3061acc1781f5db..1d1ec5212fa03d1741d13a3c0e657eb63f78e264 100644 (file)
--- a/.depend
+++ b/.depend
@@ -59,7 +59,6 @@ groupaccess.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-c
 gss-genr.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h
 gss-serv-krb5.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h
 gss-serv.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h
-hash.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h crypto_api.h
 hmac.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h sshbuf.h digest.h hmac.h
 hostfile.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h xmalloc.h match.h sshkey.h hostfile.h log.h ssherr.h misc.h pathnames.h digest.h hmac.h sshbuf.h
 kex-names.o: includes.h config.h defines.h platform.h openbsd-compat/openbsd-compat.h openbsd-compat/base64.h openbsd-compat/sigact.h openbsd-compat/readpassphrase.h openbsd-compat/vis.h openbsd-compat/getrrsetbyname.h openbsd-compat/sha1.h openbsd-compat/sha2.h openbsd-compat/md5.h openbsd-compat/blf.h openbsd-compat/fnmatch.h openbsd-compat/getopt.h openbsd-compat/bsd-signal.h openbsd-compat/bsd-misc.h openbsd-compat/bsd-setres_id.h openbsd-compat/bsd-statvfs.h openbsd-compat/bsd-waitpid.h openbsd-compat/bsd-poll.h openbsd-compat/fake-rfc2553.h openbsd-compat/bsd-cygwin_util.h openbsd-compat/port-aix.h openbsd-compat/port-irix.h openbsd-compat/port-linux.h openbsd-compat/port-solaris.h openbsd-compat/port-net.h openbsd-compat/port-uw.h openbsd-compat/bsd-nextstep.h entropy.h kex.h mac.h crypto_api.h log.h ssherr.h match.h digest.h misc.h xmalloc.h
index 35a6fb15e4bfcc8b72693492f329b0095d577be6..a61d4f023a914ffb7a20039a47ce3122844792ea 100644 (file)
@@ -102,7 +102,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
        smult_curve25519_ref.o \
        poly1305.o chacha.o cipher-chachapoly.o cipher-chachapoly-libcrypto.o \
        ssh-ed25519.o digest-openssl.o digest-libc.o \
-       hmac.o ed25519.o ed25519-openssl.o hash.o \
+       hmac.o ed25519.o ed25519-openssl.o \
        kex.o kex-names.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
        kexgexc.o kexgexs.o \
        kexsntrup761x25519.o kexmlkem768x25519.o sntrup761.o kexgen.o \
index 693b67bbc0e76c63ca61d5454812f900eb16e472..f5e38b547ff330aa472dd86f342dd88dbe6f570f 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto_api.h,v 1.9 2024/09/02 12:13:56 djm Exp $ */
+/* $OpenBSD: crypto_api.h,v 1.10 2025/10/30 23:19:33 djm Exp $ */
 
 /*
  * Assembled from generated headers and source files by Markus Friedl.
@@ -27,8 +27,34 @@ typedef uint64_t crypto_uint64;
 
 #define crypto_hash_sha512_BYTES 64U
 
-int    crypto_hash_sha512(unsigned char *, const unsigned char *,
-    unsigned long long);
+#ifdef WITH_OPENSSL
+#include <openssl/evp.h>
+static inline int
+crypto_hash_sha512(unsigned char *out, const unsigned char *in,
+    unsigned long long inlen)
+{
+
+       if (!EVP_Digest(in, inlen, out, NULL, EVP_sha512(), NULL))
+               return -1;
+       return 0;
+}
+#else /* WITH_OPENSSL */
+# ifdef HAVE_SHA2_H
+#  include <sha2.h>
+# endif
+static inline int
+crypto_hash_sha512(unsigned char *out, const unsigned char *in,
+    unsigned long long inlen)
+{
+
+       SHA2_CTX ctx;
+
+       SHA512Init(&ctx);
+       SHA512Update(&ctx, in, inlen);
+       SHA512Final(out, &ctx);
+       return 0;
+}
+#endif /* WITH_OPENSSL */
 
 #define crypto_sign_ed25519_SECRETKEYBYTES 64U
 #define crypto_sign_ed25519_PUBLICKEYBYTES 32U
diff --git a/hash.c b/hash.c
deleted file mode 100644 (file)
index b4f8f6c..0000000
--- a/hash.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: hash.c,v 1.6 2019/11/29 00:11:21 djm Exp $ */
-/*
- * Public domain. Author: Christian Weisgerber <naddy@openbsd.org>
- * API compatible reimplementation of function from nacl
- */
-
-#include "includes.h"
-
-#include "crypto_api.h"
-
-#include <stdarg.h>
-
-#ifdef WITH_OPENSSL
-#include <openssl/evp.h>
-
-int
-crypto_hash_sha512(unsigned char *out, const unsigned char *in,
-    unsigned long long inlen)
-{
-
-       if (!EVP_Digest(in, inlen, out, NULL, EVP_sha512(), NULL))
-               return -1;
-       return 0;
-}
-
-#else
-# ifdef HAVE_SHA2_H
-#  include <sha2.h>
-# endif
-
-int
-crypto_hash_sha512(unsigned char *out, const unsigned char *in,
-    unsigned long long inlen)
-{
-
-       SHA2_CTX ctx;
-
-       SHA512Init(&ctx);
-       SHA512Update(&ctx, in, inlen);
-       SHA512Final(out, &ctx);
-       return 0;
-}
-#endif /* WITH_OPENSSL */