Shaka Packager SDK
Loading...
Searching...
No Matches
aes_decryptor.h
1// Copyright 2016 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6//
7// AES Decryptor implementation using mbedtls.
8
9#ifndef PACKAGER_MEDIA_BASE_AES_DECRYPTOR_H_
10#define PACKAGER_MEDIA_BASE_AES_DECRYPTOR_H_
11
12#include <vector>
13
14#include <packager/macros/classes.h>
15#include <packager/media/base/aes_cryptor.h>
16#include <packager/media/base/aes_encryptor.h>
17
18namespace shaka {
19namespace media {
20
22using AesCtrDecryptor = AesCtrEncryptor;
23
26 public:
31 explicit AesCbcDecryptor(CbcPaddingScheme padding_scheme);
32
40 AesCbcDecryptor(CbcPaddingScheme padding_scheme,
41 ConstantIvFlag constant_iv_flag);
42
43 ~AesCbcDecryptor() override;
44
47 bool InitializeWithIv(const std::vector<uint8_t>& key,
48 const std::vector<uint8_t>& iv) override;
49
50 size_t RequiredOutputSize(size_t plaintext_size) override;
52
53 private:
54 bool CryptInternal(const uint8_t* ciphertext,
55 size_t ciphertext_size,
56 uint8_t* plaintext,
57 size_t* plaintext_size) override;
58 void SetIvInternal() override;
59 void CbcDecryptBlocks(const uint8_t* plaintext,
60 size_t plaintext_size,
61 uint8_t* ciphertext,
62 uint8_t* iv);
63
64 const CbcPaddingScheme padding_scheme_;
65 // 16-byte internal iv for crypto operations.
66 std::vector<uint8_t> internal_iv_;
67
68 DISALLOW_COPY_AND_ASSIGN(AesCbcDecryptor);
69};
70
71} // namespace media
72} // namespace shaka
73
74#endif // PACKAGER_MEDIA_BASE_AES_DECRYPTOR_H_
Class which implements AES-CBC (Cipher block chaining) decryption.
bool InitializeWithIv(const std::vector< uint8_t > &key, const std::vector< uint8_t > &iv) override
const std::vector< uint8_t > & iv() const
Definition aes_cryptor.h:85
All the methods that are virtual are virtual for mocking.