Skip to content

Commit 44a1834

Browse files
committed
rename ed25519_set_key to ed25519_import_raw
1 parent 3540fd7 commit 44a1834

File tree

4 files changed

+54
-71
lines changed

4 files changed

+54
-71
lines changed

src/headers/tomcrypt_pk.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,12 @@ typedef struct {
349349
/** Ed25519 Signature API */
350350
int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
351351

352-
int ed25519_set_key(const unsigned char *sk, unsigned long sklen,
353-
const unsigned char *pk, unsigned long pklen,
354-
curve25519_key *key);
355-
356352
int ed25519_export( unsigned char *out, unsigned long *outlen,
357353
int which,
358354
const curve25519_key *key);
359355

360356
int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
357+
int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key);
361358
int ed25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_key *key);
362359
int ed25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
363360
const void *pwd, unsigned long pwdlen,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2+
*
3+
* LibTomCrypt is a library that provides various cryptographic
4+
* algorithms in a highly modular and flexible manner.
5+
*
6+
* The library is free for all purposes without any express
7+
* guarantee it works.
8+
*/
9+
#include "tomcrypt_private.h"
10+
11+
/**
12+
@file ed25519_import_raw.c
13+
Set the parameters of an Ed25519 key, Steffen Jaeckel
14+
*/
15+
16+
#ifdef LTC_CURVE25519
17+
18+
/**
19+
Set the parameters of an Ed25519 key
20+
21+
@param in The key
22+
@param inlen The length of the key
23+
@param which Which type of key (PK_PRIVATE or PK_PUBLIC)
24+
@param key [out] Destination of the key
25+
@return CRYPT_OK if successful
26+
*/
27+
int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key)
28+
{
29+
LTC_ARGCHK(in != NULL);
30+
LTC_ARGCHK(inlen == 32uL);
31+
LTC_ARGCHK(key != NULL);
32+
33+
if (which == PK_PRIVATE) {
34+
XMEMCPY(key->priv, in, sizeof(key->priv));
35+
tweetnacl_crypto_sk_to_pk(key->pub, key->priv);
36+
} else if (which == PK_PUBLIC) {
37+
XMEMCPY(key->pub, in, sizeof(key->pub));
38+
} else {
39+
return CRYPT_INVALID_ARG;
40+
}
41+
key->algo = PKA_ED25519;
42+
key->type = which;
43+
44+
return CRYPT_OK;
45+
}
46+
47+
#endif
48+
49+
/* ref: $Format:%D$ */
50+
/* git commit: $Format:%H$ */
51+
/* commit time: $Format:%ai$ */

src/pk/ed25519/ed25519_set_key.c

Lines changed: 0 additions & 65 deletions
This file was deleted.

tests/ed25519_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int _rfc_8032_7_1_test(void)
201201
DO(base16_decode(rfc_8032_7_1[n].message, XSTRLEN(rfc_8032_7_1[n].message), msg, &mlen));
202202
siglen = sizeof(sig);
203203
DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
204-
DO(ed25519_set_key(sec, slen, pub, plen, &key));
204+
DO(ed25519_import_raw(sec, slen, PK_PRIVATE, &key));
205205
buflen = sizeof(buf);
206206
DO(ed25519_sign(msg, mlen, buf, &buflen, &key));
207207
DO(do_compare_testvector(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.1 - sign", n));
@@ -214,7 +214,7 @@ static int _rfc_8032_7_1_test(void)
214214
DO(base16_decode(rfc_8032_7_1[n].message, XSTRLEN(rfc_8032_7_1[n].message), msg, &mlen));
215215
siglen = sizeof(sig);
216216
DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
217-
DO(ed25519_set_key(NULL, 0, pub, plen, &key2));
217+
DO(ed25519_import_raw(pub, plen, PK_PUBLIC, &key2));
218218
DO(ed25519_verify(msg, mlen, sig, siglen, &ret, &key2));
219219
DO(do_compare_testvector(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ pubkey", n));
220220

0 commit comments

Comments
 (0)