forked from wolfSSL/wolfssl
adjust ./configure format, change ed sign/verify to msg from hash
This commit is contained in:
@ -653,7 +653,7 @@ AM_CONDITIONAL([BUILD_ECC25519], [test "x$ENABLED_ECC25519" = "xyes"])
|
|||||||
|
|
||||||
# ED25519
|
# ED25519
|
||||||
AC_ARG_ENABLE([ed25519],
|
AC_ARG_ENABLE([ed25519],
|
||||||
[ AS_HELP_STRING(--enable-ed25519 Enable ED25519 (default: disabled))],
|
[AS_HELP_STRING([--enable-ed25519],[Enable ED25519 (default: disabled)])],
|
||||||
[ ENABLED_ED25519=$enableval ],
|
[ ENABLED_ED25519=$enableval ],
|
||||||
[ ENABLED_ED25519=no ]
|
[ ENABLED_ED25519=no ]
|
||||||
)
|
)
|
||||||
|
@ -1773,7 +1773,7 @@ void bench_ed25519KeySign(void)
|
|||||||
|
|
||||||
for(i = 0; i < agreeTimes; i++) {
|
for(i = 0; i < agreeTimes; i++) {
|
||||||
x = sizeof(sig);
|
x = sizeof(sig);
|
||||||
ret = wc_ed25519_sign_hash(digest, sizeof(digest), sig, &x, &genKey);
|
ret = wc_ed25519_sign_msg(digest, sizeof(digest), sig, &x, &genKey);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("ed25519_sign_hash failed\n");
|
printf("ed25519_sign_hash failed\n");
|
||||||
return;
|
return;
|
||||||
@ -1790,7 +1790,8 @@ void bench_ed25519KeySign(void)
|
|||||||
|
|
||||||
for(i = 0; i < agreeTimes; i++) {
|
for(i = 0; i < agreeTimes; i++) {
|
||||||
int verify = 0;
|
int verify = 0;
|
||||||
ret = wc_ed25519_verify_hash(sig, x, digest, sizeof(digest), &verify, &genKey);
|
ret = wc_ed25519_verify_msg(sig, x, digest, sizeof(digest), &verify,
|
||||||
|
&genKey);
|
||||||
if (ret != 0 || verify != 1) {
|
if (ret != 0 || verify != 1) {
|
||||||
printf("ed25519_verify_hash failed\n");
|
printf("ed25519_verify_hash failed\n");
|
||||||
return;
|
return;
|
||||||
|
@ -710,8 +710,8 @@ int wc_ed25519_make_key(RNG* rng, int keySz, ed25519_key* key)
|
|||||||
key is the ed25519 key to use when signing
|
key is the ed25519 key to use when signing
|
||||||
return 0 on success
|
return 0 on success
|
||||||
*/
|
*/
|
||||||
int wc_ed25519_sign_hash(const byte* in, word32 inlen, byte* out,
|
int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
|
||||||
word32 *outlen, ed25519_key* key)
|
word32 *outlen, ed25519_key* key)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
byte nonce[64];
|
byte nonce[64];
|
||||||
@ -761,12 +761,12 @@ int wc_ed25519_sign_hash(const byte* in, word32 inlen, byte* out,
|
|||||||
/*
|
/*
|
||||||
sig is array of bytes containing the signature
|
sig is array of bytes containing the signature
|
||||||
siglen is the length of sig byte array
|
siglen is the length of sig byte array
|
||||||
hash the array of bytes containing the message
|
msg the array of bytes containing the message
|
||||||
hashlen length of hash array
|
msglen length of msg array
|
||||||
stat will be 1 on successful verify and 0 on unsuccessful
|
stat will be 1 on successful verify and 0 on unsuccessful
|
||||||
*/
|
*/
|
||||||
int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash,
|
int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
|
||||||
word32 hashlen, int* stat, ed25519_key* key)
|
word32 msglen, int* stat, ed25519_key* key)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
word32 sigSz;
|
word32 sigSz;
|
||||||
@ -777,7 +777,7 @@ int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash,
|
|||||||
ge_p2 R;
|
ge_p2 R;
|
||||||
|
|
||||||
/* sanity check on arguments */
|
/* sanity check on arguments */
|
||||||
if (sig == NULL || hash == NULL || stat == NULL || key == NULL)
|
if (sig == NULL || msg == NULL || stat == NULL || key == NULL)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -796,7 +796,7 @@ int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash,
|
|||||||
ret |= wc_InitSha512(&sha);
|
ret |= wc_InitSha512(&sha);
|
||||||
ret |= wc_Sha512Update(&sha, sig, 32);
|
ret |= wc_Sha512Update(&sha, sig, 32);
|
||||||
ret |= wc_Sha512Update(&sha, key->p, 32);
|
ret |= wc_Sha512Update(&sha, key->p, 32);
|
||||||
ret |= wc_Sha512Update(&sha, hash, hashlen);
|
ret |= wc_Sha512Update(&sha, msg, msglen);
|
||||||
ret |= wc_Sha512Final(&sha, h);
|
ret |= wc_Sha512Final(&sha, h);
|
||||||
sc_reduce(h);
|
sc_reduce(h);
|
||||||
|
|
||||||
@ -818,7 +818,7 @@ int wc_ed25519_init(ed25519_key* key)
|
|||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
ForceZero(key, sizeof(ed25519_key));
|
XMEMSET(key, 0, sizeof(ed25519_key));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -5691,7 +5691,7 @@ int ed25519_test(void)
|
|||||||
pKeySz[i], &key) != 0)
|
pKeySz[i], &key) != 0)
|
||||||
return -1021;
|
return -1021;
|
||||||
|
|
||||||
if (wc_ed25519_sign_hash(msgs[i], msgSz[i], out, &outlen, &key)
|
if (wc_ed25519_sign_msg(msgs[i], msgSz[i], out, &outlen, &key)
|
||||||
!= 0)
|
!= 0)
|
||||||
return -1022;
|
return -1022;
|
||||||
|
|
||||||
@ -5699,13 +5699,13 @@ int ed25519_test(void)
|
|||||||
return -1023;
|
return -1023;
|
||||||
|
|
||||||
/* test verify on good msg */
|
/* test verify on good msg */
|
||||||
if (wc_ed25519_verify_hash(out, outlen, msgs[i], msgSz[i], &verify,
|
if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify,
|
||||||
&key) != 0 || verify != 1)
|
&key) != 0 || verify != 1)
|
||||||
return -1024;
|
return -1024;
|
||||||
|
|
||||||
/* test verify on bad msg */
|
/* test verify on bad msg */
|
||||||
out[outlen-1] = out[outlen-1] + 1;
|
out[outlen-1] = out[outlen-1] + 1;
|
||||||
if (wc_ed25519_verify_hash(out, outlen, msgs[i], msgSz[i], &verify,
|
if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify,
|
||||||
&key) == 0 || verify == 1)
|
&key) == 0 || verify == 1)
|
||||||
return -1025;
|
return -1025;
|
||||||
|
|
||||||
@ -5728,12 +5728,11 @@ int ed25519_test(void)
|
|||||||
/* clear "out" buffer and test sign with imported keys */
|
/* clear "out" buffer and test sign with imported keys */
|
||||||
outlen = sizeof(out);
|
outlen = sizeof(out);
|
||||||
XMEMSET(out, 0, sizeof(out));
|
XMEMSET(out, 0, sizeof(out));
|
||||||
if (wc_ed25519_sign_hash(msgs[i], msgSz[i], out, &outlen, &key2)
|
if (wc_ed25519_sign_msg(msgs[i], msgSz[i], out, &outlen, &key2) != 0)
|
||||||
!= 0)
|
|
||||||
return -1030;
|
return -1030;
|
||||||
|
|
||||||
if (wc_ed25519_verify_hash(out, outlen, msgs[i], msgSz[i], &verify,
|
if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify,
|
||||||
&key2) != 0 || verify != 1)
|
&key2) != 0 || verify != 1)
|
||||||
return -1031;
|
return -1031;
|
||||||
|
|
||||||
if (XMEMCMP(out, sigs[i], 64))
|
if (XMEMCMP(out, sigs[i], 64))
|
||||||
|
@ -60,11 +60,11 @@ typedef struct {
|
|||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ed25519_make_key(RNG* rng, int keysize, ed25519_key* key);
|
int wc_ed25519_make_key(RNG* rng, int keysize, ed25519_key* key);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ed25519_sign_hash(const byte* in, word32 inlen, byte* out,
|
int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
|
||||||
word32 *outlen, ed25519_key* key);
|
word32 *outlen, ed25519_key* key);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash,
|
int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
|
||||||
word32 hashlen, int* stat, ed25519_key* key);
|
word32 msglen, int* stat, ed25519_key* key);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ed25519_init(ed25519_key* key);
|
int wc_ed25519_init(ed25519_key* key);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
|
Reference in New Issue
Block a user