Change order of loading certificates from pk7 cert

-------------
Add libcurl to media_cas_packager_sdk. libcurl will later be used by a key fetcher to retrieve entitlement key from License Server using a HTTP request.

-------------
Add a function named parsehelper to parse DCSL from the key smith response.

-------------
Move wv_cas_key_fetcher to media_cas_packager_sdk so partners can use it request entitlement keys from License Server.

-------------
Add pkcs7 write method to x509_cert.cc

-------------
Update boringssl_repo to latest in master-with-bazel

-------------
Add a TsPacket class to media_cas_packager_sdk to allow the construction of a ECM TS packet in the SDK.

-------------
Move InsertEcm() from our internal CAS directory to the media_cas_packager_sdk, to be used to build a ECM TS packet by the SDK.

-------------
Add METADATA in common folder

-------------
Refactoring of certificate verification into DrmRootCertificate.

-------------
Extend the default duration of leaf certificates.

-------------
Fix moe_test

-------------
Add a new method to WvCasEcm to allow partner to create a TS packet carrying the generated ECM.

-------------
Change from SHA1 to SHA256 for Cast certificates

-------------
Update crypto mode enumeration to match WV ECM document

-------------
Fix the way we set the validity dates

-------------
Move exported_root/util/status to common/ to prepare for util::Status migration

Also added constructor/operator to copy from/to util::Status.

-------------
Add GenerateDCSLrequest function to certificate_util.h.

-------------
Fix build break

-------------
Allow 'table_id' (in the section header) be specified by caller of SDK method WvCasEcm::GenerateTsPacket().

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224535399
This commit is contained in:
Fang Yu
2018-12-07 10:16:38 -08:00
parent fb96918196
commit 121d554c20
63 changed files with 4834 additions and 560 deletions

View File

@@ -15,22 +15,6 @@ filegroup(
name = "binary_release_files",
srcs = [
"error_space.h",
"status.h",
],
)
cc_library(
name = "status",
srcs = [
"status.cc",
],
hdrs = [
"status.h",
],
deps = [
":error_space",
"//base",
"@abseil_repo//absl/strings",
],
)
@@ -43,17 +27,8 @@ cc_library(
name = "proto_status",
hdrs = ["proto_status.h"],
deps = [
":status",
"//external:protobuf",
],
)
cc_test(
name = "status_test",
srcs = ["status_test.cc"],
deps = [
":status",
"//testing:gunit_main",
"//util:error_space",
],
)

View File

@@ -49,11 +49,11 @@ class ErrorSpaceImpl : public ErrorSpace {
// pointer to stateless static methods, so that clients of ErrorSpaceImpl are
// safe to have constexpr global instances.
static std::string SpaceNameImpl(const ErrorSpace* /*space*/) {
return T::SpaceName();
return T::space_name();
}
static std::string CodeToStringImpl(const ErrorSpace* /*space*/, int code) {
return T::CodeToString(code);
return T::code_to_string(code);
}
};

View File

@@ -16,14 +16,16 @@ namespace {
class Space1 : public util::ErrorSpaceImpl<Space1> {
public:
static std::string SpaceName() { return "Space1"; }
static std::string CodeToString(int code) { return "Test" + std::to_string(code); }
static std::string space_name() { return "Space1"; }
static std::string code_to_string(int code) {
return "Test" + std::to_string(code);
}
};
TEST(ErrorSpaceTest, Basic) {
const ErrorSpace* space1 = Space1::Get();
EXPECT_EQ("Space1", space1->SpaceName());
EXPECT_EQ(Space1::CodeToString(23), space1->String(23));
EXPECT_EQ(Space1::code_to_string(23), space1->String(23));
}
} // namespace

View File

@@ -11,24 +11,26 @@
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_enum_reflection.h"
#include "util/status.h"
#include "util/error_space.h"
namespace widevine {
namespace util {
template <typename T>
class ProtoEnumErrorSpace : public ErrorSpaceImpl<ProtoEnumErrorSpace<T>> {
class ProtoEnumErrorSpace
: public util::ErrorSpaceImpl<ProtoEnumErrorSpace<T>> {
public:
static std::string SpaceName() {
static std::string space_name() {
return google::protobuf::GetEnumDescriptor<T>()->full_name();
}
static std::string CodeToString(int code) {
static std::string code_to_string(int code) {
const google::protobuf::EnumValueDescriptor* v =
google::protobuf::GetEnumDescriptor<T>()->FindValueByNumber(code);
if (v) return v->name();
return std::to_string(code);
}
};
} // namespace util

View File

@@ -9,6 +9,7 @@
#include "util/proto_status.h"
#include "testing/gunit.h"
#include "common/status.h"
#include "protos/public/errors.pb.h"
namespace widevine {
@@ -31,10 +32,18 @@ TEST(StatusTest, Same) {
Status status1(ProtoEnumErrorSpace<Errors>::Get(), PROVIDER_ID_MISMATCH,
"provider_id_mismatch");
Status status2(ProtoEnumErrorSpace<Errors>::Get(), PROVIDER_ID_MISMATCH,
"this is a provider_id_mismatch error");
"provider_id_mismatch");
EXPECT_EQ(status1, status2);
}
TEST(StatusTest, ErrorMessageMismatch) {
Status status1(ProtoEnumErrorSpace<Errors>::Get(), PROVIDER_ID_MISMATCH,
"provider_id_mismatch");
Status status2(ProtoEnumErrorSpace<Errors>::Get(), PROVIDER_ID_MISMATCH,
"this is a provider_id_mismatch error");
EXPECT_NE(status1, status2);
}
TEST(StatusTest, NotTheSameStatus) {
Status status1(ProtoEnumErrorSpace<Errors>::Get(), PROVIDER_ID_MISMATCH,
"provider_id_mismatch");

View File

@@ -1,62 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 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 <string>
#include "base/macros.h"
#include "absl/strings/str_cat.h"
#include "util/status.h"
namespace widevine {
namespace util {
namespace {
const char* kLicenseServerStatusMessage[] = {"OK",
"UNKNOWN_ERROR",
"UNKNOWN_ERROR",
"INVALID_ARGUMENT",
"UNKNOWN_ERROR",
"NOT_FOUND",
"ALREADY_EXISTS",
"PERMISSION_DENIED",
"UNKNOWN_ERROR",
"UNKNOWN_ERROR",
"UNKNOWN_ERROR",
"UNKNOWN_ERROR",
"UNIMPLEMENTED",
"INTERNAL",
"UNAVAILABLE"};
} // namespace
std::string GenericErrorSpace::SpaceName() { return "generic"; }
std::string GenericErrorSpace::CodeToString(int code) {
static_assert(
arraysize(kLicenseServerStatusMessage) == error::NUM_ERRORS,
"mismatching license_server_sdk status message and license_server_sdk "
"status.");
if (code >= 0 && code < error::NUM_ERRORS)
return kLicenseServerStatusMessage[code];
return std::to_string(code);
}
std::string Status::ToString() const {
if (status_code_ == error::OK) return "OK";
return absl::StrCat("Errors::", error_space_->String(status_code_), ": ",
error_message_);
}
std::ostream& operator<<(std::ostream& os, const Status& x) {
os << x.ToString();
return os;
}
} // namespace util
} // namespace widevine

View File

@@ -1,119 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 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.
////////////////////////////////////////////////////////////////////////////////
#ifndef UTIL_STATUS_H_
#define UTIL_STATUS_H_
#include <string>
#include "util/error_space.h"
namespace widevine {
namespace util {
namespace error {
enum StatusCode {
// Success.
OK = 0,
// Client specified an invalid argument.
INVALID_ARGUMENT = 3,
// Some requested entity (e.g., file or directory) was not found.
NOT_FOUND = 5,
// Some entity that we attempted to create (e.g., file or directory)
// already exists.
ALREADY_EXISTS = 6,
// The caller does not have permission to execute the specified
// operation. PERMISSION_DENIED must not be used for rejections
// caused by exhausting some resource (use RESOURCE_EXHAUSTED
// instead for those errors).
PERMISSION_DENIED = 7,
// Operation is not implemented or not supported/enabled in this service.
UNIMPLEMENTED = 12,
// Internal errors. Means some invariants expected by underlying
// system has been broken. If you see one of these errors,
// something is very broken.
INTERNAL = 13,
// Operation is not implemented or not supported/enabled in this service.
UNAVAILABLE = 14,
// Number of generic (non license related) errors.
NUM_ERRORS,
};
} // namespace error
class GenericErrorSpace : public ErrorSpaceImpl<GenericErrorSpace> {
public:
static std::string SpaceName();
static std::string CodeToString(int code);
};
class Status {
public:
Status() : status_code_(error::OK) {}
~Status() {}
explicit Status(error::StatusCode c) : status_code_(c) {}
Status(error::StatusCode c, const std::string& error_message)
: status_code_(c), error_message_(error_message) {}
Status(const ErrorSpace* e, error::StatusCode c,
const std::string& error_message) {
SetError(e, c, error_message);
}
Status(const ErrorSpace* e, int error, const std::string& error_message) {
SetError(e, error, error_message);
}
void SetError(const ErrorSpace* e, int c, const std::string& error_message) {
error_space_ = e;
status_code_ = c;
error_message_ = error_message;
}
bool ok() const { return status_code_ == error::OK; }
const ErrorSpace* error_space() const { return error_space_; }
static const ErrorSpace* canonical_space() {
return GenericErrorSpace::Get();
}
std::string ToString() const;
std::string error_message() const { return error_message_; }
int error_code() const { return status_code_; }
private:
const ErrorSpace* error_space_ = GenericErrorSpace::Get();
int status_code_;
std::string error_message_;
}; // class Status
inline Status OkStatus() { return Status(); }
// Here error_message_ is ignored during comparison.
inline bool operator==(const Status& s1, const Status& s2) {
return s1.error_space() == s2.error_space() &&
s1.error_code() == s2.error_code();
}
inline bool operator!=(const Status& s1, const Status& s2) {
return s1.error_space() != s2.error_space() ||
s1.error_code() != s2.error_code();
}
// Prints a human-readable representation of 'x' to 'os'.
std::ostream& operator<<(std::ostream& os, const Status& x);
#define CHECK_OK(expression) CHECK_EQ(util::error::OK, expression.error_code())
} // namespace util
} // namespace widevine
#endif // UTIL_STATUS_H_

View File

@@ -1,63 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 2007 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 "util/status.h"
#include "testing/gunit.h"
namespace widevine {
namespace util {
TEST(StatusTest, OK_Status) {
// test case for ok status.
Status status(error::OK);
EXPECT_EQ("OK", status.ToString());
}
TEST(StatusTest, OK_Status2) {
// test case for ok status.
Status status;
EXPECT_EQ("OK", status.ToString());
}
TEST(StatusTest, ALREADY_EXISTS_Status) {
Status status(error::ALREADY_EXISTS, "it is already exist");
EXPECT_EQ("Errors::ALREADY_EXISTS: it is already exist", status.ToString());
}
// test case for status in boundary cases.
TEST(StatusTest, UNAVAILABLE_Status) {
Status status(error::UNAVAILABLE, "unavailable");
EXPECT_EQ("Errors::UNAVAILABLE: unavailable", status.ToString());
}
TEST(StatusTest, NoNameCode) {
Status status(static_cast<error::StatusCode>(101), "Unknown error");
EXPECT_EQ("Errors::101: Unknown error", status.ToString());
}
TEST(StatusTest, EQUAL_OPERATOR) {
Status status1(error::ALREADY_EXISTS, "already exists 1");
Status status2(error::ALREADY_EXISTS, "already exists 2");
EXPECT_EQ(status1, status2);
}
TEST(StatusTest, NOT_EQUAL_OPERATOR) {
Status status1(error::ALREADY_EXISTS, "already exists");
Status status2(error::UNAVAILABLE, "unavailable");
EXPECT_NE(status1, status2);
}
TEST(StatusTest, NOT_EQUAL_OPERATOR_NONE_MSG) {
Status status1(error::ALREADY_EXISTS);
Status status2(error::UNAVAILABLE);
EXPECT_NE(status1, status2);
}
} // namespace util
} // namespace widevine