changes
This commit is contained in:
parent
3aad2934a3
commit
7da894b006
@ -1,12 +0,0 @@
|
|||||||
#ifndef crypto_sign_edwards25519sha512batch_H
|
|
||||||
#define crypto_sign_edwards25519sha512batch_H
|
|
||||||
|
|
||||||
#define SECRETKEYBYTES 64
|
|
||||||
#define PUBLICKEYBYTES 32
|
|
||||||
#define SIGNATUREBYTES 64
|
|
||||||
|
|
||||||
extern int crypto_sign(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
|
|
||||||
extern int crypto_sign_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
|
|
||||||
extern int crypto_sign_keypair(unsigned char *,unsigned char *,unsigned char *);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,8 +1,8 @@
|
|||||||
#include "crypto_sign.h"
|
#include "ed25519.h"
|
||||||
#include "sha512.h"
|
#include "sha512.h"
|
||||||
#include "ge.h"
|
#include "ge.h"
|
||||||
|
|
||||||
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk, unsigned char *seed)
|
int ed25519_sign_keypair(unsigned char *pk, unsigned char *sk, unsigned char *seed)
|
||||||
{
|
{
|
||||||
unsigned char h[64];
|
unsigned char h[64];
|
||||||
ge_p3 A;
|
ge_p3 A;
|
||||||
@ -18,5 +18,6 @@ int crypto_sign_keypair(unsigned char *pk, unsigned char *sk, unsigned char *see
|
|||||||
|
|
||||||
for (i = 0;i < 32;++i) sk[i] = seed[i];
|
for (i = 0;i < 32;++i) sk[i] = seed[i];
|
||||||
for (i = 0;i < 32;++i) sk[32 + i] = pk[i];
|
for (i = 0;i < 32;++i) sk[32 + i] = pk[i];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
4
open.c
4
open.c
@ -1,9 +1,9 @@
|
|||||||
#include "crypto_sign.h"
|
#include "ed25519.h"
|
||||||
#include "sha512.h"
|
#include "sha512.h"
|
||||||
#include "ge.h"
|
#include "ge.h"
|
||||||
#include "sc.h"
|
#include "sc.h"
|
||||||
|
|
||||||
int crypto_sign_open(
|
int ed25519_sign_open(
|
||||||
unsigned char *m,unsigned long long *mlen,
|
unsigned char *m,unsigned long long *mlen,
|
||||||
const unsigned char *sm,unsigned long long smlen,
|
const unsigned char *sm,unsigned long long smlen,
|
||||||
const unsigned char *pk
|
const unsigned char *pk
|
||||||
|
4
sign.c
4
sign.c
@ -1,9 +1,9 @@
|
|||||||
#include "crypto_sign.h"
|
#include "ed25519.h"
|
||||||
#include "sha512.h"
|
#include "sha512.h"
|
||||||
#include "ge.h"
|
#include "ge.h"
|
||||||
#include "sc.h"
|
#include "sc.h"
|
||||||
|
|
||||||
int crypto_sign(
|
int ed25519_sign(
|
||||||
unsigned char *sm,unsigned long long *smlen,
|
unsigned char *sm,unsigned long long *smlen,
|
||||||
const unsigned char *m,unsigned long long mlen,
|
const unsigned char *m,unsigned long long mlen,
|
||||||
const unsigned char *sk
|
const unsigned char *sk
|
||||||
|
10
test.c
10
test.c
@ -2,7 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "crypto_sign.h"
|
#include "ed25519.h"
|
||||||
|
|
||||||
char *msg = "Hello World";
|
char *msg = "Hello World";
|
||||||
|
|
||||||
@ -11,26 +11,26 @@ int main(int argc, char *argv[]) {
|
|||||||
unsigned char *sigmsg, *newmsg;
|
unsigned char *sigmsg, *newmsg;
|
||||||
unsigned long long sigmsglen, newmsglen;
|
unsigned long long sigmsglen, newmsglen;
|
||||||
int ret;
|
int ret;
|
||||||
crypto_sign_keypair(vk, sk, "0123456890123456789012");
|
ed25519_sign_keypair(vk, sk, "0123456890123456789012");
|
||||||
printf("got keypair\n");
|
printf("got keypair\n");
|
||||||
sigmsg = malloc(strlen(msg)+1+64);
|
sigmsg = malloc(strlen(msg)+1+64);
|
||||||
if (!sigmsg)
|
if (!sigmsg)
|
||||||
return 1;
|
return 1;
|
||||||
crypto_sign(sigmsg, &sigmsglen, (unsigned char *)msg, strlen(msg)+1, sk);
|
ed25519_sign(sigmsg, &sigmsglen, (unsigned char *)msg, strlen(msg)+1, sk);
|
||||||
printf("got signature\n");
|
printf("got signature\n");
|
||||||
if (sigmsglen != strlen(msg)+1+64)
|
if (sigmsglen != strlen(msg)+1+64)
|
||||||
return 2;
|
return 2;
|
||||||
newmsg = malloc(sigmsglen);
|
newmsg = malloc(sigmsglen);
|
||||||
if (!newmsg)
|
if (!newmsg)
|
||||||
return 3;
|
return 3;
|
||||||
ret = crypto_sign_open(newmsg, &newmsglen, sigmsg, sigmsglen, vk);
|
ret = ed25519_sign_open(newmsg, &newmsglen, sigmsg, sigmsglen, vk);
|
||||||
printf("verified signature\n");
|
printf("verified signature\n");
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
printf("good!\n");
|
printf("good!\n");
|
||||||
else
|
else
|
||||||
printf("bad\n");
|
printf("bad\n");
|
||||||
sigmsg[0] ^= 0x01;
|
sigmsg[0] ^= 0x01;
|
||||||
ret = crypto_sign_open(newmsg, &newmsglen, sigmsg, sigmsglen, vk);
|
ret = ed25519_sign_open(newmsg, &newmsglen, sigmsg, sigmsglen, vk);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
printf("bad: failed to detect simple corruption\n");
|
printf("bad: failed to detect simple corruption\n");
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user