From 1278f51f1de471b6d0effabd4c615a0abea734f7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 29 Jan 2020 06:18:03 +0000 Subject: [PATCH] Remove a few completely unused functions. MD5_Simple and SHA512_Simple are superseded by the general hash_simple() in sshauxcrypt.c. The SHA-1 and SHA-256 analogues of those functions were already removed as a side effect of reorganising their source files for hardware acceleration, but the hashes I didn't rewrite managed to keep their 'Simple' APIs. mp_neg was never used in the first place. I wrote it as an obvious companion to mp_neg_into, but since I never put either of those in the header file, none of the rest of the code ever called them; and internally to mpint.c, only mp_neg_into is used out of the two. (Which makes sense, because mp_int is fundamentally an unsigned type, so mp_neg has weird semantics - it will give you not -x but 2^k-x for some not-entirely-specified k. mp_neg_into is actually more coherent, because _you_ get to control k by your choice of the target mp_int.) --- mpint.c | 7 ------- sshmd5.c | 10 ---------- sshsh512.c | 18 ------------------ 3 files changed, 35 deletions(-) diff --git a/mpint.c b/mpint.c index 8140fafe..20bc6661 100644 --- a/mpint.c +++ b/mpint.c @@ -899,13 +899,6 @@ mp_int *mp_sub(mp_int *x, mp_int *y) return r; } -mp_int *mp_neg(mp_int *a) -{ - mp_int *r = mp_make_sized(a->nw); - mp_neg_into(r, a); - return r; -} - /* * Internal routine: multiply and accumulate in the trivial O(N^2) * way. Sets r <- r + a*b. diff --git a/sshmd5.c b/sshmd5.c index dbcba3f7..79ca39e9 100644 --- a/sshmd5.c +++ b/sshmd5.c @@ -213,16 +213,6 @@ void MD5Final(unsigned char output[16], struct MD5Context *s) } } -void MD5Simple(void const *p, unsigned len, unsigned char output[16]) -{ - struct MD5Context s; - - MD5Init(&s); - put_data(&s, (unsigned char const *)p, len); - MD5Final(output, &s); - smemclr(&s, sizeof(s)); -} - /* ---------------------------------------------------------------------- * Thin abstraction for things where hashes are pluggable. */ diff --git a/sshsh512.c b/sshsh512.c index 03201d74..b5af140a 100644 --- a/sshsh512.c +++ b/sshsh512.c @@ -277,24 +277,6 @@ void SHA384_Final(SHA512_State *s, unsigned char *digest) { memcpy(digest, biggerDigest, 384 / 8); } -void SHA512_Simple(const void *p, int len, unsigned char *output) { - SHA512_State s; - - SHA512_Init(&s); - put_data(&s, p, len); - SHA512_Final(&s, output); - smemclr(&s, sizeof(s)); -} - -void SHA384_Simple(const void *p, int len, unsigned char *output) { - SHA512_State s; - - SHA384_Init(&s); - put_data(&s, p, len); - SHA384_Final(&s, output); - smemclr(&s, sizeof(s)); -} - /* * Thin abstraction for things where hashes are pluggable. */