mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-23 16:20:26 -05:00
compat for arc4random with openssl 0.9.7 and openssl 0.9.8
git-svn-id: file:///svn/unbound/trunk@3174 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
2669be8beb
commit
ed2f8b1057
4 changed files with 54 additions and 6 deletions
|
|
@ -16,9 +16,12 @@
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
/*
|
||||||
#define _POSIX_C_SOURCE 199309L
|
#define _POSIX_C_SOURCE 199309L
|
||||||
#define _GNU_SOURCE 1
|
#define _GNU_SOURCE 1
|
||||||
|
*/
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@
|
||||||
#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
|
#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
|
||||||
#include <assert.h> /* assert() */
|
#include <assert.h> /* assert() */
|
||||||
|
|
||||||
|
/* do we have sha512 header defs */
|
||||||
|
#ifndef SHA512_DIGEST_LENGTH
|
||||||
#define SHA512_BLOCK_LENGTH 128
|
#define SHA512_BLOCK_LENGTH 128
|
||||||
#define SHA512_DIGEST_LENGTH 64
|
#define SHA512_DIGEST_LENGTH 64
|
||||||
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||||
|
|
@ -53,11 +55,12 @@ typedef struct _SHA512_CTX {
|
||||||
uint64_t bitcount[2];
|
uint64_t bitcount[2];
|
||||||
uint8_t buffer[SHA512_BLOCK_LENGTH];
|
uint8_t buffer[SHA512_BLOCK_LENGTH];
|
||||||
} SHA512_CTX;
|
} SHA512_CTX;
|
||||||
|
#endif /* do we have sha512 header defs */
|
||||||
|
|
||||||
void SHA512_init(SHA512_CTX*);
|
void SHA512_Init(SHA512_CTX*);
|
||||||
void SHA512_update(SHA512_CTX*, const uint8_t*, size_t);
|
void SHA512_Update(SHA512_CTX*, void*, size_t);
|
||||||
void SHA512_final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
||||||
unsigned char *SHA512(unsigned char *data, unsigned int data_len, unsigned char *digest);
|
unsigned char *SHA512(void *data, unsigned int data_len, unsigned char *digest);
|
||||||
|
|
||||||
|
|
||||||
/*** SHA-256/384/512 Machine Architecture Definitions *****************/
|
/*** SHA-256/384/512 Machine Architecture Definitions *****************/
|
||||||
|
|
@ -250,6 +253,11 @@ static const sha2_word64 sha512_initial_hash_value[8] = {
|
||||||
0x5be0cd19137e2179ULL
|
0x5be0cd19137e2179ULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef union _ldns_sha2_buffer_union {
|
||||||
|
uint8_t* theChars;
|
||||||
|
uint64_t* theLongs;
|
||||||
|
} ldns_sha2_buffer_union;
|
||||||
|
|
||||||
/*** SHA-512: *********************************************************/
|
/*** SHA-512: *********************************************************/
|
||||||
void SHA512_Init(SHA512_CTX* context) {
|
void SHA512_Init(SHA512_CTX* context) {
|
||||||
if (context == (SHA512_CTX*)0) {
|
if (context == (SHA512_CTX*)0) {
|
||||||
|
|
@ -337,8 +345,9 @@ static void SHA512_Transform(SHA512_CTX* context,
|
||||||
a = b = c = d = e = f = g = h = T1 = T2 = 0;
|
a = b = c = d = e = f = g = h = T1 = T2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
|
void SHA512_Update(SHA512_CTX* context, void *datain, size_t len) {
|
||||||
size_t freespace, usedspace;
|
size_t freespace, usedspace;
|
||||||
|
const sha2_byte* data = (const sha2_byte*)datain;
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
/* Calling with no data is valid - we do nothing */
|
/* Calling with no data is valid - we do nothing */
|
||||||
|
|
@ -458,7 +467,7 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *
|
unsigned char *
|
||||||
SHA512(unsigned char *data, unsigned int data_len, unsigned char *digest)
|
SHA512(void *data, unsigned int data_len, unsigned char *digest)
|
||||||
{
|
{
|
||||||
SHA512_CTX ctx;
|
SHA512_CTX ctx;
|
||||||
SHA512_Init(&ctx);
|
SHA512_Init(&ctx);
|
||||||
|
|
|
||||||
18
config.h.in
18
config.h.in
|
|
@ -907,6 +907,24 @@ void _ARC4_UNLOCK(void);
|
||||||
#ifndef HAVE_ARC4RANDOM_UNIFORM
|
#ifndef HAVE_ARC4RANDOM_UNIFORM
|
||||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAVE_SHA512_UPDATE
|
||||||
|
#ifndef SHA512_DIGEST_LENGTH
|
||||||
|
#define SHA512_BLOCK_LENGTH 128
|
||||||
|
#define SHA512_DIGEST_LENGTH 64
|
||||||
|
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||||
|
typedef struct _SHA512_CTX {
|
||||||
|
uint64_t state[8];
|
||||||
|
uint64_t bitcount[2];
|
||||||
|
uint8_t buffer[SHA512_BLOCK_LENGTH];
|
||||||
|
} SHA512_CTX;
|
||||||
|
#endif /* SHA512_DIGEST_LENGTH */
|
||||||
|
void SHA512_Init(SHA512_CTX*);
|
||||||
|
void SHA512_Update(SHA512_CTX*, void*, size_t);
|
||||||
|
void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
||||||
|
unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest);
|
||||||
|
#endif /* HAVE_SHA512_UPDATE */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
|
#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
|
||||||
/* using version of libevent that is not threadsafe. */
|
/* using version of libevent that is not threadsafe. */
|
||||||
|
|
|
||||||
18
configure.ac
18
configure.ac
|
|
@ -1213,6 +1213,24 @@ void _ARC4_UNLOCK(void);
|
||||||
#ifndef HAVE_ARC4RANDOM_UNIFORM
|
#ifndef HAVE_ARC4RANDOM_UNIFORM
|
||||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAVE_SHA512_UPDATE
|
||||||
|
#ifndef SHA512_DIGEST_LENGTH
|
||||||
|
#define SHA512_BLOCK_LENGTH 128
|
||||||
|
#define SHA512_DIGEST_LENGTH 64
|
||||||
|
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||||
|
typedef struct _SHA512_CTX {
|
||||||
|
uint64_t state[8];
|
||||||
|
uint64_t bitcount[2];
|
||||||
|
uint8_t buffer[SHA512_BLOCK_LENGTH];
|
||||||
|
} SHA512_CTX;
|
||||||
|
#endif /* SHA512_DIGEST_LENGTH */
|
||||||
|
void SHA512_Init(SHA512_CTX*);
|
||||||
|
void SHA512_Update(SHA512_CTX*, void*, size_t);
|
||||||
|
void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
||||||
|
unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest);
|
||||||
|
#endif /* HAVE_SHA512_UPDATE */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
|
#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
|
||||||
/* using version of libevent that is not threadsafe. */
|
/* using version of libevent that is not threadsafe. */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue