Use header files where possible

This fixes an incorrect re-declaration of ed25519_sign.

Implement header files for some of the other library bits so that we don't need
to declare functions in crypto.cpp.
This commit is contained in:
Richard van der Hoff 2015-12-03 12:18:21 +00:00
parent 2416658443
commit 25953b350b
3 changed files with 45 additions and 38 deletions

18
lib/curve25519-donna.h Normal file
View file

@ -0,0 +1,18 @@
/* header file for the curve25519-donna implementation, because the
* authors of that project don't supply one.
*/
#ifndef CURVE25519_DONNA_H
#define CURVE25519_DONNA_H
#ifdef __cplusplus
extern "C" {
#endif
extern int curve25519_donna(unsigned char *output, const unsigned char *a,
const unsigned char *b);
#ifdef __cplusplus
}
#endif
#endif

24
lib/ed25519_additions.h Normal file
View file

@ -0,0 +1,24 @@
#ifndef ED25519_ADDITIONS_H
#define ED25519_ADDITIONS_H
#ifdef __cplusplus
extern "C" {
#endif
void convert_curve25519_to_ed25519(
unsigned char * public_key,
unsigned char * signature);
void convert_ed25519_to_curve25519(
unsigned char const * public_key,
unsigned char * signature);
void ed25519_keypair(
unsigned char * private_key,
unsigned char * public_key);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -19,49 +19,14 @@
extern "C" {
int curve25519_donna(
uint8_t * output,
const uint8_t * secret,
const uint8_t * basepoint
);
#include "crypto-algorithms/aes.h"
#include "crypto-algorithms/sha256.h"
int ed25519_sign(
unsigned char *signature,
const unsigned char *message, size_t message_len,
const unsigned char *public_key,
const unsigned char *private_key
);
int ed25519_verify(
const unsigned char *signature,
const unsigned char *message, size_t message_len,
const unsigned char *public_key
);
void convert_curve25519_to_ed25519(
unsigned char * public_key,
unsigned char * signature
);
void convert_ed25519_to_curve25519(
unsigned char const * public_key,
unsigned char * signature
);
void ed25519_keypair(
unsigned char * private_key,
unsigned char * public_key
);
}
#include "ed25519/src/ed25519.h"
#include "ed25519_additions.h"
#include "curve25519-donna.h"
namespace {