Changeset 3999 for pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
- Timestamp:
- Mar 30, 2012 7:10:13 AM (12 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r3841 r3999 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
Note: See TracChangeset
for help on using the changeset viewer.