Drop urandom_test.
It didn't do too much and I didn't notice that CRYPTO_sysrand wasn't OPENSSL_EXPORTed, which makes the test impossible on shared-library builds. Change-Id: I38986572aa34fa9c0f30075d562b8ee4e1a0c8b8
This commit is contained in:
parent
7c6d09b9e5
commit
f673831272
@ -22,12 +22,3 @@ add_library(
|
|||||||
)
|
)
|
||||||
|
|
||||||
perlasm(rdrand-x86_64.${ASM_EXT} asm/rdrand-x86_64.pl)
|
perlasm(rdrand-x86_64.${ASM_EXT} asm/rdrand-x86_64.pl)
|
||||||
|
|
||||||
add_executable(
|
|
||||||
urandom_test
|
|
||||||
|
|
||||||
urandom_test.cc
|
|
||||||
$<TARGET_OBJECTS:test_support>
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(urandom_test crypto)
|
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/* Copyright (c) 2015, Google Inc.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
||||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <openssl/rand.h>
|
|
||||||
#include <openssl/crypto.h>
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
extern void CRYPTO_sysrand(uint8_t *out, size_t requested);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool TestBuffering() {
|
|
||||||
RAND_enable_fork_unsafe_buffering(-1);
|
|
||||||
uint8_t buf[4096];
|
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
static const size_t kBufSize = 4096;
|
|
||||||
CRYPTO_sysrand(buf, 0);
|
|
||||||
CRYPTO_sysrand(buf, 2048); /* fills the buffer */
|
|
||||||
CRYPTO_sysrand(buf, kBufSize - 1); /* triggers a second fill */
|
|
||||||
CRYPTO_sysrand(buf, kBufSize - 2048 + 1); /* consumes the remainder */
|
|
||||||
CRYPTO_sysrand(buf, 4096); /* bypasses the buffer */
|
|
||||||
|
|
||||||
/* Lame, but might as well sanity check that something happened. */
|
|
||||||
uint8_t cmp[4096];
|
|
||||||
memset(cmp, 0, sizeof(cmp));
|
|
||||||
return memcmp(buf, cmp, 4096) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
CRYPTO_library_init();
|
|
||||||
if (!TestBuffering()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("PASS\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -47,7 +47,6 @@
|
|||||||
["crypto/pkcs8/pkcs8_test"],
|
["crypto/pkcs8/pkcs8_test"],
|
||||||
["crypto/pkcs8/pkcs12_test"],
|
["crypto/pkcs8/pkcs12_test"],
|
||||||
["crypto/poly1305/poly1305_test", "crypto/poly1305/poly1305_test.txt"],
|
["crypto/poly1305/poly1305_test", "crypto/poly1305/poly1305_test.txt"],
|
||||||
["crypto/rand/urandom_test"],
|
|
||||||
["crypto/refcount_test"],
|
["crypto/refcount_test"],
|
||||||
["crypto/rsa/rsa_test"],
|
["crypto/rsa/rsa_test"],
|
||||||
["crypto/thread_test"],
|
["crypto/thread_test"],
|
||||||
|
Loading…
Reference in New Issue
Block a user