Improve names of RSA methods.
GitOrigin-RevId: b6f61f141987f282b5cf4faa9ff6cdf1219e8562
This commit is contained in:
parent
08a5f1b874
commit
3e559e457c
@ -34,7 +34,7 @@ RSA RSA::clone() const {
|
||||
return RSA(n_.clone(), e_.clone());
|
||||
}
|
||||
|
||||
Result<RSA> RSA::from_pem(Slice pem) {
|
||||
Result<RSA> RSA::from_pem_public_key(Slice pem) {
|
||||
init_crypto();
|
||||
|
||||
auto *bio =
|
||||
@ -91,7 +91,7 @@ int64 RSA::get_fingerprint() const {
|
||||
}
|
||||
|
||||
size_t RSA::size() const {
|
||||
// Checked in RSA::from_pem step
|
||||
// Checked in RSA::from_pem_public_key step
|
||||
return 256;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ size_t RSA::encrypt(unsigned char *from, size_t from_len, size_t max_from_len, u
|
||||
return chunks * 256;
|
||||
}
|
||||
|
||||
void RSA::decrypt(Slice from, MutableSlice to) const {
|
||||
void RSA::decrypt_signature(Slice from, MutableSlice to) const {
|
||||
CHECK(from.size() == 256);
|
||||
BigNumContext ctx;
|
||||
BigNum x = BigNum::from_binary(from);
|
||||
|
@ -23,9 +23,9 @@ class RSA {
|
||||
size_t size() const;
|
||||
size_t encrypt(unsigned char *from, size_t from_len, size_t max_from_len, unsigned char *to, size_t to_len) const;
|
||||
|
||||
void decrypt(Slice from, MutableSlice to) const;
|
||||
void decrypt_signature(Slice from, MutableSlice to) const;
|
||||
|
||||
static Result<RSA> from_pem(Slice pem);
|
||||
static Result<RSA> from_pem_public_key(Slice pem);
|
||||
|
||||
private:
|
||||
RSA(BigNum n, BigNum e);
|
||||
|
@ -141,7 +141,7 @@ Result<int32> HttpDate::parse_http_date(std::string slice) {
|
||||
}
|
||||
|
||||
Result<SimpleConfig> decode_config(Slice input) {
|
||||
static auto rsa = RSA::from_pem(
|
||||
static auto rsa = RSA::from_pem_public_key(
|
||||
"-----BEGIN RSA PUBLIC KEY-----\n"
|
||||
"MIIBCgKCAQEAyr+18Rex2ohtVy8sroGP\n"
|
||||
"BwXD3DOoKCSpjDqYoXgCqB7ioln4eDCFfOBUlfXUEvM/fnKCpF46VkAftlb4VuPD\n"
|
||||
@ -167,7 +167,7 @@ Result<SimpleConfig> decode_config(Slice input) {
|
||||
}
|
||||
|
||||
MutableSlice data_rsa_slice(data_rsa);
|
||||
rsa.decrypt(data_rsa_slice, data_rsa_slice);
|
||||
rsa.decrypt_signature(data_rsa_slice, data_rsa_slice);
|
||||
|
||||
MutableSlice data_cbc = data_rsa_slice.substr(32);
|
||||
UInt256 key;
|
||||
|
@ -21,7 +21,7 @@ PublicRsaKeyShared::PublicRsaKeyShared(DcId dc_id, bool is_test) : dc_id_(dc_id)
|
||||
return;
|
||||
}
|
||||
auto add_pem = [this](CSlice pem) {
|
||||
auto r_rsa = RSA::from_pem(pem);
|
||||
auto r_rsa = RSA::from_pem_public_key(pem);
|
||||
LOG_CHECK(r_rsa.is_ok()) << r_rsa.error() << " " << pem;
|
||||
|
||||
if (r_rsa.is_ok()) {
|
||||
|
@ -110,7 +110,7 @@ void PublicRsaKeyWatchdog::sync_key(std::shared_ptr<PublicRsaKeyShared> &key) {
|
||||
}
|
||||
for (auto &config_key : cdn_config_->public_keys_) {
|
||||
if (key->dc_id().get_raw_id() == config_key->dc_id_) {
|
||||
auto r_rsa = RSA::from_pem(config_key->public_key_);
|
||||
auto r_rsa = RSA::from_pem_public_key(config_key->public_key_);
|
||||
if (r_rsa.is_error()) {
|
||||
LOG(ERROR) << r_rsa.error();
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user