- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjmedia/src/pjmedia/transport_srtp.c
r5136 r5513 48 48 #else 49 49 # include <srtp.h> 50 # include <crypto_kernel.h> 50 51 #endif 51 52 … … 71 72 static const pj_str_t ID_INACTIVE = { "inactive", 8 }; 72 73 static const pj_str_t ID_CRYPTO = { "crypto", 6 }; 74 75 typedef void (*crypto_method_t)(crypto_policy_t *policy); 73 76 74 77 typedef struct crypto_suite … … 82 85 unsigned srtcp_auth_tag_len; 83 86 sec_serv_t service; 87 /* This is an attempt to validate crypto support by libsrtp, i.e: it should 88 * raise linking error if the libsrtp does not support the crypto. 89 */ 90 cipher_type_t *ext_cipher_type; 91 crypto_method_t ext_crypto_method; 84 92 } crypto_suite; 85 93 86 /* Crypto suites as defined on RFC 4568 */ 94 extern cipher_type_t aes_gcm_256_openssl; 95 extern cipher_type_t aes_gcm_128_openssl; 96 extern cipher_type_t aes_icm_192; 97 98 /* https://www.iana.org/assignments/sdp-security-descriptions/sdp-security-descriptions.xhtml */ 87 99 static crypto_suite crypto_suites[] = { 88 100 /* plain RTP/RTCP (no cipher & no auth) */ 89 101 {"NULL", NULL_CIPHER, 0, NULL_AUTH, 0, 0, 0, sec_serv_none}, 90 91 /* cipher AES_CM, auth HMAC_SHA1, auth tag len = 10 octets */ 92 {"AES_CM_128_HMAC_SHA1_80", AES_128_ICM, 30, HMAC_SHA1, 20, 10, 10, 102 #if defined(PJMEDIA_SRTP_HAS_AES_GCM_256) && \ 103 (PJMEDIA_SRTP_HAS_AES_GCM_256 != 0) 104 /* cipher AES_GCM, NULL auth, auth tag len = 16 octets */ 105 {"AEAD_AES_256_GCM", AES_256_GCM, AES_256_GCM_KEYSIZE_WSALT, 106 NULL_AUTH, 0, 16, 16, sec_serv_conf_and_auth, &aes_gcm_256_openssl}, 107 /* cipher AES_GCM, NULL auth, auth tag len = 8 octets */ 108 {"AEAD_AES_256_GCM_8", AES_256_GCM, AES_256_GCM_KEYSIZE_WSALT, 109 NULL_AUTH, 0, 8, 8, sec_serv_conf_and_auth, &aes_gcm_256_openssl}, 110 #endif 111 #if defined(PJMEDIA_SRTP_HAS_AES_CM_256) && \ 112 (PJMEDIA_SRTP_HAS_AES_CM_256 != 0) 113 /* cipher AES_CM_256, auth HMAC_SHA1, auth tag len = 10 octets */ 114 {"AES_256_CM_HMAC_SHA1_80", AES_ICM, 46, HMAC_SHA1, 20, 10, 10, 115 sec_serv_conf_and_auth, NULL, 116 &crypto_policy_set_aes_cm_256_hmac_sha1_80}, 117 /* cipher AES_CM_256, auth HMAC_SHA1, auth tag len = 10 octets */ 118 {"AES_256_CM_HMAC_SHA1_32", AES_ICM, 46, HMAC_SHA1, 20, 4, 10, 119 sec_serv_conf_and_auth, NULL, 120 &crypto_policy_set_aes_cm_256_hmac_sha1_32}, 121 #endif 122 #if defined(PJMEDIA_SRTP_HAS_AES_CM_192) && \ 123 (PJMEDIA_SRTP_HAS_AES_CM_192 != 0) 124 /* cipher AES_CM_192, auth HMAC_SHA1, auth tag len = 10 octets */ 125 {"AES_192_CM_HMAC_SHA1_80", AES_ICM, 38, HMAC_SHA1, 20, 10, 10, 126 sec_serv_conf_and_auth, &aes_icm_192}, 127 /* cipher AES_CM_192, auth HMAC_SHA1, auth tag len = 4 octets */ 128 {"AES_192_CM_HMAC_SHA1_32", AES_ICM, 38, HMAC_SHA1, 20, 4, 10, 129 sec_serv_conf_and_auth, &aes_icm_192}, 130 #endif 131 #if defined(PJMEDIA_SRTP_HAS_AES_GCM_128) && \ 132 (PJMEDIA_SRTP_HAS_AES_GCM_128 != 0) 133 /* cipher AES_GCM, NULL auth, auth tag len = 16 octets */ 134 {"AEAD_AES_128_GCM", AES_128_GCM, AES_128_GCM_KEYSIZE_WSALT, 135 NULL_AUTH, 0, 16, 16, sec_serv_conf_and_auth, &aes_gcm_128_openssl}, 136 137 /* cipher AES_GCM, NULL auth, auth tag len = 8 octets */ 138 {"AEAD_AES_128_GCM_8", AES_128_GCM, AES_128_GCM_KEYSIZE_WSALT, 139 NULL_AUTH, 0, 8, 8, sec_serv_conf_and_auth, &aes_gcm_128_openssl}, 140 #endif 141 #if defined(PJMEDIA_SRTP_HAS_AES_CM_128) && \ 142 (PJMEDIA_SRTP_HAS_AES_CM_128 != 0) 143 /* cipher AES_CM_128, auth HMAC_SHA1, auth tag len = 10 octets */ 144 {"AES_CM_128_HMAC_SHA1_80", AES_ICM, 30, HMAC_SHA1, 20, 10, 10, 93 145 sec_serv_conf_and_auth}, 94 95 /* cipher AES_CM, auth HMAC_SHA1, auth tag len = 4 octets */ 96 {"AES_CM_128_HMAC_SHA1_32", AES_128_ICM, 30, HMAC_SHA1, 20, 4, 10, 146 /* cipher AES_CM_128, auth HMAC_SHA1, auth tag len = 4 octets */ 147 {"AES_CM_128_HMAC_SHA1_32", AES_ICM, 30, HMAC_SHA1, 20, 4, 10, 97 148 sec_serv_conf_and_auth}, 98 149 #endif 99 150 /* 100 151 * F8_128_HMAC_SHA1_8 not supported by libsrtp? … … 337 388 PJ_UNUSED_ARG(endpt); 338 389 339 #if defined(PJMEDIA_EXTERNAL_SRTP) && (PJMEDIA_EXTERNAL_SRTP != 0) 390 #if !defined(PJMEDIA_SRTP_HAS_DEINIT) && !defined(PJMEDIA_SRTP_HAS_SHUTDOWN) 391 # define PJMEDIA_SRTP_HAS_SHUTDOWN 1 392 #endif 340 393 341 394 # if defined(PJMEDIA_SRTP_HAS_DEINIT) && PJMEDIA_SRTP_HAS_DEINIT!=0 … … 346 399 err = err_status_ok; 347 400 # endif 348 349 #else350 err = srtp_deinit();351 #endif352 401 if (err != err_status_ok) { 353 402 PJ_LOG(4, (THIS_FILE, "Failed to deinitialize libsrtp: %s", … … 1170 1219 pj_str_t input; 1171 1220 char *token; 1172 pj_size_t token_len;1173 1221 pj_str_t tmp; 1174 1222 pj_status_t status; 1175 int itmp ;1223 int itmp, token_len; 1176 1224 1177 1225 pj_bzero(crypto, sizeof(*crypto)); … … 1371 1419 /* Generate crypto attribute if not yet */ 1372 1420 if (pjmedia_sdp_media_find_attr(m_loc, &ID_CRYPTO, NULL) == NULL) { 1421 int tag = 1; 1422 1373 1423 /* Offer only current active crypto if any, otherwise offer all 1374 1424 * crypto-suites in the setting. … … 1385 1435 status = generate_crypto_attr_value(srtp->pool, buffer, &buffer_len, 1386 1436 &srtp->setting.crypto[i], 1387 i+1);1437 tag); 1388 1438 if (status != PJ_SUCCESS) 1389 1439 return status; … … 1395 1445 &attr_value); 1396 1446 m_loc->attr[m_loc->attr_count++] = attr; 1447 ++tag; 1397 1448 } 1398 1449 } … … 1457 1508 { 1458 1509 int cs_idx = get_crypto_idx(&tmp_rx_crypto.name); 1510 1511 if (cs_idx == -1) 1512 return PJMEDIA_SRTP_ENOTSUPCRYPTO; 1459 1513 1460 1514 /* Force to use test key */
Note: See TracChangeset
for help on using the changeset viewer.