CURVE25519_SIZE
{ GROUP_CURVE25519, 31, CURVE25519_SIZE * 8 },
CURVE25519_SIZE) * 8 }
uint8_t secret[CURVE25519_SIZE];
uint8_t public[CURVE25519_SIZE];
static const uint8_t basepoint[CURVE25519_SIZE] = { 9 };
arc4random_buf(curve25519->secret, CURVE25519_SIZE);
extern int crypto_scalarmult_curve25519(unsigned char a[CURVE25519_SIZE],
return (CURVE25519_SIZE);
const unsigned char b[CURVE25519_SIZE],
const unsigned char c[CURVE25519_SIZE])
__attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 3, CURVE25519_SIZE)));
CURVE25519_SIZE;
CURVE25519_SIZE;
CURVE25519_SIZE;
memcpy(cp, curve25519->public, CURVE25519_SIZE);
uint8_t shared[CURVE25519_SIZE];
CURVE25519_SIZE;
CURVE25519_SIZE;
u_char c25519_client_key[CURVE25519_SIZE]; /* 25519 + KEM */
u_char c25519_client_pubkey[CURVE25519_SIZE]; /* 25519 */
void kexc25519_keygen(u_char key[CURVE25519_SIZE], u_char pub[CURVE25519_SIZE])
__attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)));
int kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
const u_char pub[CURVE25519_SIZE], struct sshbuf *out)
__attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)));
int kexc25519_shared_key_ext(const u_char key[CURVE25519_SIZE],
const u_char pub[CURVE25519_SIZE], struct sshbuf *out, int)
__attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)));
dump_digest("client public key c25519:", cp, CURVE25519_SIZE);
u_char server_key[CURVE25519_SIZE];
if (sshbuf_len(client_blob) != CURVE25519_SIZE) {
dump_digest("client public key 25519:", client_pub, CURVE25519_SIZE);
if ((r = sshbuf_reserve(server_blob, CURVE25519_SIZE, &server_pub)) != 0)
dump_digest("server public key 25519:", server_pub, CURVE25519_SIZE);
if (sshbuf_len(server_blob) != CURVE25519_SIZE) {
dump_digest("server public key c25519:", server_pub, CURVE25519_SIZE);
extern int crypto_scalarmult_curve25519(u_char a[CURVE25519_SIZE],
const u_char b[CURVE25519_SIZE], const u_char c[CURVE25519_SIZE])
__attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)))
__attribute__((__bounded__(__minbytes__, 3, CURVE25519_SIZE)));
kexc25519_keygen(u_char key[CURVE25519_SIZE], u_char pub[CURVE25519_SIZE])
static const u_char basepoint[CURVE25519_SIZE] = {9};
arc4random_buf(key, CURVE25519_SIZE);
kexc25519_shared_key_ext(const u_char key[CURVE25519_SIZE],
const u_char pub[CURVE25519_SIZE], struct sshbuf *out, int raw)
u_char shared_key[CURVE25519_SIZE];
u_char zero[CURVE25519_SIZE];
explicit_bzero(zero, CURVE25519_SIZE);
if (timingsafe_bcmp(zero, shared_key, CURVE25519_SIZE) == 0)
dump_digest("shared secret 25519", shared_key, CURVE25519_SIZE);
r = sshbuf_put(out, shared_key, CURVE25519_SIZE);
r = sshbuf_put_bignum2_bytes(out, shared_key, CURVE25519_SIZE);
explicit_bzero(shared_key, CURVE25519_SIZE);
kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
const u_char pub[CURVE25519_SIZE], struct sshbuf *out)
if ((r = sshbuf_reserve(buf, CURVE25519_SIZE, &cp)) != 0)
need = crypto_kem_mlkem768_PUBLICKEYBYTES + CURVE25519_SIZE;
CURVE25519_SIZE);
dump_digest("server public key 25519:", server_pub, CURVE25519_SIZE);
need = crypto_kem_mlkem768_CIPHERTEXTBYTES + CURVE25519_SIZE;
dump_digest("server public key c25519:", server_pub, CURVE25519_SIZE);
need = crypto_kem_mlkem768_PUBLICKEYBYTES + CURVE25519_SIZE;
dump_digest("client public key c25519:", cp, CURVE25519_SIZE);
u_char server_pub[CURVE25519_SIZE], server_key[CURVE25519_SIZE];
CURVE25519_SIZE);
need = crypto_kem_sntrup761_CIPHERTEXTBYTES + CURVE25519_SIZE;
dump_digest("server public key 25519:", server_pub, CURVE25519_SIZE);
need = crypto_kem_sntrup761_CIPHERTEXTBYTES + CURVE25519_SIZE;
dump_digest("server public key c25519:", server_pub, CURVE25519_SIZE);
need = crypto_kem_sntrup761_PUBLICKEYBYTES + CURVE25519_SIZE;
dump_digest("client public key c25519:", cp, CURVE25519_SIZE);
u_char server_key[CURVE25519_SIZE];
need = crypto_kem_sntrup761_PUBLICKEYBYTES + CURVE25519_SIZE;