Commit 76574a1a authored by Cedric Roux's avatar Cedric Roux

Revert "fix nettle"

This reverts commit d31634c3.

Laurent Thomas had a problem on one machine with the build_oai
way of checking for nettle.

The problem with the alternative solution of including nettle/bignum.h
is that it is very unclear.

The problem with nettle is that the file nettle/config.h does not
exist for version 2. It was introduced in version 3.

We want to support both versions, but there is an API incompatibility.
So we need an #if #else mechanism.

The file nettle/bignum.h is present in both versions 2 and 3 and it
includes nettle/version.h in the version 3.

So by including this file, we can check for the existence of
NETTLE_VERSION_MAJOR (that comes from nettle/config.h) in the
code.

But as you can see, the reasoning is way too complex.

So it's better to keep the check in cmake_targets/CMakeLists.txt.

As long as we support version 2 this will be the way to go.

It is possible to force a given version in specific non-generic
customized environments.
parent eadcba95
......@@ -1664,6 +1664,18 @@ endif()
message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}")
string(REGEX REPLACE "([0-9]+).*" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION})
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION})
message ("NETTLE_VERSION_MAJOR = ${NETTLE_VERSION_MAJOR}")
message ("NETTLE_VERSION_MINOR = ${NETTLE_VERSION_MINOR}")
if ("${NETTLE_VERSION_MAJOR}" STREQUAL "" OR "${NETTLE_VERSION_MINOR}" STREQUAL "")
message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" )
endif()
add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}")
add_definitions("-DNETTLE_VERSION_MINOR=${NETTLE_VERSION_MINOR}")
pkg_search_module(XPM xpm)
if(NOT ${XPM_FOUND})
message("PACKAGE xpm not found: some targets will fail")
......
......@@ -27,7 +27,6 @@
#include <nettle/nettle-meta.h>
#include <nettle/aes.h>
#include <nettle/ctr.h>
#include <nettle/bignum.h>
#include "UTIL/LOG/log.h"
......@@ -192,7 +191,7 @@ int stream_encrypt_eea2(stream_cipher_t *stream_cipher, uint8_t **out)
}
#endif
#if !defined(NETTLE_VERSION_MAJOR) || NETTLE_VERSION_MAJOR < 3
#if NETTLE_VERSION_MAJOR < 3
nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length,
stream_cipher->key);
#else
......
......@@ -27,7 +27,6 @@
#include <nettle/nettle-meta.h>
#include <nettle/aes.h>
#include <nettle/ctr.h>
#include <nettle/bignum.h>
#include "assertions.h"
#include "conversions.h"
......@@ -79,7 +78,7 @@ int nas_stream_encrypt_eea2(nas_stream_cipher_t *stream_cipher, uint8_t *out)
}
#endif
#if !defined(NETTLE_VERSION_MAJOR) || NETTLE_VERSION_MAJOR < 3
#if NETTLE_VERSION_MAJOR < 3
nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length,
stream_cipher->key);
#else
......
......@@ -31,7 +31,6 @@
#include <nettle/nettle-meta.h>
#include <nettle/aes.h>
#include <nettle/ctr.h>
#include <nettle/bignum.h>
static
void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key,
......@@ -42,7 +41,7 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key,
uint8_t *data = malloc(length);
uint8_t *ctr = malloc(cipher->block_size);
#if !defined(NETTLE_VERSION_MAJOR) || NETTLE_VERSION_MAJOR < 3
#if NETTLE_VERSION_MAJOR < 3
cipher->set_encrypt_key(ctx, key_length, key);
#else
cipher->set_encrypt_key(ctx, key);
......
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