NewProvisioningSession expects pkcs8 private key and SHA race fix
------------- Fix SHA hashing to remove race condition. This change fixes the implementation by passing in the digest buffer. ------------- The input to ProvisioningEngine::NewProvisioningSession should be pkcs8 private key instead of pkcs1 private key ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151273394 Change-Id: Ibcdff7757b2ac2878ee8b1b88365083964bfa10a
This commit is contained in:
@@ -18,11 +18,11 @@
|
||||
#include "common/sha_util.h"
|
||||
#include "provisioning_sdk/public/provisioning_status.h"
|
||||
|
||||
DEFINE_int32(provisioning_log_every_n, 1,
|
||||
DEFINE_int32(prov_sdk_log_every_n, 1,
|
||||
"parameter for LOG_EVERY_N to help abate log spamming.");
|
||||
|
||||
#define LOG_EVERY_N_WITH_PROTO(message, proto) \
|
||||
LOG_EVERY_N(WARNING, FLAGS_provisioning_log_every_n) \
|
||||
LOG_EVERY_N(WARNING, FLAGS_prov_sdk_log_every_n) \
|
||||
<< (message) << " [proto: " << (proto).ShortDebugString() << "]"
|
||||
|
||||
namespace widevine {
|
||||
@@ -42,8 +42,10 @@ ProvisioningStatus ProvisioningSessionImpl::Initialize(
|
||||
auto rsa_public_key =
|
||||
rsa_key_factory_->CreateFromPkcs1PublicKey(device_public_key);
|
||||
if (!rsa_public_key) return INVALID_DEVICE_PUBLIC_KEY;
|
||||
auto rsa_private_key =
|
||||
rsa_key_factory_->CreateFromPkcs1PrivateKey(device_private_key);
|
||||
// Use empty std::string to indicate the private key is not encrypted.
|
||||
const std::string kClearPkcs8PrivateKeyPassphrase;
|
||||
auto rsa_private_key = rsa_key_factory_->CreateFromPkcs8PrivateKey(
|
||||
device_private_key, kClearPkcs8PrivateKeyPassphrase);
|
||||
if (!rsa_private_key) return INVALID_DEVICE_PRIVATE_KEY;
|
||||
if (!rsa_public_key->MatchesPrivateKey(*rsa_private_key)) {
|
||||
LOG(WARNING) << "Device public key and private key do not match.";
|
||||
@@ -141,7 +143,7 @@ bool ProvisioningSessionImpl::ValidateAndDeserializeRequest(
|
||||
const std::string& message, SignedProvisioningMessage* signed_request,
|
||||
ProvisioningRequest* request) const {
|
||||
if (!signed_request->ParseFromString(message)) {
|
||||
LOG_EVERY_N(WARNING, FLAGS_provisioning_log_every_n)
|
||||
LOG_EVERY_N(WARNING, FLAGS_prov_sdk_log_every_n)
|
||||
<< "Failed to parse SignedProvisioningMessage.";
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user