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