blob: ddbbd54bf15c4dfdb3f8034f459bd638e199a88b (
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
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
#include "tomcrypt_private.h"
/**
@file x25519_import.c
Import a X25519 key from a SubjectPublicKeyInfo, Steffen Jaeckel
*/
#ifdef LTC_CURVE25519
/**
Import a X25519 key
@param in The packet to read
@param inlen The length of the input packet
@param key [out] Where to import the key to
@return CRYPT_OK if successful, on error all allocated memory is freed automatically
*/
int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key)
{
int err;
unsigned long key_len;
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(key != NULL);
key_len = sizeof(key->pub);
if ((err = x509_decode_subject_public_key_info(in, inlen, PKA_X25519, key->pub, &key_len, LTC_ASN1_EOL, NULL, 0uL)) == CRYPT_OK) {
key->type = PK_PUBLIC;
key->algo = PKA_X25519;
}
return err;
}
#endif
|