changeset 1707:41a0ff8d5a89

void return types for curve25519
author Matt Johnston <matt@ucc.asn.au>
date Sat, 30 May 2020 00:05:49 +0800
parents 3f80da5fe0b4
children 58f7ca8ebc82
files curve25519.c curve25519.h ed25519.c
diffstat 3 files changed, 9 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/curve25519.c	Fri May 29 23:32:19 2020 +0800
+++ b/curve25519.c	Sat May 30 00:05:49 2020 +0800
@@ -208,7 +208,7 @@
 #endif /* DROPBEAR_ED25519 && DROPBEAR_SIGNKEY_VERIFY */
 
 #if DROPBEAR_CURVE25519
-int dropbear_curve25519_scalarmult(u8 *q,const u8 *n,const u8 *p)
+void dropbear_curve25519_scalarmult(u8 *q,const u8 *n,const u8 *p)
 {
   u8 z[32];
   i64 x[80],r,i;
@@ -256,7 +256,6 @@
   inv25519(x+32,x+32);
   M(x+16,x+16,x+32);
   pack25519(q,x+16);
-  return 0;
 }
 #endif /* DROPBEAR_CURVE25519 */
 
@@ -338,7 +337,7 @@
   scalarmult(p,q,s);
 }
 
-int dropbear_ed25519_make_key(u8 *pk,u8 *sk)
+void dropbear_ed25519_make_key(u8 *pk,u8 *sk)
 {
   u8 d[64];
   gf p[4];
@@ -352,8 +351,6 @@
 
   scalarbase(p,d);
   pack(pk,p);
-
-  return 0;
 }
 
 static const u64 L[32] = {0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10};
@@ -392,7 +389,7 @@
   modL(r,x);
 }
 
-int dropbear_ed25519_sign(const u8 *m,u32 mlen,u8 *s,u32 *slen,const u8 *sk, const u8 *pk)
+void dropbear_ed25519_sign(const u8 *m,u32 mlen,u8 *s,u32 *slen,const u8 *sk, const u8 *pk)
 {
   hash_state hs;
   u8 d[64],h[64],r[64];
@@ -426,8 +423,6 @@
   FOR(i,32) x[i] = (u64) r[i];
   FOR(i,32) FOR(j,32) x[i+j] += h[i] * (u64) d[j];
   modL(s + 32,x);
-
-  return 0;
 }
 
 #if DROPBEAR_SIGNKEY_VERIFY
--- a/curve25519.h	Fri May 29 23:32:19 2020 +0800
+++ b/curve25519.h	Sat May 30 00:05:49 2020 +0800
@@ -25,9 +25,9 @@
 #ifndef DROPBEAR_CURVE25519_H
 #define DROPBEAR_CURVE25519_H
 
-int dropbear_curve25519_scalarmult(unsigned char *q, const unsigned char *n, const unsigned char *p);
-int dropbear_ed25519_make_key(unsigned char *pk, unsigned char  *sk);
-int dropbear_ed25519_sign(const unsigned char *m, unsigned long mlen,
+void dropbear_curve25519_scalarmult(unsigned char *q, const unsigned char *n, const unsigned char *p);
+void dropbear_ed25519_make_key(unsigned char *pk, unsigned char  *sk);
+void dropbear_ed25519_sign(const unsigned char *m, unsigned long mlen,
 			  unsigned char *s, unsigned long *slen,
 			  const unsigned char *sk, const unsigned char *pk);
 int dropbear_ed25519_verify(const unsigned char *m, unsigned long mlen,
--- a/ed25519.c	Fri May 29 23:32:19 2020 +0800
+++ b/ed25519.c	Sat May 30 00:05:49 2020 +0800
@@ -139,11 +139,9 @@
 	TRACE(("enter buf_put_ed25519_sign"))
 	dropbear_assert(key != NULL);
 
-	if (dropbear_ed25519_sign(data_buf->data, data_buf->len,
-				  s, &slen, key->priv, key->pub) == 0) {
-		buf_putstring(buf, SSH_SIGNKEY_ED25519, SSH_SIGNKEY_ED25519_LEN);
-		buf_putstring(buf, s, slen);
-	}
+	dropbear_ed25519_sign(data_buf->data, data_buf->len, s, &slen, key->priv, key->pub);
+	buf_putstring(buf, SSH_SIGNKEY_ED25519, SSH_SIGNKEY_ED25519_LEN);
+	buf_putstring(buf, s, slen);
 
 	TRACE(("leave buf_put_ed25519_sign"))
 }