Commit 4fd20960 authored by Niels Möller's avatar Niels Möller

* 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
parent b26c3925
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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 */
......
......@@ -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
......
......@@ -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. */
......
......@@ -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. */
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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,
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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 };
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment