Improve names of RSA methods.

GitOrigin-RevId: b6f61f141987f282b5cf4faa9ff6cdf1219e8562
This commit is contained in:
levlam 2020-03-10 18:27:43 +03:00
parent 08a5f1b874
commit 3e559e457c
5 changed files with 9 additions and 9 deletions

View File

@ -34,7 +34,7 @@ RSA RSA::clone() const {
return RSA(n_.clone(), e_.clone()); return RSA(n_.clone(), e_.clone());
} }
Result<RSA> RSA::from_pem(Slice pem) { Result<RSA> RSA::from_pem_public_key(Slice pem) {
init_crypto(); init_crypto();
auto *bio = auto *bio =
@ -91,7 +91,7 @@ int64 RSA::get_fingerprint() const {
} }
size_t RSA::size() const { size_t RSA::size() const {
// Checked in RSA::from_pem step // Checked in RSA::from_pem_public_key step
return 256; 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; return chunks * 256;
} }
void RSA::decrypt(Slice from, MutableSlice to) const { void RSA::decrypt_signature(Slice from, MutableSlice to) const {
CHECK(from.size() == 256); CHECK(from.size() == 256);
BigNumContext ctx; BigNumContext ctx;
BigNum x = BigNum::from_binary(from); BigNum x = BigNum::from_binary(from);

View File

@ -23,9 +23,9 @@ class RSA {
size_t size() const; 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; 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: private:
RSA(BigNum n, BigNum e); RSA(BigNum n, BigNum e);

View File

@ -141,7 +141,7 @@ Result<int32> HttpDate::parse_http_date(std::string slice) {
} }
Result<SimpleConfig> decode_config(Slice input) { 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" "-----BEGIN RSA PUBLIC KEY-----\n"
"MIIBCgKCAQEAyr+18Rex2ohtVy8sroGP\n" "MIIBCgKCAQEAyr+18Rex2ohtVy8sroGP\n"
"BwXD3DOoKCSpjDqYoXgCqB7ioln4eDCFfOBUlfXUEvM/fnKCpF46VkAftlb4VuPD\n" "BwXD3DOoKCSpjDqYoXgCqB7ioln4eDCFfOBUlfXUEvM/fnKCpF46VkAftlb4VuPD\n"
@ -167,7 +167,7 @@ Result<SimpleConfig> decode_config(Slice input) {
} }
MutableSlice data_rsa_slice(data_rsa); 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); MutableSlice data_cbc = data_rsa_slice.substr(32);
UInt256 key; UInt256 key;

View File

@ -21,7 +21,7 @@ PublicRsaKeyShared::PublicRsaKeyShared(DcId dc_id, bool is_test) : dc_id_(dc_id)
return; return;
} }
auto add_pem = [this](CSlice pem) { 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; LOG_CHECK(r_rsa.is_ok()) << r_rsa.error() << " " << pem;
if (r_rsa.is_ok()) { if (r_rsa.is_ok()) {

View File

@ -110,7 +110,7 @@ void PublicRsaKeyWatchdog::sync_key(std::shared_ptr<PublicRsaKeyShared> &key) {
} }
for (auto &config_key : cdn_config_->public_keys_) { for (auto &config_key : cdn_config_->public_keys_) {
if (key->dc_id().get_raw_id() == config_key->dc_id_) { 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()) { if (r_rsa.is_error()) {
LOG(ERROR) << r_rsa.error(); LOG(ERROR) << r_rsa.error();
continue; continue;