summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2003-04-12 17:42:20 +0200
committerNiels Möller <nisse@lysator.liu.se>2003-04-12 17:42:20 +0200
commit4fd20960e0ed6712fa89e119bd8c639e303655e1 (patch)
tree853f119938cc410d329e5f33f38bfaa7aac3ed6d
parentb26c392549490d4d593fbdaa88cac0c3dcd3bfd8 (diff)
downloadnettle-4fd20960e0ed6712fa89e119bd8c639e303655e1.tar.gz
* New name mangling, to reduce the risk of link collisions. All
functions (except memxor) now use a nettle_ or _nettle prefix when seen by the linker. For most functions, the header file that declares a function also use #define to provide a shorter more readable name without the prefix. Rev: src/nettle/aes-internal.h:1.9 Rev: src/nettle/aes.h:1.6 Rev: src/nettle/arcfour.h:1.4 Rev: src/nettle/base16.h:1.2 Rev: src/nettle/base64.h:1.12 Rev: src/nettle/blowfish.h:1.8 Rev: src/nettle/cast128.h:1.4 Rev: src/nettle/cbc.h:1.4 Rev: src/nettle/des.h:1.8 Rev: src/nettle/dsa.h:1.7 Rev: src/nettle/hmac.h:1.5 Rev: src/nettle/knuth-lfib.h:1.2 Rev: src/nettle/md5-compat.h:1.2 Rev: src/nettle/md5.h:1.6 Rev: src/nettle/pgp.h:1.2 Rev: src/nettle/pkcs1.h:1.2 Rev: src/nettle/rsa-compat.h:1.3 Rev: src/nettle/rsa.h:1.22 Rev: src/nettle/serpent.h:1.6 Rev: src/nettle/sexp.h:1.15 Rev: src/nettle/sha.h:1.3 Rev: src/nettle/twofish.h:1.5 Rev: src/nettle/yarrow.h:1.10
-rw-r--r--aes-internal.h20
-rw-r--r--aes.h6
-rw-r--r--arcfour.h5
-rw-r--r--base16.h7
-rw-r--r--base64.h11
-rw-r--r--blowfish.h5
-rw-r--r--cast128.h5
-rw-r--r--cbc.h4
-rw-r--r--des.h15
-rw-r--r--dsa.h16
-rw-r--r--hmac.h14
-rw-r--r--knuth-lfib.h6
-rw-r--r--md5-compat.h5
-rw-r--r--md5.h5
-rw-r--r--pgp.h15
-rw-r--r--pkcs1.h7
-rw-r--r--rsa-compat.h8
-rw-r--r--rsa.h25
-rw-r--r--serpent.h5
-rw-r--r--sexp.h17
-rw-r--r--sha.h8
-rw-r--r--twofish.h5
-rw-r--r--yarrow.h11
23 files changed, 210 insertions, 15 deletions
diff --git a/aes-internal.h b/aes-internal.h
index e79c8b9b..2b7f06f7 100644
--- a/aes-internal.h
+++ b/aes-internal.h
@@ -39,6 +39,19 @@
# define AES_TABLE_SIZE 4
#endif
+/* Name mangling */
+#define _aes_crypt _nettle_aes_crypt
+
+/* Assembler code using the table should get link errors if linked
+ * against a small table. */
+#if AES_SMALL
+# define _aes_encrypt_table _nettle_aes_encrypt_table_small
+# define _aes_decrypt_table _nettle_aes_decrypt_table_small
+#else
+# define _aes_encrypt_table _nettle_aes_encrypt_table
+# define _aes_decrypt_table _nettle_aes_decrypt_table
+#endif
+
struct aes_table
{
uint8_t sbox[0x100];
@@ -70,13 +83,6 @@ _aes_crypt(const struct aes_ctx *ctx,
((box)[(((x) >> 16) & 0xff)] << 16) | \
((box)[(((x) >> 24) & 0xff)] << 24))
-/* Assembler code using the table should get link errors when compiled
- * against a small table. */
-#if AES_SMALL
-# define _aes_encrypt_table _aes_encrypt_table_small
-# define _aes_decrypt_table _aes_decrypt_table_small
-#endif
-
/* Internal tables */
extern const struct aes_table _aes_encrypt_table;
extern const struct aes_table _aes_decrypt_table;
diff --git a/aes.h b/aes.h
index b505b0e7..87464cf4 100644
--- a/aes.h
+++ b/aes.h
@@ -28,6 +28,12 @@
#include <inttypes.h>
+/* Name mangling */
+#define aes_set_encrypt_key nettle_aes_set_encrypt_key
+#define aes_set_decrypt_key nettle_aes_set_decrypt_key
+#define aes_encrypt nettle_aes_encrypt
+#define aes_decrypt nettle_aes_decrypt
+
#define AES_BLOCK_SIZE 16
/* Variable key size between 128 and 256 bits. But the only valid
diff --git a/arcfour.h b/arcfour.h
index 54aee479..9499e981 100644
--- a/arcfour.h
+++ b/arcfour.h
@@ -28,6 +28,11 @@
#include <inttypes.h>
+/* Name mangling */
+#define arcfour_set_key nettle_arcfour_set_key
+#define arcfour_crypt nettle_arcfour_crypt
+#define arcfour_stream nettle_arcfour_stream
+
/* Minimum and maximum keysizes, and a reasonable default. In
* octets.*/
#define ARCFOUR_MIN_KEY_SIZE 1
diff --git a/base16.h b/base16.h
index b00bc869..2701725b 100644
--- a/base16.h
+++ b/base16.h
@@ -29,6 +29,13 @@
#include <inttypes.h>
+/* Name mangling */
+#define base16_encode_single nettle_base16_encode_single
+#define base16_encode_update nettle_base16_encode_update
+#define base16_decode_init nettle_base16_decode_init
+#define base16_decode_single nettle_base16_decode_single
+#define base16_decode_update nettle_base16_decode_update
+#define base16_decode_final nettle_base16_decode_final
/* Base16 encoding */
diff --git a/base64.h b/base64.h
index 9532e54f..1e1c7ed5 100644
--- a/base64.h
+++ b/base64.h
@@ -28,6 +28,17 @@
#include <inttypes.h>
+/* Name mangling */
+#define base64_encode_init nettle_base64_encode_init
+#define base64_encode_single nettle_base64_encode_single
+#define base64_encode_update nettle_base64_encode_update
+#define base64_encode_final nettle_base64_encode_final
+#define base64_encode_raw nettle_base64_encode_raw
+#define base64_encode_group nettle_base64_encode_group
+#define base64_decode_init nettle_base64_decode_init
+#define base64_decode_single nettle_base64_decode_single
+#define base64_decode_update nettle_base64_decode_update
+#define base64_decode_final nettle_base64_decode_final
#define BASE64_BINARY_BLOCK_SIZE 3
#define BASE64_TEXT_BLOCK_SIZE 4
diff --git a/blowfish.h b/blowfish.h
index 72934da5..7f7ddcd6 100644
--- a/blowfish.h
+++ b/blowfish.h
@@ -28,6 +28,11 @@
#include <inttypes.h>
+/* Name mangling */
+#define blowfish_set_key nettle_blowfish_set_key
+#define blowfish_encrypt nettle_blowfish_encrypt
+#define blowfish_decrypt nettle_blowfish_decrypt
+
#define BLOWFISH_BLOCK_SIZE 8
/* Variable key size between 64 and 448 bits. */
diff --git a/cast128.h b/cast128.h
index 0d1e044e..39102cbc 100644
--- a/cast128.h
+++ b/cast128.h
@@ -34,6 +34,11 @@
#include <inttypes.h>
+/* Name mangling */
+#define cast128_set_key nettle_cast128_set_key
+#define cast128_encrypt nettle_cast128_encrypt
+#define cast128_decrypt nettle_cast128_decrypt
+
#define CAST128_BLOCK_SIZE 8
/* Variable key size between 40 and 128. */
diff --git a/cbc.h b/cbc.h
index dba52fdd..9428aa55 100644
--- a/cbc.h
+++ b/cbc.h
@@ -28,6 +28,10 @@
#include <inttypes.h>
+/* Name mangling */
+#define cbc_encrypt nettle_cbc_encrypt
+#define cbc_decrypt nettle_cbc_decrypt
+
/* Uses a void * for cipher contexts. */
void
diff --git a/des.h b/des.h
index 9f674736..25168d11 100644
--- a/des.h
+++ b/des.h
@@ -35,15 +35,16 @@
#ifndef NETTLE_DES_H_INCLUDED
#define NETTLE_DES_H_INCLUDED
-/* Namespace mangling.
- *
- * FIXME: In the long run, all nettle symbols should probably have the
- * prefix nettle_, with the appropriate header file defining
- * shorthands. */
+#include <inttypes.h>
+/* Namespace mangling */
#define des_set_key nettle_des_set_key
-
-#include <inttypes.h>
+#define des_encrypt nettle_des_encrypt
+#define des_decrypt nettle_des_decrypt
+#define des_fix_parity nettle_des_fix_parity
+#define des3_set_key nettle_des3_set_key
+#define des3_encrypt nettle_des3_encrypt
+#define des3_decrypt nettle_des3_decrypt
#define DES_KEY_SIZE 8
#define DES_BLOCK_SIZE 8
diff --git a/dsa.h b/dsa.h
index 5214c36a..15de1e1a 100644
--- a/dsa.h
+++ b/dsa.h
@@ -34,6 +34,22 @@
/* For nettle_random_func */
#include "nettle-meta.h"
+/* Name mangling */
+#define dsa_public_key_init nettle_dsa_public_key_init
+#define dsa_public_key_clear nettle_dsa_public_key_clear
+#define dsa_private_key_init nettle_dsa_private_key_init
+#define dsa_private_key_clear nettle_dsa_private_key_clear
+#define dsa_signature_init nettle_dsa_signature_init
+#define dsa_signature_clear nettle_dsa_signature_clear
+#define dsa_sign nettle_dsa_sign
+#define dsa_verify nettle_dsa_verify
+#define dsa_sign_digest nettle_dsa_sign_digest
+#define dsa_verify_digest nettle_dsa_verify_digest
+#define dsa_generate_keypair nettle_dsa_generate_keypair
+#define dsa_signature_from_sexp nettle_dsa_signature_from_sexp
+#define dsa_keypair_from_sexp_alist nettle_dsa_keypair_from_sexp_alist
+#define dsa_keypair_from_sexp nettle_dsa_keypair_from_sexp
+
#define DSA_MIN_P_BITS 512
#define DSA_Q_OCTETS 20
#define DSA_Q_BITS 160
diff --git a/hmac.h b/hmac.h
index cc425ae4..a89fb2ee 100644
--- a/hmac.h
+++ b/hmac.h
@@ -31,7 +31,19 @@
#include "md5.h"
#include "sha.h"
-#include <inttypes.h>
+/* Namespace mangling */
+#define hmac_set_key nettle_hmac_set_key
+#define hmac_update nettle_hmac_update
+#define hmac_digest nettle_hmac_digest
+#define hmac_md5_set_key nettle_hmac_md5_set_key
+#define hmac_md5_update nettle_hmac_md5_update
+#define hmac_md5_digest nettle_hmac_md5_digest
+#define hmac_sha1_set_key nettle_hmac_sha1_set_key
+#define hmac_sha1_update nettle_hmac_sha1_update
+#define hmac_sha1_digest nettle_hmac_sha1_digest
+#define hmac_sha256_set_key nettle_hmac_sha256_set_key
+#define hmac_sha256_update nettle_hmac_sha256_update
+#define hmac_sha256_digest nettle_hmac_sha256_digest
void
hmac_set_key(void *outer, void *inner, void *state,
diff --git a/knuth-lfib.h b/knuth-lfib.h
index 8ca45a71..c8a1f93a 100644
--- a/knuth-lfib.h
+++ b/knuth-lfib.h
@@ -33,6 +33,12 @@
#include <inttypes.h>
+/* Namespace mangling */
+#define knuth_lfib_init nettle_knuth_lfib_init
+#define knuth_lfib_get nettle_knuth_lfib_get
+#define knuth_lfib_get_array nettle_knuth_lfib_get_array
+#define knuth_lfib_random nettle_knuth_lfib_random
+
#define _KNUTH_LFIB_KK 100
struct knuth_lfib_ctx
diff --git a/md5-compat.h b/md5-compat.h
index bb2e768e..32925d09 100644
--- a/md5-compat.h
+++ b/md5-compat.h
@@ -28,6 +28,11 @@
#include "md5.h"
+/* Name mangling */
+#define MD5Init nettle_MD5Init
+#define MD5Update nettle_MD5Update
+#define MD5Final nettle_MD5Final
+
typedef struct md5_ctx MD5_CTX;
void MD5Init(MD5_CTX *ctx);
diff --git a/md5.h b/md5.h
index 0859cb3e..95e42c62 100644
--- a/md5.h
+++ b/md5.h
@@ -28,6 +28,11 @@
#include <inttypes.h>
+/* Name mangling */
+#define md5_init nettle_md5_init
+#define md5_update nettle_md5_update
+#define md5_digest nettle_md5_digest
+
#define MD5_DIGEST_SIZE 16
#define MD5_DATA_SIZE 64
diff --git a/pgp.h b/pgp.h
index b13bafe4..54a02406 100644
--- a/pgp.h
+++ b/pgp.h
@@ -28,6 +28,21 @@
#include "bignum.h"
+/* Name mangling */
+#define pgp_put_uint32 nettle_pgp_put_uint32
+#define pgp_put_uint16 nettle_pgp_put_uint16
+#define pgp_put_mpi nettle_pgp_put_mpi
+#define pgp_put_string nettle_pgp_put_string
+#define pgp_put_length nettle_pgp_put_length
+#define pgp_put_header nettle_pgp_put_header
+#define pgp_put_header_length nettle_pgp_put_header_length
+#define pgp_sub_packet_start nettle_pgp_sub_packet_start
+#define pgp_put_sub_packet nettle_pgp_put_sub_packet
+#define pgp_sub_packet_end nettle_pgp_sub_packet_end
+#define pgp_put_userid nettle_pgp_put_userid
+#define pgp_crc24 nettle_pgp_crc24
+#define pgp_armor nettle_pgp_armor
+
struct nettle_buffer;
int
diff --git a/pkcs1.h b/pkcs1.h
index 3671f801..0db9121f 100644
--- a/pkcs1.h
+++ b/pkcs1.h
@@ -29,6 +29,13 @@
#include <inttypes.h>
#include <gmp.h>
+/* Name mangling */
+#define pkcs1_signature_prefix nettle_pkcs1_signature_prefix
+#define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode
+#define pkcs1_rsa_md5_encode_digest nettle_pkcs1_rsa_md5_encode_digest
+#define pkcs1_rsa_sha1_encode nettle_pkcs1_rsa_sha1_encode
+#define pkcs1_rsa_sha1_encode_digest nettle_pkcs1_rsa_sha1_encode_digest
+
struct md5_ctx;
struct sha1_ctx;
diff --git a/rsa-compat.h b/rsa-compat.h
index ad5c2757..7b40f3cf 100644
--- a/rsa-compat.h
+++ b/rsa-compat.h
@@ -28,6 +28,14 @@
#include "rsa.h"
+/* Name mangling */
+#define R_SignInit nettle_R_SignInit
+#define R_SignUpdate nettle_R_SignUpdate
+#define R_SignFinal nettle_R_SignFinal
+#define R_VerifyInit nettle_R_VerifyInit
+#define R_VerifyUpdate nettle_R_VerifyUpdate
+#define R_VerifyFinal nettle_R_VerifyFinal
+
/* 256 octets or 2048 bits */
#define MAX_RSA_MODULUS_LEN 256
diff --git a/rsa.h b/rsa.h
index dd500557..a924fb2b 100644
--- a/rsa.h
+++ b/rsa.h
@@ -35,6 +35,31 @@
/* For nettle_random_func */
#include "nettle-meta.h"
+/* Name mangling */
+#define rsa_public_key_init nettle_rsa_public_key_init
+#define rsa_public_key_clear nettle_rsa_public_key_clear
+#define rsa_public_key_prepare nettle_rsa_public_key_prepare
+#define rsa_private_key_init nettle_rsa_private_key_init
+#define rsa_private_key_clear nettle_rsa_private_key_clear
+#define rsa_private_key_prepare nettle_rsa_private_key_prepare
+#define rsa_md5_sign nettle_rsa_md5_sign
+#define rsa_md5_verify nettle_rsa_md5_verify
+#define rsa_sha1_sign nettle_rsa_sha1_sign
+#define rsa_sha1_verify nettle_rsa_sha1_verify
+#define rsa_md5_sign_digest nettle_rsa_md5_sign_digest
+#define rsa_md5_verify_digest nettle_rsa_md5_verify_digest
+#define rsa_sha1_sign_digest nettle_rsa_sha1_sign_digest
+#define rsa_sha1_verify_digest nettle_rsa_sha1_verify_digest
+#define rsa_encrypt nettle_rsa_encrypt
+#define rsa_decrypt nettle_rsa_decrypt
+#define rsa_compute_root nettle_rsa_compute_root
+#define rsa_generate_keypair nettle_rsa_generate_keypair
+#define rsa_keypair_to_sexp nettle_rsa_keypair_to_sexp
+#define rsa_keypair_from_sexp_alist nettle_rsa_keypair_from_sexp_alist
+#define rsa_keypair_from_sexp nettle_rsa_keypair_from_sexp
+#define rsa_keypair_to_openpgp nettle_rsa_keypair_to_openpgp
+#define _rsa_verify _nettle_rsa_verify
+#define _rsa_check_size _nettle_rsa_check_size
/* For PKCS#1 to make sense, the size of the modulo, in octets, must
* be at least 11 + the length of the DER-encoded Digest Info.
diff --git a/serpent.h b/serpent.h
index ae8afeb7..79cad0ef 100644
--- a/serpent.h
+++ b/serpent.h
@@ -33,6 +33,11 @@
#include <inttypes.h>
+/* Name mangling */
+#define serpent_set_key nettle_serpent_set_key
+#define serpent_encrypt nettle_serpent_encrypt
+#define serpent_decrypt nettle_serpent_decrypt
+
#define SERPENT_BLOCK_SIZE 16
/* Other key lengths are possible, but the design of Serpent makes
diff --git a/sexp.h b/sexp.h
index 2b72a2be..181cc576 100644
--- a/sexp.h
+++ b/sexp.h
@@ -29,6 +29,23 @@
#include <inttypes.h>
#include <stdarg.h>
+/* Name mangling */
+#define sexp_iterator_first nettle_sexp_iterator_first
+#define sexp_transport_iterator_first nettle_sexp_transport_iterator_first
+#define sexp_iterator_next nettle_sexp_iterator_next
+#define sexp_iterator_enter_list nettle_sexp_iterator_enter_list
+#define sexp_iterator_exit_list nettle_sexp_iterator_exit_list
+#define sexp_iterator_subexpr nettle_sexp_iterator_subexpr
+#define sexp_iterator_get_uint32 nettle_sexp_iterator_get_uint32
+#define sexp_iterator_check_type nettle_sexp_iterator_check_type
+#define sexp_iterator_check_types nettle_sexp_iterator_check_types
+#define sexp_iterator_assoc nettle_sexp_iterator_assoc
+#define sexp_format nettle_sexp_format
+#define sexp_vformat nettle_sexp_vformat
+#define sexp_transport_format nettle_sexp_transport_format
+#define sexp_transport_vformat nettle_sexp_transport_vformat
+#define sexp_token_chars nettle_sexp_token_chars
+
enum sexp_type
{ SEXP_ATOM, SEXP_LIST, SEXP_END };
diff --git a/sha.h b/sha.h
index f9eb69bd..134de1d5 100644
--- a/sha.h
+++ b/sha.h
@@ -28,6 +28,14 @@
#include <inttypes.h>
+/* Name mangling */
+#define sha1_init nettle_sha1_init
+#define sha1_update nettle_sha1_update
+#define sha1_digest nettle_sha1_digest
+#define sha256_init nettle_sha256_init
+#define sha256_update nettle_sha256_update
+#define sha256_digest nettle_sha256_digest
+
/* SHA1 */
#define SHA1_DIGEST_SIZE 20
diff --git a/twofish.h b/twofish.h
index a33554c5..3d007d7a 100644
--- a/twofish.h
+++ b/twofish.h
@@ -34,6 +34,11 @@
#include <inttypes.h>
+/* Name mangling */
+#define twofish_set_key nettle_twofish_set_key
+#define twofish_encrypt nettle_twofish_encrypt
+#define twofish_decrypt nettle_twofish_decrypt
+
#define TWOFISH_BLOCK_SIZE 16
/* Variable key size between 128 and 256 bits. But the only valid
diff --git a/yarrow.h b/yarrow.h
index 802542db..a83e53d3 100644
--- a/yarrow.h
+++ b/yarrow.h
@@ -29,6 +29,17 @@
#include "aes.h"
#include "sha.h"
+/* Name mangling */
+#define yarrow256_init nettle_yarrow256_init
+#define yarrow256_seed nettle_yarrow256_seed
+#define yarrow256_update nettle_yarrow256_update
+#define yarrow256_random nettle_yarrow256_random
+#define yarrow256_is_seeded nettle_yarrow256_is_seeded
+#define yarrow256_needed_sources nettle_yarrow256_needed_sources
+#define yarrow256_force_reseed nettle_yarrow256_force_reseed
+#define yarrow_key_event_init nettle_yarrow_key_event_init
+#define yarrow_key_event_estimate nettle_yarrow_key_event_estimate
+
enum yarrow_pool_id { YARROW_FAST = 0, YARROW_SLOW = 1 };
struct yarrow_source