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 <cstddef>
13#include <cstdint>
14#include <vector>
15
16#include <packager/macros/classes.h>
17#include <packager/media/base/aes_cryptor.h>
18#include <packager/media/base/aes_encryptor.h>
19
20namespace shaka {
21namespace media {
22
24using AesCtrDecryptor = AesCtrEncryptor;
25
28 public:
33 explicit AesCbcDecryptor(CbcPaddingScheme padding_scheme);
34
42 AesCbcDecryptor(CbcPaddingScheme padding_scheme,
43 ConstantIvFlag constant_iv_flag);
44
45 ~AesCbcDecryptor() override;
46
49 bool InitializeWithIv(const std::vector<uint8_t>& key,
50 const std::vector<uint8_t>& iv) override;
51
52 size_t RequiredOutputSize(size_t plaintext_size) override;
54
55 private:
56 bool CryptInternal(const uint8_t* ciphertext,
57 size_t ciphertext_size,
58 uint8_t* plaintext,
59 size_t* plaintext_size) override;
60 void SetIvInternal() override;
61 void CbcDecryptBlocks(const uint8_t* plaintext,
62 size_t plaintext_size,
63 uint8_t* ciphertext,
64 uint8_t* iv);
65
66 const CbcPaddingScheme padding_scheme_;
67 // 16-byte internal iv for crypto operations.
68 std::vector<uint8_t> internal_iv_;
69
70 DISALLOW_COPY_AND_ASSIGN(AesCbcDecryptor);
71};
72
73} // namespace media
74} // namespace shaka
75
76#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:86
All the methods that are virtual are virtual for mocking.