Nits after pnacl merge

This commit is contained in:
Frank Denis 2015-08-02 13:53:22 +02:00
parent f610f781f2
commit 7fca230be8
9 changed files with 40 additions and 34 deletions

2
.gitignore vendored
View File

@ -1,12 +1,14 @@
*.cmake *.cmake
*.dSYM *.dSYM
*.exp *.exp
*.final
*.gcda *.gcda
*.gcno *.gcno
*.la *.la
*.lo *.lo
*.log *.log
*.mem *.mem
*.nexe
*.o *.o
*.plist *.plist
*.scan *.scan

View File

@ -143,6 +143,8 @@ AC_PROG_CC_C99
AM_PROG_AS AM_PROG_AS
AC_USE_SYSTEM_EXTENSIONS AC_USE_SYSTEM_EXTENSIONS
AC_CHECK_DEFINE([__native_client__], [NATIVECLIENT="yes"], [])
AC_CHECK_DEFINE([_FORTIFY_SOURCE], [], [ AC_CHECK_DEFINE([_FORTIFY_SOURCE], [], [
AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2], AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
[CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"]) [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])

View File

@ -158,6 +158,7 @@ libsodium_la_SOURCES = \
if !EMSCRIPTEN if !EMSCRIPTEN
libsodium_la_SOURCES += \ libsodium_la_SOURCES += \
randombytes/salsa20/randombytes_salsa20_random.c randombytes/salsa20/randombytes_salsa20_random.c
if NATIVECLIENT if NATIVECLIENT
libsodium_la_SOURCES += \ libsodium_la_SOURCES += \
randombytes/nativeclient/randombytes_nativeclient.c randombytes/nativeclient/randombytes_nativeclient.c
@ -165,6 +166,7 @@ else
libsodium_la_SOURCES += \ libsodium_la_SOURCES += \
randombytes/sysrandom/randombytes_sysrandom.c randombytes/sysrandom/randombytes_sysrandom.c
endif endif
endif endif
if HAVE_TI_MODE if HAVE_TI_MODE

View File

@ -50,10 +50,14 @@ SODIUM_EXPORT = \
sodium/randombytes.h \ sodium/randombytes.h \
sodium/randombytes_salsa20_random.h \ sodium/randombytes_salsa20_random.h \
sodium/randombytes_sysrandom.h \ sodium/randombytes_sysrandom.h \
sodium/randombytes_nativeclient.h \
sodium/runtime.h \ sodium/runtime.h \
sodium/utils.h sodium/utils.h
if NATIVECLIENT
SODIUM_EXPORT += \
sodium/randombytes_nativeclient.h
endif
EXTRA_SRC = $(SODIUM_EXPORT) \ EXTRA_SRC = $(SODIUM_EXPORT) \
sodium/version.h.in sodium/version.h.in

View File

@ -41,9 +41,11 @@
#include "sodium/crypto_verify_32.h" #include "sodium/crypto_verify_32.h"
#include "sodium/crypto_verify_64.h" #include "sodium/crypto_verify_64.h"
#include "sodium/randombytes.h" #include "sodium/randombytes.h"
#ifdef __native_client__
# include "sodium/randombytes_nativeclient.h"
#endif
#include "sodium/randombytes_salsa20_random.h" #include "sodium/randombytes_salsa20_random.h"
#include "sodium/randombytes_sysrandom.h" #include "sodium/randombytes_sysrandom.h"
#include "sodium/randombytes_nativeclient.h"
#include "sodium/runtime.h" #include "sodium/runtime.h"
#include "sodium/utils.h" #include "sodium/utils.h"
#include "sodium/version.h" #include "sodium/version.h"

View File

@ -2,6 +2,8 @@
#ifndef randombytes_nativeclient_H #ifndef randombytes_nativeclient_H
#define randombytes_nativeclient_H #define randombytes_nativeclient_H
#ifdef __native_client__
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
@ -20,20 +22,16 @@ const char *randombytes_nativeclient_implementation_name(void);
SODIUM_EXPORT SODIUM_EXPORT
uint32_t randombytes_nativeclient(void); uint32_t randombytes_nativeclient(void);
SODIUM_EXPORT
void randombytes_nativeclient_stir(void);
SODIUM_EXPORT SODIUM_EXPORT
uint32_t randombytes_nativeclient_uniform(const uint32_t upper_bound); uint32_t randombytes_nativeclient_uniform(const uint32_t upper_bound);
SODIUM_EXPORT SODIUM_EXPORT
void randombytes_nativeclient_buf(void * const buf, const size_t size); void randombytes_nativeclient_buf(void * const buf, const size_t size);
SODIUM_EXPORT
int randombytes_nativeclient_close(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
#endif

View File

@ -1,21 +1,24 @@
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "nacl/nacl_random.h" #ifdef __native_client__
#include "utils.h" # include <nacl/nacl_random.h>
#include "randombytes.h"
#include "randombytes_nativeclient.h" # include "utils.h"
# include "randombytes.h"
# include "randombytes_nativeclient.h"
void void
randombytes_nativeclient_random_stir(void) randombytes_nativeclient_buf(void * const buf, const size_t size)
{ {
} size_t readnb;
int if (nacl_secure_random(buf, size, &readnb) != 0) {
randombytes_nativeclient_random_close(void) abort();
{ }
return 0; assert(readnb == size);
} }
uint32_t uint32_t
@ -28,18 +31,6 @@ randombytes_nativeclient_random(void)
return r; return r;
} }
void
randombytes_nativeclient_buf(void * const buf, const size_t size)
{
size_t readnb;
if (nacl_secure_random(buf, size, &readnb) != 0) {
abort();
}
assert(readnb == size);
}
const char * const char *
randombytes_nativeclient_implementation_name(void) randombytes_nativeclient_implementation_name(void)
{ {
@ -49,8 +40,10 @@ randombytes_nativeclient_implementation_name(void)
struct randombytes_implementation randombytes_nativeclient_implementation = { struct randombytes_implementation randombytes_nativeclient_implementation = {
SODIUM_C99(.implementation_name =) randombytes_nativeclient_implementation_name, SODIUM_C99(.implementation_name =) randombytes_nativeclient_implementation_name,
SODIUM_C99(.random =) randombytes_nativeclient_random, SODIUM_C99(.random =) randombytes_nativeclient_random,
SODIUM_C99(.stir =) randombytes_nativeclient_random_stir, SODIUM_C99(.stir =) NULL,
SODIUM_C99(.uniform =) NULL, SODIUM_C99(.uniform =) NULL,
SODIUM_C99(.buf =) randombytes_nativeclient_buf, SODIUM_C99(.buf =) randombytes_nativeclient_buf,
SODIUM_C99(.close =) randombytes_nativeclient_random_close SODIUM_C99(.close =) NULL
}; };
#endif

View File

@ -11,7 +11,10 @@
#include "randombytes.h" #include "randombytes.h"
#include "randombytes_sysrandom.h" #include "randombytes_sysrandom.h"
#include "randombytes_nativeclient.h"
#ifdef __native_client__
# include "randombytes_nativeclient.h"
#endif
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#ifdef __native_client__ #ifdef __native_client__

View File

@ -1,4 +1,4 @@
#!/bin/bash #! /usr/bin/env bash
if [ -z "$NACL_SDK_ROOT" -o -z "$PNACL_TRANSLATE" -o -z "$PNACL_FINALIZE" ] if [ -z "$NACL_SDK_ROOT" -o -z "$PNACL_TRANSLATE" -o -z "$PNACL_FINALIZE" ]
then then