forked from wolfSSL/wolfssl
Merge pull request #3053 from SparkiDev/ed448_fixes
Fix ED448 calls to use context and correct variable name
This commit is contained in:
@@ -42845,7 +42845,7 @@ int wolfSSL_ED448_sign(const unsigned char *msg, unsigned int msgSz,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wc_ed448_sign_msg(msg, msgSz, sig, sigSz, &key) != MP_OKAY)
|
if (wc_ed448_sign_msg(msg, msgSz, sig, sigSz, &key, NULL, 0) != MP_OKAY)
|
||||||
WOLFSSL_MSG("wc_curve448_shared_secret_ex failed");
|
WOLFSSL_MSG("wc_curve448_shared_secret_ex failed");
|
||||||
else
|
else
|
||||||
ret = WOLFSSL_SUCCESS;
|
ret = WOLFSSL_SUCCESS;
|
||||||
@@ -42897,7 +42897,7 @@ int wolfSSL_ED448_verify(const unsigned char *msg, unsigned int msgSz,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = wc_ed448_verify_msg((byte*)sig, sigSz, msg, msgSz, &check,
|
if ((ret = wc_ed448_verify_msg((byte*)sig, sigSz, msg, msgSz, &check,
|
||||||
&key)) != MP_OKAY) {
|
&key, NULL, 0)) != MP_OKAY) {
|
||||||
WOLFSSL_MSG("wc_ed448_verify_msg failed");
|
WOLFSSL_MSG("wc_ed448_verify_msg failed");
|
||||||
}
|
}
|
||||||
else if (!check)
|
else if (!check)
|
||||||
|
60
tests/api.c
60
tests/api.c
@@ -333,6 +333,12 @@
|
|||||||
#ifdef HAVE_PKCS7
|
#ifdef HAVE_PKCS7
|
||||||
#include <wolfssl/openssl/pkcs7.h>
|
#include <wolfssl/openssl/pkcs7.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_ED25519
|
||||||
|
#include <wolfssl/openssl/ed25519.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ED448
|
||||||
|
#include <wolfssl/openssl/ed448.h>
|
||||||
|
#endif
|
||||||
#endif /* OPENSSL_EXTRA */
|
#endif /* OPENSSL_EXTRA */
|
||||||
|
|
||||||
#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \
|
#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \
|
||||||
@@ -2069,6 +2075,58 @@ static void test_ECDSA_size_sign(void)
|
|||||||
|
|
||||||
#endif /* HAVE_ECC && !NO_ECC256 && !NO_ECC_SECP */
|
#endif /* HAVE_ECC && !NO_ECC256 && !NO_ECC_SECP */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_ED25519(void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_ED25519) && defined(WOLFSSL_KEY_GEN)
|
||||||
|
byte priv[ED25519_PRV_KEY_SIZE];
|
||||||
|
unsigned int privSz = (unsigned int)sizeof(priv);
|
||||||
|
byte pub[ED25519_PUB_KEY_SIZE];
|
||||||
|
unsigned int pubSz = (unsigned int)sizeof(pub);
|
||||||
|
const char* msg = "Everyone gets Friday off.";
|
||||||
|
unsigned int msglen = (unsigned int)XSTRLEN(msg);
|
||||||
|
byte sig[ED25519_SIG_SIZE];
|
||||||
|
unsigned int sigSz = (unsigned int)sizeof(sig);
|
||||||
|
|
||||||
|
AssertIntEQ(wolfSSL_ED25519_generate_key(priv, &privSz, pub, &pubSz),
|
||||||
|
WOLFSSL_SUCCESS);
|
||||||
|
AssertIntEQ(privSz, ED25519_PRV_KEY_SIZE);
|
||||||
|
AssertIntEQ(pubSz, ED25519_PUB_KEY_SIZE);
|
||||||
|
|
||||||
|
AssertIntEQ(wolfSSL_ED25519_sign((byte*)msg, msglen, priv, privSz, sig,
|
||||||
|
&sigSz), WOLFSSL_SUCCESS);
|
||||||
|
AssertIntEQ(sigSz, ED25519_SIG_SIZE);
|
||||||
|
|
||||||
|
AssertIntEQ(wolfSSL_ED25519_verify((byte*)msg, msglen, pub, pubSz, sig,
|
||||||
|
sigSz), WOLFSSL_SUCCESS);
|
||||||
|
#endif /* HAVE_ED25519 && WOLFSSL_KEY_GEN */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_ED448(void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_ED448) && defined(WOLFSSL_KEY_GEN)
|
||||||
|
byte priv[ED448_PRV_KEY_SIZE];
|
||||||
|
unsigned int privSz = (unsigned int)sizeof(priv);
|
||||||
|
byte pub[ED448_PUB_KEY_SIZE];
|
||||||
|
unsigned int pubSz = (unsigned int)sizeof(pub);
|
||||||
|
const char* msg = "Everyone gets Friday off.";
|
||||||
|
unsigned int msglen = (unsigned int)XSTRLEN(msg);
|
||||||
|
byte sig[ED448_SIG_SIZE];
|
||||||
|
unsigned int sigSz = (unsigned int)sizeof(sig);
|
||||||
|
|
||||||
|
AssertIntEQ(wolfSSL_ED448_generate_key(priv, &privSz, pub, &pubSz),
|
||||||
|
WOLFSSL_SUCCESS);
|
||||||
|
AssertIntEQ(privSz, ED448_PRV_KEY_SIZE);
|
||||||
|
AssertIntEQ(pubSz, ED448_PUB_KEY_SIZE);
|
||||||
|
|
||||||
|
AssertIntEQ(wolfSSL_ED448_sign((byte*)msg, msglen, priv, privSz, sig,
|
||||||
|
&sigSz), WOLFSSL_SUCCESS);
|
||||||
|
AssertIntEQ(sigSz, ED448_SIG_SIZE);
|
||||||
|
|
||||||
|
AssertIntEQ(wolfSSL_ED448_verify((byte*)msg, msglen, pub, pubSz, sig,
|
||||||
|
sigSz), WOLFSSL_SUCCESS);
|
||||||
|
#endif /* HAVE_ED448 && WOLFSSL_KEY_GEN */
|
||||||
|
}
|
||||||
#endif /* OPENSSL_EXTRA */
|
#endif /* OPENSSL_EXTRA */
|
||||||
|
|
||||||
#include <wolfssl/openssl/pem.h>
|
#include <wolfssl/openssl/pem.h>
|
||||||
@@ -32518,6 +32576,8 @@ void ApiTest(void)
|
|||||||
#endif
|
#endif
|
||||||
test_wolfSSL_ECDSA_SIG();
|
test_wolfSSL_ECDSA_SIG();
|
||||||
test_ECDSA_size_sign();
|
test_ECDSA_size_sign();
|
||||||
|
test_ED25519();
|
||||||
|
test_ED448();
|
||||||
#endif
|
#endif
|
||||||
#if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && \
|
#if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && \
|
||||||
!defined(HAVE_SELFTEST) && \
|
!defined(HAVE_SELFTEST) && \
|
||||||
|
@@ -14031,7 +14031,7 @@ static int SetKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *eckey,
|
|||||||
#ifdef HAVE_ED448
|
#ifdef HAVE_ED448
|
||||||
/* ED448 public key */
|
/* ED448 public key */
|
||||||
if (ed448Key != NULL)
|
if (ed448Key != NULL)
|
||||||
bufferSz = SetEd448PublicKey(buffer, ed448Key, 0);
|
bufferSz = SetEd448PublicKey(buf, ed448Key, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bufferSz <= 0) {
|
if (bufferSz <= 0) {
|
||||||
|
@@ -22282,7 +22282,7 @@ static int ed448_test_cert(void)
|
|||||||
if (wc_ed448_verify_msg(serverCert->signature, serverCert->sigLength,
|
if (wc_ed448_verify_msg(serverCert->signature, serverCert->sigLength,
|
||||||
serverCert->source + serverCert->certBegin,
|
serverCert->source + serverCert->certBegin,
|
||||||
serverCert->sigIndex - serverCert->certBegin,
|
serverCert->sigIndex - serverCert->certBegin,
|
||||||
&verify, pubKey) < 0 || verify != 1) {
|
&verify, pubKey, NULL, 0) < 0 || verify != 1) {
|
||||||
ERROR_OUT(-11032, done);
|
ERROR_OUT(-11032, done);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_ED448_VERIFY */
|
#endif /* HAVE_ED448_VERIFY */
|
||||||
|
Reference in New Issue
Block a user