summaryrefslogtreecommitdiff
path: root/src/ltc/pk/ed25519/ed25519_make_key.c
blob: 5d81e5ac8f7e7eb24995e96d5bc7d3413fc4e65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
#include "tomcrypt_private.h"

/**
  @file ed25519_make_key.c
  Create an Ed25519 key, Steffen Jaeckel
*/

#ifdef LTC_CURVE25519

/**
   Create an Ed25519 key
   @param prng     An active PRNG state
   @param wprng    The index of the PRNG desired
   @param key      [out] Destination of a newly created private key pair
   @return CRYPT_OK if successful
*/
int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
{
   int err;

   LTC_ARGCHK(prng != NULL);
   LTC_ARGCHK(key  != NULL);

   if ((err = tweetnacl_crypto_sign_keypair(prng, wprng, key->pub, key->priv)) != CRYPT_OK) {
      return err;
   }

   key->type = PK_PRIVATE;
   key->algo = PKA_ED25519;

   return err;
}

#endif