tdutils: AesCbcState
GitOrigin-RevId: 2145e9861785f5d3b955623bd860ca05fadbc977
This commit is contained in:
parent
40b314f60d
commit
26b5c231a6
@ -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);
|
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 {
|
class AesCtrState::Impl {
|
||||||
public:
|
public:
|
||||||
Impl(const UInt256 &key, const UInt128 &iv) {
|
Impl(const UInt256 &key, const UInt128 &iv) {
|
||||||
|
@ -44,6 +44,18 @@ class AesCtrState {
|
|||||||
std::unique_ptr<Impl> ctx_;
|
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 sha1(Slice data, unsigned char output[20]);
|
||||||
|
|
||||||
void sha256(Slice data, MutableSlice output);
|
void sha256(Slice data, MutableSlice output);
|
||||||
|
Reference in New Issue
Block a user