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

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
......@@ -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:
*;
};
# Internal symbols which are to be used only for unit or other
# testing. Compatibility may break across releases.
HOGWEED_INTERNAL_@LIBHOGWEED_MAJOR@_@LIBNETTLE_MINOR@
{
global:
_nettle_*;
local:
*;
};
# libnettle.map -- libnettle linker version script. -*- ld-script -*-
# libnettle.map.in -- linker version script. -*- ld-script -*-
#
# The symbol version must be updated on every nettle
......@@ -9,9 +9,18 @@ NETTLE_@LIBNETTLE_MAJOR@
{
global:
nettle_*;
_nettle_*;
local:
*;
};
# Internal symbols which are to be used only for unit or other
# testing. Compatibility may break across releases.
NETTLE_INTERNAL_@LIBNETTLE_MAJOR@_@LIBNETTLE_MINOR@
{
global:
_nettle_*;
local:
*;
};
......@@ -79,7 +79,7 @@
* (_MD5_DIGEST_LENGTH) words. */
void
_nettle_md5_compress(uint32_t *digest, const uint8_t *input)
nettle_md5_compress(uint32_t *digest, const uint8_t *input)
{
uint32_t data[MD5_DATA_LENGTH];
uint32_t a, b, c, d;
......
......@@ -61,7 +61,7 @@ md5_init(struct md5_ctx *ctx)
ctx->index = 0;
}
#define COMPRESS(ctx, data) (_nettle_md5_compress((ctx)->state, (data)))
#define COMPRESS(ctx, data) (nettle_md5_compress((ctx)->state, (data)))
void
md5_update(struct md5_ctx *ctx,
......@@ -86,7 +86,7 @@ md5_digest(struct md5_ctx *ctx,
bit_count = (ctx->count << 9) | (ctx->index << 3);
LE_WRITE_UINT64(ctx->block + (MD5_BLOCK_SIZE - 8), bit_count);
_nettle_md5_compress(ctx->state, ctx->block);
nettle_md5_compress(ctx->state, ctx->block);
_nettle_write_le32(length, digest, ctx->state);
md5_init(ctx);
......
......@@ -77,7 +77,9 @@ md5_digest(struct md5_ctx *ctx,
/* Internal compression function. STATE points to 4 uint32_t words,
and DATA points to 64 bytes of input data, possibly unaligned. */
void
_nettle_md5_compress(uint32_t *state, const uint8_t *data);
nettle_md5_compress(uint32_t *state, const uint8_t *data);
#define _nettle_md5_compress nettle_md5_compress
#ifdef __cplusplus
}
......
......@@ -115,4 +115,6 @@ extern const struct nettle_aead nettle_openssl_arcfour128;
extern const struct nettle_hash nettle_openssl_md5;
extern const struct nettle_hash nettle_openssl_sha1;
extern const struct nettle_hash * const _nettle_hashes[];
#endif /* NETTLE_INTERNAL_H_INCLUDED */
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