From b2bb7b41fc3b1c5f33afbbe685064ee4442efe85 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 13 Sep 2013 17:32:00 -0400 Subject: More work in progress on new crypto... --- node/C25519.hpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'node/C25519.hpp') diff --git a/node/C25519.hpp b/node/C25519.hpp index 9880035a..1260b9e1 100644 --- a/node/C25519.hpp +++ b/node/C25519.hpp @@ -32,14 +32,31 @@ namespace ZeroTier { +#define ZT_C25519_PUBLIC_KEY_LEN 64 + +#define ZT_C25519_PRIVATE_KEY_LEN 64 + +#define ZT_C25519_SIGNATURE_LEN 96 + /** * C25519 elliptic curve key agreement and signing */ class C25519 { public: - typedef Array Public; // crypto key, signing key - typedef Array Private; // crypto key, signing key (64 bytes) + /** + * Public key (both crypto and signing) + */ + typedef Array Public; // crypto key, signing key (both 32 bytes) + + /** + * Private key (both crypto and signing) + */ + typedef Array Private; // crypto key, signing key (both 32 bytes) + + /** + * Public/private key pair + */ typedef struct { Public pub; Private priv; @@ -48,7 +65,8 @@ public: /** * Generate a C25519 elliptic curve key pair */ - static Pair generate(); + static Pair generate() + throw(); /** * Perform C25519 ECC key agreement @@ -61,7 +79,14 @@ public: * @param keybuf Buffer to fill * @param keylen Number of key bytes to generate */ - static void agree(const Pair &mine,const Public &their,void *keybuf,unsigned int keylen); + static void agree(const Pair &mine,const Public &their,void *keybuf,unsigned int keylen) + throw(); + + static void sign(const Pair &mine,const void *msg,unsigned int len,void *signature) + throw(); + + static bool verify(const Public &their,const void *msg,unsigned int len,const void *signature) + throw(); }; } // namespace ZeroTier -- cgit v1.2.3