n_ecc regression: X25519 agreement + Ed25519 sign/verify round-trips.
n_ecc regression: X25519 agreement + Ed25519 sign/verify round-trips.
#include <stdio.h>
#include <string.h>
#if !N_ECC_AVAILABLE
n_log(
LOG_NOTICE,
"ex_ecc: skipped, this OpenSSL does not provide X25519/Ed25519");
return 0;
#else
}
}
const unsigned char msg[] = "the quick brown fox";
size_t mlen = sizeof(msg) - 1;
} else {
}
sig[0] ^= 0x01;
n_log(
LOG_ERR,
"ed25519 verify accepted a tampered signature");
}
sig[0] ^= 0x01;
unsigned char m2[sizeof(msg) - 1];
memcpy(m2, msg, mlen);
m2[0] ^= 0x01;
n_log(
LOG_ERR,
"ed25519 verify accepted a tampered message");
}
}
return 1;
}
return 0;
#endif
}
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL ).
#define LOG_NOTICE
normal but significant condition
int n_ed25519_keypair(unsigned char *priv, unsigned char *pub)
generate an Ed25519 keypair as N_ECC_KEY_LEN-byte raw private and public keys.
int n_ed25519_verify(const unsigned char *pub, const unsigned char *msg, size_t len, const unsigned char *sig)
Ed25519 verify the N_ECC_SIG_LEN-byte sig over len bytes of msg under the N_ECC_KEY_LEN-byte raw publ...
int n_x25519_keypair(unsigned char *priv, unsigned char *pub)
generate an X25519 keypair as N_ECC_KEY_LEN-byte raw private and public keys.
#define N_ECC_SIG_LEN
Ed25519 signature length in bytes.
#define N_ECC_KEY_LEN
raw X25519/Ed25519 key length in bytes
int n_ed25519_sign(const unsigned char *priv, const unsigned char *msg, size_t len, unsigned char *sig)
Ed25519 sign len bytes of msg with the N_ECC_KEY_LEN-byte raw private key into sig (N_ECC_SIG_LEN byt...
int n_x25519_derive(const unsigned char *priv, const unsigned char *peer_pub, unsigned char *shared)
X25519 ECDH: derive the N_ECC_KEY_LEN-byte shared secret from our raw private key and the peer's raw ...
Curve25519 primitives: X25519 key agreement and Ed25519 signatures.