static bool nicer_initialized = false;
static std::mutex nicer_initialization_mutex;
static int nr_ice_crypto_openssl_random_bytes(UCHAR *buf, int len) {
RAND_bytes(buf, len);
return 0;
}
static int nr_ice_crypto_openssl_hmac_sha1(UCHAR *key, int key_l, UCHAR *buf, int buf_l, UCHAR digest[20]) {
unsigned int rl;
HMAC(EVP_sha1(),
key, key_l, buf, buf_l, digest, &rl);
if (rl != 20)
ERETURN(R_INTERNAL);
return 0;
}
static int nr_ice_crypto_openssl_md5(UCHAR *buf, int bufl, UCHAR *result) {
MD5(buf, bufl, result);
return 0;
}
static nr_ice_crypto_vtbl nr_ice_crypto_openssl_vtbl = {
nr_ice_crypto_openssl_random_bytes,
nr_ice_crypto_openssl_hmac_sha1,
nr_ice_crypto_openssl_md5
};
int nr_crypto_openssl_set() {
OpenSSL_add_all_algorithms();
nr_crypto_vtbl = &nr_ice_crypto_openssl_vtbl;
return 0;
}
void NicerConnection::gather_callback(NR_SOCKET s, int h, void *arg) {
NicerConnect