Changeset 5517 for pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
- Timestamp:
- Jan 10, 2017 9:17:07 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5501 r5517 52 52 #include <openssl/rand.h> 53 53 #include <openssl/engine.h> 54 55 #if defined(PJ_SSL_SOCK_OSSL_HAS_EC) && PJ_SSL_SOCK_OSSL_HAS_EC==1 56 extern int tls1_ec_nid2curve_id(int nid); 57 extern int tls1_ec_curve_id2nid(int curve_id); 54 #include <openssl/opensslconf.h> 55 56 #if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL 57 58 # include <openssl/obj_mac.h> 59 60 static const unsigned nid_cid_map[] = { 61 NID_sect163k1, /* sect163k1 (1) */ 62 NID_sect163r1, /* sect163r1 (2) */ 63 NID_sect163r2, /* sect163r2 (3) */ 64 NID_sect193r1, /* sect193r1 (4) */ 65 NID_sect193r2, /* sect193r2 (5) */ 66 NID_sect233k1, /* sect233k1 (6) */ 67 NID_sect233r1, /* sect233r1 (7) */ 68 NID_sect239k1, /* sect239k1 (8) */ 69 NID_sect283k1, /* sect283k1 (9) */ 70 NID_sect283r1, /* sect283r1 (10) */ 71 NID_sect409k1, /* sect409k1 (11) */ 72 NID_sect409r1, /* sect409r1 (12) */ 73 NID_sect571k1, /* sect571k1 (13) */ 74 NID_sect571r1, /* sect571r1 (14) */ 75 NID_secp160k1, /* secp160k1 (15) */ 76 NID_secp160r1, /* secp160r1 (16) */ 77 NID_secp160r2, /* secp160r2 (17) */ 78 NID_secp192k1, /* secp192k1 (18) */ 79 NID_X9_62_prime192v1, /* secp192r1 (19) */ 80 NID_secp224k1, /* secp224k1 (20) */ 81 NID_secp224r1, /* secp224r1 (21) */ 82 NID_secp256k1, /* secp256k1 (22) */ 83 NID_X9_62_prime256v1, /* secp256r1 (23) */ 84 NID_secp384r1, /* secp384r1 (24) */ 85 NID_secp521r1, /* secp521r1 (25) */ 86 NID_brainpoolP256r1, /* brainpoolP256r1 (26) */ 87 NID_brainpoolP384r1, /* brainpoolP384r1 (27) */ 88 NID_brainpoolP512r1 /* brainpoolP512r1 (28) */ 89 }; 90 91 static unsigned get_cid_from_nid(unsigned nid) 92 { 93 unsigned i, cid = 0; 94 for (i=0; i<PJ_ARRAY_SIZE(nid_cid_map); ++i) { 95 if (nid == nid_cid_map[i]) { 96 cid = i+1; 97 break; 98 } 99 } 100 return cid; 101 }; 102 103 static unsigned get_nid_from_cid(unsigned cid) 104 { 105 if ((cid == 0) || (cid > PJ_ARRAY_SIZE(nid_cid_map))) 106 return 0; 107 108 return nid_cid_map[cid-1]; 109 } 110 58 111 #endif 59 112 … … 386 439 ssl->session = SSL_SESSION_new(); 387 440 388 #if defined(PJ_SSL_SOCK_OSSL_HAS_EC) && PJ_SSL_SOCK_OSSL_HAS_EC==1441 #if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL 389 442 openssl_curves_num = SSL_get_shared_curve(ssl,-1); 390 443 if (openssl_curves_num > PJ_ARRAY_SIZE(openssl_curves)) … … 403 456 } 404 457 405 openssl_curves[i].id = tls1_ec_nid2curve_id(nid);458 openssl_curves[i].id = get_cid_from_nid(nid); 406 459 openssl_curves[i].name = cname; 407 460 } … … 1002 1055 static pj_status_t set_curves_list(pj_ssl_sock_t *ssock) 1003 1056 { 1004 #if defined(PJ_SSL_SOCK_OSSL_HAS_EC) && PJ_SSL_SOCK_OSSL_HAS_EC==11057 #if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL 1005 1058 int ret; 1006 1059 int curves[PJ_SSL_SOCK_MAX_CURVES]; 1007 intcnt;1060 unsigned cnt; 1008 1061 1009 1062 if (ssock->param.curves_num == 0) … … 1011 1064 1012 1065 for (cnt = 0; cnt < ssock->param.curves_num; cnt++) { 1013 curves[cnt] = tls1_ec_curve_id2nid(ssock->param.curves[cnt]);1066 curves[cnt] = get_nid_from_cid(ssock->param.curves[cnt]); 1014 1067 } 1015 1068 … … 1028 1081 PJ_UNUSED_ARG(ssock); 1029 1082 #endif 1030 1031 1083 return PJ_SUCCESS; 1032 1084 } … … 1034 1086 static pj_status_t set_sigalgs(pj_ssl_sock_t *ssock) 1035 1087 { 1036 #if defined(PJ_SSL_SOCK_OSSL_HAS_SIGALG) && PJ_SSL_SOCK_OSSL_HAS_SIGALG==11088 #if OPENSSL_VERSION_NUMBER >= 0x1000200fL 1037 1089 int ret; 1038 1090 … … 1052 1104 PJ_UNUSED_ARG(ssock); 1053 1105 #endif 1054 1055 1106 return PJ_SUCCESS; 1056 1107 }
Note: See TracChangeset
for help on using the changeset viewer.