| 1 |
|
| 2 |
|
| 3 |
#include "tomcrypt_private.h" |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#ifdef LTC_CURVE25519 |
| 11 |
|
| 12 |
static int s_x25519_decode(const unsigned char *in, unsigned long inlen, curve25519_key *key) |
| 13 |
{ |
| 14 |
if (inlen != sizeof(key->pub)) return CRYPT_PK_INVALID_SIZE; |
| 15 |
XMEMCPY(key->pub, in, sizeof(key->pub)); |
| 16 |
return CRYPT_OK; |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
int x25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_key *key) |
| 27 |
{ |
| 28 |
int err; |
| 29 |
|
| 30 |
LTC_ARGCHK(in != NULL); |
| 31 |
LTC_ARGCHK(key != NULL); |
| 32 |
|
| 33 |
if ((err = x509_decode_public_key_from_certificate(in, inlen, |
| 34 |
LTC_OID_X25519, |
| 35 |
LTC_ASN1_EOL, NULL, NULL, |
| 36 |
(public_key_decode_cb)s_x25519_decode, key)) != CRYPT_OK) { |
| 37 |
return err; |
| 38 |
} |
| 39 |
key->type = PK_PUBLIC; |
| 40 |
key->pka = LTC_PKA_X25519; |
| 41 |
|
| 42 |
return err; |
| 43 |
} |
| 44 |
|
| 45 |
#endif |