Browse Source

rename x25519_set_ku() to x25519_set_key()

Steffen Jaeckel 6 years ago
parent
commit
8ea0fb1195
3 changed files with 17 additions and 19 deletions
  1. 10 12
      src/headers/tomcrypt_pk.h
  2. 3 3
      src/pk/x25519/x25519_set_key.c
  3. 4 4
      tests/x25519_test.c

+ 10 - 12
src/headers/tomcrypt_pk.h

@@ -346,21 +346,20 @@ typedef struct {
 } curve25519_key;
 } curve25519_key;
 
 
 
 
-/* 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_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_set_key(const unsigned char *sk, unsigned long sklen,
-                    const unsigned char *pk, unsigned long pklen,
-                         curve25519_key *key);
-
 int ed25519_sign(const unsigned char  *msg, unsigned long msglen,
 int ed25519_sign(const unsigned char  *msg, unsigned long msglen,
                        unsigned char  *sig, unsigned long *siglen,
                        unsigned char  *sig, unsigned long *siglen,
                  const curve25519_key *private_key);
                  const curve25519_key *private_key);
@@ -369,21 +368,20 @@ int ed25519_verify(const  unsigned char *msg, unsigned long msglen,
                    const  unsigned char *sig, unsigned long siglen,
                    const  unsigned char *sig, unsigned long siglen,
                    int *stat, const curve25519_key *public_key);
                    int *stat, const curve25519_key *public_key);
 
 
-/* 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_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_set_ku(const unsigned char *k,  unsigned long klen,
-                  const unsigned char *u,  unsigned long ulen,
-                       curve25519_key *key);
-
 int x25519_shared_secret(const curve25519_key *private_key,
 int x25519_shared_secret(const curve25519_key *private_key,
                          const curve25519_key *public_key,
                          const curve25519_key *public_key,
                                 unsigned char *out, unsigned long *outlen);
                                 unsigned char *out, unsigned long *outlen);

+ 3 - 3
src/pk/x25519/x25519_set_ku.c → src/pk/x25519/x25519_set_key.c

@@ -28,9 +28,9 @@
    @param key      [out] Destination of the key
    @param key      [out] Destination of the key
    @return CRYPT_OK if successful
    @return CRYPT_OK if successful
 */
 */
-int x25519_set_ku(const unsigned char *k, unsigned long klen,
-                  const unsigned char *u, unsigned long ulen,
-                           curve25519_key *key)
+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);
    LTC_ARGCHK(key != NULL);
 
 

+ 4 - 4
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_ku(alice_private, sizeof(alice_private), alice_public, sizeof(alice_public), &alice_priv));
-   DO(x25519_set_ku(bob_private, sizeof(bob_private), bob_public, sizeof(bob_public), &bob_priv));
-   DO(x25519_set_ku(NULL, 0, alice_public, sizeof(alice_public), &alice_pub));
-   DO(x25519_set_ku(NULL, 0, bob_public, sizeof(bob_public), &bob_pub));
+   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_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));