Hi,

I spent most of the evening reading and programming on ssh/hmac.c.  While the
stuff I tried to do didn't work, here is something I believe will make the
security better in any possible corefiles.  We conceal the contents of the
secret hmac key from being dumped.  Also an update on a comment on how to
compile the -DTEST of hmac.c:

Best Regards,
-peter

Index: hmac.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/hmac.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 hmac.c
--- hmac.c      26 Feb 2020 13:40:09 -0000      1.14
+++ hmac.c      14 Aug 2023 19:50:49 -0000
@@ -51,7 +51,7 @@ ssh_hmac_start(int alg)
            (ret->digest = ssh_digest_start(alg)) == NULL)
                goto fail;
        ret->buf_len = ssh_digest_blocksize(ret->ictx);
-       if ((ret->buf = calloc(1, ret->buf_len)) == NULL)
+       if ((ret->buf = calloc_conceal(1, ret->buf_len)) == NULL)
                goto fail;
        return ret;
 fail:
@@ -133,8 +133,12 @@ ssh_hmac_free(struct ssh_hmac_ctx *ctx)
 }
 
 #ifdef TEST
+/*
+       cc -DTEST digest-openssl.c hmac.c  cleanup.c fatal.c log.c \
+               xmalloc.c  sshbuf.c sshbuf-misc.c match.c misc.c \
+               ssherr.c addrmatch.c addr.c sshbuf-getput-basic.c -lcrypto
+ */
 
-/* cc -DTEST hmac.c digest.c buffer.c cleanup.c fatal.c log.c xmalloc.c 
-lcrypto */
 static void
 hmac_test(void *key, size_t klen, void *m, size_t mlen, u_char *e, size_t elen)
 {

-- 
Over thirty years experience on Unix-like Operating Systems starting with QNX.

Reply via email to