Exemplo n.º 1
0
bool SSLImpl::rand(unsigned char *entropy, size_t length)
{
    //unsigned char* rand_array = new unsigned char[length];
    int res = SecRandomCopyBytes(kSecRandomDefault, length, entropy);
    if (res) return false;

    return true;    
}
Exemplo n.º 2
0
  virtual bool pseudoRandom(byte *out, int length) {
    if (length == 0) return true;
#ifdef HAVE_SEC_RANDOM_H
    if (SecRandomCopyBytes(kSecRandomDefault, length, out) < 0) {
      PLOG(ERROR) << "random key generation failure for length " << length;
      return false;
    }
#else
#error No random number generator provided.
#endif
    return true;
  }
Exemplo n.º 3
0
/**
* Gather entropy from SecRandomCopyBytes
*/
size_t Darwin_SecRandom::poll(RandomNumberGenerator& rng)
   {
   secure_vector<uint8_t> buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);

   if(0 == SecRandomCopyBytes(kSecRandomDefault, buf.size(), buf.data()))
      {
      rng.add_entropy(buf.data(), buf.size());
      return buf.size() * 8;
      }

   return 0;
   }
Exemplo n.º 4
0
  virtual CipherKey randomKey(int length) {
    CipherKey key(length);
    if (length == 0) return key;
#ifdef HAVE_SEC_RANDOM_H
    if (SecRandomCopyBytes(kSecRandomDefault, key.size(), key.data()) < 0) {
      PLOG(ERROR) << "random key generation failure for length " << length;
      key.reset();
    }
#else
#error No random number generator provided.
#endif
    return key;
  }
Exemplo n.º 5
0
static int dhRngCallback(struct ccrng_state *rng, unsigned long outlen, void *out)
{
    return SecRandomCopyBytes(kSecRandomDefault, outlen, out);
}
Exemplo n.º 6
0
int32_t mz_crypt_rand(uint8_t *buf, int32_t size)
{
    if (SecRandomCopyBytes(kSecRandomDefault, size, buf) != errSecSuccess)
        return 0;
    return size;
}
int
_mongoc_rand_bytes (uint8_t *buf, int num)
{
   return !SecRandomCopyBytes (kSecRandomDefault, num, buf);
}
/* random number generator */
void ntlmRand(
	unsigned		len,
	void			*buf)				/* allocated by caller, random data RETURNED */
{
	SecRandomCopyBytes(kSecRandomDefault, len, buf);
}