shithub: drawterm-fdroid

Download patch

ref: 9863ee8b03349ab88b5fd2cc0b0e6bc6a4cd9c1a
parent: e56902a661c4c62e04596b3c2c58e43ed8328590
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Mar 1 10:14:07 EST 2020

libsec: remove hash pickle functions

--- a/include/libsec.h
+++ b/include/libsec.h
@@ -223,6 +223,7 @@
 	SHA2_512dlen=	64,	/* SHA-512 digest length */
 	MD4dlen=	16,	/* MD4 digest length */
 	MD5dlen=	16,	/* MD5 digest length */
+	RIPEMD160dlen=	20,	/* RIPEMD-160 digest length */
 	Poly1305dlen=	16,	/* Poly1305 digest length */
 
 	Hmacblksz	= 64,	/* in bytes; from rfc2104 */
@@ -252,6 +253,7 @@
 
 DigestState*	md4(uchar*, ulong, uchar*, DigestState*);
 DigestState*	md5(uchar*, ulong, uchar*, DigestState*);
+DigestState*	ripemd160(uchar *, ulong, uchar *, DigestState *);
 DigestState*	sha1(uchar*, ulong, uchar*, DigestState*);
 DigestState*	sha2_224(uchar*, ulong, uchar*, DigestState*);
 DigestState*	sha2_256(uchar*, ulong, uchar*, DigestState*);
@@ -267,10 +269,6 @@
 DigestState*	hmac_sha2_256(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 DigestState*	hmac_sha2_384(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 DigestState*	hmac_sha2_512(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
-char*		md5pickle(MD5state*);
-MD5state*	md5unpickle(char*);
-char*		sha1pickle(SHA1state*);
-SHA1state*	sha1unpickle(char*);
 
 DigestState*	poly1305(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 
@@ -547,8 +545,6 @@
 void	secp256r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
 void	secp256k1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
 void	secp384r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
-
-DigestState*	ripemd160(uchar *, ulong, uchar *, DigestState *);
 
 /*
  * Diffie-Hellman key exchange
--- a/libsec/Makefile
+++ b/libsec/Makefile
@@ -43,7 +43,6 @@
 	hmac.$O\
 	md4.$O\
 	md5.$O\
-	md5pickle.$O\
 	nfastrand.$O\
 	pbkdf2.$O\
 	poly1305.$O\
@@ -63,7 +62,6 @@
 	secp256r1.$O\
 	secp384r1.$O\
 	sha1.$O\
-	sha1pickle.$O\
 	sha2_128.$O\
 	sha2_64.$O\
 	sha1block.$O\
--- a/libsec/md5pickle.c
+++ /dev/null
@@ -1,39 +1,0 @@
-#include "os.h"
-#include <libsec.h>
-
-char*
-md5pickle(MD5state *s)
-{
-	char *p;
-	int m, n;
-
-	m = 17+4*9+4*((s->blen+3)/3 + 1);
-	p = malloc(m);
-	if(p == nil)
-		return p;
-	n = sprint(p, "%16.16llux %8.8ux %8.8ux %8.8ux %8.8ux ",
-		s->len,
-		s->state[0], s->state[1], s->state[2],
-		s->state[3]);
-	enc64(p+n, m-n, s->buf, s->blen);
-	return p;
-}
-
-MD5state*
-md5unpickle(char *p)
-{
-	MD5state *s;
-
-	s = malloc(sizeof(*s));
-	if(s == nil)
-		return nil;
-	s->len = strtoull(p, &p, 16);
-	s->state[0] = strtoul(p, &p, 16);
-	s->state[1] = strtoul(p, &p, 16);
-	s->state[2] = strtoul(p, &p, 16);
-	s->state[3] = strtoul(p, &p, 16);
-	s->blen = dec64(s->buf, sizeof(s->buf), p, strlen(p));
-	s->malloced = 1;
-	s->seeded = 1;
-	return s;
-}
--- a/libsec/sha1pickle.c
+++ /dev/null
@@ -1,38 +1,0 @@
-#include "os.h"
-#include <libsec.h>
-
-char*
-sha1pickle(SHA1state *s)
-{
-	char *p;
-	int m, n;
-
-	m = 5*9+4*((s->blen+3)/3);
-	p = malloc(m);
-	if(p == nil)
-		return p;
-	n = sprint(p, "%8.8ux %8.8ux %8.8ux %8.8ux %8.8ux ",
-		s->state[0], s->state[1], s->state[2],
-		s->state[3], s->state[4]);
-	enc64(p+n, m-n, s->buf, s->blen);
-	return p;
-}
-
-SHA1state*
-sha1unpickle(char *p)
-{
-	SHA1state *s;
-
-	s = malloc(sizeof(*s));
-	if(s == nil)
-		return nil;
-	s->state[0] = strtoul(p, &p, 16);
-	s->state[1] = strtoul(p, &p, 16);
-	s->state[2] = strtoul(p, &p, 16);
-	s->state[3] = strtoul(p, &p, 16);
-	s->state[4] = strtoul(p, &p, 16);
-	s->blen = dec64(s->buf, sizeof(s->buf), p, strlen(p));
-	s->malloced = 1;
-	s->seeded = 1;
-	return s;
-}