tweetnacl-ed25519blake2b.diff at [5caf8fe3fd]

File build/tweetnacl/patches/tweetnacl-ed25519blake2b.diff artifact df305f7e81 part of check-in 5caf8fe3fd


--- 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.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 "-"