From 9da429b4a0cc3b77ce5fdb321e432b42841b566b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Mon, 30 Nov 2020 12:14:40 +0100
Subject: [PATCH] Delete name mangling of internal Camellia symbols

---
 ChangeLog                     |  1 +
 camellia-absorb.c             |  2 +-
 camellia-crypt-internal.c     | 10 +++++-----
 camellia-internal.h           | 22 ++++++++--------------
 camellia-invert-key.c         |  4 ++--
 camellia-table.c              |  2 +-
 camellia128-crypt.c           |  6 +++---
 camellia128-set-decrypt-key.c |  2 +-
 camellia128-set-encrypt-key.c |  2 +-
 camellia256-crypt.c           |  6 +++---
 camellia256-set-decrypt-key.c |  2 +-
 camellia256-set-encrypt-key.c |  2 +-
 12 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 427ad879..adfe5a57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 	* aes-internal.h: Delete name mangling of internal symbols. Update
 	all internal references to use _nettle prefix.
+	* camellia-internal.h: Likewise.
 
 2020-11-26  Niels Möller  <nisse@lysator.liu.se>
 
diff --git a/camellia-absorb.c b/camellia-absorb.c
index d865dc6d..60646dcd 100644
--- a/camellia-absorb.c
+++ b/camellia-absorb.c
@@ -55,7 +55,7 @@
 #include "macros.h"
 
 void
-_camellia_absorb(unsigned nkeys, uint64_t *dst, uint64_t *subkey)
+_nettle_camellia_absorb(unsigned nkeys, uint64_t *dst, uint64_t *subkey)
 {
   uint64_t kw2, kw4;
   uint32_t dw, tl, tr;
diff --git a/camellia-crypt-internal.c b/camellia-crypt-internal.c
index 6e2727b8..1816d768 100644
--- a/camellia-crypt-internal.c
+++ b/camellia-crypt-internal.c
@@ -135,11 +135,11 @@
 #endif
 
 void
-_camellia_crypt(unsigned nkeys,
-		const uint64_t *keys,
-		const struct camellia_table *T,
-		size_t length, uint8_t *dst,
-		const uint8_t *src)
+_nettle_camellia_crypt(unsigned nkeys,
+		       const uint64_t *keys,
+		       const struct camellia_table *T,
+		       size_t length, uint8_t *dst,
+		       const uint8_t *src)
 {
   FOR_BLOCKS(length, dst, src, CAMELLIA_BLOCK_SIZE)
     {
diff --git a/camellia-internal.h b/camellia-internal.h
index e09ef114..3a9b1712 100644
--- a/camellia-internal.h
+++ b/camellia-internal.h
@@ -48,12 +48,6 @@
 
 #include "camellia.h"
 
-/* Name mangling */
-#define _camellia_crypt _nettle_camellia_crypt
-#define _camellia_absorb _nettle_camellia_absorb
-#define _camellia_invert_key _nettle_camellia_invert_key
-#define _camellia_table _nettle_camellia_table
-
 /*
  *  macros
  */
@@ -117,21 +111,21 @@ struct camellia_table
 #endif
 
 void
-_camellia_crypt(unsigned nkeys, const uint64_t *keys,
-		const struct camellia_table *T,
-		size_t length, uint8_t *dst,
-		const uint8_t *src);
+_nettle_camellia_crypt(unsigned nkeys, const uint64_t *keys,
+		       const struct camellia_table *T,
+		       size_t length, uint8_t *dst,
+		       const uint8_t *src);
 
 /* The initial NKEYS + 2 subkeys in SUBKEY are reduced to the final
    NKEYS subkeys stored in DST. SUBKEY data is modified in the
    process. */
 void
-_camellia_absorb(unsigned nkeys, uint64_t *dst, uint64_t *subkey);
+_nettle_camellia_absorb(unsigned nkeys, uint64_t *dst, uint64_t *subkey);
 
 void
-_camellia_invert_key(unsigned nkeys,
-		     uint64_t *dst, const uint64_t *src);
+_nettle_camellia_invert_key(unsigned nkeys,
+			    uint64_t *dst, const uint64_t *src);
 
-extern const struct camellia_table _camellia_table;
+extern const struct camellia_table _nettle_camellia_table;
 
 #endif /* NETTLE_CAMELLIA_INTERNAL_H_INCLUDED */
diff --git a/camellia-invert-key.c b/camellia-invert-key.c
index 2edbfdbd..5461e44e 100644
--- a/camellia-invert-key.c
+++ b/camellia-invert-key.c
@@ -41,8 +41,8 @@
 do { uint64_t t_swap = (a); (a) = (b); (b) = t_swap; } while(0)
 
 void
-_camellia_invert_key(unsigned nkeys,
-		     uint64_t *dst, const uint64_t *src)
+_nettle_camellia_invert_key(unsigned nkeys,
+			    uint64_t *dst, const uint64_t *src)
 {
   unsigned i;
   if (dst == src)
diff --git a/camellia-table.c b/camellia-table.c
index 834ac4dc..2fec93b6 100644
--- a/camellia-table.c
+++ b/camellia-table.c
@@ -49,7 +49,7 @@
 
 #include "camellia-internal.h"
 
-const struct camellia_table _camellia_table = {
+const struct camellia_table _nettle_camellia_table = {
   /* sp1110 */
   {
     0x70707000,0x82828200,0x2c2c2c00,0xececec00,
diff --git a/camellia128-crypt.c b/camellia128-crypt.c
index a9395f26..64bcda61 100644
--- a/camellia128-crypt.c
+++ b/camellia128-crypt.c
@@ -48,7 +48,7 @@ camellia128_crypt(const struct camellia128_ctx *ctx,
 		  const uint8_t *src)
 {
   assert(!(length % CAMELLIA_BLOCK_SIZE) );
-  _camellia_crypt(_CAMELLIA128_NKEYS, ctx->keys,
-		  &_camellia_table,
-		  length, dst, src);
+  _nettle_camellia_crypt(_CAMELLIA128_NKEYS, ctx->keys,
+			 &_nettle_camellia_table,
+			 length, dst, src);
 }
diff --git a/camellia128-set-decrypt-key.c b/camellia128-set-decrypt-key.c
index 96050f62..2e38cf1e 100644
--- a/camellia128-set-decrypt-key.c
+++ b/camellia128-set-decrypt-key.c
@@ -41,7 +41,7 @@ void
 camellia128_invert_key(struct camellia128_ctx *dst,
 		       const struct camellia128_ctx *src)
 {
-  _camellia_invert_key (_CAMELLIA128_NKEYS, dst->keys, src->keys);
+  _nettle_camellia_invert_key (_CAMELLIA128_NKEYS, dst->keys, src->keys);
 }
 
 void
diff --git a/camellia128-set-encrypt-key.c b/camellia128-set-encrypt-key.c
index 66d8a66f..5eccd9b8 100644
--- a/camellia128-set-encrypt-key.c
+++ b/camellia128-set-encrypt-key.c
@@ -120,5 +120,5 @@ camellia128_set_encrypt_key (struct camellia128_ctx *ctx,
   subkey[24] = k0; subkey[25] = k1;
 
   /* Common final processing */
-  _camellia_absorb (_CAMELLIA128_NKEYS, ctx->keys, subkey);
+  _nettle_camellia_absorb (_CAMELLIA128_NKEYS, ctx->keys, subkey);
 }
diff --git a/camellia256-crypt.c b/camellia256-crypt.c
index dc5b11c4..31ba9887 100644
--- a/camellia256-crypt.c
+++ b/camellia256-crypt.c
@@ -48,7 +48,7 @@ camellia256_crypt(const struct camellia256_ctx *ctx,
 		  const uint8_t *src)
 {
   assert(!(length % CAMELLIA_BLOCK_SIZE) );
-  _camellia_crypt(_CAMELLIA256_NKEYS, ctx->keys,
-		  &_camellia_table,
-		  length, dst, src);
+  _nettle_camellia_crypt(_CAMELLIA256_NKEYS, ctx->keys,
+			 &_nettle_camellia_table,
+			 length, dst, src);
 }
diff --git a/camellia256-set-decrypt-key.c b/camellia256-set-decrypt-key.c
index 70da7c5c..1026901d 100644
--- a/camellia256-set-decrypt-key.c
+++ b/camellia256-set-decrypt-key.c
@@ -41,7 +41,7 @@ void
 camellia256_invert_key(struct camellia256_ctx *dst,
 		       const struct camellia256_ctx *src)
 {
-  _camellia_invert_key (_CAMELLIA256_NKEYS, dst->keys, src->keys);
+  _nettle_camellia_invert_key (_CAMELLIA256_NKEYS, dst->keys, src->keys);
 }
 
 void
diff --git a/camellia256-set-encrypt-key.c b/camellia256-set-encrypt-key.c
index 608224e7..4c96e568 100644
--- a/camellia256-set-encrypt-key.c
+++ b/camellia256-set-encrypt-key.c
@@ -139,7 +139,7 @@ _camellia256_set_encrypt_key (struct camellia256_ctx *ctx,
   subkey[32] = k2; subkey[33] = k3;
 
   /* Common final processing */
-  _camellia_absorb (_CAMELLIA256_NKEYS, ctx->keys, subkey);
+  _nettle_camellia_absorb (_CAMELLIA256_NKEYS, ctx->keys, subkey);
 }
 
 void
-- 
GitLab