Skip to content

ed448.h

Functions

Name
int wc_ed448_make_public(ed448_key * key, unsigned char * pubKey, word32 pubKeySz)
This function generates the Ed448 public key from the private key. It stores the public key in the buffer pubKey, and sets the bytes written to this buffer in pubKeySz.
int wc_ed448_make_key(WC_RNG * rng, int keysize, ed448_key * key)
This function generates a new Ed448 key and stores it in key.
int wc_ed448_sign_msg(const byte * in, word32 inlen, byte * out, word32 * outlen, ed448_key * key)
This function signs a message using an ed448_key object to guarantee authenticity.
int wc_ed448ph_sign_hash(const byte * hash, word32 hashLen, byte * out, word32 * outLen, ed448_key * key, const byte * context, byte contextLen)
This function signs a message digest using an ed448_key object to guarantee authenticity. The context is included as part of the data signed. The hash is the pre-hashed message before signature calculation. The hash algorithm used to create message digest must be SHAKE-256.
int wc_ed448ph_sign_msg(const byte * in, word32 inLen, byte * out, word32 * outLen, ed448_key * key, const byte * context, byte contextLen)
This function signs a message using an ed448_key object to guarantee authenticity. The context is included as part of the data signed. The message is pre-hashed before signature calculation.
int wc_ed448_verify_msg(const byte * sig, word32 siglen, const byte * msg, word32 msgLen, int * res, ed448_key * key, const byte * context, byte contextLen)
This function verifies the Ed448 signature of a message to ensure authenticity. The context is included as part of the data verified. The answer is returned through res, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.
int wc_ed448ph_verify_hash(const byte * sig, word32 siglen, const byte * hash, word32 hashlen, int * res, ed448_key * key, const byte * context, byte contextLen)
This function verifies the Ed448 signature of the digest of a message to ensure authenticity. The context is included as part of the data verified. The hash is the pre-hashed message before signature calculation. The hash algorithm used to create message digest must be SHAKE-256. The answer is returned through res, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.
int wc_ed448ph_verify_msg(const byte * sig, word32 siglen, const byte * msg, word32 msgLen, int * res, ed448_key * key, const byte * context, byte contextLen)
This function verifies the Ed448 signature of a message to ensure authenticity. The context is included as part of the data verified. The message is pre-hashed before verification. The answer is returned through res, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.
int wc_ed448_init(ed448_key * key)
This function initializes an ed448_key object for future use with message verification.
void wc_ed448_free(ed448_key * key)
This function frees an Ed448 object after it has been used.
int wc_ed448_import_public(const byte * in, word32 inLen, ed448_key * key)
This function imports a public ed448_key pair from a buffer containing the public key. This function will handle both compressed and uncompressed keys.
int wc_ed448_import_private_only(const byte * priv, word32 privSz, ed448_key * key)
This function imports an Ed448 private key only from a buffer.
int wc_ed448_import_private_key(const byte * priv, word32 privSz, const byte * pub, word32 pubSz, ed448_key * key)
This function imports a public/private Ed448 key pair from a pair of buffers. This function will handle both compressed and uncompressed keys.
int wc_ed448_export_public(ed448_key * key, byte * out, word32 * outLen)
This function exports the private key from an ed448_key structure. It stores the public key in the buffer out, and sets the bytes written to this buffer in outLen.
int wc_ed448_export_private_only(ed448_key * key, byte * out, word32 * outLen)
This function exports only the private key from an ed448_key structure. It stores the private key in the buffer out, and sets the bytes written to this buffer in outLen.
int wc_ed448_export_private(ed448_key * key, byte * out, word32 * outLen)
This function exports the key pair from an ed448_key structure. It stores the key pair in the buffer out, and sets the bytes written to this buffer in outLen.
int wc_ed448_export_key(ed448_key * key, byte * priv, word32 * privSz, byte * pub, word32 * pubSz)
This function exports the private and public key separately from an ed448_key structure. It stores the private key in the buffer priv, and sets the bytes written to this buffer in privSz. It stores the public key in the buffer pub, and sets the bytes written to this buffer in pubSz.
int wc_ed448_check_key(ed448_key * key)
This function checks the public key in ed448_key structure matches the private key.
int wc_ed448_size(ed448_key * key)
This function returns the size of an Ed448 private key - 57 bytes.
int wc_ed448_priv_size(ed448_key * key)
This function returns the private key size (secret + public) in bytes.
int wc_ed448_pub_size(ed448_key * key)
This function returns the compressed key size in bytes (public key).
int wc_ed448_sig_size(ed448_key * key)
This function returns the size of an Ed448 signature (114 in bytes).

Functions Documentation

function wc_ed448_make_public

int wc_ed448_make_public(
    ed448_key * key,
    unsigned char * pubKey,
    word32 pubKeySz
)

This function generates the Ed448 public key from the private key. It stores the public key in the buffer pubKey, and sets the bytes written to this buffer in pubKeySz.

Parameters:

  • key Pointer to the ed448_key for which to generate a key.
  • out Pointer to the buffer in which to store the public key.
  • outLen Pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the public key.

See:

Return:

  • 0 Returned upon successfully making the public key.
  • BAD_FUNC_ARG Returned ifi key or pubKey evaluate to NULL, or if the specified key size is not 57 bytes (Ed448 has 57 byte keys).
  • MEMORY_E Returned if there is an error allocating memory during function execution.

Example

int ret;

ed448_key key;
byte priv[] = { initialize with 57 byte private key };
byte pub[57];
word32 pubSz = sizeof(pub);

wc_ed448_init(&key);
wc_ed448_import_private_only(priv, sizeof(priv), &key);
ret = wc_ed448_make_public(&key, pub, &pubSz);
if (ret != 0) {
    // error making public key
}

function wc_ed448_make_key

int wc_ed448_make_key(
    WC_RNG * rng,
    int keysize,
    ed448_key * key
)

This function generates a new Ed448 key and stores it in key.

Parameters:

  • rng Pointer to an initialized RNG object with which to generate the key.
  • keysize Length of key to generate. Should always be 57 for Ed448.
  • key Pointer to the ed448_key for which to generate a key.

See: wc_ed448_init

Return:

  • 0 Returned upon successfully making an ed448_key.
  • BAD_FUNC_ARG Returned if rng or key evaluate to NULL, or if the specified key size is not 57 bytes (Ed448 has 57 byte keys).
  • MEMORY_E Returned if there is an error allocating memory during function execution.

Example

int ret;

WC_RNG rng;
ed448_key key;

wc_InitRng(&rng);
wc_ed448_init(&key);
ret = wc_ed448_make_key(&rng, 57, &key);
if (ret != 0) {
    // error making key
}

function wc_ed448_sign_msg

int wc_ed448_sign_msg(
    const byte * in,
    word32 inlen,
    byte * out,
    word32 * outlen,
    ed448_key * key
)

This function signs a message using an ed448_key object to guarantee authenticity.

Parameters:

  • in Pointer to the buffer containing the message to sign.
  • inlen Length of the message to sign.
  • out Buffer in which to store the generated signature.
  • outlen Maximum length of the output buffer. Will store the bytes written to out upon successfully generating a message signature.
  • key Pointer to a private ed448_key with which to generate the signature.

See:

Return:

  • 0 Returned upon successfully generating a signature for the message.
  • BAD_FUNC_ARG Returned if any of the input parameters evaluate to NULL, or if the output buffer is too small to store the generated signature.
  • MEMORY_E Returned if there is an error allocating memory during function execution.

Example

ed448_key key;
WC_RNG rng;
int ret, sigSz;

byte sig[114]; // will hold generated signature
sigSz = sizeof(sig);
byte message[] = { initialize with message };

wc_InitRng(&rng); // initialize rng
wc_ed448_init(&key); // initialize key
wc_ed448_make_key(&rng, 57, &key); // make public/private key pair
ret = wc_ed448_sign_msg(message, sizeof(message), sig, &sigSz, &key);
if (ret != 0 ) {
    // error generating message signature
}

function wc_ed448ph_sign_hash

int wc_ed448ph_sign_hash(
    const byte * hash,
    word32 hashLen,
    byte * out,
    word32 * outLen,
    ed448_key * key,
    const byte * context,
    byte contextLen
)

This function signs a message digest using an ed448_key object to guarantee authenticity. The context is included as part of the data signed. The hash is the pre-hashed message before signature calculation. The hash algorithm used to create message digest must be SHAKE-256.

Parameters:

  • hash Pointer to the buffer containing the hash of the message to sign.
  • hashLen Length of the hash of the message to sign.
  • out Buffer in which to store the generated signature.
  • outlen Maximum length of the output buffer. Will store the bytes written to out upon successfully generating a message signature.
  • key Pointer to a private ed448_key with which to generate the signature.
  • context Pointer to the buffer containing the context for which message is being signed.
  • contextLen Length of the context buffer.

See:

Return:

  • 0 Returned upon successfully generating a signature for the message digest.
  • BAD_FUNC_ARG Returned any of the input parameters evaluate to NULL, or if the output buffer is too small to store the generated signature.
  • MEMORY_E Returned if there is an error allocating memory during function execution.

Example

ed448_key key;
WC_RNG rng;
int ret, sigSz;

byte sig[114]; // will hold generated signature
sigSz = sizeof(sig);
byte hash[] = { initialize with SHAKE-256 hash of message };
byte context[] = { initialize with context of signing };

wc_InitRng(&rng); // initialize rng
wc_ed448_init(&key); // initialize key
wc_ed448_make_key(&rng, 57, &key); // make public/private key pair
ret = wc_ed448ph_sign_hash(hash, sizeof(hash), sig, &sigSz, &key,
        context, sizeof(context));
if (ret != 0) {
    // error generating message signature
}

function wc_ed448ph_sign_msg

int wc_ed448ph_sign_msg(
    const byte * in,
    word32 inLen,
    byte * out,
    word32 * outLen,
    ed448_key * key,
    const byte * context,
    byte contextLen
)

This function signs a message using an ed448_key object to guarantee authenticity. The context is included as part of the data signed. The message is pre-hashed before signature calculation.

Parameters:

  • in Pointer to the buffer containing the message to sign.
  • inlen Length of the message to sign.
  • out Buffer in which to store the generated signature.
  • outlen Maximum length of the output buffer. Will store the bytes written to out upon successfully generating a message signature.
  • key Pointer to a private ed448_key with which to generate the signature.
  • context Pointer to the buffer containing the context for which message is being signed.
  • contextLen Length of the context buffer.

See:

Return:

  • 0 Returned upon successfully generating a signature for the message.
  • BAD_FUNC_ARG Returned any of the input parameters evaluate to NULL, or if the output buffer is too small to store the generated signature.
  • MEMORY_E Returned if there is an error allocating memory during function execution.

Example

ed448_key key;
WC_RNG rng;
int ret, sigSz;

byte sig[114]; // will hold generated signature
sigSz = sizeof(sig);
byte message[] = { initialize with message };
byte context[] = { initialize with context of signing };

wc_InitRng(&rng); // initialize rng
wc_ed448_init(&key); // initialize key
wc_ed448_make_key(&rng, 57, &key); // make public/private key pair
ret = wc_ed448ph_sign_msg(message, sizeof(message), sig, &sigSz, &key,
        context, sizeof(context));
if (ret != 0) {
    // error generating message signature
}

function wc_ed448_verify_msg

int wc_ed448_verify_msg(
    const byte * sig,
    word32 siglen,
    const byte * msg,
    word32 msgLen,
    int * res,
    ed448_key * key,
    const byte * context,
    byte contextLen
)

This function verifies the Ed448 signature of a message to ensure authenticity. The context is included as part of the data verified. The answer is returned through res, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.

Parameters:

  • sig Pointer to the buffer containing the signature to verify.
  • siglen Length of the signature to verify.
  • msg Pointer to the buffer containing the message to verify.
  • msgLen Length of the message to verify.
  • key Pointer to a public Ed448 key with which to verify the signature.
  • context Pointer to the buffer containing the context for which the message was signed.
  • contextLen Length of the context buffer.

See:

Return:

  • 0 Returned upon successfully performing the signature verification and authentication.
  • BAD_FUNC_ARG Returned if any of the input parameters evaluate to NULL, or if the siglen does not match the actual length of a signature.
  • SIG_VERIFY_E Returned if verification completes, but the signature generated does not match the signature provided.

Example

ed448_key key;
int ret, verified = 0;

byte sig[] { initialize with received signature };
byte msg[] = { initialize with message };
byte context[] = { initialize with context of signature };
// initialize key with received public key
ret = wc_ed448_verify_msg(sig, sizeof(sig), msg, sizeof(msg), &verified,
        &key, context, sizeof(context));
if (ret < 0) {
    // error performing verification
} else if (verified == 0)
    // the signature is invalid
}

function wc_ed448ph_verify_hash

int wc_ed448ph_verify_hash(
    const byte * sig,
    word32 siglen,
    const byte * hash,
    word32 hashlen,
    int * res,
    ed448_key * key,
    const byte * context,
    byte contextLen
)

This function verifies the Ed448 signature of the digest of a message to ensure authenticity. The context is included as part of the data verified. The hash is the pre-hashed message before signature calculation. The hash algorithm used to create message digest must be SHAKE-256. The answer is returned through res, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.

Parameters:

  • sig Pointer to the buffer containing the signature to verify.
  • siglen Length of the signature to verify.
  • hash Pointer to the buffer containing the hash of the message to verify.
  • hashLen Length of the hash to verify.
  • key Pointer to a public Ed448 key with which to verify the signature.
  • context Pointer to the buffer containing the context for which the message was signed.
  • contextLen Length of the context buffer.

See:

Return:

  • 0 Returned upon successfully performing the signature verification and authentication.
  • BAD_FUNC_ARG Returned if any of the input parameters evaluate to NULL, or if the siglen does not match the actual length of a signature.
  • SIG_VERIFY_E Returned if verification completes, but the signature generated does not match the signature provided.

Example

ed448_key key;
int ret, verified = 0;

byte sig[] { initialize with received signature };
byte hash[] = { initialize with SHAKE-256 hash of message };
byte context[] = { initialize with context of signature };
// initialize key with received public key
ret = wc_ed448ph_verify_hash(sig, sizeof(sig), hash, sizeof(hash),
        &verified, &key, context, sizeof(context));
if (ret < 0) {
    // error performing verification
} else if (verified == 0)
    // the signature is invalid
}

function wc_ed448ph_verify_msg

int wc_ed448ph_verify_msg(
    const byte * sig,
    word32 siglen,
    const byte * msg,
    word32 msgLen,
    int * res,
    ed448_key * key,
    const byte * context,
    byte contextLen
)

This function verifies the Ed448 signature of a message to ensure authenticity. The context is included as part of the data verified. The message is pre-hashed before verification. The answer is returned through res, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.

Parameters:

  • sig Pointer to the buffer containing the signature to verify.
  • siglen Length of the signature to verify.
  • msg Pointer to the buffer containing the message to verify.
  • msgLen Length of the message to verify.
  • key Pointer to a public Ed448 key with which to verify the signature.
  • context Pointer to the buffer containing the context for which the message was signed.
  • contextLen Length of the context buffer.

See:

Return:

  • 0 Returned upon successfully performing the signature verification and authentication.
  • BAD_FUNC_ARG Returned if any of the input parameters evaluate to NULL, or if the siglen does not match the actual length of a signature.
  • SIG_VERIFY_E Returned if verification completes, but the signature generated does not match the signature provided.

Example

ed448_key key;
int ret, verified = 0;

byte sig[] { initialize with received signature };
byte msg[] = { initialize with message };
byte context[] = { initialize with context of signature };
// initialize key with received public key
ret = wc_ed448ph_verify_msg(sig, sizeof(sig), msg, sizeof(msg), &verified,
        &key, context, sizeof(context));
if (ret < 0) {
    // error performing verification
} else if (verified == 0)
    // the signature is invalid
}

function wc_ed448_init

int wc_ed448_init(
    ed448_key * key
)

This function initializes an ed448_key object for future use with message verification.

Parameters:

  • key Pointer to the ed448_key object to initialize.

See:

Return:

  • 0 Returned upon successfully initializing the ed448_key object.
  • BAD_FUNC_ARG Returned if key is NULL.

Example

ed448_key key;
wc_ed448_init(&key);

function wc_ed448_free

void wc_ed448_free(
    ed448_key * key
)

This function frees an Ed448 object after it has been used.

Parameters:

  • key Pointer to the ed448_key object to free

See: wc_ed448_init

Example

ed448_key key;
// initialize key and perform secure exchanges
...
wc_ed448_free(&key);

function wc_ed448_import_public

int wc_ed448_import_public(
    const byte * in,
    word32 inLen,
    ed448_key * key
)

This function imports a public ed448_key pair from a buffer containing the public key. This function will handle both compressed and uncompressed keys.

Parameters:

  • in Pointer to the buffer containing the public key.
  • inLen Length of the buffer containing the public key.
  • key Pointer to the ed448_key object in which to store the public key.

See:

Return:

  • 0 Returned on successfully importing the ed448_key.
  • BAD_FUNC_ARG Returned if in or key evaluate to NULL, or inLen is less than the size of an Ed448 key.

Example

int ret;
byte pub[] = { initialize Ed448 public key };

ed_448 key;
wc_ed448_init_key(&key);
ret = wc_ed448_import_public(pub, sizeof(pub), &key);
if (ret != 0) {
    // error importing key
}

function wc_ed448_import_private_only

int wc_ed448_import_private_only(
    const byte * priv,
    word32 privSz,
    ed448_key * key
)

This function imports an Ed448 private key only from a buffer.

Parameters:

  • priv Pointer to the buffer containing the private key.
  • privSz Length of the private key.
  • key Pointer to the ed448_key object in which to store the imported private key.

See:

Return:

  • 0 Returned on successfully importing the Ed448 private key.
  • BAD_FUNC_ARG Returned if in or key evaluate to NULL, or if privSz is less than ED448_KEY_SIZE.

Example

int ret;
byte priv[] = { initialize with 57 byte private key };

ed448_key key;
wc_ed448_init_key(&key);
ret = wc_ed448_import_private_only(priv, sizeof(priv), &key);
if (ret != 0) {
    // error importing private key
}

function wc_ed448_import_private_key

int wc_ed448_import_private_key(
    const byte * priv,
    word32 privSz,
    const byte * pub,
    word32 pubSz,
    ed448_key * key
)

This function imports a public/private Ed448 key pair from a pair of buffers. This function will handle both compressed and uncompressed keys.

Parameters:

  • priv Pointer to the buffer containing the private key.
  • privSz Length of the private key.
  • pub Pointer to the buffer containing the public key.
  • pubSz Length of the public key.
  • key Pointer to the ed448_key object in which to store the imported private/public key pair.

See:

Return:

  • 0 Returned on successfully importing the Ed448 key.
  • BAD_FUNC_ARG Returned if in or key evaluate to NULL, or if either privSz is less than ED448_KEY_SIZE or pubSz is less than ED448_PUB_KEY_SIZE.

Example

int ret;
byte priv[] = { initialize with 57 byte private key };
byte pub[]  = { initialize with the corresponding public key };

ed448_key key;
wc_ed448_init_key(&key);
ret = wc_ed448_import_private_key(priv, sizeof(priv), pub, sizeof(pub),
        &key);
if (ret != 0) {
    // error importing key
}

function wc_ed448_export_public

int wc_ed448_export_public(
    ed448_key * key,
    byte * out,
    word32 * outLen
)

This function exports the private key from an ed448_key structure. It stores the public key in the buffer out, and sets the bytes written to this buffer in outLen.

Parameters:

  • key Pointer to an ed448_key structure from which to export the public key.
  • out Pointer to the buffer in which to store the public key.
  • outLen Pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the public key.

See:

Return:

  • 0 Returned upon successfully exporting the public key.
  • BAD_FUNC_ARG Returned if any of the input values evaluate to NULL.
  • BUFFER_E Returned if the buffer provided is not large enough to store the private key. Upon returning this error, the function sets the size required in outLen.

Example

int ret;
ed448_key key;
// initialize key, make key

char pub[57];
word32 pubSz = sizeof(pub);

ret = wc_ed448_export_public(&key, pub, &pubSz);
if (ret != 0) {
    // error exporting public key
}

function wc_ed448_export_private_only

int wc_ed448_export_private_only(
    ed448_key * key,
    byte * out,
    word32 * outLen
)

This function exports only the private key from an ed448_key structure. It stores the private key in the buffer out, and sets the bytes written to this buffer in outLen.

Parameters:

  • key Pointer to an ed448_key structure from which to export the private key.
  • out Pointer to the buffer in which to store the private key.
  • outLen Pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the private key.

See:

Return:

  • 0 Returned upon successfully exporting the private key.
  • ECC_BAD_ARG_E Returned if any of the input values evaluate to NULL.
  • BUFFER_E Returned if the buffer provided is not large enough to store the private key.

Example

int ret;
ed448_key key;
// initialize key, make key

char priv[57]; // 57 bytes because only private key
word32 privSz = sizeof(priv);
ret = wc_ed448_export_private_only(&key, priv, &privSz);
if (ret != 0) {
    // error exporting private key
}

function wc_ed448_export_private

int wc_ed448_export_private(
    ed448_key * key,
    byte * out,
    word32 * outLen
)

This function exports the key pair from an ed448_key structure. It stores the key pair in the buffer out, and sets the bytes written to this buffer in outLen.

Parameters:

  • key Pointer to an ed448_key structure from which to export the key pair.
  • out Pointer to the buffer in which to store the key pair.
  • outLen Pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the key pair.

See:

Return:

  • 0 Returned upon successfully exporting the key pair.
  • ECC_BAD_ARG_E Returned if any of the input values evaluate to NULL.
  • BUFFER_E Returned if the buffer provided is not large enough to store the key pair.

Example

ed448_key key;
wc_ed448_init(&key);

WC_RNG rng;
wc_InitRng(&rng);

wc_ed448_make_key(&rng, 57, &key); // initialize 57 byte Ed448 key

byte out[114]; // out needs to be a sufficient buffer size
word32 outLen = sizeof(out);
int key_size = wc_ed448_export_private(&key, out, &outLen);
if (key_size == BUFFER_E) {
    // Check size of out compared to outLen to see if function reset outLen
}

function wc_ed448_export_key

int wc_ed448_export_key(
    ed448_key * key,
    byte * priv,
    word32 * privSz,
    byte * pub,
    word32 * pubSz
)

This function exports the private and public key separately from an ed448_key structure. It stores the private key in the buffer priv, and sets the bytes written to this buffer in privSz. It stores the public key in the buffer pub, and sets the bytes written to this buffer in pubSz.

Parameters:

  • key Pointer to an ed448_key structure from which to export the key pair.
  • priv Pointer to the buffer in which to store the private key.
  • privSz Pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the private key.
  • pub Pointer to the buffer in which to store the public key.
  • pubSz Pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the public key.

See:

Return:

  • 0 Returned upon successfully exporting the key pair.
  • ECC_BAD_ARG_E Returned if any of the input values evaluate to NULL.
  • BUFFER_E Returned if the buffer provided is not large enough to store the key pair.

Example

int ret;
ed448_key key;
// initialize key, make key

char pub[57];
word32 pubSz = sizeof(pub);
char priv[57];
word32 privSz = sizeof(priv);

ret = wc_ed448_export_key(&key, priv, &pubSz, pub, &pubSz);
if (ret != 0) {
    // error exporting private and public key
}

function wc_ed448_check_key

int wc_ed448_check_key(
    ed448_key * key
)

This function checks the public key in ed448_key structure matches the private key.

Parameters:

  • key Pointer to an ed448_key structure holding a private and public key.

See: wc_ed448_import_private_key

Return:

  • 0 Returned if the private and public key matched.
  • BAD_FUNC_ARGS Returned if the given key is NULL.

Example

int ret;
byte priv[] = { initialize with 57 byte private key };
byte pub[]  = { initialize with the corresponding public key };

ed448_key key;
wc_ed448_init_key(&key);
wc_ed448_import_private_key(priv, sizeof(priv), pub, sizeof(pub), &key);
ret = wc_ed448_check_key(&key);
if (ret != 0) {
    // error checking key
}

function wc_ed448_size

int wc_ed448_size(
    ed448_key * key
)

This function returns the size of an Ed448 private key - 57 bytes.

Parameters:

  • key Pointer to an ed448_key structure for which to get the key size.

See: wc_ed448_make_key

Return:

  • ED448_KEY_SIZE The size of a valid private key (57 bytes).
  • BAD_FUNC_ARGS Returned if the given key is NULL.

Example

int keySz;
ed448_key key;
// initialize key, make key
keySz = wc_ed448_size(&key);
if (keySz == 0) {
    // error determining key size
}

function wc_ed448_priv_size

int wc_ed448_priv_size(
    ed448_key * key
)

This function returns the private key size (secret + public) in bytes.

Parameters:

  • key Pointer to an ed448_key structure for which to get the key size.

See: wc_ed448_pub_size

Return:

  • ED448_PRV_KEY_SIZE The size of the private key (114 bytes).
  • BAD_FUNC_ARG Returns if key argument is NULL.

Example

ed448_key key;
wc_ed448_init(&key);

WC_RNG rng;
wc_InitRng(&rng);

wc_ed448_make_key(&rng, 57, &key); // initialize 57 byte Ed448 key
int key_size = wc_ed448_priv_size(&key);

function wc_ed448_pub_size

int wc_ed448_pub_size(
    ed448_key * key
)

This function returns the compressed key size in bytes (public key).

Parameters:

  • key Pointer to an ed448_key structure for which to get the key size.

See: wc_ed448_priv_size

Return:

  • ED448_PUB_KEY_SIZE The size of the compressed public key (57 bytes).
  • BAD_FUNC_ARG Returns if key argument is NULL.

Example

ed448_key key;
wc_ed448_init(&key);
WC_RNG rng;
wc_InitRng(&rng);

wc_ed448_make_key(&rng, 57, &key); // initialize 57 byte Ed448 key
int key_size = wc_ed448_pub_size(&key);

function wc_ed448_sig_size

int wc_ed448_sig_size(
    ed448_key * key
)

This function returns the size of an Ed448 signature (114 in bytes).

Parameters:

  • key Pointer to an ed448_key structure for which to get the signature size.

See: wc_ed448_sign_msg

Return:

  • ED448_SIG_SIZE The size of an Ed448 signature (114 bytes).
  • BAD_FUNC_ARG Returns if key argument is NULL.

Example

int sigSz;
ed448_key key;
// initialize key, make key

sigSz = wc_ed448_sig_size(&key);
if (sigSz == 0) {
    // error determining sig size
}

Source code


int wc_ed448_make_public(ed448_key* key, unsigned char* pubKey,
                         word32 pubKeySz);

int wc_ed448_make_key(WC_RNG* rng, int keysize, ed448_key* key);

int wc_ed448_sign_msg(const byte* in, word32 inlen, byte* out,
                        word32 *outlen, ed448_key* key);

int wc_ed448ph_sign_hash(const byte* hash, word32 hashLen, byte* out,
                         word32 *outLen, ed448_key* key,
                         const byte* context, byte contextLen);

int wc_ed448ph_sign_msg(const byte* in, word32 inLen, byte* out,
                        word32 *outLen, ed448_key* key, const byte* context,
                        byte contextLen);

int wc_ed448_verify_msg(const byte* sig, word32 siglen, const byte* msg,
                          word32 msgLen, int* res, ed448_key* key,
                          const byte* context, byte contextLen);

int wc_ed448ph_verify_hash(const byte* sig, word32 siglen, const byte* hash,
                          word32 hashlen, int* res, ed448_key* key,
                          const byte* context, byte contextLen);

int wc_ed448ph_verify_msg(const byte* sig, word32 siglen, const byte* msg,
                          word32 msgLen, int* res, ed448_key* key,
                          const byte* context, byte contextLen);

int wc_ed448_init(ed448_key* key);

void wc_ed448_free(ed448_key* key);

int wc_ed448_import_public(const byte* in, word32 inLen, ed448_key* key);

int wc_ed448_import_private_only(const byte* priv, word32 privSz,
                                 ed448_key* key);

int wc_ed448_import_private_key(const byte* priv, word32 privSz,
                               const byte* pub, word32 pubSz, ed448_key* key);

int wc_ed448_export_public(ed448_key* key, byte* out, word32* outLen);

int wc_ed448_export_private_only(ed448_key* key, byte* out, word32* outLen);

int wc_ed448_export_private(ed448_key* key, byte* out, word32* outLen);

int wc_ed448_export_key(ed448_key* key,
                          byte* priv, word32 *privSz,
                          byte* pub, word32 *pubSz);

int wc_ed448_check_key(ed448_key* key);


int wc_ed448_size(ed448_key* key);

int wc_ed448_priv_size(ed448_key* key);

int wc_ed448_pub_size(ed448_key* key);

int wc_ed448_sig_size(ed448_key* key);

Updated on 2022-06-25 at 08:30:56 +0000