… | |
… | |
158 | { |
158 | { |
159 | if (RSA_public_encrypt (sizeof (auth.rsa), |
159 | if (RSA_public_encrypt (sizeof (auth.rsa), |
160 | (unsigned char *)&auth.rsa, (unsigned char *)&encr.rsa, |
160 | (unsigned char *)&auth.rsa, (unsigned char *)&encr.rsa, |
161 | key, RSA_PKCS1_OAEP_PADDING) < 0) |
161 | key, RSA_PKCS1_OAEP_PADDING) < 0) |
162 | fatal ("RSA_public_encrypt error"); |
162 | fatal ("RSA_public_encrypt error"); |
|
|
163 | |
|
|
164 | memcpy (&encr.ecdh, &auth.ecdh, sizeof (encr.ecdh)); |
163 | } |
165 | } |
164 | |
166 | |
165 | static inline bool |
167 | static inline bool |
166 | auth_decrypt (RSA *key, const auth_encr &encr, auth_data &auth) |
168 | auth_decrypt (RSA *key, const auth_encr &encr, auth_data &auth) |
167 | { |
169 | { |
… | |
… | |
171 | (const unsigned char *)&encr.rsa, (unsigned char *)rsa_decrypt, |
173 | (const unsigned char *)&encr.rsa, (unsigned char *)rsa_decrypt, |
172 | key, RSA_PKCS1_OAEP_PADDING) != sizeof (auth.rsa)) |
174 | key, RSA_PKCS1_OAEP_PADDING) != sizeof (auth.rsa)) |
173 | return 0; |
175 | return 0; |
174 | |
176 | |
175 | memcpy (&auth.rsa, rsa_decrypt, sizeof (auth.rsa)); |
177 | memcpy (&auth.rsa, rsa_decrypt, sizeof (auth.rsa)); |
|
|
178 | memcpy (&auth.ecdh, &encr.ecdh, sizeof (auth.ecdh)); |
176 | |
179 | |
177 | return 1; |
180 | return 1; |
178 | } |
181 | } |
179 | |
182 | |
180 | static void |
183 | static void |