Below are a set of CLs being merged from the wv cdm repo to the android repo. * Fix handling of OEM Cert public key. Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/27921 ] This is a potential fix for b/36656190. Set aside public key on first call to get the public key, and use it afterwards. This gets rid of extra calls to OEMCrypto_GetOEMPublicCertificate(), which has side-effect of staging the OEM private key. This also fixes a problem where the public cert string was not being trimmed to match the size returned by OEMCrypto_GetOEMPublicCertificate(). * Complete provisioning request/response for Provisioning 3.0 Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/27780 ] Fix bug on provisioning request path where GenerateDerivedKeys() was being called when preparing to generate the signature. Add message signature verification, and call correct OEMCrypto routine to rewrap the private key (OEMCrypto_RewrapDeviceRSAKey30). * Implement Cdm::deleteAllUsageRecords() Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/27780 ] Delete all usage records for current origin. Removes usage records from file system and retains the PSTs. The deletes any usage entries matching those PSTs held by OEMCrypto. BUG: 35319024 * Remove stringencoders library from third_party. Author: Jacob Trimble <modmaker@google.com> [ Merge of http://go/wvgerrit/27585 ] We have a fork of the stringencoders library that we use for base64 encoding. This reimplements base64 encoding to remove the extra dependency and to reduce the amount of code. * Add Cdm::deleteUsageRecord() based on key_set_id. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/27605 ] Delete specified usage record from file system usage info and from OEMCrypto. BUG: 35319024 * Modifiable OEMCrypto Author: Fred Gylys-Colwell <fredgc@google.com> [ Merge of http://go/wvgerrit/24729 ] This CL adds a new variant of the OEMCrypto mock code that adjusts its behavior based on a configuration file. This is intended for testing. For example, a tester can set current_hdcp to 2 in the options.txt file, push it to the device, and verify that a license is granted for HDCP 2.0. Then the tester can edit the value of current_hdcp to 1 and push the file to the device. Playback should stop because the license is no longer valid. This variant uses a real level 1 liboemcrypto.so to push data to a secure buffer. That means we can test playback for a license that requires secure buffers on an Android device with real secure buffers. BUG: 35141278 BUG: 37353534 BUG: 71650075 Test: Not currently passing. Will be addressed in a subsequent commit in the chain. Change-Id: I58443c510919e992bb455192e70373490a00e2b6
101 lines
2.9 KiB
C++
101 lines
2.9 KiB
C++
// Copyright 2017 Google Inc. All Rights Reserved.
|
|
//
|
|
// This file contains the declarations for the Metric class and related
|
|
// types.
|
|
#ifndef WVCDM_METRICS_VALUE_METRIC_H_
|
|
#define WVCDM_METRICS_VALUE_METRIC_H_
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
|
|
#include "metric_serialization.h"
|
|
|
|
namespace wvcdm {
|
|
namespace metrics {
|
|
|
|
// Private namespace for some helper implementation functions.
|
|
namespace impl {
|
|
|
|
// These helper functions map the templated ValueMetric class
|
|
// Serialize call to the MetricSerializer explicit calls.
|
|
template<typename T>
|
|
void Serialize(MetricSerializer* serializer,
|
|
const std::string& metric_name, const T& t);
|
|
|
|
inline void SerializeError(MetricSerializer* serializer,
|
|
const std::string& metric_name,
|
|
const int& error_code) {
|
|
serializer->SetInt32(metric_name + "/error", error_code);
|
|
}
|
|
|
|
} // namespace impl
|
|
|
|
// The Metric class supports storing a single value which can be overwritten.
|
|
// the Metric class also supports the MetricSerializer interface through
|
|
// which the value can be serialized. If the value was never given a value
|
|
// or an error code, then the metric will not serialize anything.
|
|
//
|
|
// Example Usage:
|
|
// Metric<string> cdm_version("drm/cdm/version")
|
|
// .Record("a.b.c.d");
|
|
//
|
|
// MyMetricSerializerImpl serialzer;
|
|
// cdm_version.Serialize(&serializer);
|
|
//
|
|
// Example Error Usage:
|
|
//
|
|
// Metric<string> cdm_version("drm/cdm/version")
|
|
// .SetError(error_code);
|
|
//
|
|
// Note that serialization is the same. But the ValueMetric will serialize
|
|
// the error code to <metric_name>/error instead of just <metric_name>.
|
|
template<typename T>
|
|
class ValueMetric : public MetricSerializable {
|
|
public:
|
|
// Constructs a metric with the given metric name.
|
|
explicit ValueMetric(const std::string& metric_name)
|
|
: metric_name_(metric_name), error_code_(0),
|
|
has_error_(false), has_value_(false) {}
|
|
|
|
// Serialize the metric name and value using the given serializer.
|
|
// Caller owns |serializer| which cannot be null.
|
|
virtual void Serialize(MetricSerializer* serializer) {
|
|
if (has_value_) {
|
|
impl::Serialize(serializer, metric_name_, value_);
|
|
} else if (has_error_) {
|
|
impl::SerializeError(serializer, metric_name_, error_code_);
|
|
} else {
|
|
// Do nothing if there is no value and no error.
|
|
}
|
|
}
|
|
|
|
// Record the value of the metric.
|
|
void Record(const T& value) {
|
|
value_ = value;
|
|
has_value_ = true;
|
|
has_error_ = false;
|
|
}
|
|
|
|
// Set the error code if an error was encountered.
|
|
void SetError(int error_code) {
|
|
error_code_ = error_code;
|
|
has_value_ = false;
|
|
has_error_ = true;
|
|
}
|
|
|
|
// Get the current value of the metric.
|
|
const T& GetValue() { return value_; }
|
|
|
|
private:
|
|
std::string metric_name_;
|
|
T value_;
|
|
int error_code_;
|
|
bool has_error_;
|
|
bool has_value_;
|
|
};
|
|
|
|
} // namespace metrics
|
|
} // namespace wvcdm
|
|
|
|
#endif // WVCDM_METRICS_VALUE_METRIC_H_
|