forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClearKeyUtils.h
53 lines (41 loc) · 1.33 KB
/
ClearKeyUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __ClearKeyUtils_h__
#define __ClearKeyUtils_h__
#include <stdint.h>
#include <string>
#include <vector>
#define CLEARKEY_KEY_LEN 16
#if 0
void CK_Log(const char* aFmt, ...);
#define CK_LOGE(...) CK_Log(__VA_ARGS__)
#define CK_LOGD(...) CK_Log(__VA_ARGS__)
#define CK_LOGW(...) CK_Log(__VA_ARGS__)
#else
#define CK_LOGE(...)
#define CK_LOGD(...)
#define CK_LOGW(...)
#endif
struct GMPPlatformAPI;
extern GMPPlatformAPI* GetPlatform();
typedef std::vector<uint8_t> KeyId;
typedef std::vector<uint8_t> Key;
struct KeyIdPair
{
KeyId mKeyId;
Key mKey;
};
class ClearKeyUtils
{
public:
static void DecryptAES(const std::vector<uint8_t>& aKey,
std::vector<uint8_t>& aData, std::vector<uint8_t>& aIV);
static void ParseInitData(const uint8_t* aInitData, uint32_t aInitDataSize,
std::vector<Key>& aOutKeys);
static void MakeKeyRequest(const std::vector<KeyId>& aKeyIds,
std::string& aOutRequest);
static bool ParseJWK(const uint8_t* aKeyData, uint32_t aKeyDataSize,
std::vector<KeyIdPair>& aOutKeys);
};
#endif // __ClearKeyUtils_h__