2018-12-31 20:04:05 +01:00
|
|
|
//
|
2021-01-01 13:57:46 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/utils/BigNum.h"
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
2021-07-05 20:04:23 +02:00
|
|
|
namespace mtproto {
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
class RSA {
|
|
|
|
public:
|
|
|
|
RSA clone() const;
|
|
|
|
int64 get_fingerprint() const;
|
|
|
|
size_t size() const;
|
2021-07-08 15:39:34 +02:00
|
|
|
|
|
|
|
bool encrypt(Slice from, MutableSlice to) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-10 16:27:43 +01:00
|
|
|
void decrypt_signature(Slice from, MutableSlice to) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-10 16:27:43 +01:00
|
|
|
static Result<RSA> from_pem_public_key(Slice pem);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
RSA(BigNum n, BigNum e);
|
|
|
|
BigNum n_;
|
|
|
|
BigNum e_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PublicRsaKeyInterface {
|
|
|
|
public:
|
|
|
|
virtual ~PublicRsaKeyInterface() = default;
|
2021-07-05 21:09:45 +02:00
|
|
|
|
|
|
|
struct RsaKey {
|
|
|
|
RSA rsa;
|
|
|
|
int64 fingerprint;
|
|
|
|
};
|
|
|
|
virtual Result<RsaKey> get_rsa_key(const vector<int64> &fingerprints) = 0;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
virtual void drop_keys() = 0;
|
|
|
|
};
|
|
|
|
|
2021-07-05 20:04:23 +02:00
|
|
|
} // namespace mtproto
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|