Changeset 2950 for pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp
- Timestamp:
- Oct 16, 2009 3:06:13 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp
r2913 r2950 21 21 #include <pj/assert.h> 22 22 #include <pj/errno.h> 23 #include <pj/math.h> 23 24 #include <pj/pool.h> 24 25 #include <pj/sock.h> … … 414 415 pj_ssl_sock_proto proto; 415 416 pj_time_val timeout; 416 pj_str_t ciphers; 417 unsigned ciphers_num; 418 pj_ssl_cipher *ciphers; 417 419 pj_str_t servername; 418 420 }; 419 421 422 423 /* 424 * Get cipher list supported by SSL/TLS backend. 425 */ 426 PJ_DEF(pj_status_t) pj_ssl_cipher_get_availables (pj_ssl_cipher ciphers[], 427 unsigned *cipher_num) 428 { 429 /* Available ciphers */ 430 static pj_ssl_cipher ciphers_[64]; 431 static unsigned ciphers_num_ = 0; 432 unsigned i; 433 434 PJ_ASSERT_RETURN(ciphers && cipher_num, PJ_EINVAL); 435 436 if (ciphers_num_ == 0) { 437 RSocket sock; 438 CSecureSocket *secure_sock; 439 TPtrC16 proto(_L16("TLS1.0")); 440 441 secure_sock = CSecureSocket::NewL(sock, proto); 442 if (secure_sock) { 443 TBuf8<128> ciphers_buf(0); 444 secure_sock->AvailableCipherSuites(ciphers_buf); 445 446 ciphers_num_ = ciphers_buf.Length() / 2; 447 if (ciphers_num_ > PJ_ARRAY_SIZE(ciphers_)) 448 ciphers_num_ = PJ_ARRAY_SIZE(ciphers_); 449 for (i = 0; i < ciphers_num_; ++i) 450 ciphers_[i] = (pj_ssl_cipher)ciphers_buf[i*2]; 451 } 452 453 delete secure_sock; 454 } 455 456 if (ciphers_num_ == 0) { 457 return PJ_ENOTFOUND; 458 } 459 460 *cipher_num = PJ_MIN(*cipher_num, ciphers_num_); 461 for (i = 0; i < *cipher_num; ++i) 462 ciphers[i] = ciphers_[i]; 463 464 return PJ_SUCCESS; 465 } 420 466 421 467 /* … … 445 491 ssock->cb = param->cb; 446 492 ssock->user_data = param->user_data; 447 pj_strdup_with_null(pool, &ssock->ciphers, ¶m->ciphers); 493 ssock->ciphers_num = param->ciphers_num; 494 if (param->ciphers_num > 0) { 495 unsigned i; 496 ssock->ciphers = (pj_ssl_cipher*) 497 pj_pool_calloc(pool, param->ciphers_num, 498 sizeof(pj_ssl_cipher)); 499 for (i = 0; i < param->ciphers_num; ++i) 500 ssock->ciphers[i] = param->ciphers[i]; 501 } 448 502 pj_strdup_with_null(pool, &ssock->servername, ¶m->servername); 449 503 … … 452 506 453 507 return PJ_SUCCESS; 508 } 509 510 511 PJ_DEF(pj_status_t) pj_ssl_cert_load_from_files(pj_pool_t *pool, 512 const pj_str_t *CA_file, 513 const pj_str_t *cert_file, 514 const pj_str_t *privkey_file, 515 const pj_str_t *privkey_pass, 516 pj_ssl_cert_t **p_cert) 517 { 518 PJ_UNUSED_ARG(pool); 519 PJ_UNUSED_ARG(CA_file); 520 PJ_UNUSED_ARG(cert_file); 521 PJ_UNUSED_ARG(privkey_file); 522 PJ_UNUSED_ARG(privkey_pass); 523 PJ_UNUSED_ARG(p_cert); 524 return PJ_ENOTSUP; 454 525 } 455 526 … … 522 593 pj_ssl_sock_info *info) 523 594 { 524 const char *cipher_names[0x1B] = {525 "TLS_RSA_WITH_NULL_MD5",526 "TLS_RSA_WITH_NULL_SHA",527 "TLS_RSA_EXPORT_WITH_RC4_40_MD5",528 "TLS_RSA_WITH_RC4_128_MD5",529 "TLS_RSA_WITH_RC4_128_SHA",530 "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5",531 "TLS_RSA_WITH_IDEA_CBC_SHA",532 "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA",533 "TLS_RSA_WITH_DES_CBC_SHA",534 "TLS_RSA_WITH_3DES_EDE_CBC_SHA",535 "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA",536 "TLS_DH_DSS_WITH_DES_CBC_SHA",537 "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA",538 "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA",539 "TLS_DH_RSA_WITH_DES_CBC_SHA",540 "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA",541 "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA",542 "TLS_DHE_DSS_WITH_DES_CBC_SHA",543 "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA",544 "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",545 "TLS_DHE_RSA_WITH_DES_CBC_SHA",546 "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA",547 "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5",548 "TLS_DH_anon_WITH_RC4_128_MD5",549 "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA",550 "TLS_DH_anon_WITH_DES_CBC_SHA",551 "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA"552 };553 554 595 PJ_ASSERT_RETURN(ssock && info, PJ_EINVAL); 555 596 … … 571 612 } 572 613 573 /* Remote address */574 pj_sockaddr_cp((pj_sockaddr_t*)&info->remote_addr,575 (pj_sockaddr_t*)&ssock->rem_addr);576 577 /* Cipher suite */578 614 if (info->established) { 579 TBuf8<8> cipher; 615 /* Cipher suite */ 616 TBuf8<4> cipher; 580 617 if (ssock->sock->GetCipher(cipher) == KErrNone) { 581 TLex8 lex(cipher); 582 TUint cipher_code = cipher[1]; 583 if (cipher_code>=1 && cipher_code<=0x1B) 584 info->cipher = pj_str((char*)cipher_names[cipher_code-1]); 585 } 618 info->cipher = (pj_ssl_cipher)cipher[1]; 619 } 620 621 /* Remote address */ 622 pj_sockaddr_cp((pj_sockaddr_t*)&info->remote_addr, 623 (pj_sockaddr_t*)&ssock->rem_addr); 586 624 } 587 625
Note: See TracChangeset
for help on using the changeset viewer.