Source release 17.1.0
This commit is contained in:
52
core/include/crypto_wrapped_key.h
Normal file
52
core/include/crypto_wrapped_key.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#ifndef WVCDM_CORE_CRYPTO_WRAPPED_KEY_H_
|
||||
#define WVCDM_CORE_CRYPTO_WRAPPED_KEY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
// Represents OEMCrypto's wrapped private DRM key. As of v16, it is
|
||||
// possible for OEMCrypto to support ECC-based DRM certificates. The
|
||||
// format of the wrapped key is vendor specific; however, the API
|
||||
// requires that the CDM track whether the wrapped key is RSA or ECC.
|
||||
class CryptoWrappedKey {
|
||||
public:
|
||||
enum Type : int32_t { kUninitialized = 0, kRsa = 1, kEcc = 2 };
|
||||
CryptoWrappedKey() {}
|
||||
CryptoWrappedKey(Type type, const std::string& key)
|
||||
: type_(type), key_(key) {}
|
||||
|
||||
Type type() const { return type_; }
|
||||
void set_type(Type type) { type_ = type; }
|
||||
|
||||
const std::string& key() const { return key_; }
|
||||
// Mutable reference getter for passing to OMECrypto.
|
||||
std::string& key() { return key_; }
|
||||
void set_key(const std::string& key) { key_ = key; }
|
||||
|
||||
void Clear() {
|
||||
type_ = kUninitialized;
|
||||
key_.clear();
|
||||
}
|
||||
// A valid key must have a known key type and have key data.
|
||||
bool IsValid() const { return type_ != kUninitialized && !key_.empty(); }
|
||||
// Equality operator is for testing only. Real keys may have
|
||||
// different meta data but the same logical key.
|
||||
bool operator==(const CryptoWrappedKey& other) const {
|
||||
return type_ == other.type_ && key_ == other.key_;
|
||||
}
|
||||
|
||||
private:
|
||||
// DRM key type of the wrapped key. For wrapped keys which the type
|
||||
// of key is unknown, assume it to be RSA.
|
||||
Type type_ = kUninitialized;
|
||||
// Vendor-specific wrapped DRM key.
|
||||
std::string key_;
|
||||
}; // class CryptoWrappedKey
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_CRYPTO_WRAPPED_KEY_H_
|
||||
Reference in New Issue
Block a user