Browse Source

Merge pull request #503 from libtom/fix-502

Replace (ed|x)25519_set_key by (ed|x)25519_import_raw
Steffen Jaeckel 6 years ago
parent
commit
0c30412a66

+ 12 - 21
doc/crypt.tex

@@ -5747,24 +5747,19 @@ int x25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
 \end{verbatim}
 \end{verbatim}
 
 
 To generate a fresh X25529 key, one can use \textit{x25519\_make\_key} which will create a private\&public key-pair.
 To generate a fresh X25529 key, one can use \textit{x25519\_make\_key} which will create a private\&public key-pair.
-
-\index{x25519\_set\_key}
+\index{x25519\_import}
 \begin{verbatim}
 \begin{verbatim}
-int x25519_set_key(const unsigned char *k,  unsigned long klen,
-                   const unsigned char *u,  unsigned long ulen,
-                        curve25519_key *key);
+int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 \end{verbatim}
 \end{verbatim}
 
 
-To import a public or private key in raw format, one can use the function \textit{x25519\_set\_key}.
-In case both, the secret part \textit{k} and the public part \textit{u} are given, the operation validates that the given 
-public part fits to the secret part.
+The \textit{x25519\_import} function can be used to import a public key in DER-encoded \textit{SubjectPublicKeyInfo} format.
 
 
-\index{x25519\_import}
+\index{x25519\_import\_raw}
 \begin{verbatim}
 \begin{verbatim}
-int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
+int x25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key);
 \end{verbatim}
 \end{verbatim}
 
 
-The \textit{x25519\_import} function can be used to import a public key in DER-encoded \textit{SubjectPublicKeyInfo} format.
+To import a public or private key in raw format, one can use the function \textit{x25519\_import\_raw}.
 
 
 \index{x25519\_import\_x509}
 \index{x25519\_import\_x509}
 \begin{verbatim}
 \begin{verbatim}
@@ -5836,23 +5831,19 @@ int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
 
 
 To generate a fresh Ed25529 key, one can use \textit{ed25519\_make\_key} which will create a private\&public key-pair.
 To generate a fresh Ed25529 key, one can use \textit{ed25519\_make\_key} which will create a private\&public key-pair.
 
 
-\index{ed25519\_set\_key}
+\index{ed25519\_import}
 \begin{verbatim}
 \begin{verbatim}
-int ed25519_set_key(const unsigned char *sk, unsigned long sklen,
-                    const unsigned char *pk, unsigned long pklen,
-                         curve25519_key *key);
+int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 \end{verbatim}
 \end{verbatim}
 
 
-To import a public or private key in raw format, one can use the function \textit{ed25519\_set\_key}.
-In case both, the secret part \textit{sk} and the public part \textit{pk} are given, the operation validates that the given 
-public part fits to the secret part.
+The \textit{ed25519\_import} function can be used to import a public key in DER-encoded \textit{SubjectPublicKeyInfo} format.
 
 
-\index{ed25519\_import}
+\index{ed25519\_import\_raw}
 \begin{verbatim}
 \begin{verbatim}
-int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
+int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key);
 \end{verbatim}
 \end{verbatim}
 
 
-The \textit{ed25519\_import} function can be used to import a public key in DER-encoded \textit{SubjectPublicKeyInfo} format.
+To import a public or private key in raw format, one can use the function \textit{ed25519\_import\_raw}.
 
 
 \index{ed25519\_import\_x509}
 \index{ed25519\_import\_x509}
 \begin{verbatim}
 \begin{verbatim}

+ 6 - 6
libtomcrypt_VS2008.vcproj

@@ -2511,15 +2511,15 @@
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
-					RelativePath="src\pk\ed25519\ed25519_import_x509.c"
+					RelativePath="src\pk\ed25519\ed25519_import_raw.c"
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
-					RelativePath="src\pk\ed25519\ed25519_make_key.c"
+					RelativePath="src\pk\ed25519\ed25519_import_x509.c"
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
-					RelativePath="src\pk\ed25519\ed25519_set_key.c"
+					RelativePath="src\pk\ed25519\ed25519_make_key.c"
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
@@ -2647,15 +2647,15 @@
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
-					RelativePath="src\pk\x25519\x25519_import_x509.c"
+					RelativePath="src\pk\x25519\x25519_import_raw.c"
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
-					RelativePath="src\pk\x25519\x25519_make_key.c"
+					RelativePath="src\pk\x25519\x25519_import_x509.c"
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File
-					RelativePath="src\pk\x25519\x25519_set_key.c"
+					RelativePath="src\pk\x25519\x25519_make_key.c"
 					>
 					>
 				</File>
 				</File>
 				<File
 				<File

+ 19 - 19
makefile.mingw

@@ -194,8 +194,8 @@ src/pk/ecc/ltc_ecc_is_point_at_infinity.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/lt
 src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
 src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
 src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
 src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
 src/pk/ecc/ltc_ecc_verify_key.o src/pk/ed25519/ed25519_export.o src/pk/ed25519/ed25519_import.o \
 src/pk/ecc/ltc_ecc_verify_key.o src/pk/ed25519/ed25519_export.o src/pk/ed25519/ed25519_import.o \
-src/pk/ed25519/ed25519_import_pkcs8.o src/pk/ed25519/ed25519_import_x509.o \
-src/pk/ed25519/ed25519_make_key.o src/pk/ed25519/ed25519_set_key.o src/pk/ed25519/ed25519_sign.o \
+src/pk/ed25519/ed25519_import_pkcs8.o src/pk/ed25519/ed25519_import_raw.o \
+src/pk/ed25519/ed25519_import_x509.o src/pk/ed25519/ed25519_make_key.o src/pk/ed25519/ed25519_sign.o \
 src/pk/ed25519/ed25519_verify.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
 src/pk/ed25519/ed25519_verify.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
 src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
 src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
 src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
 src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
@@ -204,23 +204,23 @@ src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_get_size.o src/p
 src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o src/pk/rsa/rsa_key.o \
 src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o src/pk/rsa/rsa_key.o \
 src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
 src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
 src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/pk/x25519/x25519_export.o \
 src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/pk/x25519/x25519_export.o \
-src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/x25519_import_x509.o \
-src/pk/x25519/x25519_make_key.o src/pk/x25519/x25519_set_key.o src/pk/x25519/x25519_shared_secret.o \
-src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o src/prngs/rng_get_bytes.o \
-src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o src/prngs/yarrow.o \
-src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o src/stream/chacha/chacha_ivctr32.o \
-src/stream/chacha/chacha_ivctr64.o src/stream/chacha/chacha_keystream.o \
-src/stream/chacha/chacha_memory.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \
-src/stream/rabbit/rabbit.o src/stream/rabbit/rabbit_memory.o src/stream/rc4/rc4_stream.o \
-src/stream/rc4/rc4_stream_memory.o src/stream/rc4/rc4_test.o src/stream/salsa20/salsa20_crypt.o \
-src/stream/salsa20/salsa20_done.o src/stream/salsa20/salsa20_ivctr64.o \
-src/stream/salsa20/salsa20_keystream.o src/stream/salsa20/salsa20_memory.o \
-src/stream/salsa20/salsa20_setup.o src/stream/salsa20/salsa20_test.o \
-src/stream/salsa20/xsalsa20_memory.o src/stream/salsa20/xsalsa20_setup.o \
-src/stream/salsa20/xsalsa20_test.o src/stream/sober128/sober128_stream.o \
-src/stream/sober128/sober128_stream_memory.o src/stream/sober128/sober128_test.o \
-src/stream/sosemanuk/sosemanuk.o src/stream/sosemanuk/sosemanuk_memory.o \
-src/stream/sosemanuk/sosemanuk_test.o
+src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/x25519_import_raw.o \
+src/pk/x25519/x25519_import_x509.o src/pk/x25519/x25519_make_key.o \
+src/pk/x25519/x25519_shared_secret.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \
+src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \
+src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
+src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
+src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_memory.o \
+src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o src/stream/rabbit/rabbit.o \
+src/stream/rabbit/rabbit_memory.o src/stream/rc4/rc4_stream.o src/stream/rc4/rc4_stream_memory.o \
+src/stream/rc4/rc4_test.o src/stream/salsa20/salsa20_crypt.o src/stream/salsa20/salsa20_done.o \
+src/stream/salsa20/salsa20_ivctr64.o src/stream/salsa20/salsa20_keystream.o \
+src/stream/salsa20/salsa20_memory.o src/stream/salsa20/salsa20_setup.o \
+src/stream/salsa20/salsa20_test.o src/stream/salsa20/xsalsa20_memory.o \
+src/stream/salsa20/xsalsa20_setup.o src/stream/salsa20/xsalsa20_test.o \
+src/stream/sober128/sober128_stream.o src/stream/sober128/sober128_stream_memory.o \
+src/stream/sober128/sober128_test.o src/stream/sosemanuk/sosemanuk.o \
+src/stream/sosemanuk/sosemanuk_memory.o src/stream/sosemanuk/sosemanuk_test.o
 
 
 #List of test objects to compile
 #List of test objects to compile
 TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \
 TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \

+ 19 - 19
makefile.msvc

@@ -187,8 +187,8 @@ src/pk/ecc/ltc_ecc_is_point_at_infinity.obj src/pk/ecc/ltc_ecc_map.obj src/pk/ec
 src/pk/ecc/ltc_ecc_mulmod.obj src/pk/ecc/ltc_ecc_mulmod_timing.obj src/pk/ecc/ltc_ecc_points.obj \
 src/pk/ecc/ltc_ecc_mulmod.obj src/pk/ecc/ltc_ecc_mulmod_timing.obj src/pk/ecc/ltc_ecc_points.obj \
 src/pk/ecc/ltc_ecc_projective_add_point.obj src/pk/ecc/ltc_ecc_projective_dbl_point.obj \
 src/pk/ecc/ltc_ecc_projective_add_point.obj src/pk/ecc/ltc_ecc_projective_dbl_point.obj \
 src/pk/ecc/ltc_ecc_verify_key.obj src/pk/ed25519/ed25519_export.obj src/pk/ed25519/ed25519_import.obj \
 src/pk/ecc/ltc_ecc_verify_key.obj src/pk/ed25519/ed25519_export.obj src/pk/ed25519/ed25519_import.obj \
-src/pk/ed25519/ed25519_import_pkcs8.obj src/pk/ed25519/ed25519_import_x509.obj \
-src/pk/ed25519/ed25519_make_key.obj src/pk/ed25519/ed25519_set_key.obj src/pk/ed25519/ed25519_sign.obj \
+src/pk/ed25519/ed25519_import_pkcs8.obj src/pk/ed25519/ed25519_import_raw.obj \
+src/pk/ed25519/ed25519_import_x509.obj src/pk/ed25519/ed25519_make_key.obj src/pk/ed25519/ed25519_sign.obj \
 src/pk/ed25519/ed25519_verify.obj src/pk/pkcs1/pkcs_1_i2osp.obj src/pk/pkcs1/pkcs_1_mgf1.obj \
 src/pk/ed25519/ed25519_verify.obj src/pk/pkcs1/pkcs_1_i2osp.obj src/pk/pkcs1/pkcs_1_mgf1.obj \
 src/pk/pkcs1/pkcs_1_oaep_decode.obj src/pk/pkcs1/pkcs_1_oaep_encode.obj src/pk/pkcs1/pkcs_1_os2ip.obj \
 src/pk/pkcs1/pkcs_1_oaep_decode.obj src/pk/pkcs1/pkcs_1_oaep_encode.obj src/pk/pkcs1/pkcs_1_os2ip.obj \
 src/pk/pkcs1/pkcs_1_pss_decode.obj src/pk/pkcs1/pkcs_1_pss_encode.obj src/pk/pkcs1/pkcs_1_v1_5_decode.obj \
 src/pk/pkcs1/pkcs_1_pss_decode.obj src/pk/pkcs1/pkcs_1_pss_encode.obj src/pk/pkcs1/pkcs_1_v1_5_decode.obj \
@@ -197,23 +197,23 @@ src/pk/rsa/rsa_export.obj src/pk/rsa/rsa_exptmod.obj src/pk/rsa/rsa_get_size.obj
 src/pk/rsa/rsa_import_pkcs8.obj src/pk/rsa/rsa_import_x509.obj src/pk/rsa/rsa_key.obj \
 src/pk/rsa/rsa_import_pkcs8.obj src/pk/rsa/rsa_import_x509.obj src/pk/rsa/rsa_key.obj \
 src/pk/rsa/rsa_make_key.obj src/pk/rsa/rsa_set.obj src/pk/rsa/rsa_sign_hash.obj \
 src/pk/rsa/rsa_make_key.obj src/pk/rsa/rsa_set.obj src/pk/rsa/rsa_sign_hash.obj \
 src/pk/rsa/rsa_sign_saltlen_get.obj src/pk/rsa/rsa_verify_hash.obj src/pk/x25519/x25519_export.obj \
 src/pk/rsa/rsa_sign_saltlen_get.obj src/pk/rsa/rsa_verify_hash.obj src/pk/x25519/x25519_export.obj \
-src/pk/x25519/x25519_import.obj src/pk/x25519/x25519_import_pkcs8.obj src/pk/x25519/x25519_import_x509.obj \
-src/pk/x25519/x25519_make_key.obj src/pk/x25519/x25519_set_key.obj src/pk/x25519/x25519_shared_secret.obj \
-src/prngs/chacha20.obj src/prngs/fortuna.obj src/prngs/rc4.obj src/prngs/rng_get_bytes.obj \
-src/prngs/rng_make_prng.obj src/prngs/sober128.obj src/prngs/sprng.obj src/prngs/yarrow.obj \
-src/stream/chacha/chacha_crypt.obj src/stream/chacha/chacha_done.obj src/stream/chacha/chacha_ivctr32.obj \
-src/stream/chacha/chacha_ivctr64.obj src/stream/chacha/chacha_keystream.obj \
-src/stream/chacha/chacha_memory.obj src/stream/chacha/chacha_setup.obj src/stream/chacha/chacha_test.obj \
-src/stream/rabbit/rabbit.obj src/stream/rabbit/rabbit_memory.obj src/stream/rc4/rc4_stream.obj \
-src/stream/rc4/rc4_stream_memory.obj src/stream/rc4/rc4_test.obj src/stream/salsa20/salsa20_crypt.obj \
-src/stream/salsa20/salsa20_done.obj src/stream/salsa20/salsa20_ivctr64.obj \
-src/stream/salsa20/salsa20_keystream.obj src/stream/salsa20/salsa20_memory.obj \
-src/stream/salsa20/salsa20_setup.obj src/stream/salsa20/salsa20_test.obj \
-src/stream/salsa20/xsalsa20_memory.obj src/stream/salsa20/xsalsa20_setup.obj \
-src/stream/salsa20/xsalsa20_test.obj src/stream/sober128/sober128_stream.obj \
-src/stream/sober128/sober128_stream_memory.obj src/stream/sober128/sober128_test.obj \
-src/stream/sosemanuk/sosemanuk.obj src/stream/sosemanuk/sosemanuk_memory.obj \
-src/stream/sosemanuk/sosemanuk_test.obj
+src/pk/x25519/x25519_import.obj src/pk/x25519/x25519_import_pkcs8.obj src/pk/x25519/x25519_import_raw.obj \
+src/pk/x25519/x25519_import_x509.obj src/pk/x25519/x25519_make_key.obj \
+src/pk/x25519/x25519_shared_secret.obj src/prngs/chacha20.obj src/prngs/fortuna.obj src/prngs/rc4.obj \
+src/prngs/rng_get_bytes.obj src/prngs/rng_make_prng.obj src/prngs/sober128.obj src/prngs/sprng.obj \
+src/prngs/yarrow.obj src/stream/chacha/chacha_crypt.obj src/stream/chacha/chacha_done.obj \
+src/stream/chacha/chacha_ivctr32.obj src/stream/chacha/chacha_ivctr64.obj \
+src/stream/chacha/chacha_keystream.obj src/stream/chacha/chacha_memory.obj \
+src/stream/chacha/chacha_setup.obj src/stream/chacha/chacha_test.obj src/stream/rabbit/rabbit.obj \
+src/stream/rabbit/rabbit_memory.obj src/stream/rc4/rc4_stream.obj src/stream/rc4/rc4_stream_memory.obj \
+src/stream/rc4/rc4_test.obj src/stream/salsa20/salsa20_crypt.obj src/stream/salsa20/salsa20_done.obj \
+src/stream/salsa20/salsa20_ivctr64.obj src/stream/salsa20/salsa20_keystream.obj \
+src/stream/salsa20/salsa20_memory.obj src/stream/salsa20/salsa20_setup.obj \
+src/stream/salsa20/salsa20_test.obj src/stream/salsa20/xsalsa20_memory.obj \
+src/stream/salsa20/xsalsa20_setup.obj src/stream/salsa20/xsalsa20_test.obj \
+src/stream/sober128/sober128_stream.obj src/stream/sober128/sober128_stream_memory.obj \
+src/stream/sober128/sober128_test.obj src/stream/sosemanuk/sosemanuk.obj \
+src/stream/sosemanuk/sosemanuk_memory.obj src/stream/sosemanuk/sosemanuk_test.obj
 
 
 #List of test objects to compile
 #List of test objects to compile
 TOBJECTS=tests/base16_test.obj tests/base32_test.obj tests/base64_test.obj tests/bcrypt_test.obj \
 TOBJECTS=tests/base16_test.obj tests/base32_test.obj tests/base64_test.obj tests/bcrypt_test.obj \

+ 19 - 19
makefile.unix

@@ -204,8 +204,8 @@ src/pk/ecc/ltc_ecc_is_point_at_infinity.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/lt
 src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
 src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
 src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
 src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
 src/pk/ecc/ltc_ecc_verify_key.o src/pk/ed25519/ed25519_export.o src/pk/ed25519/ed25519_import.o \
 src/pk/ecc/ltc_ecc_verify_key.o src/pk/ed25519/ed25519_export.o src/pk/ed25519/ed25519_import.o \
-src/pk/ed25519/ed25519_import_pkcs8.o src/pk/ed25519/ed25519_import_x509.o \
-src/pk/ed25519/ed25519_make_key.o src/pk/ed25519/ed25519_set_key.o src/pk/ed25519/ed25519_sign.o \
+src/pk/ed25519/ed25519_import_pkcs8.o src/pk/ed25519/ed25519_import_raw.o \
+src/pk/ed25519/ed25519_import_x509.o src/pk/ed25519/ed25519_make_key.o src/pk/ed25519/ed25519_sign.o \
 src/pk/ed25519/ed25519_verify.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
 src/pk/ed25519/ed25519_verify.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
 src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
 src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
 src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
 src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
@@ -214,23 +214,23 @@ src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_get_size.o src/p
 src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o src/pk/rsa/rsa_key.o \
 src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o src/pk/rsa/rsa_key.o \
 src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
 src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
 src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/pk/x25519/x25519_export.o \
 src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/pk/x25519/x25519_export.o \
-src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/x25519_import_x509.o \
-src/pk/x25519/x25519_make_key.o src/pk/x25519/x25519_set_key.o src/pk/x25519/x25519_shared_secret.o \
-src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o src/prngs/rng_get_bytes.o \
-src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o src/prngs/yarrow.o \
-src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o src/stream/chacha/chacha_ivctr32.o \
-src/stream/chacha/chacha_ivctr64.o src/stream/chacha/chacha_keystream.o \
-src/stream/chacha/chacha_memory.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \
-src/stream/rabbit/rabbit.o src/stream/rabbit/rabbit_memory.o src/stream/rc4/rc4_stream.o \
-src/stream/rc4/rc4_stream_memory.o src/stream/rc4/rc4_test.o src/stream/salsa20/salsa20_crypt.o \
-src/stream/salsa20/salsa20_done.o src/stream/salsa20/salsa20_ivctr64.o \
-src/stream/salsa20/salsa20_keystream.o src/stream/salsa20/salsa20_memory.o \
-src/stream/salsa20/salsa20_setup.o src/stream/salsa20/salsa20_test.o \
-src/stream/salsa20/xsalsa20_memory.o src/stream/salsa20/xsalsa20_setup.o \
-src/stream/salsa20/xsalsa20_test.o src/stream/sober128/sober128_stream.o \
-src/stream/sober128/sober128_stream_memory.o src/stream/sober128/sober128_test.o \
-src/stream/sosemanuk/sosemanuk.o src/stream/sosemanuk/sosemanuk_memory.o \
-src/stream/sosemanuk/sosemanuk_test.o
+src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/x25519_import_raw.o \
+src/pk/x25519/x25519_import_x509.o src/pk/x25519/x25519_make_key.o \
+src/pk/x25519/x25519_shared_secret.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \
+src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \
+src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
+src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
+src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_memory.o \
+src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o src/stream/rabbit/rabbit.o \
+src/stream/rabbit/rabbit_memory.o src/stream/rc4/rc4_stream.o src/stream/rc4/rc4_stream_memory.o \
+src/stream/rc4/rc4_test.o src/stream/salsa20/salsa20_crypt.o src/stream/salsa20/salsa20_done.o \
+src/stream/salsa20/salsa20_ivctr64.o src/stream/salsa20/salsa20_keystream.o \
+src/stream/salsa20/salsa20_memory.o src/stream/salsa20/salsa20_setup.o \
+src/stream/salsa20/salsa20_test.o src/stream/salsa20/xsalsa20_memory.o \
+src/stream/salsa20/xsalsa20_setup.o src/stream/salsa20/xsalsa20_test.o \
+src/stream/sober128/sober128_stream.o src/stream/sober128/sober128_stream_memory.o \
+src/stream/sober128/sober128_test.o src/stream/sosemanuk/sosemanuk.o \
+src/stream/sosemanuk/sosemanuk_memory.o src/stream/sosemanuk/sosemanuk_test.o
 
 
 #List of test objects to compile (all goes to libtomcrypt_prof.a)
 #List of test objects to compile (all goes to libtomcrypt_prof.a)
 TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \
 TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \

+ 19 - 19
makefile_include.mk

@@ -365,8 +365,8 @@ src/pk/ecc/ltc_ecc_is_point_at_infinity.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/lt
 src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
 src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
 src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
 src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
 src/pk/ecc/ltc_ecc_verify_key.o src/pk/ed25519/ed25519_export.o src/pk/ed25519/ed25519_import.o \
 src/pk/ecc/ltc_ecc_verify_key.o src/pk/ed25519/ed25519_export.o src/pk/ed25519/ed25519_import.o \
-src/pk/ed25519/ed25519_import_pkcs8.o src/pk/ed25519/ed25519_import_x509.o \
-src/pk/ed25519/ed25519_make_key.o src/pk/ed25519/ed25519_set_key.o src/pk/ed25519/ed25519_sign.o \
+src/pk/ed25519/ed25519_import_pkcs8.o src/pk/ed25519/ed25519_import_raw.o \
+src/pk/ed25519/ed25519_import_x509.o src/pk/ed25519/ed25519_make_key.o src/pk/ed25519/ed25519_sign.o \
 src/pk/ed25519/ed25519_verify.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
 src/pk/ed25519/ed25519_verify.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
 src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
 src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
 src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
 src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
@@ -375,23 +375,23 @@ src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_get_size.o src/p
 src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o src/pk/rsa/rsa_key.o \
 src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o src/pk/rsa/rsa_key.o \
 src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
 src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
 src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/pk/x25519/x25519_export.o \
 src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/pk/x25519/x25519_export.o \
-src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/x25519_import_x509.o \
-src/pk/x25519/x25519_make_key.o src/pk/x25519/x25519_set_key.o src/pk/x25519/x25519_shared_secret.o \
-src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o src/prngs/rng_get_bytes.o \
-src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o src/prngs/yarrow.o \
-src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o src/stream/chacha/chacha_ivctr32.o \
-src/stream/chacha/chacha_ivctr64.o src/stream/chacha/chacha_keystream.o \
-src/stream/chacha/chacha_memory.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \
-src/stream/rabbit/rabbit.o src/stream/rabbit/rabbit_memory.o src/stream/rc4/rc4_stream.o \
-src/stream/rc4/rc4_stream_memory.o src/stream/rc4/rc4_test.o src/stream/salsa20/salsa20_crypt.o \
-src/stream/salsa20/salsa20_done.o src/stream/salsa20/salsa20_ivctr64.o \
-src/stream/salsa20/salsa20_keystream.o src/stream/salsa20/salsa20_memory.o \
-src/stream/salsa20/salsa20_setup.o src/stream/salsa20/salsa20_test.o \
-src/stream/salsa20/xsalsa20_memory.o src/stream/salsa20/xsalsa20_setup.o \
-src/stream/salsa20/xsalsa20_test.o src/stream/sober128/sober128_stream.o \
-src/stream/sober128/sober128_stream_memory.o src/stream/sober128/sober128_test.o \
-src/stream/sosemanuk/sosemanuk.o src/stream/sosemanuk/sosemanuk_memory.o \
-src/stream/sosemanuk/sosemanuk_test.o
+src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/x25519_import_raw.o \
+src/pk/x25519/x25519_import_x509.o src/pk/x25519/x25519_make_key.o \
+src/pk/x25519/x25519_shared_secret.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \
+src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \
+src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
+src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
+src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_memory.o \
+src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o src/stream/rabbit/rabbit.o \
+src/stream/rabbit/rabbit_memory.o src/stream/rc4/rc4_stream.o src/stream/rc4/rc4_stream_memory.o \
+src/stream/rc4/rc4_test.o src/stream/salsa20/salsa20_crypt.o src/stream/salsa20/salsa20_done.o \
+src/stream/salsa20/salsa20_ivctr64.o src/stream/salsa20/salsa20_keystream.o \
+src/stream/salsa20/salsa20_memory.o src/stream/salsa20/salsa20_setup.o \
+src/stream/salsa20/salsa20_test.o src/stream/salsa20/xsalsa20_memory.o \
+src/stream/salsa20/xsalsa20_setup.o src/stream/salsa20/xsalsa20_test.o \
+src/stream/sober128/sober128_stream.o src/stream/sober128/sober128_stream_memory.o \
+src/stream/sober128/sober128_test.o src/stream/sosemanuk/sosemanuk.o \
+src/stream/sosemanuk/sosemanuk_memory.o src/stream/sosemanuk/sosemanuk_test.o
 
 
 # List of test objects to compile (all goes to libtomcrypt_prof.a)
 # List of test objects to compile (all goes to libtomcrypt_prof.a)
 TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \
 TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \

+ 2 - 8
src/headers/tomcrypt_pk.h

@@ -349,15 +349,12 @@ typedef struct {
 /** Ed25519 Signature API */
 /** Ed25519 Signature API */
 int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
 int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
 
 
-int ed25519_set_key(const unsigned char *sk, unsigned long sklen,
-                    const unsigned char *pk, unsigned long pklen,
-                         curve25519_key *key);
-
 int ed25519_export(       unsigned char *out, unsigned long *outlen,
 int ed25519_export(       unsigned char *out, unsigned long *outlen,
                                     int  which,
                                     int  which,
                    const curve25519_key *key);
                    const curve25519_key *key);
 
 
 int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
+int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key);
 int ed25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 int ed25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 int ed25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
 int ed25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
                                   const void *pwd, unsigned long pwdlen,
                                   const void *pwd, unsigned long pwdlen,
@@ -374,15 +371,12 @@ int ed25519_verify(const  unsigned char *msg, unsigned long msglen,
 /** X25519 Key-Exchange API */
 /** X25519 Key-Exchange API */
 int x25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
 int x25519_make_key(prng_state *prng, int wprng, curve25519_key *key);
 
 
-int x25519_set_key(const unsigned char *k,  unsigned long klen,
-                   const unsigned char *u,  unsigned long ulen,
-                        curve25519_key *key);
-
 int x25519_export(       unsigned char *out, unsigned long *outlen,
 int x25519_export(       unsigned char *out, unsigned long *outlen,
                                    int  which,
                                    int  which,
                   const curve25519_key *key);
                   const curve25519_key *key);
 
 
 int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *key);
+int x25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key);
 int x25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 int x25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_key *key);
 int x25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
 int x25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
                                  const void *pwd, unsigned long pwdlen,
                                  const void *pwd, unsigned long pwdlen,

+ 1 - 1
src/pk/ed25519/ed25519_import.c

@@ -10,7 +10,7 @@
 
 
 /**
 /**
   @file ed25519_import.c
   @file ed25519_import.c
-  Import a Ed25519 key from a binary packet, Steffen Jaeckel
+  Import a Ed25519 key from a SubjectPublicKeyInfo, Steffen Jaeckel
 */
 */
 
 
 #ifdef LTC_CURVE25519
 #ifdef LTC_CURVE25519

+ 51 - 0
src/pk/ed25519/ed25519_import_raw.c

@@ -0,0 +1,51 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+#include "tomcrypt_private.h"
+
+/**
+  @file ed25519_import_raw.c
+  Set the parameters of an Ed25519 key, Steffen Jaeckel
+*/
+
+#ifdef LTC_CURVE25519
+
+/**
+   Set the parameters of an Ed25519 key
+
+   @param in       The key
+   @param inlen    The length of the key
+   @param which    Which type of key (PK_PRIVATE or PK_PUBLIC)
+   @param key      [out] Destination of the key
+   @return CRYPT_OK if successful
+*/
+int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key)
+{
+   LTC_ARGCHK(in   != NULL);
+   LTC_ARGCHK(inlen == 32uL);
+   LTC_ARGCHK(key  != NULL);
+
+   if (which == PK_PRIVATE) {
+      XMEMCPY(key->priv, in, sizeof(key->priv));
+      tweetnacl_crypto_sk_to_pk(key->pub, key->priv);
+   } else if (which == PK_PUBLIC) {
+      XMEMCPY(key->pub, in, sizeof(key->pub));
+   } else {
+      return CRYPT_INVALID_ARG;
+   }
+   key->algo = PKA_ED25519;
+   key->type = which;
+
+   return CRYPT_OK;
+}
+
+#endif
+
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */

+ 0 - 65
src/pk/ed25519/ed25519_set_key.c

@@ -1,65 +0,0 @@
-/* LibTomCrypt, modular cryptographic library -- Tom St Denis
- *
- * LibTomCrypt is a library that provides various cryptographic
- * algorithms in a highly modular and flexible manner.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- */
-#include "tomcrypt_private.h"
-
-/**
-  @file ed25519_set_ku.c
-  Set the parameters of an Ed25519 key, Steffen Jaeckel
-*/
-
-#ifdef LTC_CURVE25519
-
-/**
-   Set the parameters of an Ed25519 key
-
-   In case sk and pk are given it is validated that pk is really the
-   corresponding public part of the key pair.
-
-   @param sk       The secret key
-   @param sklen    The length of sk
-   @param pk       The public key
-   @param pklen    The length of pk
-   @param key      [out] Destination of the key
-   @return CRYPT_OK if successful
-*/
-int ed25519_set_key(const unsigned char *sk, unsigned long sklen,
-                    const unsigned char *pk, unsigned long pklen,
-                         curve25519_key *key)
-{
-   LTC_ARGCHK(key != NULL);
-
-   if (sk != NULL) {
-      LTC_ARGCHK(sklen == 32uL);
-      XMEMCPY(key->priv, sk, sizeof(key->priv));
-      tweetnacl_crypto_sk_to_pk(key->pub, key->priv);
-      if (pk != NULL) {
-         LTC_ARGCHK(pklen == 32uL);
-         if (XMEM_NEQ(pk, key->pub, sizeof(key->pub)) != 0) {
-            zeromem(key, sizeof(*key));
-            return CRYPT_INVALID_ARG;
-         }
-      }
-      key->type = PK_PRIVATE;
-   } else if (pk != NULL) {
-      LTC_ARGCHK(pklen == 32uL);
-      XMEMCPY(key->pub, pk, sizeof(key->pub));
-      key->type = PK_PUBLIC;
-   } else {
-      return CRYPT_INVALID_ARG;
-   }
-   key->algo = PKA_ED25519;
-
-   return CRYPT_OK;
-}
-
-#endif
-
-/* ref:         $Format:%D$ */
-/* git commit:  $Format:%H$ */
-/* commit time: $Format:%ai$ */

+ 2 - 12
src/pk/x25519/x25519_import.c

@@ -10,13 +10,13 @@
 
 
 /**
 /**
   @file x25519_import.c
   @file x25519_import.c
-  Import a X25519 key from a binary packet, Steffen Jaeckel
+  Import a X25519 key from a SubjectPublicKeyInfo, Steffen Jaeckel
 */
 */
 
 
 #ifdef LTC_CURVE25519
 #ifdef LTC_CURVE25519
 
 
 /**
 /**
-  Import a X25519 key from a binary packet
+  Import a X25519 key
   @param in     The packet to read
   @param in     The packet to read
   @param inlen  The length of the input packet
   @param inlen  The length of the input packet
   @param key    [out] Where to import the key to
   @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 *
    LTC_ARGCHK(in  != NULL);
    LTC_ARGCHK(in  != NULL);
    LTC_ARGCHK(key != NULL);
    LTC_ARGCHK(key != NULL);
 
 
-   /* There's only one case where the inlen is equal to the pubkey-size
-    * and that's a raw pubkey, so let's just do a raw import.
-    */
-   if (inlen == sizeof(key->pub)) {
-      XMEMCPY(key->pub, in, sizeof(key->pub));
-      key->type = PK_PUBLIC;
-      key->algo = PKA_X25519;
-      return CRYPT_OK;
-   }
-
    key_len = sizeof(key->pub);
    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) {
    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->type = PK_PUBLIC;

+ 51 - 0
src/pk/x25519/x25519_import_raw.c

@@ -0,0 +1,51 @@
+/* LibTomCrypt, modular cryptographic library -- Tom St Denis
+ *
+ * LibTomCrypt is a library that provides various cryptographic
+ * algorithms in a highly modular and flexible manner.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ */
+#include "tomcrypt_private.h"
+
+/**
+  @file x25519_import_raw.c
+  Set the parameters of a X25519 key, Steffen Jaeckel
+*/
+
+#ifdef LTC_CURVE25519
+
+/**
+   Set the parameters of a X25519 key
+
+   @param in       The key
+   @param inlen    The length of the key
+   @param which    Which type of key (PK_PRIVATE or PK_PUBLIC)
+   @param key      [out] Destination of the key
+   @return CRYPT_OK if successful
+*/
+int x25519_import_raw(const unsigned char *in, unsigned long inlen, int which, curve25519_key *key)
+{
+   LTC_ARGCHK(in   != NULL);
+   LTC_ARGCHK(inlen == 32uL);
+   LTC_ARGCHK(key  != NULL);
+
+   if (which == PK_PRIVATE) {
+      XMEMCPY(key->priv, in, sizeof(key->priv));
+      tweetnacl_crypto_scalarmult_base(key->pub, key->priv);
+   } else if (which == PK_PUBLIC) {
+      XMEMCPY(key->pub, in, sizeof(key->pub));
+   } else {
+      return CRYPT_INVALID_ARG;
+   }
+   key->algo = PKA_X25519;
+   key->type = which;
+
+   return CRYPT_OK;
+}
+
+#endif
+
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */

+ 0 - 65
src/pk/x25519/x25519_set_key.c

@@ -1,65 +0,0 @@
-/* LibTomCrypt, modular cryptographic library -- Tom St Denis
- *
- * LibTomCrypt is a library that provides various cryptographic
- * algorithms in a highly modular and flexible manner.
- *
- * The library is free for all purposes without any express
- * guarantee it works.
- */
-#include "tomcrypt_private.h"
-
-/**
-  @file x25519_set_ku.c
-  Set the parameters of a X25519 key, Steffen Jaeckel
-*/
-
-#ifdef LTC_CURVE25519
-
-/**
-   Set the parameters of a X25519 key
-
-   In case k and u are given it is validated that u is really the
-   corresponding public part of the key pair
-
-   @param k        The k value (a.k.a scalar or private part)
-   @param klen     The length of k
-   @param u        The u-coordinate (a.k.a public part)
-   @param ulen     The length of u
-   @param key      [out] Destination of the key
-   @return CRYPT_OK if successful
-*/
-int x25519_set_key(const unsigned char *k, unsigned long klen,
-                   const unsigned char *u, unsigned long ulen,
-                        curve25519_key *key)
-{
-   LTC_ARGCHK(key != NULL);
-
-   if (k != NULL) {
-      LTC_ARGCHK(klen == 32uL);
-      XMEMCPY(key->priv, k, sizeof(key->priv));
-      tweetnacl_crypto_scalarmult_base(key->pub, key->priv);
-      if (u != NULL) {
-         LTC_ARGCHK(ulen == 32uL);
-         if (XMEM_NEQ(u, key->pub, sizeof(key->pub)) != 0) {
-            zeromem(key, sizeof(*key));
-            return CRYPT_INVALID_ARG;
-         }
-      }
-      key->type = PK_PRIVATE;
-   } else if (u != NULL) {
-      LTC_ARGCHK(ulen == 32uL);
-      XMEMCPY(key->pub, u, sizeof(key->pub));
-      key->type = PK_PUBLIC;
-   } else {
-      return CRYPT_INVALID_ARG;
-   }
-   key->algo = PKA_X25519;
-
-   return CRYPT_OK;
-}
-
-#endif
-
-/* ref:         $Format:%D$ */
-/* git commit:  $Format:%H$ */
-/* commit time: $Format:%ai$ */

+ 2 - 2
tests/ed25519_test.c

@@ -201,7 +201,7 @@ static int _rfc_8032_7_1_test(void)
       DO(base16_decode(rfc_8032_7_1[n].message, XSTRLEN(rfc_8032_7_1[n].message), msg, &mlen));
       DO(base16_decode(rfc_8032_7_1[n].message, XSTRLEN(rfc_8032_7_1[n].message), msg, &mlen));
       siglen = sizeof(sig);
       siglen = sizeof(sig);
       DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
       DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
-      DO(ed25519_set_key(sec, slen, pub, plen, &key));
+      DO(ed25519_import_raw(sec, slen, PK_PRIVATE, &key));
       buflen = sizeof(buf);
       buflen = sizeof(buf);
       DO(ed25519_sign(msg, mlen, buf, &buflen, &key));
       DO(ed25519_sign(msg, mlen, buf, &buflen, &key));
       DO(do_compare_testvector(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.1 - sign", n));
       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)
       DO(base16_decode(rfc_8032_7_1[n].message, XSTRLEN(rfc_8032_7_1[n].message), msg, &mlen));
       DO(base16_decode(rfc_8032_7_1[n].message, XSTRLEN(rfc_8032_7_1[n].message), msg, &mlen));
       siglen = sizeof(sig);
       siglen = sizeof(sig);
       DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
       DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
-      DO(ed25519_set_key(NULL, 0, pub, plen, &key2));
+      DO(ed25519_import_raw(pub, plen, PK_PUBLIC, &key2));
       DO(ed25519_verify(msg, mlen, sig, siglen, &ret, &key2));
       DO(ed25519_verify(msg, mlen, sig, siglen, &ret, &key2));
       DO(do_compare_testvector(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ pubkey", n));
       DO(do_compare_testvector(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ pubkey", n));
 
 

+ 5 - 5
tests/x25519_test.c

@@ -101,10 +101,10 @@ static int _rfc_7748_6_test(void)
    unsigned char buf[32];
    unsigned char buf[32];
    unsigned long buflen = sizeof(buf);
    unsigned long buflen = sizeof(buf);
 
 
-   DO(x25519_set_key(alice_private, sizeof(alice_private), alice_public, sizeof(alice_public), &alice_priv));
-   DO(x25519_set_key(bob_private, sizeof(bob_private), bob_public, sizeof(bob_public), &bob_priv));
-   DO(x25519_set_key(NULL, 0, alice_public, sizeof(alice_public), &alice_pub));
-   DO(x25519_set_key(NULL, 0, bob_public, sizeof(bob_public), &bob_pub));
+   DO(x25519_import_raw(alice_private, sizeof(alice_private), PK_PRIVATE, &alice_priv));
+   DO(x25519_import_raw(bob_private, sizeof(bob_private), PK_PRIVATE, &bob_priv));
+   DO(x25519_import_raw(alice_public, sizeof(alice_public), PK_PUBLIC, &alice_pub));
+   DO(x25519_import_raw(bob_public, sizeof(bob_public), PK_PUBLIC, &bob_pub));
 
 
    DO(x25519_shared_secret(&alice_priv, &bob_pub, buf, &buflen));
    DO(x25519_shared_secret(&alice_priv, &bob_pub, buf, &buflen));
    DO(compare_testvector(buf, buflen, shared_secret, sizeof(shared_secret), "x25519 - RFC 7748 Ch. 6", 0));
    DO(compare_testvector(buf, buflen, shared_secret, sizeof(shared_secret), "x25519 - RFC 7748 Ch. 6", 0));
@@ -199,7 +199,7 @@ static int _x25519_compat_test(void)
 
 
    buflen = sizeof(buf);
    buflen = sizeof(buf);
    DO(x25519_export(buf, &buflen, PK_PUBLIC, &priv));
    DO(x25519_export(buf, &buflen, PK_PUBLIC, &priv));
-   DO(x25519_import(buf, buflen, &pub));
+   DO(x25519_import_raw(buf, buflen, PK_PUBLIC, &pub));
 
 
    buflen = sizeof(buf);
    buflen = sizeof(buf);
    DO(x25519_export(buf, &buflen, PK_PUBLIC | PK_STD, &priv));
    DO(x25519_export(buf, &buflen, PK_PUBLIC | PK_STD, &priv));