1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6   @file ed25519_make_key.c
7   Create an Ed25519 key, Steffen Jaeckel
8 */
9 
10 #ifdef LTC_CURVE25519
11 
12 /**
13    Create an Ed25519 key
14    @param prng     An active PRNG state
15    @param wprng    The index of the PRNG desired
16    @param key      [out] Destination of a newly created private key pair
17    @return CRYPT_OK if successful
18 */
ed25519_make_key(prng_state * prng,int wprng,curve25519_key * key)19 int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
20 {
21    int err;
22 
23    LTC_ARGCHK(key  != NULL);
24 
25    if ((err = tweetnacl_crypto_sign_keypair(prng, wprng, key->pub, key->priv)) != CRYPT_OK) {
26       return err;
27    }
28 
29    key->type = PK_PRIVATE;
30    key->algo = LTC_OID_ED25519;
31 
32    return err;
33 }
34 
35 #endif
36