+ sodium_library_minimal() and SODIUM_LIBRARY_MINIMAL
This commit is contained in:
parent
8465469167
commit
8679e717db
@ -30,6 +30,7 @@ function can especially be useful to write reproducible tests.
|
||||
- `contrib/Findsodium.cmake` was added as an example to include
|
||||
libsodium in a project using cmake.
|
||||
- Compatibility with gcc 2.x has been restored.
|
||||
- Minimal builds can be checked using `sodium_library_minimal()`.
|
||||
|
||||
* Version 1.0.11
|
||||
- `sodium_init()` is now thread-safe, and can be safely called multiple
|
||||
|
@ -22,6 +22,9 @@ int sodium_library_version_major(void);
|
||||
SODIUM_EXPORT
|
||||
int sodium_library_version_minor(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_library_minimal(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -102,6 +102,7 @@ AC_ARG_ENABLE(minimal,
|
||||
[
|
||||
AS_IF([test "x$enableval" = "xyes"], [
|
||||
enable_minimal="yes"
|
||||
SODIUM_LIBRARY_MINIMAL_DEF="#define SODIUM_LIBRARY_MINIMAL 1"
|
||||
AC_DEFINE([MINIMAL], [1], [Define for a minimal build, without deprecated functions and functions that high-level APIs depend on])
|
||||
], [
|
||||
enable_minimal="no"
|
||||
@ -111,6 +112,7 @@ AC_ARG_ENABLE(minimal,
|
||||
enable_minimal="no"
|
||||
])
|
||||
AM_CONDITIONAL([MINIMAL], [test x$enable_minimal = xyes])
|
||||
AC_SUBST(SODIUM_LIBRARY_MINIMAL_DEF)
|
||||
|
||||
AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
|
||||
[use pthreads library, or --without-pthreads to disable threading support.]),
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef sodium_H
|
||||
#define sodium_H
|
||||
|
||||
#include "sodium/version.h"
|
||||
|
||||
#include "sodium/core.h"
|
||||
#include "sodium/crypto_aead_aes256gcm.h"
|
||||
#include "sodium/crypto_aead_chacha20poly1305.h"
|
||||
@ -11,7 +13,6 @@
|
||||
#include "sodium/crypto_auth_hmacsha512.h"
|
||||
#include "sodium/crypto_auth_hmacsha512256.h"
|
||||
#include "sodium/crypto_box.h"
|
||||
#include "sodium/crypto_box_curve25519xchacha20poly1305.h"
|
||||
#include "sodium/crypto_box_curve25519xsalsa20poly1305.h"
|
||||
#include "sodium/crypto_core_hsalsa20.h"
|
||||
#include "sodium/crypto_core_hchacha20.h"
|
||||
@ -34,18 +35,13 @@
|
||||
#include "sodium/crypto_scalarmult_curve25519.h"
|
||||
#include "sodium/crypto_secretbox.h"
|
||||
#include "sodium/crypto_secretbox_xsalsa20poly1305.h"
|
||||
#include "sodium/crypto_secretbox_xchacha20poly1305.h"
|
||||
#include "sodium/crypto_shorthash.h"
|
||||
#include "sodium/crypto_shorthash_siphash24.h"
|
||||
#include "sodium/crypto_sign.h"
|
||||
#include "sodium/crypto_sign_ed25519.h"
|
||||
#include "sodium/crypto_stream.h"
|
||||
#include "sodium/crypto_stream_aes128ctr.h"
|
||||
#include "sodium/crypto_stream_chacha20.h"
|
||||
#include "sodium/crypto_stream_salsa20.h"
|
||||
#include "sodium/crypto_stream_salsa2012.h"
|
||||
#include "sodium/crypto_stream_salsa208.h"
|
||||
#include "sodium/crypto_stream_xchacha20.h"
|
||||
#include "sodium/crypto_stream_xsalsa20.h"
|
||||
#include "sodium/crypto_verify_16.h"
|
||||
#include "sodium/crypto_verify_32.h"
|
||||
@ -58,6 +54,14 @@
|
||||
#include "sodium/randombytes_sysrandom.h"
|
||||
#include "sodium/runtime.h"
|
||||
#include "sodium/utils.h"
|
||||
#include "sodium/version.h"
|
||||
|
||||
#ifndef SODIUM_LIBRARY_MINIMAL
|
||||
# include "sodium/crypto_box_curve25519xchacha20poly1305.h"
|
||||
# include "sodium/crypto_secretbox_xchacha20poly1305.h"
|
||||
# include "sodium/crypto_stream_aes128ctr.h"
|
||||
# include "sodium/crypto_stream_salsa2012.h"
|
||||
# include "sodium/crypto_stream_salsa208.h"
|
||||
# include "sodium/crypto_stream_xchacha20.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@ SODIUM_EXPORT
|
||||
int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
|
||||
#ifndef SODIUM_LIBRARY_MINIMAL
|
||||
/* -- 128-bit output -- */
|
||||
|
||||
#define crypto_shorthash_siphashx24_BYTES 16U
|
||||
@ -38,6 +39,7 @@ size_t crypto_shorthash_siphashx24_keybytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#define SODIUM_LIBRARY_VERSION_MAJOR @SODIUM_LIBRARY_VERSION_MAJOR@
|
||||
#define SODIUM_LIBRARY_VERSION_MINOR @SODIUM_LIBRARY_VERSION_MINOR@
|
||||
@SODIUM_LIBRARY_MINIMAL_DEF@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -22,6 +23,9 @@ int sodium_library_version_major(void);
|
||||
SODIUM_EXPORT
|
||||
int sodium_library_version_minor(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_library_minimal(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -18,3 +18,13 @@ sodium_library_version_minor(void)
|
||||
{
|
||||
return SODIUM_LIBRARY_VERSION_MINOR;
|
||||
}
|
||||
|
||||
int
|
||||
sodium_library_minimal(void)
|
||||
{
|
||||
#ifdef SODIUM_LIBRARY_MINIMAL
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -8,6 +8,11 @@ main(void)
|
||||
printf("%d\n", sodium_version_string() != NULL);
|
||||
printf("%d\n", sodium_library_version_major() > 0);
|
||||
printf("%d\n", sodium_library_version_minor() >= 0);
|
||||
#ifdef SODIUM_LIBRARY_MINIMAL
|
||||
assert(sodium_library_minimal() == 1);
|
||||
#else
|
||||
assert(sodium_library_minimal() == 0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user