int shcert_init_serial(uint8_t ser[16]) { unsigned char *raw = (unsigned char *)ser; uint64_t rand1 = shrand(); uint64_t rand2 = shrand(); memcpy(raw, &rand1, sizeof(uint64_t)); memcpy(raw + sizeof(uint64_t), &rand2, sizeof(uint64_t)); }
shkey_t *ashkey_uniq(void) { int i; memset(&_shmem_key, 0, sizeof(_shmem_key)); for (i = 0; i < SHKEY_WORDS; i++) { _shmem_key.code[i] = (uint32_t)htonl((uint32_t)shrand()); } return (&_shmem_key); }
shkey_t *shkey_uniq(void) { shkey_t *ret_key; int i; ret_key = (shkey_t *)calloc(1, sizeof(shkey_t)); for (i = 0; i < SHKEY_WORDS; i++) { ret_key->code[i] = (uint32_t)htonl((uint32_t)shrand()); } return (ret_key); }
int shalg_priv_rand(int alg, shalg_t ret_key) { static const int max = SHALG_PRIV_RAND_SIZE / 8; unsigned char raw[SHALG_PRIV_RAND_SIZE]; uint64_t *v; int i; v = (uint32_t *)raw; for (i = 0; i < max; i++) { v[i] = shrand(); } return (shalg_priv(alg, ret_key, raw, sizeof(raw))); }
static int _lbase_random(lua_State *L) { double d = (double)(shrand() & 0xFFFFFFFF); lua_pushnumber(L, d); return 1; /* math 'random' integral */ }