Secure random number generator for SRTP key when using PJ_SSL_SOCK_IMP_APPLE (#3860)
This commit is contained in:
parent
beb06a57ca
commit
fc3b03c937
|
@ -34,6 +34,9 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_APPLE)
|
||||
#include <Security/SecRandom.h>
|
||||
#endif
|
||||
|
||||
#include <pj/rand.h>
|
||||
|
||||
|
@ -134,6 +137,16 @@ static pj_status_t generate_crypto_attr_value(pj_pool_t *pool,
|
|||
"(native err=%d)", err));
|
||||
return PJMEDIA_ERRNO_FROM_LIBSRTP(1);
|
||||
}
|
||||
#elif defined(PJ_HAS_SSL_SOCK) && (PJ_HAS_SSL_SOCK != 0) && \
|
||||
(PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_APPLE)
|
||||
int err = SecRandomCopyBytes(kSecRandomDefault,
|
||||
crypto_suites[cs_idx].cipher_key_len,
|
||||
&key);
|
||||
if (err != errSecSuccess) {
|
||||
PJ_LOG(4,(THIS_FILE, "Failed generating random key "
|
||||
"(native err=%d)", err));
|
||||
return PJMEDIA_ERRNO_FROM_LIBSRTP(1);
|
||||
}
|
||||
#else
|
||||
PJ_LOG(3,(THIS_FILE, "Warning: simple random generator is used "
|
||||
"for generating SRTP key"));
|
||||
|
|
Loading…
Reference in New Issue