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
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
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
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
#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"
+#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 "-"
|
|
|
|
|
|
|
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 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 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 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 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-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 "-"
|