tdutils: AesCbcState

GitOrigin-RevId: 2145e9861785f5d3b955623bd860ca05fadbc977
This commit is contained in:
Arseny Smirnov 2018-03-26 17:00:26 +03:00
parent 40b314f60d
commit 26b5c231a6
2 changed files with 22 additions and 0 deletions

View File

@ -279,6 +279,16 @@ void aes_cbc_decrypt(const UInt256 &aes_key, UInt128 *aes_iv, Slice from, Mutabl
aes_cbc_xcrypt(aes_key, aes_iv, from, to, false);
}
AesCbcState::AesCbcState(const UInt256 &key, const UInt128 &iv) : key_(key), iv_(iv) {
}
void AesCbcState::encrypt(Slice from, MutableSlice to) {
::td::aes_cbc_encrypt(key_, &iv_, from, to);
}
void AesCbcState::decrypt(Slice from, MutableSlice to) {
::td::aes_cbc_decrypt(key_, &iv_, from, to);
}
class AesCtrState::Impl {
public:
Impl(const UInt256 &key, const UInt128 &iv) {

View File

@ -44,6 +44,18 @@ class AesCtrState {
std::unique_ptr<Impl> ctx_;
};
class AesCbcState {
public:
AesCbcState(const UInt256 &key, const UInt128 &iv);
void encrypt(Slice from, MutableSlice to);
void decrypt(Slice from, MutableSlice to);
private:
UInt256 key_;
UInt128 iv_;
};
void sha1(Slice data, unsigned char output[20]);
void sha256(Slice data, MutableSlice output);