blob: cb5b72305d7e4ae1bf73ee33778df43b902db7ad [file] [log] [blame]
/*
*
* Copyright (c) 2011-2015 Nest Labs, Inc.
* All rights reserved.
*
* This document is the property of Nest. It is considered
* confidential and proprietary information.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Nest.
*
* Description:
* Custom implemenation of OpenSSL's random number API that maps
* these functions onto the system's random number source (gCTRDRBG_ctx),
* which is an instance of the PolarSSL AES_CTR DRBG fed by the
* hardware random number source.
*/
#include <rand.h>
#include <openssl/rand.h>
#include <openssl/err.h>
extern int GetSecureRandomData(unsigned char *, uint16_t);
int RAND_bytes(unsigned char *buf, int num)
{
int retval = 0, err;
err = GetSecureRandomData(buf, num);
if (err == 0)
{
retval = 1;
}else{
RANDerr(RAND_F_RAND_GET_RAND_METHOD, RAND_R_PRNG_ERROR);
}
return retval;
}
void RAND_add(const void *buf, int num, double entropy)
{
/* Do nothing. This function is used to add additionaly entropy into the OpenSSL entropy pool.
* In the context of Pumice, all entropy comes from the system hardware RNG, making this
* function unnecessary.
*/
}
int RAND_pseudo_bytes(unsigned char *buf, int num)
{
return RAND_bytes(buf, num);
}