This adds: - Requires WB_RESULT_NOT_IMPLEMENTED for masked in CE - WB_License_RemoveEntitledContentKey - WB_License_Generic* methods
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
// Copyright 2021 Google LLC. All Rights Reserved.
|
|
|
|
#ifndef WHITEBOX_REFERENCE_IMPL_CONTENT_KEY_H_
|
|
#define WHITEBOX_REFERENCE_IMPL_CONTENT_KEY_H_
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
#include "api/license_whitebox.h"
|
|
#include "license_protocol.pb.h"
|
|
|
|
namespace widevine {
|
|
|
|
enum class KeyType {
|
|
kInvalid,
|
|
kContentKey,
|
|
kEntitlementKey,
|
|
kGenericCryptoKey,
|
|
};
|
|
|
|
struct InternalKey {
|
|
// This is the status will be returned in |WB_License_QueryKeyStatus()|.
|
|
WB_KeyStatus status = WB_KEY_STATUS_INVALID;
|
|
KeyType type = KeyType::kInvalid;
|
|
std::array<uint8_t, 32u> key;
|
|
uint32_t kcb_flags = 0;
|
|
|
|
// These are the permission flags that will be used internally to check if
|
|
// we can use a key.
|
|
//
|
|
// | Valid | Masked | Decrypt
|
|
// | | Decrypt |
|
|
// -----------------------------------------+-------+---------+--------
|
|
// WB_KEY_STATUS_INVALID | false | false | false
|
|
// WB_KEY_STATUS_CONTENT_KEY_VALID | true | false | false
|
|
// WB_KEY_STATUS_CONTENT_KEY_MASKED_DECRYPT | true | true | false
|
|
// WB_KEY_STATUS_CONTENT_KEY_DECRYPT | true | true | true
|
|
bool can_decrypt() const {
|
|
return status == WB_KEY_STATUS_CONTENT_KEY_DECRYPT;
|
|
}
|
|
bool can_masked_decrypt() const {
|
|
return can_decrypt() || status == WB_KEY_STATUS_CONTENT_KEY_MASKED_DECRYPT;
|
|
}
|
|
bool is_valid() const {
|
|
return can_masked_decrypt() || status == WB_KEY_STATUS_CONTENT_KEY_VALID;
|
|
}
|
|
};
|
|
|
|
} // namespace widevine
|
|
|
|
#endif // WHITEBOX_REFERENCE_IMPL_CONTENT_KEY_H_
|