Skip to content

Commit

Permalink
When PJ_SSL_SOCK_IMP_APPLE is used, Apple’s Security Frameworks secur…
Browse files Browse the repository at this point in the history
…e number generator is used
  • Loading branch information
j4nnis committed Feb 13, 2024
1 parent beb06a5 commit a53fcab
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pjmedia/src/pjmedia/transport_srtp_sdes.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
# endif
#endif

#ifdef PJ_SSL_SOCK_IMP_APPLE
#include <Security/SecRandom.h>
#endif

#include <pj/rand.h>

Expand Down Expand Up @@ -134,6 +137,14 @@ 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 status = SecRandomCopyBytes(kSecRandomDefault, crypto_suites[cs_idx].cipher_key_len, &key);
if (status != errSecSuccess) {
PJ_LOG(4,(THIS_FILE, "Failed generating random key "
"(native err=%d)", status));
return PJMEDIA_ERRNO_FROM_LIBSRTP(1);
}
#else
PJ_LOG(3,(THIS_FILE, "Warning: simple random generator is used "
"for generating SRTP key"));
Expand Down

0 comments on commit a53fcab

Please sign in to comment.