Skip to content

Commit 307befa

Browse files
committed
Rename C25519.* to ECC.*
1 parent 7647c8e commit 307befa

22 files changed

+111
-114
lines changed

attic/world/mkworld.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#include <node/Constants.hpp>
4545
#include <node/World.hpp>
46-
#include <node/C25519.hpp>
46+
#include <node/ECC.hpp>
4747
#include <node/Identity.hpp>
4848
#include <node/InetAddress.hpp>
4949
#include <osdep/OSUtils.hpp>
@@ -54,7 +54,7 @@ int main(int argc,char **argv)
5454
{
5555
std::string previous,current;
5656
if ((!OSUtils::readFile("previous.c25519",previous))||(!OSUtils::readFile("current.c25519",current))) {
57-
C25519::Pair np(C25519::generate());
57+
ECC::Pair np(ECC::generate());
5858
previous = std::string();
5959
previous.append((const char *)np.pub.data,ZT_C25519_PUBLIC_KEY_LEN);
6060
previous.append((const char *)np.priv.data,ZT_C25519_PRIVATE_KEY_LEN);
@@ -68,10 +68,10 @@ int main(int argc,char **argv)
6868
fprintf(stderr,"FATAL: previous.c25519 or current.c25519 empty or invalid" ZT_EOL_S);
6969
return 1;
7070
}
71-
C25519::Pair previousKP;
71+
ECC::Pair previousKP;
7272
memcpy(previousKP.pub.data,previous.data(),ZT_C25519_PUBLIC_KEY_LEN);
7373
memcpy(previousKP.priv.data,previous.data() + ZT_C25519_PUBLIC_KEY_LEN,ZT_C25519_PRIVATE_KEY_LEN);
74-
C25519::Pair currentKP;
74+
ECC::Pair currentKP;
7575
memcpy(currentKP.pub.data,current.data(),ZT_C25519_PUBLIC_KEY_LEN);
7676
memcpy(currentKP.priv.data,current.data() + ZT_C25519_PUBLIC_KEY_LEN,ZT_C25519_PRIVATE_KEY_LEN);
7777

ext/ed25519-amd64-asm/sign.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int crypto_sign(
6161
#endif
6262

6363
#if 0
64-
void C25519::sign(const C25519::Private &myPrivate,const C25519::Public &myPublic,const void *msg,unsigned int len,void *signature)
64+
void ECC::sign(const ECC::Private &myPrivate,const ECC::Public &myPublic,const void *msg,unsigned int len,void *signature)
6565
{
6666
sc25519 sck, scs, scsk;
6767
ge25519 ger;

node/Capability.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "Constants.hpp"
2222
#include "Credential.hpp"
2323
#include "Address.hpp"
24-
#include "C25519.hpp"
24+
#include "ECC.hpp"
2525
#include "Utils.hpp"
2626
#include "Buffer.hpp"
2727
#include "Identity.hpp"
@@ -496,7 +496,7 @@ class Capability : public Credential
496496
struct {
497497
Address to;
498498
Address from;
499-
C25519::Signature signature;
499+
ECC::Signature signature;
500500
} _custody[ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH];
501501
};
502502

node/CertificateOfMembership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/****/
1313

1414
#include "CertificateOfMembership.hpp"
15-
#include "C25519.hpp"
15+
#include "ECC.hpp"
1616
#include "RuntimeEnvironment.hpp"
1717
#include "Topology.hpp"
1818
#include "Switch.hpp"

node/CertificateOfMembership.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "Credential.hpp"
2626
#include "Buffer.hpp"
2727
#include "Address.hpp"
28-
#include "C25519.hpp"
28+
#include "ECC.hpp"
2929
#include "Identity.hpp"
3030
#include "Utils.hpp"
3131

@@ -310,7 +310,7 @@ class CertificateOfMembership : public Credential
310310
Address _signedBy;
311311
_Qualifier _qualifiers[ZT_NETWORK_COM_MAX_QUALIFIERS];
312312
unsigned int _qualifierCount;
313-
C25519::Signature _signature;
313+
ECC::Signature _signature;
314314
};
315315

316316
} // namespace ZeroTier

node/CertificateOfOwnership.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "Constants.hpp"
2323
#include "Credential.hpp"
24-
#include "C25519.hpp"
24+
#include "ECC.hpp"
2525
#include "Address.hpp"
2626
#include "Identity.hpp"
2727
#include "Buffer.hpp"
@@ -243,7 +243,7 @@ class CertificateOfOwnership : public Credential
243243
uint8_t _thingValues[ZT_CERTIFICATEOFOWNERSHIP_MAX_THINGS][ZT_CERTIFICATEOFOWNERSHIP_MAX_THING_VALUE_SIZE];
244244
Address _issuedTo;
245245
Address _signedBy;
246-
C25519::Signature _signature;
246+
ECC::Signature _signature;
247247
};
248248

249249
} // namespace ZeroTier

node/C25519.cpp renamed to node/ECC.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Derived from public domain code by D. J. Bernstein.
1212
#include <string.h>
1313

1414
#include "Constants.hpp"
15-
#include "C25519.hpp"
15+
#include "ECC.hpp"
1616
#include "SHA512.hpp"
1717
#include "Buffer.hpp"
1818
#include "Hashtable.hpp"
@@ -2508,7 +2508,7 @@ extern "C" void ed25519_amd64_asm_sign(const unsigned char *sk,const unsigned ch
25082508

25092509
namespace ZeroTier {
25102510

2511-
void C25519::agree(const C25519::Private &mine,const C25519::Public &their,void *keybuf,unsigned int keylen)
2511+
void ECC::agree(const ECC::Private &mine,const ECC::Public &their,void *keybuf,unsigned int keylen)
25122512
{
25132513
unsigned char rawkey[32];
25142514
unsigned char digest[64];
@@ -2524,7 +2524,7 @@ void C25519::agree(const C25519::Private &mine,const C25519::Public &their,void
25242524
}
25252525
}
25262526

2527-
void C25519::sign(const C25519::Private &myPrivate,const C25519::Public &myPublic,const void *msg,unsigned int len,void *signature)
2527+
void ECC::sign(const ECC::Private &myPrivate,const ECC::Public &myPublic,const void *msg,unsigned int len,void *signature)
25282528
{
25292529
unsigned char digest[64]; // we sign the first 32 bytes of SHA-512(msg)
25302530
SHA512(digest,msg,len);
@@ -2580,7 +2580,7 @@ void C25519::sign(const C25519::Private &myPrivate,const C25519::Public &myPubli
25802580
#endif
25812581
}
25822582

2583-
bool C25519::verify(const C25519::Public &their,const void *msg,unsigned int len,const void *signature)
2583+
bool ECC::verify(const ECC::Public &their,const void *msg,unsigned int len,const void *signature)
25842584
{
25852585
const unsigned char *const sig = (const unsigned char *)signature;
25862586
unsigned char digest[64]; // we sign the first 32 bytes of SHA-512(msg)
@@ -2611,14 +2611,14 @@ bool C25519::verify(const C25519::Public &their,const void *msg,unsigned int len
26112611
return Utils::secureEq(sig,t2,32);
26122612
}
26132613

2614-
void C25519::_calcPubDH(C25519::Pair &kp)
2614+
void ECC::_calcPubDH(ECC::Pair &kp)
26152615
{
26162616
// First 32 bytes of pub and priv are the keys for ECDH key
26172617
// agreement. This generates the public portion from the private.
26182618
crypto_scalarmult_base(kp.pub.data,kp.priv.data);
26192619
}
26202620

2621-
void C25519::_calcPubED(C25519::Pair &kp)
2621+
void ECC::_calcPubED(ECC::Pair &kp)
26222622
{
26232623
unsigned char extsk[64];
26242624
sc25519 scsk;

node/C25519.hpp renamed to node/ECC.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*/
1212
/****/
1313

14-
#ifndef ZT_C25519_HPP
15-
#define ZT_C25519_HPP
14+
#ifndef ZT_ECC_HPP
15+
#define ZT_ECC_HPP
1616

1717
#include "Utils.hpp"
1818

@@ -22,10 +22,7 @@ namespace ZeroTier {
2222
#define ZT_ECC_PRIVATE_KEY_SET_LEN 64
2323
#define ZT_ECC_SIGNATURE_LEN 96
2424

25-
/**
26-
* A combined Curve25519 ECDH and Ed25519 signature engine
27-
*/
28-
class C25519
25+
class ECC
2926
{
3027
public:
3128
struct Public { uint8_t data[ZT_ECC_PUBLIC_KEY_SET_LEN]; };
@@ -34,7 +31,7 @@ class C25519
3431
struct Pair { Public pub; Private priv; };
3532

3633
/**
37-
* Generate a C25519 elliptic curve key pair
34+
* Generate an elliptic curve key pair
3835
*/
3936
static inline Pair generate()
4037
{

node/Identity.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <string.h>
1717
#include <stdint.h>
1818

19-
#include "C25519.hpp"
19+
#include "ECC.hpp"
2020
#include "Constants.hpp"
2121
#include "Identity.hpp"
2222
#include "SHA512.hpp"
@@ -73,7 +73,7 @@ struct _Identity_generate_cond
7373
{
7474
_Identity_generate_cond() {}
7575
_Identity_generate_cond(unsigned char *sb,char *gm) : digest(sb),genmem(gm) {}
76-
inline bool operator()(const C25519::Pair &kp) const
76+
inline bool operator()(const ECC::Pair &kp) const
7777
{
7878
_computeMemoryHardHash(kp.pub.data,ZT_ECC_PUBLIC_KEY_SET_LEN,digest,genmem);
7979
return (digest[0] < ZT_IDENTITY_GEN_HASHCASH_FIRST_BYTE_LESS_THAN);
@@ -87,15 +87,15 @@ void Identity::generate()
8787
unsigned char digest[64];
8888
char *genmem = new char[ZT_IDENTITY_GEN_MEMORY];
8989

90-
C25519::Pair kp;
90+
ECC::Pair kp;
9191
do {
92-
kp = C25519::generateSatisfying(_Identity_generate_cond(digest,genmem));
92+
kp = ECC::generateSatisfying(_Identity_generate_cond(digest,genmem));
9393
_address.setTo(digest + 59,ZT_ADDRESS_LENGTH); // last 5 bytes are address
9494
} while (_address.isReserved());
9595

9696
_publicKey = kp.pub;
9797
if (!_privateKey) {
98-
_privateKey = new C25519::Private();
98+
_privateKey = new ECC::Private();
9999
}
100100
*_privateKey = kp.priv;
101101

@@ -157,7 +157,7 @@ bool Identity::fromString(const char *str)
157157
}
158158

159159
delete _privateKey;
160-
_privateKey = (C25519::Private *)0;
160+
_privateKey = (ECC::Private *)0;
161161

162162
int fno = 0;
163163
char *saveptr = (char *)0;
@@ -183,7 +183,7 @@ bool Identity::fromString(const char *str)
183183
}
184184
break;
185185
case 3:
186-
_privateKey = new C25519::Private();
186+
_privateKey = new ECC::Private();
187187
if (Utils::unhex(f,_privateKey->data,ZT_ECC_PRIVATE_KEY_SET_LEN) != ZT_ECC_PRIVATE_KEY_SET_LEN) {
188188
_address.zero();
189189
return false;

0 commit comments

Comments
 (0)