Check-in [1f76e42a02]
Overview
Comment:Restructuring to get rid of SUPERCOP reference, it is incorrect
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1f76e42a02a1d7f7ea0b01ada2b5f3f8070a113a6e2d0a19b5d11cf123aa0d8a
User & Date: rkeene on 2018-07-02 06:41:42
Other Links: manifest | tags
Context
2018-07-02
07:20
Moved our patchwork to its own internal directories in preparation for a release cleanup check-in: 4168b04669 user: rkeene tags: trunk
06:41
Restructuring to get rid of SUPERCOP reference, it is incorrect check-in: 1f76e42a02 user: rkeene tags: trunk
06:22
Added some whitespace for readability check-in: de6758280f user: rkeene tags: trunk
Changes

Modified .fossil-settings/ignore-glob from [003b6d91a2] to [bac52d47ba].

8
9
10
11
12
13
14

15
16
17
8
9
10
11
12
13
14
15
16
17
18







+



config.guess
config.sub
configure
install-sh
config.log
config.status
blake2b/blake2b.o
blake2b/blake2b-ref-nacl.c
tweetnacl/tweetnacl.c
tweetnacl/tweetnacl.h
tweetnacl/tweetnacl.o

Modified Makefile.in from [86dc23739a] to [995ac69c25].

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







CC            := @CC@
CFLAGS        := @CFLAGS@ @SHOBJFLAGS@
CPPFLAGS      := -I. -I@srcdir@/tweetnacl/ -I@srcdir@/blake2b/ -DSUPERCOP=1 @CPPFLAGS@ @SHOBJCPPFLAGS@ @DEFS@
CPPFLAGS      := -I. -I@srcdir@/tweetnacl/ -I@srcdir@/blake2b/ -DNACL_ED25519_BLAKE2B=1 @CPPFLAGS@ @SHOBJCPPFLAGS@ @DEFS@
LDFLAGS       := @LDFLAGS@
LIBS          := @LIBS@
SHOBJLDFLAGS  := @SHOBJLDFLAGS@
srcdir        := @srcdir@
export CC CFLAGS CPPFLAGS
@SET_MAKE@

Modified blake2b/Makefile from [9845ac7671] to [b148d945c1].

1
2


3




4

5
6
7
8
9


1
2
3
4
5
6
7
8
9
10
11
12
13
14
-
-
+
+

+
+
+
+

+





blake2b.o: blake2b-ref.c blake2-impl.h blake2.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -DSUPERCOP=1 -o blake2b.o -c blake2b-ref.c
blake2b.o: blake2b-ref-nacl.c blake2-impl.h blake2.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o blake2b.o -c blake2b-ref-nacl.c

blake2b-ref-nacl.c: blake2b-ref.c blake2-nacl.c
	rm -f blake2b-ref-nacl.c
	cat blake2b-ref.c blake2-nacl.c > blake2b-ref-nacl.c

clean:
	rm -f blake2b-ref-nacl.c
	rm -f blake2b.o

distclean: clean

.PHONY: clean distclean

Added blake2b/blake2-nacl.c version [dc9825f995].







1
2
3
4
5
6
+
+
+
+
+
+
#if defined(NACL_ED25519_BLAKE2B)
int crypto_hash_blake2b( unsigned char *out, unsigned char *in, unsigned long long inlen )
{
  return blake2b( out, BLAKE2B_OUTBYTES, in, inlen, NULL, 0 );
}
#endif

Renamed and modified blake2b/blake2-supercop.h [0657242b46] to blake2b/blake2-nacl.h [8986e1e5b4].

1
2
3
4
5
6

7
8

1
2
3
4
5

6
7
8
9





-
+


+
#define crypto_hash_PRIMITIVE "blake2b"
#define crypto_hash_BYTES crypto_hash_blake2b_BYTES
#define crypto_hash_IMPLEMENTATION crypto_hash_blake2b_IMPLEMENTATION
#define crypto_hash_VERSION crypto_hash_blake2b_VERSION
#define crypto_hash_blake2b_BYTES 64
extern int crypto_hash(unsigned char *,const unsigned char *,unsigned long long);
extern int crypto_hash_blake2b(unsigned char *,const unsigned char *,unsigned long long);
#define crypto_hash_blake2b_VERSION "-"
#define crypto_hash_blake2b_IMPLEMENTATION "blake2b-ref"
#define crypto_hash crypto_hash_blake2b

Modified nano.c from [f4f5005da0] to [1242d36c58].

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16








-
+







#include <stdint.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <tcl.h>

#include "tweetnacl.h"
#include "blake2-supercop.h"
#include "blake2-nacl.h"

#define NANO_SECRET_KEY_LENGTH (crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES)
#define NANO_PUBLIC_KEY_LENGTH (crypto_sign_PUBLICKEYBYTES)
#define TclNano_AttemptAlloc(x) ((void *) Tcl_AttemptAlloc(x))
#define TclNano_Free(x) Tcl_Free((char *) x)

#if defined(HAVE_GETRANDOM)

Modified tweetnacl/Makefile from [b9469f5858] to [9e180a9dbc].

1
2
3
4
5
6
7
8
9
10
11

12
13

14
15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
1
2
3
4
5
6
7
8
9
10

11
12

13
14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
29










-
+

-
+








-
+







all: tweetnacl.o

tweetnacl.h.new: src/tweetnacl.h
	rm -f tweetnacl.h.new tweetnacl.h
	cp src/tweetnacl.h tweetnacl.h.new

tweetnacl.c.new: src/tweetnacl.c
	rm -f tweetnacl.c.new tweetnacl.c
	cp src/tweetnacl.c tweetnacl.c.new

tweetnacl.c: tweetnacl.c.new tweetnacl.h.new patches/tweetnacl-supercop.diff patches/tweetnacl-derivepubkey.diff
tweetnacl.c: tweetnacl.c.new tweetnacl.h.new patches/tweetnacl-ed25519blake2b.diff patches/tweetnacl-derivepubkey.diff
	rm -f tweetnacl.c tweetnacl.h
	patch -p1 < patches/tweetnacl-supercop.diff || ( rm -f tweetnacl.c.new tweetnacl.h.new; exit 1 )
	patch -p1 < patches/tweetnacl-ed25519blake2b.diff || ( rm -f tweetnacl.c.new tweetnacl.h.new; exit 1 )
	patch -p1 < patches/tweetnacl-derivepubkey.diff || ( rm -f tweetnacl.c.new tweetnacl.h.new; exit 1 )
	rm -f tweetnacl.c.new.orig tweetnacl.h.new.orig
	mv tweetnacl.h.new tweetnacl.h
	mv tweetnacl.c.new tweetnacl.c

tweetnacl.h: tweetnacl.c

tweetnacl.o: tweetnacl.c tweetnacl.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -DSUPERCOP=1 -I../blake2b/ -o tweetnacl.o -c tweetnacl.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -I../blake2b/ -o tweetnacl.o -c tweetnacl.c

clean:
	rm -f tweetnacl.c.new.orig tweetnacl.h.new.orig
	rm -f tweetnacl.h.new tweetnacl.h
	rm -f tweetnacl.c.new tweetnacl.c
	rm -f tweetnacl.o

Renamed and modified tweetnacl/patches/tweetnacl-supercop.diff [822aac2959] to tweetnacl/patches/tweetnacl-ed25519blake2b.diff [5d9e8c11d3].

1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61

62
63
64
65
1
2
3
4
5
6

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60

61
62
63
64
65






-
+














-
+













-
+

















-
+






-
+




--- a/tweetnacl.c.new
+++ b/tweetnacl.c.new
@@ -32,12 +32,14 @@
   return (u<<8)|x[0];
 }
 
+#ifndef SUPERCOP
+#ifndef NACL_ED25519_BLAKE2B
 static u64 dl64(const u8 *x)
 {
   u64 i,u=0;
   FOR(i,8) u=(u<<8)|x[i];
   return u;
 }
+#endif
 
 sv st32(u8 *x,u32 u)
 {
@@ -45,11 +47,13 @@
   FOR(i,4) { x[i] = u; u >>= 8; }
 }
 
+#ifndef SUPERCOP
+#ifndef NACL_ED25519_BLAKE2B
 sv ts64(u8 *x,u64 u)
 {
   int i;
   for (i = 7;i >= 0;--i) { x[i] = u; u >>= 8; }
 }
+#endif
 
 static int vn(const u8 *x,const u8 *y,int n)
 {
@@ -484,6 +488,7 @@
   return crypto_box_open_afternm(m,c,d,n,k);
 }
 
+#ifndef SUPERCOP
+#ifndef NACL_ED25519_BLAKE2B
 static u64 R(u64 x,int c) { return (x >> c) | (x << (64 - c)); }
 static u64 Ch(u64 x,u64 y,u64 z) { return (x & y) ^ (~x & z); }
 static u64 Maj(u64 x,u64 y,u64 z) { return (x & y) ^ (x & z) ^ (y & z); }
@@ -584,6 +589,7 @@
 
   return 0;
 }
+#endif
 
 sv add(gf p[4],gf q[4])
 {
--- a/tweetnacl.h.new
+++ b/tweetnacl.h.new
@@ -118,11 +118,15 @@
 #define crypto_hashblocks_sha256_BLOCKBYTES crypto_hashblocks_sha256_tweet_BLOCKBYTES
 #define crypto_hashblocks_sha256_VERSION crypto_hashblocks_sha256_tweet_VERSION
 #define crypto_hashblocks_sha256_IMPLEMENTATION "crypto_hashblocks/sha256/tweet"
+#ifndef SUPERCOP
+#ifndef NACL_ED25519_BLAKE2B
 #define crypto_hash_PRIMITIVE "sha512"
 #define crypto_hash crypto_hash_sha512
 #define crypto_hash_BYTES crypto_hash_sha512_BYTES
 #define crypto_hash_IMPLEMENTATION crypto_hash_sha512_IMPLEMENTATION
 #define crypto_hash_VERSION crypto_hash_sha512_VERSION
+#else
+#include "blake2-supercop.h"
+#include "blake2-nacl.h"
+#endif
 #define crypto_hash_sha512_tweet_BYTES 64
 extern int crypto_hash_sha512_tweet(unsigned char *,const unsigned char *,unsigned long long);
 #define crypto_hash_sha512_tweet_VERSION "-"