Skip to content

Commit 3540fd7

Browse files
committed
fixup x25519_import()
bring x25519_import() in line with its ed25519 counterpart
1 parent 25410c7 commit 3540fd7

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

src/pk/ed25519/ed25519_import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/**
1212
@file ed25519_import.c
13-
Import a Ed25519 key from a binary packet, Steffen Jaeckel
13+
Import a Ed25519 key from a SubjectPublicKeyInfo, Steffen Jaeckel
1414
*/
1515

1616
#ifdef LTC_CURVE25519

src/pk/x25519/x25519_import.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
/**
1212
@file x25519_import.c
13-
Import a X25519 key from a binary packet, Steffen Jaeckel
13+
Import a X25519 key from a SubjectPublicKeyInfo, Steffen Jaeckel
1414
*/
1515

1616
#ifdef LTC_CURVE25519
1717

1818
/**
19-
Import a X25519 key from a binary packet
19+
Import a X25519 key
2020
@param in The packet to read
2121
@param inlen The length of the input packet
2222
@param key [out] Where to import the key to
@@ -30,16 +30,6 @@ int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *
3030
LTC_ARGCHK(in != NULL);
3131
LTC_ARGCHK(key != NULL);
3232

33-
/* There's only one case where the inlen is equal to the pubkey-size
34-
* and that's a raw pubkey, so let's just do a raw import.
35-
*/
36-
if (inlen == sizeof(key->pub)) {
37-
XMEMCPY(key->pub, in, sizeof(key->pub));
38-
key->type = PK_PUBLIC;
39-
key->algo = PKA_X25519;
40-
return CRYPT_OK;
41-
}
42-
4333
key_len = sizeof(key->pub);
4434
if ((err = x509_decode_subject_public_key_info(in, inlen, PKA_X25519, key->pub, &key_len, LTC_ASN1_EOL, NULL, 0uL)) == CRYPT_OK) {
4535
key->type = PK_PUBLIC;

tests/x25519_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static int _x25519_compat_test(void)
199199

200200
buflen = sizeof(buf);
201201
DO(x25519_export(buf, &buflen, PK_PUBLIC, &priv));
202-
DO(x25519_import(buf, buflen, &pub));
202+
DO(x25519_set_key(NULL, 0, buf, buflen, &pub));
203203

204204
buflen = sizeof(buf);
205205
DO(x25519_export(buf, &buflen, PK_PUBLIC | PK_STD, &priv));

0 commit comments

Comments
 (0)