Changeset 4612

Show
Ignore:
Timestamp:
02/14/07 01:01:38 (2 years ago)
Author:
morris
Message:

Encryption refactoring

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/libwired/p7/wi-p7-socket.c

    r4601 r4612  
    5454#include <zlib.h> 
    5555 
    56 #define _WI_P7_SOCKET_XML_MAGIC                 0x3C3F786D 
     56#define _WI_P7_SOCKET_XML_MAGIC                         0x3C3F786D 
     57#define _WI_P7_SOCKET_BINARY_MAGIC_LENGTH       52 
    5758 
    5859#define _WI_P7_SOCKET_OPTIONS_ENCRYPTION_ENABLED(options) \ 
     
    6162 
    6263struct _wi_p7_socket { 
    63         wi_runtime_base_t                                       base; 
    64          
    65         wi_socket_t                                                     *socket; 
    66          
    67         wi_p7_spec_t                                            *spec; 
    68          
    69         wi_p7_serialization_t                           serialization; 
    70         wi_p7_options_t                                         options; 
    71          
    72         wi_boolean_t                                            encryption_enabled; 
    73         EVP_PKEY                                                        *private_key; 
    74         EVP_PKEY                                                        *public_key; 
    75         const EVP_CIPHER                                        *cipher; 
    76         EVP_CIPHER_CTX                                          cipher_ctx; 
    77          
    78         wi_boolean_t                                            compression_enabled; 
    79         z_stream                                                        compression_stream; 
    80         z_stream                                                        decompression_stream; 
    81          
    82         wi_p7_boolean_t                                         local_compatibility_check, remote_compatibility_check; 
     64        wi_runtime_base_t                                               base; 
     65         
     66        wi_socket_t                                                             *socket; 
     67         
     68        wi_p7_spec_t                                                    *spec; 
     69         
     70        wi_p7_serialization_t                                   serialization; 
     71        wi_p7_options_t                                                 options; 
     72         
     73        wi_boolean_t                                                    encryption_enabled; 
     74        EVP_PKEY                                                                *private_key; 
     75        EVP_PKEY                                                                *public_key; 
     76        RSA                                                                             *rsa_key; 
     77        const EVP_CIPHER                                                *cipher; 
     78        EVP_CIPHER_CTX                                                  cipher_ctx; 
     79         
     80        wi_boolean_t                                                    compression_enabled; 
     81        z_stream                                                                compression_stream; 
     82        z_stream                                                                decompression_stream; 
     83         
     84        wi_p7_boolean_t                                                 local_compatibility_check; 
     85        wi_p7_boolean_t                                                 remote_compatibility_check; 
    8386}; 
    8487 
     
    102105static const EVP_CIPHER *                               _wi_p7_socket_cipher(wi_p7_socket_t *); 
    103106static void                                                             _wi_p7_socket_configure_cipher_ctx(wi_p7_socket_t *); 
    104 static wi_boolean_t                                             _wi_p7_socket_encrypt_buffer(wi_p7_socket_t *, const void *, uint32_t, void **, uint32_t *); 
    105 static wi_boolean_t                                             _wi_p7_socket_decrypt_buffer(wi_p7_socket_t *, const void *, uint32_t, void **, uint32_t *); 
     107static wi_boolean_t                                             _wi_p7_socket_public_encrypt_buffer(wi_p7_socket_t *, const void *, uint32_t, void **, uint32_t *); 
     108static wi_boolean_t                                             _wi_p7_socket_public_decrypt_buffer(wi_p7_socket_t *, const void *, uint32_t, void **, uint32_t *); 
     109static wi_boolean_t                                             _wi_p7_socket_private_encrypt_buffer(wi_p7_socket_t *, const void *, uint32_t, void **, uint32_t *); 
     110static wi_boolean_t                                             _wi_p7_socket_private_decrypt_buffer(wi_p7_socket_t *, const void *, uint32_t, void **, uint32_t *); 
    106111static wi_boolean_t                                             _wi_p7_socket_configure_compression_streams(wi_p7_socket_t *); 
    107112static wi_boolean_t                                             _wi_p7_socket_xcompress_buffer(wi_p7_socket_t *, _wi_p7_socket_compression_t, const void *, uint32_t, void **, uint32_t *); 
     
    177182        if(p7_socket->private_key) 
    178183                EVP_PKEY_free(p7_socket->private_key); 
     184         
     185        if(p7_socket->public_key) 
     186                EVP_PKEY_free(p7_socket->public_key); 
     187         
     188        if(p7_socket->rsa_key) 
     189                RSA_free(p7_socket->rsa_key); 
    179190} 
    180191 
     
    196207 
    197208void wi_p7_socket_set_private_key(wi_p7_socket_t *p7_socket, void *key) { 
     209        if(EVP_PKEY_type(((EVP_PKEY *) key)->type) != EVP_PKEY_RSA) 
     210                wi_log_warn(WI_STR("private key must be RSA")); 
     211         
    198212        p7_socket->private_key = key; 
     213        p7_socket->rsa_key = EVP_PKEY_get1_RSA(p7_socket->private_key); 
    199214} 
    200215 
     
    423438        wi_p7_message_t                 *p7_message; 
    424439        wi_data_t                               *data, *rsa_data; 
    425         wi_string_t                             *client_password_string; 
    426         RSA                                             *rsa; 
    427         unsigned char                   *cipher_key = NULL, *iv = NULL, *username = NULL, *password = NULL; 
     440        wi_string_t                             *client_password_string1, *client_password_string2, *server_password_string; 
     441        unsigned char                   *cipher_key = NULL, *iv = NULL; 
    428442        const unsigned char             *bytes; 
    429         uint32_t                                cipher_key_length, iv_length; 
    430         int32_t                                 username_length, password_length; 
    431         wi_boolean_t                    result = false; 
     443        void                                    *username = NULL, *server_password = NULL, *client_password = NULL; 
     444        uint32_t                                cipher_key_length, iv_length, username_length, client_password_length, server_password_length; 
    432445         
    433446        p7_message = wi_p7_socket_read_message(p7_socket, timeout); 
     
    451464         
    452465        bytes = wi_data_bytes(rsa_data); 
    453         rsa = d2i_RSA_PUBKEY(NULL, (unsigned char **) &bytes, wi_data_length(rsa_data)); 
    454  
    455         if(!rsa) { 
     466        p7_socket->rsa_key = d2i_RSA_PUBKEY(NULL, (unsigned char **) &bytes, wi_data_length(rsa_data)); 
     467 
     468        if(!p7_socket->rsa_key) { 
    456469                ERR_print_errors_fp(stderr); 
    457470                 
     
    460473         
    461474        p7_socket->public_key = EVP_PKEY_new(); 
    462         EVP_PKEY_assign_RSA(p7_socket->public_key, rsa); 
     475        EVP_PKEY_assign_RSA(p7_socket->public_key, p7_socket->rsa_key); 
    463476         
    464477        p7_socket->cipher       = _wi_p7_socket_cipher(p7_socket); 
     
    475488        _wi_p7_socket_configure_cipher_ctx(p7_socket); 
    476489 
    477         if(EVP_SealInit(&p7_socket->cipher_ctx, NULL, &cipher_key, (int *) &cipher_key_length, iv, &p7_socket->public_key, 1) != 1) { 
     490        if(EVP_SealInit(&p7_socket->cipher_ctx, 
     491                                        NULL, &cipher_key, 
     492                                        (int *) &cipher_key_length, 
     493                                        iv, 
     494                                        &p7_socket->public_key, 1) != 1) { 
    478495                ERR_print_errors_fp(stderr); 
    479496                 
     
    481498        } 
    482499         
    483         username = wi_malloc(RSA_size(rsa)); 
    484         username_length = RSA_public_encrypt(wi_string_length(username_string), (unsigned char *) wi_string_cstring(username_string), username, rsa, RSA_PKCS1_PADDING); 
    485          
    486         if(username_length == -1) { 
    487                 ERR_print_errors_fp(stderr); 
    488                  
    489                 goto end; 
    490         } 
    491  
    492         data = wi_string_data(wi_string_sha1(password_string)); 
    493         wi_data_append_data(data, rsa_data); 
    494         client_password_string = wi_data_sha1(data); 
    495          
    496         password = wi_malloc(RSA_size(rsa)); 
    497         password_length = RSA_public_encrypt(wi_string_length(client_password_string), (unsigned char *) wi_string_cstring(client_password_string), password, rsa, RSA_PKCS1_PADDING); 
    498          
    499         if(password_length == -1) { 
    500                 ERR_print_errors_fp(stderr); 
    501                  
    502                 goto end; 
    503         } 
     500        if(!_wi_p7_socket_public_encrypt_buffer(p7_socket, 
     501                                                                                        wi_string_cstring(username_string), 
     502                                                                                        wi_string_length(username_string), 
     503                                                                                        &username, 
     504                                                                                        &username_length)) 
     505                goto end; 
     506         
     507        client_password_string1 = wi_data_sha1(wi_data_by_appending_data(wi_string_data(wi_string_sha1(password_string)), rsa_data)); 
     508        client_password_string2 = wi_data_sha1(wi_data_by_appending_data(rsa_data, wi_string_data(wi_string_sha1(password_string)))); 
     509         
     510        if(!_wi_p7_socket_public_encrypt_buffer(p7_socket, 
     511                                                                                        wi_string_cstring(client_password_string1), 
     512                                                                                        wi_string_length(client_password_string1), 
     513                                                                                        &client_password, 
     514                                                                                        &client_password_length)) 
     515                goto end; 
    504516         
    505517        p7_message = wi_autorelease(wi_p7_message_init_with_name(wi_p7_message_alloc(), WI_STR("p7.encryption.reply"), p7_socket)); 
     
    520532        wi_release(data); 
    521533 
    522         data = wi_data_init_with_bytes(wi_data_alloc(), password, password_length); 
    523         wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.password")); 
     534        data = wi_data_init_with_bytes(wi_data_alloc(), client_password, client_password_length); 
     535        wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.client_password")); 
    524536        wi_release(data); 
    525537         
     
    527539                goto end; 
    528540 
    529         p7_socket->encryption_enabled = result = true; 
    530  
     541        p7_message = wi_p7_socket_read_message(p7_socket, timeout); 
     542         
     543        if(!p7_message) 
     544                goto end; 
     545         
     546        if(!wi_is_equal(p7_message->name, WI_STR("p7.encryption.acknowledge"))) { 
     547                wi_log_warn(WI_STR("wrong message")); 
     548                 
     549                goto end; 
     550        } 
     551         
     552        data = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.server_password")); 
     553         
     554        if(!data) { 
     555                wi_log_info(WI_STR("no password")); 
     556                 
     557                goto end; 
     558        } 
     559         
     560        if(!_wi_p7_socket_private_decrypt_buffer(p7_socket, 
     561                                                                                         wi_data_bytes(data), 
     562                                                                                         wi_data_length(data), 
     563                                                                                         &server_password, 
     564                                                                                         &server_password_length)) 
     565                goto end; 
     566         
     567        server_password_string = wi_string_with_bytes((char *) server_password, server_password_length); 
     568 
     569        if(!wi_is_equal(server_password_string, client_password_string2)) { 
     570                wi_log_info(WI_STR("password mismatch: %@ != %@"), server_password_string, client_password_string2); 
     571                 
     572                goto end; 
     573        } 
     574 
     575        p7_socket->encryption_enabled = true; 
     576         
    531577end: 
    532578        if(cipher_key) 
     
    539585                wi_free(username); 
    540586 
    541         if(password) 
    542                 wi_free(password); 
    543          
    544         return result; 
     587        if(client_password) 
     588                wi_free(client_password); 
     589         
     590        if(server_password) 
     591                wi_free(server_password); 
     592         
     593        return p7_socket->encryption_enabled; 
    545594} 
    546595 
     
    550599        wi_p7_message_t                 *p7_message; 
    551600        wi_data_t                               *data, *rsa_data, *cipher_key_data, *iv_data; 
    552         wi_string_t                             *string, *username_string, *client_password_string, *server_password_string; 
    553         RSA                                             *rsa = NULL; 
    554         unsigned char                   *public_key = NULL, *username = NULL, *password = NULL; 
    555         uint32_t                                public_key_length; 
    556         int32_t                                 username_length, password_length; 
    557         wi_boolean_t                    result = false; 
     601        wi_string_t                             *string, *username_string, *client_password_string, *server_password_string1, *server_password_string2; 
     602        unsigned char                   *public_key = NULL; 
     603        void                                    *username = NULL, *client_password = NULL, *server_password; 
     604        uint32_t                                public_key_length, username_length, client_password_length, server_password_length; 
    558605         
    559606        if(!p7_socket->private_key) { 
     
    563610        } 
    564611         
    565         if(EVP_PKEY_type(p7_socket->private_key->type) != EVP_PKEY_RSA) { 
    566                 wi_log_warn(WI_STR("private key must be RSA")); 
    567                  
    568                 goto end; 
    569         } 
    570          
    571         rsa = EVP_PKEY_get1_RSA(p7_socket->private_key); 
    572         public_key_length = i2d_RSA_PUBKEY(rsa, &public_key); 
     612        public_key_length = i2d_RSA_PUBKEY(p7_socket->rsa_key, &public_key); 
    573613         
    574614        if(public_key_length <= 0) { 
     
    631671        } 
    632672         
     673        data = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.username")); 
     674 
     675        if(!data) { 
     676                wi_log_warn(WI_STR("missing key: username")); 
     677                 
     678                goto end; 
     679        } 
     680         
     681        if(!_wi_p7_socket_public_decrypt_buffer(p7_socket, 
     682                                                                                        wi_data_bytes(data), 
     683                                                                                        wi_data_length(data), 
     684                                                                                        &username, 
     685                                                                                        &username_length)) 
     686                goto end; 
     687         
     688        username_string = wi_string_with_bytes((char *) username, username_length); 
     689         
     690        data = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.client_password")); 
     691 
     692        if(!data) { 
     693                wi_log_warn(WI_STR("missing key: password")); 
     694                 
     695                goto end; 
     696        } 
     697         
     698        if(!_wi_p7_socket_public_decrypt_buffer(p7_socket, 
     699                                                                                        wi_data_bytes(data), 
     700                                                                                        wi_data_length(data), 
     701                                                                                        &client_password, 
     702                                                                                        &client_password_length)) 
     703                goto end; 
     704 
    633705        if(wi_p7_socket_password_provider) { 
    634                 data = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.username")); 
    635  
    636                 if(!data) { 
    637                         wi_log_warn(WI_STR("missing key: username")); 
    638                          
    639                         goto end; 
    640                 } 
    641                  
    642                 username = wi_malloc(RSA_size(rsa)); 
    643                 username_length = RSA_private_decrypt(wi_data_length(data), wi_data_bytes(data), username, rsa, RSA_PKCS1_PADDING); 
    644                  
    645                 if(username_length == -1) { 
    646                         ERR_print_errors_fp(stderr); 
    647                          
    648                         goto end; 
    649                 } 
    650                  
    651                 username_string = wi_string_with_bytes((char *) username, username_length); 
    652                  
    653                 data = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.password")); 
    654  
    655                 if(!data) { 
    656                         wi_log_warn(WI_STR("missing key: password")); 
    657                          
    658                         goto end; 
    659                 } 
    660                  
    661                 password = wi_malloc(RSA_size(rsa)); 
    662                 password_length = RSA_private_decrypt(wi_data_length(data), wi_data_bytes(data), password, rsa, RSA_PKCS1_PADDING); 
    663                  
    664                 if(password_length == -1) { 
    665                         ERR_print_errors_fp(stderr); 
    666                          
    667                         goto end; 
    668                 } 
    669                  
    670                 client_password_string = wi_string_with_bytes((char *) password, password_length); 
    671  
    672706                string = (*wi_p7_socket_password_provider)(username_string); 
    673707                 
     
    677711                        goto end; 
    678712                } 
    679                  
    680                 data = wi_string_data(string); 
    681                 wi_data_append_data(data, rsa_data); 
    682                 server_password_string = wi_data_sha1(data); 
    683                  
    684                 if(!wi_is_equal(client_password_string, server_password_string)) { 
    685                         wi_log_info(WI_STR("password mismatch")); 
    686                          
    687                         goto end; 
    688                 } 
    689         } 
    690          
    691         p7_socket->encryption_enabled = result = true; 
     713        } else { 
     714                string = WI_STR(""); 
     715        } 
     716                 
     717        client_password_string = wi_string_with_bytes((char *) client_password, client_password_length); 
     718        server_password_string1 = wi_data_sha1(wi_data_by_appending_data(wi_string_data(string), rsa_data)); 
     719        server_password_string2 = wi_data_sha1(wi_data_by_appending_data(rsa_data, wi_string_data(string))); 
     720         
     721        if(!wi_is_equal(client_password_string, server_password_string1)) { 
     722                wi_log_info(WI_STR("password mismatch: %@ != %@"), client_password_string, server_password_string1); 
     723                 
     724                goto end; 
     725        } 
     726         
     727        p7_message = wi_autorelease(wi_p7_message_init_with_name(wi_p7_message_alloc(), WI_STR("p7.encryption.acknowledge"), p7_socket)); 
     728         
     729        if(!p7_message) 
     730                goto end; 
     731         
     732        if(!_wi_p7_socket_private_encrypt_buffer(p7_socket, 
     733                                                                                         wi_string_cstring(server_password_string2), 
     734                                                                                         wi_string_length(server_password_string2), 
     735                                                                                         &server_password, 
     736                                                                                         &server_password_length)) 
     737                goto end; 
     738         
     739        data = wi_data_init_with_bytes(wi_data_alloc(), server_password, server_password_length); 
     740        wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.server_password")); 
     741        wi_release(data); 
     742 
     743        if(!wi_p7_socket_write_message(p7_socket, timeout, p7_message)) 
     744                goto end; 
     745 
     746        p7_socket->encryption_enabled = true; 
    692747         
    693748end: 
    694         if(rsa) 
    695                 RSA_free(rsa); 
    696          
    697749        if(username) 
    698750                wi_free(username); 
    699751         
    700         if(password) 
    701                 wi_free(password); 
     752        if(client_password) 
     753                wi_free(client_password); 
     754 
     755        if(server_password) 
     756                wi_free(server_password); 
    702757 
    703758        if(public_key) 
    704759                OPENSSL_free(public_key); 
    705760         
    706         return result
     761        return p7_socket->encryption_enabled
    707762} 
    708763 
     
    826881 
    827882 
    828 static wi_boolean_t _wi_p7_socket_encrypt_buffer(wi_p7_socket_t *p7_socket, const void *decrypted_buffer, uint32_t decrypted_length, void **out_buffer, uint32_t *out_length) { 
    829         void                    *encrypted_buffer; 
    830         uint32_t                encrypted_length, padded_length; 
     883static wi_boolean_t _wi_p7_socket_public_encrypt_buffer(wi_p7_socket_t *p7_socket, const void *decrypted_buffer, uint32_t decrypted_length, void **out_buffer, uint32_t *out_length) { 
     884        void            *encrypted_buffer; 
     885        int32_t         encrypted_length; 
     886 
     887        encrypted_buffer = wi_malloc(RSA_size(p7_socket->rsa_key)); 
     888        encrypted_length = RSA_public_encrypt(decrypted_length, decrypted_buffer, encrypted_buffer, p7_socket->rsa_key, RSA_PKCS1_PADDING); 
     889         
     890        if(encrypted_length == -1) { 
     891                ERR_print_errors_fp(stderr); 
     892                 
     893                return false; 
     894        } 
     895         
     896        *out_buffer = encrypted_buffer; 
     897        *out_length = encrypted_length; 
     898 
     899        return true; 
     900
     901 
     902 
     903 
     904static wi_boolean_t _wi_p7_socket_public_decrypt_buffer(wi_p7_socket_t *p7_socket, const void *encrypted_buffer, uint32_t encrypted_length, void **out_buffer, uint32_t *out_length) { 
     905        void            *decrypted_buffer; 
     906        int32_t         decrypted_length; 
     907 
     908        decrypted_buffer = wi_malloc(RSA_size(p7_socket->rsa_key)); 
     909        decrypted_length = RSA_private_decrypt(encrypted_length, encrypted_buffer, decrypted_buffer, p7_socket->rsa_key, RSA_PKCS1_PADDING); 
     910 
     911        if(decrypted_length == -1) { 
     912                ERR_print_errors_fp(stderr); 
     913                 
     914                return false; 
     915        } 
     916         
     917        *out_buffer = decrypted_buffer; 
     918        *out_length = decrypted_length; 
     919 
     920        return true; 
     921
     922 
     923 
     924 
     925static wi_boolean_t _wi_p7_socket_private_encrypt_buffer(wi_p7_socket_t *p7_socket, const void *decrypted_buffer, uint32_t decrypted_length, void **out_buffer, uint32_t *out_length) { 
     926        void            *encrypted_buffer; 
     927        uint32_t        encrypted_length, padded_length; 
    831928         
    832929        encrypted_buffer = wi_malloc(decrypted_length + EVP_CIPHER_block_size(p7_socket->cipher)); 
     
    859956 
    860957 
    861 static wi_boolean_t _wi_p7_socket_decrypt_buffer(wi_p7_socket_t *p7_socket, const void *encrypted_buffer, uint32_t encrypted_length, void **out_buffer, uint32_t *out_length) { 
    862         void                   *decrypted_buffer; 
    863         uint32_t               decrypted_length, padded_length; 
     958static wi_boolean_t _wi_p7_socket_private_decrypt_buffer(wi_p7_socket_t *p7_socket, const void *encrypted_buffer, uint32_t encrypted_length, void **out_buffer, uint32_t *out_length) { 
     959        void            *decrypted_buffer; 
     960        uint32_t        decrypted_length, padded_length; 
    864961         
    865962        decrypted_buffer = wi_malloc(encrypted_length + EVP_CIPHER_block_size(p7_socket->cipher)); 
     
    10141111 
    10151112        if(p7_socket->encryption_enabled) { 
    1016                 if(!_wi_p7_socket_decrypt_buffer(p7_socket, message_buffer, message_length, &decrypted_buffer, &decrypted_length)) { 
     1113                if(!_wi_p7_socket_private_decrypt_buffer(p7_socket, message_buffer, message_length, &decrypted_buffer, &decrypted_length)) { 
    10171114                        wi_log_warn(WI_STR("decryption failed")); 
    10181115                         
     
    11841281         
    11851282        if(p7_socket->encryption_enabled) { 
    1186                 if(!_wi_p7_socket_encrypt_buffer(p7_socket, send_buffer, send_length, &encrypted_buffer, &encrypted_length)) 
     1283                if(!_wi_p7_socket_private_encrypt_buffer(p7_socket, send_buffer, send_length, &encrypted_buffer, &encrypted_length)) 
    11871284                        goto end; 
    11881285                 
     
    12311328                                p7_socket->serialization = WI_P7_XML; 
    12321329                                prefix = WI_STR("<?xm"); 
    1233                         } else { 
     1330                        } 
     1331                        else if(length == _WI_P7_SOCKET_BINARY_MAGIC_LENGTH) { 
    12341332                                p7_socket->serialization = WI_P7_BINARY; 
    12351333                        } 
     
    12391337        if(p7_socket->serialization == WI_P7_BINARY) 
    12401338                p7_message = _wi_p7_socket_read_binary_message(p7_socket, timeout, length); 
     1339        else if(p7_socket->serialization == WI_P7_XML) 
     1340                p7_message = _wi_p7_socket_read_xml_message(p7_socket, timeout, prefix); 
    12411341        else 
    1242                 p7_message = _wi_p7_socket_read_xml_message(p7_socket, timeout, prefix)
     1342                p7_message = NULL
    12431343 
    12441344        if(!p7_message) 
     
    12731373         
    12741374        if(p7_socket->encryption_enabled) { 
    1275                 if(!_wi_p7_socket_encrypt_buffer(p7_socket, send_buffer, send_length, &encrypted_buffer, &encrypted_length)) 
     1375                if(!_wi_p7_socket_private_encrypt_buffer(p7_socket, send_buffer, send_length, &encrypted_buffer, &encrypted_length)) 
    12761376                        goto end; 
    12771377                 
     
    13161416         
    13171417        if(p7_socket->encryption_enabled) { 
    1318                 if(!_wi_p7_socket_decrypt_buffer(p7_socket, receive_buffer, receive_length, &decrypted_buffer, &decrypted_length)) { 
     1418                if(!_wi_p7_socket_private_decrypt_buffer(p7_socket, receive_buffer, receive_length, &decrypted_buffer, &decrypted_length)) { 
    13191419                        wi_log_warn(WI_STR("decryption failed")); 
    13201420                         
  • libwired/trunk/libwired/p7/wi-p7-spec.c

    r4607 r4612  
    314314        "               <p7:field name=\"p7.encryption.cipher_key_iv\" id=\"8\" type=\"data\" />" 
    315315        "               <p7:field name=\"p7.encryption.username\" id=\"9\" type=\"data\" />" 
    316         "               <p7:field name=\"p7.encryption.password\" id=\"10\" type=\"data\" />" 
     316        "               <p7:field name=\"p7.encryption.client_password\" id=\"10\" type=\"data\" />" 
     317        "               <p7:field name=\"p7.encryption.server_password\" id=\"11\" type=\"data\" />" 
    317318        "" 
    318         "               <p7:field name=\"p7.compatibility_check.specification\" id=\"11\" type=\"string\" />" 
    319         "               <p7:field name=\"p7.compatibility_check.status\" id=\"12\" type=\"bool\" />" 
     319        "               <p7:field name=\"p7.compatibility_check.specification\" id=\"12\" type=\"string\" />" 
     320        "               <p7:field name=\"p7.compatibility_check.status\" id=\"13\" type=\"bool\" />" 
    320321        "       </p7:fields>" 
    321322        "" 
     
    348349        "                       <p7:parameter field=\"p7.encryption.cipher_key_iv\" />" 
    349350        "                       <p7:parameter field=\"p7.encryption.username\" use=\"required\" />" 
    350         "                       <p7:parameter field=\"p7.encryption.password\" use=\"required\" />" 
     351        "                       <p7:parameter field=\"p7.encryption.client_password\" use=\"required\" />" 
    351352        "               </p7:message>" 
    352353        "" 
    353354        "               <p7:message name=\"p7.encryption.acknowledge\" id=\"6\">" 
    354         "                       <p7:parameter field=\"p7.encryption.password\" use=\"required\" />" 
     355        "                       <p7:parameter field=\"p7.encryption.server_password\" use=\"required\" />" 
    355356        "               </p7:message>" 
    356357        ""