1 // SPDX-License-Identifier: BSD-2-Clause
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3  *
4  * LibTomCrypt is a library that provides various cryptographic
5  * algorithms in a highly modular and flexible manner.
6  *
7  * The library is free for all purposes without any express
8  * guarantee it works.
9  */
10 #include "tomcrypt_private.h"
11 
12 /**
13   @file x25519_export.c
14   Export a X25519 key to a binary packet, Steffen Jaeckel
15 */
16 
17 #ifdef LTC_CURVE25519
18 
19 /**
20    Export a X25519 key to a binary packet
21    @param out    [out] The destination for the key
22    @param outlen [in/out] The max size and resulting size of the X25519 key
23    @param type   Which type of key (PK_PRIVATE, PK_PUBLIC|PK_STD or PK_PUBLIC)
24    @param key    The key you wish to export
25    @return CRYPT_OK if successful
26 */
x25519_export(unsigned char * out,unsigned long * outlen,int which,const curve25519_key * key)27 int x25519_export(      unsigned char *out, unsigned long *outlen,
28                                   int  which,
29                   const    curve25519_key *key)
30 {
31    LTC_ARGCHK(key != NULL);
32 
33    if (key->algo != PKA_X25519) return CRYPT_PK_INVALID_TYPE;
34 
35    return ec25519_export(out, outlen, which, key);
36 }
37 
38 #endif
39 
40 /* ref:         $Format:%D$ */
41 /* git commit:  $Format:%H$ */
42 /* commit time: $Format:%ai$ */
43