45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2016 Google LLC.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "common/signing_key_util.h"
|
|
|
|
#include "glog/logging.h"
|
|
#include "common/crypto_util.h"
|
|
#include "protos/public/license_protocol.pb.h"
|
|
|
|
namespace widevine {
|
|
|
|
using crypto_util::kSigningKeySizeBits;
|
|
|
|
uint32_t SigningKeyMaterialSize(ProtocolVersion protocol_version) {
|
|
if (protocol_version <= VERSION_2_0) {
|
|
return kSigningKeySizeBits;
|
|
} else {
|
|
return kSigningKeySizeBits * 2;
|
|
}
|
|
}
|
|
|
|
using crypto_util::kSigningKeySizeBytes;
|
|
std::string GetClientSigningKey(const std::string& derived_key,
|
|
ProtocolVersion protocol_version) {
|
|
if (protocol_version == VERSION_2_0) {
|
|
DCHECK(derived_key.size() >= kSigningKeySizeBytes);
|
|
return derived_key.substr(0, kSigningKeySizeBytes);
|
|
} else {
|
|
DCHECK(derived_key.size() >= kSigningKeySizeBytes * 2);
|
|
return derived_key.substr(kSigningKeySizeBytes, kSigningKeySizeBytes);
|
|
}
|
|
}
|
|
|
|
std::string GetServerSigningKey(const std::string& derived_key) {
|
|
DCHECK(derived_key.size() >= kSigningKeySizeBytes);
|
|
return derived_key.substr(0, kSigningKeySizeBytes);
|
|
}
|
|
|
|
} // namespace widevine
|