Simplify rsa_key usage.
This commit is contained in:
parent
313f0b45df
commit
d23064812f
@ -84,8 +84,7 @@ Status AuthKeyHandshake::on_res_pq(Slice message, Callback *connection, PublicRs
|
|||||||
public_rsa_key->drop_keys();
|
public_rsa_key->drop_keys();
|
||||||
return r_rsa_key.move_as_error();
|
return r_rsa_key.move_as_error();
|
||||||
}
|
}
|
||||||
int64 rsa_fingerprint = r_rsa_key.ok().fingerprint;
|
auto rsa_key = r_rsa_key.move_as_ok();
|
||||||
RSA rsa = std::move(r_rsa_key.ok_ref().rsa);
|
|
||||||
|
|
||||||
string p, q;
|
string p, q;
|
||||||
if (pq_factorize(res_pq->pq_, &p, &q) == -1) {
|
if (pq_factorize(res_pq->pq_, &p, &q) == -1) {
|
||||||
@ -122,12 +121,12 @@ Status AuthKeyHandshake::on_res_pq(Slice message, Callback *connection, PublicRs
|
|||||||
// encrypted_data := RSA (data_with_hash, server_public_key); a 255-byte long number (big endian)
|
// encrypted_data := RSA (data_with_hash, server_public_key); a 255-byte long number (big endian)
|
||||||
// is raised to the requisite power over the requisite modulus, and the result is stored as a 256-byte number.
|
// is raised to the requisite power over the requisite modulus, and the result is stored as a 256-byte number.
|
||||||
string encrypted_data(256, 0);
|
string encrypted_data(256, 0);
|
||||||
rsa.encrypt(data_with_hash, size, sizeof(data_with_hash), reinterpret_cast<unsigned char *>(&encrypted_data[0]),
|
rsa_key.rsa.encrypt(data_with_hash, size, sizeof(data_with_hash),
|
||||||
encrypted_data.size());
|
reinterpret_cast<unsigned char *>(&encrypted_data[0]), encrypted_data.size());
|
||||||
|
|
||||||
// req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long
|
// req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long
|
||||||
// encrypted_data:string = Server_DH_Params
|
// encrypted_data:string = Server_DH_Params
|
||||||
mtproto_api::req_DH_params req_dh_params(nonce_, server_nonce_, p, q, rsa_fingerprint, encrypted_data);
|
mtproto_api::req_DH_params req_dh_params(nonce_, server_nonce_, p, q, rsa_key.fingerprint, encrypted_data);
|
||||||
|
|
||||||
send(connection, create_storer(req_dh_params));
|
send(connection, create_storer(req_dh_params));
|
||||||
state_ = ServerDHParams;
|
state_ = ServerDHParams;
|
||||||
|
@ -711,7 +711,7 @@ class CliClient final : public Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class FirstType, class SecondType, class... Types>
|
template <class FirstType, class SecondType, class... Types>
|
||||||
static void get_args(string &args, FirstType &first_arg, SecondType &second_arg, Types &...other_args) {
|
static void get_args(string &args, FirstType &first_arg, SecondType &second_arg, Types &... other_args) {
|
||||||
string arg;
|
string arg;
|
||||||
std::tie(arg, args) = split(args);
|
std::tie(arg, args) = split(args);
|
||||||
get_args(arg, first_arg);
|
get_args(arg, first_arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user