Commit da81c86a authored by Nikos Mavrogiannopoulos's avatar Nikos Mavrogiannopoulos Committed by Niels Möller

abi: explicitly export intended symbols and hide others

This adds all exported symbols in the map files explicitly under
the following rules:
 - Symbols mentioned in internal headers go in a section which is
   valid only for testing, and linking with these symbols will break
   in library updates.
 - Symbols mentioned in installed headers go in the exported sections
   and are considered part of the ABI.
 - All internal symbols move to internal headers.
 - The _nettle_md5_compress and _nettle_sha1_compress become exported
   without the _nettle prefix, due to existing usage.
parent 7ef18d1e
......@@ -226,8 +226,11 @@ DISTFILES = $(SOURCES) $(HEADERS) getopt.h getopt_int.h \
$(des_headers) descore.README desdata.stamp \
aes-internal.h camellia-internal.h serpent-internal.h \
cast128_sboxes.h desinfo.h desCode.h \
ripemd160-internal.h sha2-internal.h \
memxor-internal.h nettle-internal.h nettle-write.h \
ctr-internal.h \
ctr-internal.h chacha-internal.h sha3-internal.h \
salsa20-internal.h umac-internal.h hogweed-internal.h \
rsa-internal.h dsa-internal.h eddsa-internal.h \
gmp-glue.h ecc-internal.h fat-setup.h \
mini-gmp.h asm.m4 \
nettle.texinfo nettle.info nettle.html nettle.pdf sha-example.c
......
......@@ -31,7 +31,7 @@ ifelse(<
not, see http://www.gnu.org/licenses/.
>)
dnl PROLOGUE(_nettle_sha1_compress) picked up by configure
dnl PROLOGUE(nettle_sha1_compress) picked up by configure
define(<fat_transform>, <$1_armv6>)
include_src(<arm/v6/sha1-compress.asm>)
......@@ -101,7 +101,7 @@ define(<ROUND3>, <
ror $2, $2, #2
add $5, $5, T0
>)
C void _nettle_sha1_compress(uint32_t *state, const uint8_t *input)
C void nettle_sha1_compress(uint32_t *state, const uint8_t *input)
.text
.align 2
......@@ -112,7 +112,7 @@ define(<ROUND3>, <
.LK3:
.int 0x8F1BBCDC
PROLOGUE(_nettle_sha1_compress)
PROLOGUE(nettle_sha1_compress)
push {r4,r5,r6,r7,r8,r10,lr}
sub sp, sp, #64
......@@ -246,7 +246,7 @@ IF_BE(< rsb SHIFT, SHIFT, #32>)
add sp, sp, #64
stm STATE, {SA,SB,SC,SD,SE}
pop {r4,r5,r6,r7,r8,r10,pc}
EPILOGUE(_nettle_sha1_compress)
EPILOGUE(nettle_sha1_compress)
.LK4:
.int 0xCA62C1D6
......@@ -109,13 +109,6 @@ nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,
void *ctx, nettle_random_func *random,
void *progress_ctx, nettle_progress_func *progress);
void
_nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
unsigned bits, int top_bits_set,
void *ctx, nettle_random_func *random,
const mpz_t p0,
const mpz_t q,
const mpz_t p0q);
/* sexp parsing */
struct sexp_iterator;
......
......@@ -47,6 +47,7 @@
#include <string.h>
#include "chacha.h"
#include "chacha-internal.h"
#include "macros.h"
......
......@@ -47,6 +47,7 @@
#include <string.h>
#include "chacha.h"
#include "chacha-internal.h"
#include "macros.h"
#include "memxor.h"
......
/* chacha-internal.h
The ChaCha stream cipher.
Copyright (C) 2013 Joachim Strömbergson
Copyright (C) 2012 Simon Josefsson
Copyright (C) 2014 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#ifndef NETTLE_CHACHA_INTERNAL_H_INCLUDED
#define NETTLE_CHACHA_INTERNAL_H_INCLUDED
#include "nettle-types.h"
#define _chacha_core _nettle_chacha_core
void
_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds);
#endif /* NETTLE_CHACHA_INTERNAL_H_INCLUDED */
......@@ -52,6 +52,7 @@
#include <assert.h>
#include <string.h>
#include "chacha-internal.h"
#include "chacha-poly1305.h"
#include "macros.h"
......
......@@ -47,7 +47,6 @@ extern "C" {
#define chacha_set_nonce nettle_chacha_set_nonce
#define chacha_set_nonce96 nettle_chacha_set_nonce96
#define chacha_crypt nettle_chacha_crypt
#define _chacha_core _nettle_chacha_core
/* Currently, only 256-bit keys are supported. */
#define CHACHA_KEY_SIZE 32
......@@ -86,9 +85,6 @@ void
chacha_crypt(struct chacha_ctx *ctx, size_t length,
uint8_t *dst, const uint8_t *src);
void
_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds);
#ifdef __cplusplus
}
#endif
......
......@@ -42,6 +42,7 @@
#include "bignum.h"
#include "nettle-internal.h"
#include "hogweed-internal.h"
/* Valid sizes, according to FIPS 186-3 are (1024, 160), (2048, 224),
......
......@@ -34,6 +34,7 @@
#endif
#include "dsa.h"
#include "dsa-internal.h"
#include "bignum.h"
......
/* dsa-internal.h
The DSA publickey algorithm.
Copyright (C) 2002, 2013, 2014 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#ifndef NETTLE_DSA_INTERNAL_H_INCLUDED
#define NETTLE_DSA_INTERNAL_H_INCLUDED
#include "nettle-types.h"
#define _dsa_hash _nettle_dsa_hash
/* Internal functions. */
void
_dsa_hash (mpz_t h, unsigned bit_size,
size_t length, const uint8_t *digest);
#endif /* NETTLE_DSA_INTERNAL_H_INCLUDED */
......@@ -39,6 +39,7 @@
#include <stdlib.h>
#include "dsa.h"
#include "dsa-internal.h"
#include "bignum.h"
......
......@@ -38,6 +38,7 @@
#include <stdlib.h>
#include "dsa.h"
#include "dsa-internal.h"
#include "bignum.h"
......
......@@ -36,6 +36,7 @@
#endif
#include "dsa.h"
#include "dsa-internal.h"
#include "bignum.h"
......
......@@ -59,7 +59,6 @@ extern "C" {
#define dsa_public_key_from_der_iterator nettle_dsa_public_key_from_der_iterator
#define dsa_openssl_private_key_from_der_iterator nettle_dsa_openssl_private_key_from_der_iterator
#define dsa_openssl_private_key_from_der nettle_openssl_provate_key_from_der
#define _dsa_hash _nettle_dsa_hash
/* For FIPS approved parameters */
#define DSA_SHA1_MIN_P_BITS 512
......@@ -204,11 +203,6 @@ dsa_openssl_private_key_from_der(struct dsa_params *params,
size_t length, const uint8_t *data);
/* Internal functions. */
void
_dsa_hash (mpz_t h, unsigned bit_size,
size_t length, const uint8_t *digest);
#ifdef __cplusplus
}
#endif
......
......@@ -41,12 +41,6 @@ extern "C" {
/* The contents of this struct is internal. */
struct ecc_curve;
extern const struct ecc_curve _nettle_secp_192r1;
extern const struct ecc_curve _nettle_secp_224r1;
extern const struct ecc_curve _nettle_secp_256r1;
extern const struct ecc_curve _nettle_secp_384r1;
extern const struct ecc_curve _nettle_secp_521r1;
#ifdef __GNUC__
#define NETTLE_PURE __attribute__((pure))
#else
......
......@@ -73,6 +73,12 @@
#define sec_modinv _nettle_sec_modinv
#define curve25519_eh_to_x _nettle_curve25519_eh_to_x
extern const struct ecc_curve _nettle_secp_192r1;
extern const struct ecc_curve _nettle_secp_224r1;
extern const struct ecc_curve _nettle_secp_256r1;
extern const struct ecc_curve _nettle_secp_384r1;
extern const struct ecc_curve _nettle_secp_521r1;
/* Keep this structure internal for now. It's misnamed (since it's
really implementing the equivalent twisted Edwards curve, with
different coordinates). And we're not quite ready to provide
......
......@@ -34,6 +34,7 @@
#endif
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc-internal.h"
#include "sha2.h"
......
......@@ -34,6 +34,7 @@
#endif
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc-internal.h"
#include "sha2.h"
......
......@@ -36,6 +36,7 @@
#include <string.h>
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc-internal.h"
#include "sha2.h"
......
......@@ -34,6 +34,7 @@
#endif
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc-internal.h"
#include "gmp-glue.h"
......
......@@ -34,6 +34,7 @@
#endif
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc-internal.h"
#include "gmp-glue.h"
......
......@@ -37,6 +37,7 @@
#include <string.h>
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc.h"
#include "ecc-internal.h"
......
......@@ -36,6 +36,7 @@
#include <assert.h>
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc.h"
#include "ecc-internal.h"
......
/* eddsa.h
Copyright (C) 2014 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#ifndef NETTLE_EDDSA_INTERNAL_H
#define NETTLE_EDDSA_INTERNAL_H
#include "nettle-types.h"
#define _eddsa_compress _nettle_eddsa_compress
#define _eddsa_compress_itch _nettle_eddsa_compress_itch
#define _eddsa_decompress _nettle_eddsa_decompress
#define _eddsa_decompress_itch _nettle_eddsa_decompress_itch
#define _eddsa_hash _nettle_eddsa_hash
#define _eddsa_expand_key _nettle_eddsa_expand_key
#define _eddsa_sign _nettle_eddsa_sign
#define _eddsa_sign_itch _nettle_eddsa_sign_itch
#define _eddsa_verify _nettle_eddsa_verify
#define _eddsa_verify_itch _nettle_eddsa_verify_itch
#define _eddsa_public_key_itch _nettle_eddsa_public_key_itch
#define _eddsa_public_key _nettle_eddsa_public_key
/* Low-level internal functions */
struct ecc_curve;
struct ecc_modulo;
mp_size_t
_eddsa_compress_itch (const struct ecc_curve *ecc);
void
_eddsa_compress (const struct ecc_curve *ecc, uint8_t *r, mp_limb_t *p,
mp_limb_t *scratch);
mp_size_t
_eddsa_decompress_itch (const struct ecc_curve *ecc);
int
_eddsa_decompress (const struct ecc_curve *ecc, mp_limb_t *p,
const uint8_t *cp,
mp_limb_t *scratch);
void
_eddsa_hash (const struct ecc_modulo *m,
mp_limb_t *rp, const uint8_t *digest);
mp_size_t
_eddsa_sign_itch (const struct ecc_curve *ecc);
void
_eddsa_sign (const struct ecc_curve *ecc,
const struct nettle_hash *H,
const uint8_t *pub,
void *ctx,
const mp_limb_t *k2,
size_t length,
const uint8_t *msg,
uint8_t *signature,
mp_limb_t *scratch);
mp_size_t
_eddsa_verify_itch (const struct ecc_curve *ecc);
int
_eddsa_verify (const struct ecc_curve *ecc,
const struct nettle_hash *H,
const uint8_t *pub,
const mp_limb_t *A,
void *ctx,
size_t length,
const uint8_t *msg,
const uint8_t *signature,
mp_limb_t *scratch);
void
_eddsa_expand_key (const struct ecc_curve *ecc,
const struct nettle_hash *H,
void *ctx,
const uint8_t *key,
uint8_t *digest,
mp_limb_t *k2);
mp_size_t
_eddsa_public_key_itch (const struct ecc_curve *ecc);
void
_eddsa_public_key (const struct ecc_curve *ecc,
const mp_limb_t *k, uint8_t *pub, mp_limb_t *scratch);
#endif /* NETTLE_EDDSA_INTERNAL_H */
......@@ -34,6 +34,7 @@
#endif
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc-internal.h"
......
......@@ -36,6 +36,7 @@
#include <assert.h>
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc.h"
#include "ecc-internal.h"
......
......@@ -36,6 +36,7 @@
#include <assert.h>
#include "eddsa.h"
#include "eddsa-internal.h"
#include "ecc.h"
#include "ecc-internal.h"
......
......@@ -46,19 +46,6 @@ extern "C" {
#define ed25519_sha512_sign nettle_ed25519_sha512_sign
#define ed25519_sha512_verify nettle_ed25519_sha512_verify
#define _eddsa_compress _nettle_eddsa_compress
#define _eddsa_compress_itch _nettle_eddsa_compress_itch
#define _eddsa_decompress _nettle_eddsa_decompress
#define _eddsa_decompress_itch _nettle_eddsa_decompress_itch
#define _eddsa_hash _nettle_eddsa_hash
#define _eddsa_expand_key _nettle_eddsa_expand_key
#define _eddsa_sign _nettle_eddsa_sign
#define _eddsa_sign_itch _nettle_eddsa_sign_itch
#define _eddsa_verify _nettle_eddsa_verify
#define _eddsa_verify_itch _nettle_eddsa_verify_itch
#define _eddsa_public_key_itch _nettle_eddsa_public_key_itch
#define _eddsa_public_key _nettle_eddsa_public_key
#define ED25519_KEY_SIZE 32
#define ED25519_SIGNATURE_SIZE 64
......@@ -76,71 +63,6 @@ ed25519_sha512_verify (const uint8_t *pub,
size_t length, const uint8_t *msg,
const uint8_t *signature);
/* Low-level internal functions */
struct ecc_curve;
struct ecc_modulo;
mp_size_t
_eddsa_compress_itch (const struct ecc_curve *ecc);
void
_eddsa_compress (const struct ecc_curve *ecc, uint8_t *r, mp_limb_t *p,
mp_limb_t *scratch);
mp_size_t
_eddsa_decompress_itch (const struct ecc_curve *ecc);
int
_eddsa_decompress (const struct ecc_curve *ecc, mp_limb_t *p,
const uint8_t *cp,
mp_limb_t *scratch);
void
_eddsa_hash (const struct ecc_modulo *m,
mp_limb_t *rp, const uint8_t *digest);
mp_size_t
_eddsa_sign_itch (const struct ecc_curve *ecc);
void
_eddsa_sign (const struct ecc_curve *ecc,
const struct nettle_hash *H,
const uint8_t *pub,
void *ctx,
const mp_limb_t *k2,
size_t length,
const uint8_t *msg,
uint8_t *signature,
mp_limb_t *scratch);
mp_size_t
_eddsa_verify_itch (const struct ecc_curve *ecc);
int
_eddsa_verify (const struct ecc_curve *ecc,
const struct nettle_hash *H,
const uint8_t *pub,
const mp_limb_t *A,
void *ctx,
size_t length,
const uint8_t *msg,
const uint8_t *signature,
mp_limb_t *scratch);
void
_eddsa_expand_key (const struct ecc_curve *ecc,
const struct nettle_hash *H,
void *ctx,
const uint8_t *key,
uint8_t *digest,
mp_limb_t *k2);
mp_size_t
_eddsa_public_key_itch (const struct ecc_curve *ecc);
void
_eddsa_public_key (const struct ecc_curve *ecc,
const mp_limb_t *k, uint8_t *pub, mp_limb_t *scratch);
#ifdef __cplusplus
}
......
......@@ -58,6 +58,7 @@
#include "gcm.h"
#include "memxor.h"
#include "salsa20.h"
#include "salsa20-internal.h"
#include "serpent.h"
#include "sha1.h"
#include "sha2.h"
......@@ -717,7 +718,7 @@ bench_sha1_compress(void)
uint8_t data[SHA1_BLOCK_SIZE];
double t;
TIME_CYCLES (t, _nettle_sha1_compress(state, data));
TIME_CYCLES (t, nettle_sha1_compress(state, data));
printf("sha1_compress: %.2f cycles\n", t);
}
......
......@@ -147,7 +147,7 @@ DECLARE_FAT_FUNC(_nettle_salsa20_core, salsa20_core_func)
DECLARE_FAT_FUNC_VAR(salsa20_core, salsa20_core_func, c)
DECLARE_FAT_FUNC_VAR(salsa20_core, salsa20_core_func, neon)
DECLARE_FAT_FUNC(_nettle_sha1_compress, sha1_compress_func)
DECLARE_FAT_FUNC(nettle_sha1_compress, sha1_compress_func)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, c)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, armv6)
......@@ -243,7 +243,7 @@ DEFINE_FAT_FUNC(_nettle_salsa20_core, void,
(uint32_t *dst, const uint32_t *src, unsigned rounds),
(dst, src, rounds))
DEFINE_FAT_FUNC(_nettle_sha1_compress, void,
DEFINE_FAT_FUNC(nettle_sha1_compress, void,
(uint32_t *state, const uint8_t *input),
(state, input))
......
......@@ -123,7 +123,7 @@ DECLARE_FAT_FUNC(nettle_memxor, memxor_func)
DECLARE_FAT_FUNC_VAR(memxor, memxor_func, x86_64)
DECLARE_FAT_FUNC_VAR(memxor, memxor_func, sse2)
DECLARE_FAT_FUNC(_nettle_sha1_compress, sha1_compress_func)
DECLARE_FAT_FUNC(nettle_sha1_compress, sha1_compress_func)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, x86_64)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, sha_ni)
......@@ -175,7 +175,7 @@ fat_init (void)
{
if (verbose)
fprintf (stderr, "libnettle: using sha_ni instructions.\n");
_nettle_sha1_compress_vec = _nettle_sha1_compress_sha_ni;
nettle_sha1_compress_vec = _nettle_sha1_compress_sha_ni;
_nettle_sha256_compress_vec = _nettle_sha256_compress_sha_ni;
}
else
......@@ -217,7 +217,7 @@ DEFINE_FAT_FUNC(nettle_memxor, void *,
(void *dst, const void *src, size_t n),
(dst, src, n))
DEFINE_FAT_FUNC(_nettle_sha1_compress, void,
DEFINE_FAT_FUNC(nettle_sha1_compress, void,
(uint32_t *state, const uint8_t *input),
(state, input))
......
/* hogweed-internal.h
Bignum operations that are missing from gmp.
Copyright (C) 2001 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#ifndef NETTLE_HOGWEED_INTERNAL_H_INCLUDED
#define NETTLE_HOGWEED_INTERNAL_H_INCLUDED
void
_nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
unsigned bits, int top_bits_set,
void *ctx, nettle_random_func *random,
const mpz_t p0,
const mpz_t q,
const mpz_t p0q);
#define _pkcs1_signature_prefix _nettle_pkcs1_signature_prefix
uint8_t *
_pkcs1_signature_prefix(unsigned key_size,
uint8_t *buffer,
unsigned id_size,
const uint8_t *id,
unsigned digest_size);
#endif /* NETTLE_HOGWEED_INTERNAL_H_INCLUDED */
# libhogweed.map -- libhogweed linker version script. -*- ld-script -*-
# libhogweed.map.in -- linker version script. -*- ld-script -*-
#
# The symbol version must be updated on every hogweed
......@@ -8,11 +8,20 @@
HOGWEED_@LIBHOGWEED_MAJOR@
{
global:
nettle_*;
_nettle_*;
@HOGWEED_EXTRA_SYMBOLS@
nettle_*;
local:
*;
};