Changeset 5424
- Timestamp:
- 03/17/08 11:52:44 (4 months ago)
- Files:
-
- libwired/trunk/libwired/p7/wi-p7-socket.c (modified) (13 diffs)
- libwired/trunk/libwired/p7/wi-p7-socket.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/p7/wi-p7-socket.c
r5417 r5424 143 143 144 144 wi_boolean_t encryption_enabled; 145 wi_rsa_t *rsa; 145 wi_rsa_t *private_key; 146 wi_rsa_t *public_key; 146 147 wi_cipher_t *cipher; 147 148 … … 284 285 wi_release(p7_socket->name); 285 286 wi_release(p7_socket->version); 286 wi_release(p7_socket->rsa); 287 wi_release(p7_socket->private_key); 288 wi_release(p7_socket->public_key); 287 289 wi_release(p7_socket->cipher); 288 290 } … … 304 306 #pragma mark - 305 307 306 void wi_p7_socket_set_private_ rsa(wi_p7_socket_t *p7_socket, wi_rsa_t *rsa) {308 void wi_p7_socket_set_private_key(wi_p7_socket_t *p7_socket, wi_rsa_t *rsa) { 307 309 wi_retain(rsa); 308 wi_release(p7_socket->rsa); 309 310 p7_socket->rsa = rsa; 311 } 312 313 314 315 wi_rsa_t * wi_p7_socket_private_rsa(wi_p7_socket_t *p7_socket) { 316 return p7_socket->rsa; 310 wi_release(p7_socket->private_key); 311 312 p7_socket->private_key = rsa; 313 } 314 315 316 317 wi_rsa_t * wi_p7_socket_private_key(wi_p7_socket_t *p7_socket) { 318 return p7_socket->private_key; 319 } 320 321 322 323 wi_rsa_t * wi_p7_socket_public_key(wi_p7_socket_t *p7_socket) { 324 return p7_socket->public_key; 317 325 } 318 326 … … 714 722 } 715 723 716 p7_socket-> rsa= wi_rsa_init_with_public_key(wi_rsa_alloc(), rsa);717 718 if(!p7_socket-> rsa)724 p7_socket->public_key = wi_rsa_init_with_public_key(wi_rsa_alloc(), rsa); 725 726 if(!p7_socket->public_key) 719 727 return false; 720 728 … … 729 737 return false; 730 738 731 data = wi_rsa_encrypt(p7_socket-> rsa, wi_cipher_key(p7_socket->cipher));739 data = wi_rsa_encrypt(p7_socket->public_key, wi_cipher_key(p7_socket->cipher)); 732 740 733 741 if(!wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.cipher.key"))) … … 737 745 738 746 if(data) { 739 data = wi_rsa_encrypt(p7_socket-> rsa, data);747 data = wi_rsa_encrypt(p7_socket->public_key, data); 740 748 741 749 if(!wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.cipher.iv"))) … … 746 754 username = WI_STR(""); 747 755 748 data = wi_rsa_encrypt(p7_socket-> rsa, wi_string_data(username));756 data = wi_rsa_encrypt(p7_socket->public_key, wi_string_data(username)); 749 757 750 758 if(!data) … … 760 768 client_password2 = wi_data_sha1(wi_data_by_appending_data(rsa, wi_string_data(wi_string_sha1(password)))); 761 769 762 data = wi_rsa_encrypt(p7_socket-> rsa, wi_string_data(client_password1));770 data = wi_rsa_encrypt(p7_socket->public_key, wi_string_data(client_password1)); 763 771 764 772 if(!data) … … 830 838 return false; 831 839 832 if(!p7_socket-> rsa) {840 if(!p7_socket->private_key) { 833 841 wi_error_set_libwired_error(WI_ERROR_P7_NORSAKEY); 834 842 … … 836 844 } 837 845 838 rsa = wi_rsa_public_key(p7_socket-> rsa);846 rsa = wi_rsa_public_key(p7_socket->private_key); 839 847 840 848 if(!wi_p7_message_set_data_for_name(p7_message, rsa, WI_STR("p7.encryption.public_key"))) … … 867 875 } 868 876 869 key = wi_rsa_decrypt(p7_socket-> rsa, key);877 key = wi_rsa_decrypt(p7_socket->private_key, key); 870 878 871 879 if(iv) 872 iv = wi_rsa_decrypt(p7_socket-> rsa, iv);880 iv = wi_rsa_decrypt(p7_socket->private_key, iv); 873 881 874 882 p7_socket->cipher = wi_cipher_init_with_key(wi_cipher_alloc(), _WI_P7_ENCRYPTION_OPTIONS_TO_CIPHER(p7_socket->options), key, iv); … … 886 894 } 887 895 888 data = wi_rsa_decrypt(p7_socket-> rsa, data);896 data = wi_rsa_decrypt(p7_socket->private_key, data); 889 897 890 898 if(!data) … … 902 910 } 903 911 904 data = wi_rsa_decrypt(p7_socket-> rsa, data);912 data = wi_rsa_decrypt(p7_socket->private_key, data); 905 913 906 914 if(!data) libwired/trunk/libwired/p7/wi-p7-socket.h
r5417 r5424 83 83 WI_EXPORT wi_p7_socket_t * wi_p7_socket_init_with_socket(wi_p7_socket_t *, wi_socket_t *, wi_p7_spec_t *); 84 84 85 WI_EXPORT void wi_p7_socket_set_private_rsa(wi_p7_socket_t *, wi_rsa_t *); 86 WI_EXPORT wi_rsa_t * wi_p7_socket_private_rsa(wi_p7_socket_t *); 85 WI_EXPORT void wi_p7_socket_set_private_key(wi_p7_socket_t *, wi_rsa_t *); 86 WI_EXPORT wi_rsa_t * wi_p7_socket_private_key(wi_p7_socket_t *); 87 WI_EXPORT wi_rsa_t * wi_p7_socket_public_key(wi_p7_socket_t *); 87 88 WI_EXPORT void wi_p7_socket_set_tls(wi_p7_socket_t *, wi_socket_tls_t *); 88 89 WI_EXPORT wi_socket_tls_t * wi_p7_socket_tls(wi_p7_socket_t *);
