Changeset 3942
- Timestamp:
- Jan 16, 2012 5:05:47 AM (13 years ago)
- Location:
- pjproject/branches/1.x
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjlib/include/pj/ssl_sock.h
r3553 r3942 333 333 334 334 /** 335 * Check if the specified cipher is supported by SSL/TLS backend. 336 * 337 * @param cipher The cipher. 338 * 339 * @return PJ_TRUE when supported. 340 */ 341 PJ_DECL(pj_bool_t) pj_ssl_cipher_is_supported(pj_ssl_cipher cipher); 342 343 344 /** 335 345 * Get cipher name string. 336 346 * 337 347 * @param cipher The cipher. 338 348 * 339 * @return The cipher name or NULL if cipher is not recognized. 349 * @return The cipher name or NULL if cipher is not recognized/ 350 * supported. 340 351 */ 341 352 PJ_DECL(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher); 353 354 355 /** 356 * Get cipher ID from cipher name string. 357 * 358 * @param cipher_name The cipher name string. 359 * 360 * @return The cipher ID or PJ_TLS_UNKNOWN_CIPHER if the cipher 361 * name string is not recognized/supported. 362 */ 363 PJ_DECL(pj_ssl_cipher) pj_ssl_cipher_id(const char *cipher_name); 342 364 343 365 -
pjproject/branches/1.x/pjlib/src/pj/ssl_sock_common.c
r3553 r3942 21 21 #include <pj/errno.h> 22 22 #include <pj/string.h> 23 24 /* Cipher name structure */25 typedef struct cipher_name_t {26 pj_ssl_cipher cipher;27 const char *name;28 } cipher_name_t;29 30 /* Cipher name constants */31 static cipher_name_t cipher_names[] =32 {33 {PJ_TLS_NULL_WITH_NULL_NULL, "NULL"},34 35 /* TLS/SSLv3 */36 {PJ_TLS_RSA_WITH_NULL_MD5, "TLS_RSA_WITH_NULL_MD5"},37 {PJ_TLS_RSA_WITH_NULL_SHA, "TLS_RSA_WITH_NULL_SHA"},38 {PJ_TLS_RSA_WITH_NULL_SHA256, "TLS_RSA_WITH_NULL_SHA256"},39 {PJ_TLS_RSA_WITH_RC4_128_MD5, "TLS_RSA_WITH_RC4_128_MD5"},40 {PJ_TLS_RSA_WITH_RC4_128_SHA, "TLS_RSA_WITH_RC4_128_SHA"},41 {PJ_TLS_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_RSA_WITH_3DES_EDE_CBC_SHA"},42 {PJ_TLS_RSA_WITH_AES_128_CBC_SHA, "TLS_RSA_WITH_AES_128_CBC_SHA"},43 {PJ_TLS_RSA_WITH_AES_256_CBC_SHA, "TLS_RSA_WITH_AES_256_CBC_SHA"},44 {PJ_TLS_RSA_WITH_AES_128_CBC_SHA256, "TLS_RSA_WITH_AES_128_CBC_SHA256"},45 {PJ_TLS_RSA_WITH_AES_256_CBC_SHA256, "TLS_RSA_WITH_AES_256_CBC_SHA256"},46 {PJ_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA"},47 {PJ_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA"},48 {PJ_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA"},49 {PJ_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA"},50 {PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA, "TLS_DH_DSS_WITH_AES_128_CBC_SHA"},51 {PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA, "TLS_DH_RSA_WITH_AES_128_CBC_SHA"},52 {PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"},53 {PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA"},54 {PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA, "TLS_DH_DSS_WITH_AES_256_CBC_SHA"},55 {PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA, "TLS_DH_RSA_WITH_AES_256_CBC_SHA"},56 {PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA"},57 {PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"},58 {PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA256, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256"},59 {PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA256, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256"},60 {PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"},61 {PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"},62 {PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA256, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256"},63 {PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA256, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256"},64 {PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"},65 {PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"},66 {PJ_TLS_DH_anon_WITH_RC4_128_MD5, "TLS_DH_anon_WITH_RC4_128_MD5"},67 {PJ_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA"},68 {PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA, "TLS_DH_anon_WITH_AES_128_CBC_SHA"},69 {PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA, "TLS_DH_anon_WITH_AES_256_CBC_SHA"},70 {PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA256, "TLS_DH_anon_WITH_AES_128_CBC_SHA256"},71 {PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA256, "TLS_DH_anon_WITH_AES_256_CBC_SHA256"},72 73 /* TLS (deprecated) */74 {PJ_TLS_RSA_EXPORT_WITH_RC4_40_MD5, "TLS_RSA_EXPORT_WITH_RC4_40_MD5"},75 {PJ_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5"},76 {PJ_TLS_RSA_WITH_IDEA_CBC_SHA, "TLS_RSA_WITH_IDEA_CBC_SHA"},77 {PJ_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA"},78 {PJ_TLS_RSA_WITH_DES_CBC_SHA, "TLS_RSA_WITH_DES_CBC_SHA"},79 {PJ_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA"},80 {PJ_TLS_DH_DSS_WITH_DES_CBC_SHA, "TLS_DH_DSS_WITH_DES_CBC_SHA"},81 {PJ_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA"},82 {PJ_TLS_DH_RSA_WITH_DES_CBC_SHA, "TLS_DH_RSA_WITH_DES_CBC_SHA"},83 {PJ_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"},84 {PJ_TLS_DHE_DSS_WITH_DES_CBC_SHA, "TLS_DHE_DSS_WITH_DES_CBC_SHA"},85 {PJ_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"},86 {PJ_TLS_DHE_RSA_WITH_DES_CBC_SHA, "TLS_DHE_RSA_WITH_DES_CBC_SHA"},87 {PJ_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5"},88 {PJ_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA"},89 {PJ_TLS_DH_anon_WITH_DES_CBC_SHA, "TLS_DH_anon_WITH_DES_CBC_SHA"},90 91 /* SSLv3 */92 {PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA, "SSL_FORTEZZA_KEA_WITH_NULL_SHA"},93 {PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA,"SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA"},94 {PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA"},95 96 /* SSLv2 */97 {PJ_SSL_CK_RC4_128_WITH_MD5, "SSL_CK_RC4_128_WITH_MD5"},98 {PJ_SSL_CK_RC4_128_EXPORT40_WITH_MD5, "SSL_CK_RC4_128_EXPORT40_WITH_MD5"},99 {PJ_SSL_CK_RC2_128_CBC_WITH_MD5, "SSL_CK_RC2_128_CBC_WITH_MD5"},100 {PJ_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5, "SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5"},101 {PJ_SSL_CK_IDEA_128_CBC_WITH_MD5, "SSL_CK_IDEA_128_CBC_WITH_MD5"},102 {PJ_SSL_CK_DES_64_CBC_WITH_MD5, "SSL_CK_DES_64_CBC_WITH_MD5"},103 {PJ_SSL_CK_DES_192_EDE3_CBC_WITH_MD5, "SSL_CK_DES_192_EDE3_CBC_WITH_MD5"}104 };105 106 23 107 24 /* … … 128 45 param->proto = PJ_SSL_SOCK_PROTO_DEFAULT; 129 46 } 130 131 132 /* Get cipher name string */133 PJ_DEF(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher)134 {135 unsigned i, n;136 137 n = PJ_ARRAY_SIZE(cipher_names);138 for (i = 0; i < n; ++i) {139 if (cipher == cipher_names[i].cipher)140 return cipher_names[i].name;141 }142 143 return NULL;144 }145 146 147 47 148 48 -
pjproject/branches/1.x/pjlib/src/pj/ssl_sock_ossl.c
r3610 r3942 40 40 #define DELAYED_CLOSE_TIMEOUT 200 41 41 42 /* Maximum ciphers */ 43 #define MAX_CIPHERS 100 44 42 45 /* 43 46 * Include OpenSSL headers … … 270 273 271 274 /* OpenSSL available ciphers */ 272 static pj_ssl_cipher openssl_ciphers[100];273 275 static unsigned openssl_cipher_num; 276 static struct openssl_ciphers_t { 277 pj_ssl_cipher id; 278 const char *name; 279 } openssl_ciphers[MAX_CIPHERS]; 274 280 275 281 /* OpenSSL application data index */ … … 330 336 SSL_CIPHER *c; 331 337 c = sk_SSL_CIPHER_value(sk_cipher,i); 332 openssl_ciphers[i] = (pj_ssl_cipher)333 (pj_uint32_t)c->id & 0x00FFFFFF;334 //printf("%3u: %08x=%s\n", i+1, c->id, SSL_CIPHER_get_name(c));338 openssl_ciphers[i].id = (pj_ssl_cipher) 339 (pj_uint32_t)c->id & 0x00FFFFFF; 340 openssl_ciphers[i].name = SSL_CIPHER_get_name(c); 335 341 } 336 342 … … 1706 1712 } 1707 1713 1708 if (openssl_cipher_num == 0) 1714 if (openssl_cipher_num == 0) { 1715 *cipher_num = 0; 1709 1716 return PJ_ENOTFOUND; 1717 } 1710 1718 1711 1719 *cipher_num = PJ_MIN(*cipher_num, openssl_cipher_num); 1712 1720 1713 1721 for (i = 0; i < *cipher_num; ++i) 1714 ciphers[i] = openssl_ciphers[i] ;1722 ciphers[i] = openssl_ciphers[i].id; 1715 1723 1716 1724 return PJ_SUCCESS; 1725 } 1726 1727 1728 /* Get cipher name string */ 1729 PJ_DEF(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher) 1730 { 1731 unsigned i; 1732 1733 if (openssl_cipher_num == 0) { 1734 init_openssl(); 1735 shutdown_openssl(); 1736 } 1737 1738 for (i = 0; i < openssl_cipher_num; ++i) { 1739 if (cipher == openssl_ciphers[i].id) 1740 return openssl_ciphers[i].name; 1741 } 1742 1743 return NULL; 1744 } 1745 1746 /* Check if the specified cipher is supported by SSL/TLS backend. */ 1747 PJ_DEF(pj_bool_t) pj_ssl_cipher_is_supported(pj_ssl_cipher cipher) 1748 { 1749 unsigned i; 1750 1751 if (openssl_cipher_num == 0) { 1752 init_openssl(); 1753 shutdown_openssl(); 1754 } 1755 1756 for (i = 0; i < openssl_cipher_num; ++i) { 1757 if (cipher == openssl_ciphers[i].id) 1758 return PJ_TRUE; 1759 } 1760 1761 return PJ_FALSE; 1717 1762 } 1718 1763 -
pjproject/branches/1.x/pjlib/src/pj/ssl_sock_symbian.cpp
r3553 r3942 33 33 #define THIS_FILE "ssl_sock_symbian.cpp" 34 34 35 36 /* Cipher name structure */ 37 typedef struct cipher_name_t { 38 pj_ssl_cipher cipher; 39 const char *name; 40 } cipher_name_t; 41 42 /* Cipher name constants */ 43 static cipher_name_t cipher_names[] = 44 { 45 {PJ_TLS_NULL_WITH_NULL_NULL, "NULL"}, 46 47 /* TLS/SSLv3 */ 48 {PJ_TLS_RSA_WITH_NULL_MD5, "TLS_RSA_WITH_NULL_MD5"}, 49 {PJ_TLS_RSA_WITH_NULL_SHA, "TLS_RSA_WITH_NULL_SHA"}, 50 {PJ_TLS_RSA_WITH_NULL_SHA256, "TLS_RSA_WITH_NULL_SHA256"}, 51 {PJ_TLS_RSA_WITH_RC4_128_MD5, "TLS_RSA_WITH_RC4_128_MD5"}, 52 {PJ_TLS_RSA_WITH_RC4_128_SHA, "TLS_RSA_WITH_RC4_128_SHA"}, 53 {PJ_TLS_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_RSA_WITH_3DES_EDE_CBC_SHA"}, 54 {PJ_TLS_RSA_WITH_AES_128_CBC_SHA, "TLS_RSA_WITH_AES_128_CBC_SHA"}, 55 {PJ_TLS_RSA_WITH_AES_256_CBC_SHA, "TLS_RSA_WITH_AES_256_CBC_SHA"}, 56 {PJ_TLS_RSA_WITH_AES_128_CBC_SHA256, "TLS_RSA_WITH_AES_128_CBC_SHA256"}, 57 {PJ_TLS_RSA_WITH_AES_256_CBC_SHA256, "TLS_RSA_WITH_AES_256_CBC_SHA256"}, 58 {PJ_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA"}, 59 {PJ_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA"}, 60 {PJ_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA"}, 61 {PJ_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA"}, 62 {PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA, "TLS_DH_DSS_WITH_AES_128_CBC_SHA"}, 63 {PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA, "TLS_DH_RSA_WITH_AES_128_CBC_SHA"}, 64 {PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"}, 65 {PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA"}, 66 {PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA, "TLS_DH_DSS_WITH_AES_256_CBC_SHA"}, 67 {PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA, "TLS_DH_RSA_WITH_AES_256_CBC_SHA"}, 68 {PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA"}, 69 {PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"}, 70 {PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA256, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256"}, 71 {PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA256, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256"}, 72 {PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"}, 73 {PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"}, 74 {PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA256, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256"}, 75 {PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA256, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256"}, 76 {PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"}, 77 {PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"}, 78 {PJ_TLS_DH_anon_WITH_RC4_128_MD5, "TLS_DH_anon_WITH_RC4_128_MD5"}, 79 {PJ_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA"}, 80 {PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA, "TLS_DH_anon_WITH_AES_128_CBC_SHA"}, 81 {PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA, "TLS_DH_anon_WITH_AES_256_CBC_SHA"}, 82 {PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA256, "TLS_DH_anon_WITH_AES_128_CBC_SHA256"}, 83 {PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA256, "TLS_DH_anon_WITH_AES_256_CBC_SHA256"}, 84 85 /* TLS (deprecated) */ 86 {PJ_TLS_RSA_EXPORT_WITH_RC4_40_MD5, "TLS_RSA_EXPORT_WITH_RC4_40_MD5"}, 87 {PJ_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5"}, 88 {PJ_TLS_RSA_WITH_IDEA_CBC_SHA, "TLS_RSA_WITH_IDEA_CBC_SHA"}, 89 {PJ_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA"}, 90 {PJ_TLS_RSA_WITH_DES_CBC_SHA, "TLS_RSA_WITH_DES_CBC_SHA"}, 91 {PJ_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA"}, 92 {PJ_TLS_DH_DSS_WITH_DES_CBC_SHA, "TLS_DH_DSS_WITH_DES_CBC_SHA"}, 93 {PJ_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA"}, 94 {PJ_TLS_DH_RSA_WITH_DES_CBC_SHA, "TLS_DH_RSA_WITH_DES_CBC_SHA"}, 95 {PJ_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"}, 96 {PJ_TLS_DHE_DSS_WITH_DES_CBC_SHA, "TLS_DHE_DSS_WITH_DES_CBC_SHA"}, 97 {PJ_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"}, 98 {PJ_TLS_DHE_RSA_WITH_DES_CBC_SHA, "TLS_DHE_RSA_WITH_DES_CBC_SHA"}, 99 {PJ_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5"}, 100 {PJ_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA"}, 101 {PJ_TLS_DH_anon_WITH_DES_CBC_SHA, "TLS_DH_anon_WITH_DES_CBC_SHA"}, 102 103 /* SSLv3 */ 104 {PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA, "SSL_FORTEZZA_KEA_WITH_NULL_SHA"}, 105 {PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA,"SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA"}, 106 {PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA"}, 107 108 /* SSLv2 */ 109 {PJ_SSL_CK_RC4_128_WITH_MD5, "SSL_CK_RC4_128_WITH_MD5"}, 110 {PJ_SSL_CK_RC4_128_EXPORT40_WITH_MD5, "SSL_CK_RC4_128_EXPORT40_WITH_MD5"}, 111 {PJ_SSL_CK_RC2_128_CBC_WITH_MD5, "SSL_CK_RC2_128_CBC_WITH_MD5"}, 112 {PJ_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5, "SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5"}, 113 {PJ_SSL_CK_IDEA_128_CBC_WITH_MD5, "SSL_CK_IDEA_128_CBC_WITH_MD5"}, 114 {PJ_SSL_CK_DES_64_CBC_WITH_MD5, "SSL_CK_DES_64_CBC_WITH_MD5"}, 115 {PJ_SSL_CK_DES_192_EDE3_CBC_WITH_MD5, "SSL_CK_DES_192_EDE3_CBC_WITH_MD5"} 116 }; 117 118 119 /* Get cipher name string */ 120 static const char* get_cipher_name(pj_ssl_cipher cipher) 121 { 122 unsigned i, n; 123 124 n = PJ_ARRAY_SIZE(cipher_names); 125 for (i = 0; i < n; ++i) { 126 if (cipher == cipher_names[i].cipher) 127 return cipher_names[i].name; 128 } 129 130 return "CIPHER_UNKNOWN"; 131 } 132 35 133 typedef void (*CPjSSLSocket_cb)(int err, void *key); 36 134 … … 116 214 int Connect(CPjSSLSocket_cb cb, void *key, const TInetAddr &local_addr, 117 215 const TInetAddr &rem_addr, 118 const TDesC8 &servername = TPtrC8(NULL,0)); 216 const TDesC8 &servername = TPtrC8(NULL,0), 217 const TDesC8 &ciphers = TPtrC8(NULL,0)); 119 218 int Send(CPjSSLSocket_cb cb, void *key, const TDesC8 &aDesc, TUint flags); 120 219 int SendSync(const TDesC8 &aDesc, TUint flags); … … 147 246 TInetAddr rem_addr_; 148 247 TPtrC8 servername_; 248 TPtrC8 ciphers_; 149 249 TInetAddr local_addr_; 150 250 TSockXfrLength sent_len_; … … 187 287 const TInetAddr &local_addr, 188 288 const TInetAddr &rem_addr, 189 const TDesC8 &servername) 289 const TDesC8 &servername, 290 const TDesC8 &ciphers) 190 291 { 191 292 pj_status_t status; … … 214 315 key_ = key; 215 316 rem_addr_ = rem_addr; 317 318 /* Note: the following members only keep the pointer, not the data */ 216 319 servername_.Set(servername); 320 ciphers_.Set(ciphers); 321 217 322 rSock.Connect(rem_addr_, iStatus); 218 323 SetActive(); … … 319 424 securesock_->SetOpt(KSoSSLDomainName, KSolInetSSL, 320 425 servername_); 426 if (ciphers_.Length() > 0) 427 securesock_->SetAvailableCipherSuites(ciphers_); 321 428 322 429 // FlushSessionCache() seems to also fire signals to all … … 442 549 pj_ssl_sock_proto proto; 443 550 pj_time_val timeout; 444 unsigned ciphers_num;445 pj_ssl_cipher *ciphers;446 551 pj_str_t servername; 552 pj_str_t ciphers; 447 553 pj_ssl_cert_info remote_cert_info; 448 554 }; … … 580 686 581 687 688 /* Available ciphers */ 689 static unsigned ciphers_num_ = 0; 690 static struct ciphers_t 691 { 692 pj_ssl_cipher id; 693 const char *name; 694 } ciphers_[64]; 695 582 696 /* 583 697 * Get cipher list supported by SSL/TLS backend. … … 586 700 unsigned *cipher_num) 587 701 { 588 /* Available ciphers */589 static pj_ssl_cipher ciphers_[64];590 static unsigned ciphers_num_ = 0;591 702 unsigned i; 592 703 … … 606 717 if (ciphers_num_ > PJ_ARRAY_SIZE(ciphers_)) 607 718 ciphers_num_ = PJ_ARRAY_SIZE(ciphers_); 608 for (i = 0; i < ciphers_num_; ++i) 609 ciphers_[i] = (pj_ssl_cipher)(ciphers_buf[i*2]*10 + 610 ciphers_buf[i*2+1]); 719 for (i = 0; i < ciphers_num_; ++i) { 720 ciphers_[i].id = (pj_ssl_cipher)(ciphers_buf[i*2]*10 + 721 ciphers_buf[i*2+1]); 722 ciphers_[i].name = get_cipher_name(ciphers_[i].id); 723 } 611 724 } 612 725 … … 615 728 616 729 if (ciphers_num_ == 0) { 730 *cipher_num = 0; 617 731 return PJ_ENOTFOUND; 618 732 } … … 620 734 *cipher_num = PJ_MIN(*cipher_num, ciphers_num_); 621 735 for (i = 0; i < *cipher_num; ++i) 622 ciphers[i] = ciphers_[i] ;736 ciphers[i] = ciphers_[i].id; 623 737 624 738 return PJ_SUCCESS; 625 739 } 740 741 742 /* Get cipher name string */ 743 PJ_DEF(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher) 744 { 745 unsigned i; 746 747 if (ciphers_num_ == 0) { 748 pj_ssl_cipher c[1]; 749 i = 0; 750 pj_ssl_cipher_get_availables(c, &i); 751 } 752 753 for (i = 0; i < ciphers_num_; ++i) { 754 if (cipher == ciphers_[i].id) 755 return ciphers_[i].name; 756 } 757 758 return NULL; 759 } 760 761 762 /* Check if the specified cipher is supported by SSL/TLS backend. */ 763 PJ_DEF(pj_bool_t) pj_ssl_cipher_is_supported(pj_ssl_cipher cipher) 764 { 765 unsigned i; 766 767 if (ciphers_num_ == 0) { 768 pj_ssl_cipher c[1]; 769 i = 0; 770 pj_ssl_cipher_get_availables(c, &i); 771 } 772 773 for (i = 0; i < ciphers_num_; ++i) { 774 if (cipher == ciphers_[i].id) 775 return PJ_TRUE; 776 } 777 778 return PJ_FALSE; 779 } 780 626 781 627 782 /* … … 653 808 ssock->user_data = param->user_data; 654 809 ssock->timeout = param->timeout; 655 ssock->ciphers_num = param->ciphers_num;656 810 if (param->ciphers_num > 0) { 657 unsigned i; 658 ssock->ciphers = (pj_ssl_cipher*) 659 pj_pool_calloc(pool, param->ciphers_num, 660 sizeof(pj_ssl_cipher)); 661 for (i = 0; i < param->ciphers_num; ++i) 662 ssock->ciphers[i] = param->ciphers[i]; 811 /* Cipher list in Symbian is represented as array of two-octets. */ 812 ssock->ciphers.slen = param->ciphers_num*2; 813 ssock->ciphers.ptr = (char*)pj_pool_alloc(pool, ssock->ciphers.slen); 814 pj_uint8_t *c = (pj_uint8_t*)ssock->ciphers.ptr; 815 for (unsigned i = 0; i < param->ciphers_num; ++i) { 816 *c++ = (pj_uint8_t)(param->ciphers[i] & 0xFF00) >> 8; 817 *c++ = (pj_uint8_t)(param->ciphers[i] & 0xFF); 818 } 663 819 } 664 820 pj_strdup_with_null(pool, &ssock->servername, ¶m->server_name); … … 1247 1403 ssock->servername.slen); 1248 1404 1405 /* Convert cipher list to Symbian descriptor */ 1406 TPtrC8 ciphers_((TUint8*)ssock->ciphers.ptr, 1407 ssock->ciphers.slen); 1408 1249 1409 /* Try to connect */ 1250 1410 status = sock->Connect(&connect_cb, ssock, localaddr_, remaddr_, 1251 servername_ );1411 servername_, ciphers_); 1252 1412 if (status != PJ_SUCCESS && status != PJ_EPENDING) { 1253 1413 delete sock; -
pjproject/branches/1.x/pjsip-apps/src/pjsua/pjsua_app.c
r3830 r3942 252 252 puts (" --stun-srv=FORMAT Set STUN server host or domain. This option may be"); 253 253 puts (" specified more than once. FORMAT is hostdom[:PORT]"); 254 255 #if defined(PJSIP_HAS_TLS_TRANSPORT) && (PJSIP_HAS_TLS_TRANSPORT != 0) 254 256 puts (""); 255 257 puts ("TLS Options:"); … … 263 265 puts (" --tls-neg-timeout Specify TLS negotiation timeout (default=no)"); 264 266 puts (" --tls-srv-name Specify TLS server name for multihosting server"); 267 puts (" --tls-cipher Specify prefered TLS cipher (optional)."); 268 puts (" May be specified multiple times"); 269 #endif 265 270 266 271 puts (""); … … 530 535 OPT_USE_TLS, OPT_TLS_CA_FILE, OPT_TLS_CERT_FILE, OPT_TLS_PRIV_FILE, 531 536 OPT_TLS_PASSWORD, OPT_TLS_VERIFY_SERVER, OPT_TLS_VERIFY_CLIENT, 532 OPT_TLS_NEG_TIMEOUT, OPT_TLS_SRV_NAME, 537 OPT_TLS_NEG_TIMEOUT, OPT_TLS_SRV_NAME, OPT_TLS_CIPHER, 533 538 OPT_CAPTURE_DEV, OPT_PLAYBACK_DEV, 534 539 OPT_CAPTURE_LAT, OPT_PLAYBACK_LAT, OPT_NO_TONES, OPT_JB_MAX_SIZE, … … 629 634 { "duration", 1, 0, OPT_DURATION}, 630 635 { "thread-cnt", 1, 0, OPT_THREAD_CNT}, 636 #if defined(PJSIP_HAS_TLS_TRANSPORT) && (PJSIP_HAS_TLS_TRANSPORT != 0) 631 637 { "use-tls", 0, 0, OPT_USE_TLS}, 632 638 { "tls-ca-file",1, 0, OPT_TLS_CA_FILE}, … … 638 644 { "tls-neg-timeout", 1, 0, OPT_TLS_NEG_TIMEOUT}, 639 645 { "tls-srv-name", 1, 0, OPT_TLS_SRV_NAME}, 646 { "tls-cipher", 1, 0, OPT_TLS_CIPHER}, 647 #endif 640 648 { "capture-dev", 1, 0, OPT_CAPTURE_DEV}, 641 649 { "playback-dev", 1, 0, OPT_PLAYBACK_DEV}, … … 1304 1312 break; 1305 1313 1314 #if defined(PJSIP_HAS_TLS_TRANSPORT) && (PJSIP_HAS_TLS_TRANSPORT != 0) 1306 1315 case OPT_USE_TLS: 1307 1316 cfg->use_tls = PJ_TRUE; 1308 #if !defined(PJSIP_HAS_TLS_TRANSPORT) || PJSIP_HAS_TLS_TRANSPORT==01309 PJ_LOG(1,(THIS_FILE, "Error: TLS support is not configured"));1310 return -1;1311 #endif1312 1317 break; 1313 1318 1314 1319 case OPT_TLS_CA_FILE: 1315 1320 cfg->udp_cfg.tls_setting.ca_list_file = pj_str(pj_optarg); 1316 #if !defined(PJSIP_HAS_TLS_TRANSPORT) || PJSIP_HAS_TLS_TRANSPORT==01317 PJ_LOG(1,(THIS_FILE, "Error: TLS support is not configured"));1318 return -1;1319 #endif1320 1321 break; 1321 1322 1322 1323 case OPT_TLS_CERT_FILE: 1323 1324 cfg->udp_cfg.tls_setting.cert_file = pj_str(pj_optarg); 1324 #if !defined(PJSIP_HAS_TLS_TRANSPORT) || PJSIP_HAS_TLS_TRANSPORT==01325 PJ_LOG(1,(THIS_FILE, "Error: TLS support is not configured"));1326 return -1;1327 #endif1328 1325 break; 1329 1326 … … 1334 1331 case OPT_TLS_PASSWORD: 1335 1332 cfg->udp_cfg.tls_setting.password = pj_str(pj_optarg); 1336 #if !defined(PJSIP_HAS_TLS_TRANSPORT) || PJSIP_HAS_TLS_TRANSPORT==01337 PJ_LOG(1,(THIS_FILE, "Error: TLS support is not configured"));1338 return -1;1339 #endif1340 1333 break; 1341 1334 … … 1356 1349 cfg->udp_cfg.tls_setting.server_name = pj_str(pj_optarg); 1357 1350 break; 1351 case OPT_TLS_CIPHER: 1352 { 1353 pj_ssl_cipher cipher; 1354 1355 if (pj_ansi_strnicmp(pj_optarg, "0x", 2) == 0) { 1356 pj_str_t cipher_st = pj_str(pj_optarg + 2); 1357 cipher = pj_strtoul2(&cipher_st, NULL, 16); 1358 } else { 1359 cipher = atoi(pj_optarg); 1360 } 1361 1362 if (pj_ssl_cipher_is_supported(cipher)) { 1363 static pj_ssl_cipher tls_ciphers[128]; 1364 1365 tls_ciphers[cfg->udp_cfg.tls_setting.ciphers_num++] = cipher; 1366 cfg->udp_cfg.tls_setting.ciphers = tls_ciphers; 1367 } else { 1368 pj_ssl_cipher ciphers[128]; 1369 unsigned j, ciphers_cnt; 1370 1371 ciphers_cnt = PJ_ARRAY_SIZE(ciphers); 1372 pj_ssl_cipher_get_availables(ciphers, &ciphers_cnt); 1373 1374 PJ_LOG(1,(THIS_FILE, "Cipher \"%s\" is not supported by " 1375 "TLS/SSL backend.", pj_optarg)); 1376 printf("Available TLS/SSL ciphers (%d):\n", ciphers_cnt); 1377 for (j=0; j<ciphers_cnt; ++j) 1378 printf("- 0x%06X: %s\n", ciphers[j], pj_ssl_cipher_name(ciphers[j])); 1379 return -1; 1380 } 1381 } 1382 break; 1383 #endif /* PJSIP_HAS_TLS_TRANSPORT */ 1358 1384 1359 1385 case OPT_CAPTURE_DEV: … … 1774 1800 } 1775 1801 1802 #if defined(PJSIP_HAS_TLS_TRANSPORT) && (PJSIP_HAS_TLS_TRANSPORT != 0) 1776 1803 /* TLS */ 1777 1804 if (config->use_tls) … … 1821 1848 pj_strcat2(&cfg, line); 1822 1849 } 1850 1851 for (i=0; i<config->udp_cfg.tls_setting.ciphers_num; ++i) { 1852 pj_ansi_sprintf(line, "--tls-cipher 0x%06X # %s\n", 1853 config->udp_cfg.tls_setting.ciphers[i], 1854 pj_ssl_cipher_name(config->udp_cfg.tls_setting.ciphers[i])); 1855 pj_strcat2(&cfg, line); 1856 } 1857 #endif 1823 1858 1824 1859 pj_strcat2(&cfg, "\n#\n# Media settings:\n#\n"); … … 3006 3041 const char *verif_msgs[32]; 3007 3042 unsigned verif_msg_cnt; 3043 3044 /* Dump server TLS cipher */ 3045 PJ_LOG(4,(THIS_FILE, "TLS cipher used: 0x%06X/%s", 3046 ssl_sock_info->cipher, 3047 pj_ssl_cipher_name(ssl_sock_info->cipher) )); 3008 3048 3009 3049 /* Dump server TLS certificate */ -
pjproject/branches/1.x/pjsip/include/pjsip/sip_transport_tls.h
r3553 r3942 27 27 28 28 #include <pjsip/sip_transport.h> 29 #include <pj/pool.h> 29 30 #include <pj/ssl_sock.h> 30 31 #include <pj/string.h> … … 107 108 108 109 /** 109 * TLS cipher list string in OpenSSL format. If empty, then default 110 * cipher list of the backend will be used. 111 */ 112 pj_str_t ciphers; 110 * Number of ciphers contained in the specified cipher preference. 111 * If this is set to zero, then default cipher list of the backend 112 * will be used. 113 * 114 * Default: 0 (zero). 115 */ 116 unsigned ciphers_num; 117 118 /** 119 * Ciphers and order preference. The #pj_ssl_cipher_get_availables() 120 * can be used to check the available ciphers supported by backend. 121 */ 122 pj_ssl_cipher *ciphers; 113 123 114 124 /** … … 247 257 pj_strdup_with_null(pool, &dst->privkey_file, &src->privkey_file); 248 258 pj_strdup_with_null(pool, &dst->password, &src->password); 249 pj_strdup_with_null(pool, &dst->ciphers, &src->ciphers); 259 if (src->ciphers_num) { 260 unsigned i; 261 dst->ciphers = (pj_ssl_cipher*) pj_pool_calloc(pool, src->ciphers_num, 262 sizeof(pj_ssl_cipher)); 263 for (i=0; i<src->ciphers_num; ++i) 264 dst->ciphers[i] = src->ciphers[i]; 265 } 250 266 } 251 267 -
pjproject/branches/1.x/pjsip/src/pjsip/sip_transport_tls.c
r3553 r3942 294 294 if (ssock_param.read_buffer_size < PJSIP_MAX_PKT_LEN) 295 295 ssock_param.read_buffer_size = PJSIP_MAX_PKT_LEN; 296 ssock_param.ciphers_num = listener->tls_setting.ciphers_num; 297 ssock_param.ciphers = listener->tls_setting.ciphers; 296 298 ssock_param.qos_type = listener->tls_setting.qos_type; 297 299 ssock_param.qos_ignore_error = listener->tls_setting.qos_ignore_error; … … 863 865 ssock_param.async_cnt = 1; 864 866 ssock_param.ioqueue = pjsip_endpt_get_ioqueue(listener->endpt); 865 PJ_TODO(synchronize_tls_cipher_type_with_ssl_sock_cipher_type);866 867 ssock_param.server_name = remote_name; 867 868 ssock_param.timeout = listener->tls_setting.timeout; … … 873 874 if (ssock_param.read_buffer_size < PJSIP_MAX_PKT_LEN) 874 875 ssock_param.read_buffer_size = PJSIP_MAX_PKT_LEN; 876 ssock_param.ciphers_num = listener->tls_setting.ciphers_num; 877 ssock_param.ciphers = listener->tls_setting.ciphers; 875 878 ssock_param.qos_type = listener->tls_setting.qos_type; 876 879 ssock_param.qos_ignore_error = listener->tls_setting.qos_ignore_error;
Note: See TracChangeset
for help on using the changeset viewer.