Restructure Project
To make it easier to have separate implementations, we have structured the repo so that there are three Bazel workspaces: - The API (and reference) - The vendor implementation for dev - The vendor implementation for prod This allows the vendor implementation to be separated from the API, while it makes little difference in this repo. While it makes little difference for this repo, it makes managing versions much easier internally. We do it here to better reflect our internal structure to partners. A vendor implementation has been stubbed in (BUILD file and directory structure) to provide vendors with some scaffolding to organize their implementation.
This commit is contained in:
111
whitebox-dev/WORKSPACE
Normal file
111
whitebox-dev/WORKSPACE
Normal file
@@ -0,0 +1,111 @@
|
||||
# Copyright 2020 Google LLC. All Rights Reserved.
|
||||
|
||||
workspace(name = "whitebox_dev")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
local_repository(
|
||||
name = "whitebox_api_repo",
|
||||
path = "../whitebox",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "glog_repo",
|
||||
commit = "3ba8976592274bc1f907c402ce22558011d6fc5e", # 2020-02-16
|
||||
remote = "https://github.com/google/glog.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "com_github_gflags_gflags",
|
||||
commit = "2e227c3daae2ea8899f49858a23f3d318ea39b57", # 2020-01-15
|
||||
remote = "https://github.com/gflags/gflags.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "abseil_repo",
|
||||
commit = "fcb104594b0bb4b8ac306cb2f55ecdad40974683", # 2018-12-04
|
||||
remote = "https://github.com/abseil/abseil-cpp.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "boringssl_repo",
|
||||
commit = "14164f6fef47b7ebd97cdb0cea1624eabd6fe6b8", # 2018-11-26
|
||||
remote = "https://github.com/google/boringssl.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "googletest_repo",
|
||||
commit = "b6cd405286ed8635ece71c72f118e659f4ade3fb", # 2019-01-04
|
||||
remote = "https://github.com/google/googletest.git",
|
||||
)
|
||||
|
||||
# We use "com_google_protobuf" instead of "protobuf_repo" because Bazel's proto
|
||||
# rules implicitly depend on @com_google_protobuf. See
|
||||
# https://bazel.build/blog/2017/02/27/protocol-buffers.html.
|
||||
git_repository(
|
||||
name = "com_google_protobuf",
|
||||
remote = "https://github.com/google/protobuf.git",
|
||||
tag = "v3.8.0",
|
||||
)
|
||||
|
||||
# bazel_skylib is required by google protobuf.
|
||||
git_repository(
|
||||
name = "bazel_skylib",
|
||||
remote = "https://github.com/bazelbuild/bazel-skylib.git",
|
||||
tag = "1.0.2",
|
||||
)
|
||||
|
||||
# Protobuf library support. Not included in the recent protobuf release.
|
||||
http_archive(
|
||||
name = "zlib",
|
||||
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
|
||||
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
|
||||
strip_prefix = "zlib-1.2.11",
|
||||
urls = ["https://zlib.net/zlib-1.2.11.tar.gz"],
|
||||
)
|
||||
|
||||
# ODK
|
||||
new_git_repository(
|
||||
name = "odk_repo",
|
||||
build_file = "@whitebox_api_repo//external:odk.BUILD",
|
||||
commit = "bee799748752fac84d9c3ecd549aa54f72c88d02",
|
||||
remote = "https://widevine-partner.googlesource.com/oemcrypto_core_message.git",
|
||||
repo_mapping = {"@whitebox" : "@whitebox_api_repo"}
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "glog",
|
||||
actual = "@glog_repo//:glog",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gflags",
|
||||
actual = "@com_github_gflags_gflags//:gflags",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "boringssl",
|
||||
actual = "@boringssl_repo//:crypto",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gtest",
|
||||
actual = "@googletest_repo//:gtest",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gtest_main",
|
||||
actual = "@googletest_repo//:gtest_main",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "protobuf",
|
||||
actual = "@com_google_protobuf//:protobuf",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "odk",
|
||||
actual = "@odk_repo//:odk",
|
||||
)
|
||||
109
whitebox-dev/impl/BUILD
Normal file
109
whitebox-dev/impl/BUILD
Normal file
@@ -0,0 +1,109 @@
|
||||
# Copyright 2020 Google LLC. All Rights Reserved.
|
||||
|
||||
package(default_visibility = [
|
||||
"//visibility:private",
|
||||
])
|
||||
|
||||
cc_library(
|
||||
name = "whitebox_common",
|
||||
srcs = [
|
||||
"common_whitebox.cc",
|
||||
"get_random_bytes.cc",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "aead_whitebox",
|
||||
srcs = [
|
||||
"aead_whitebox.cc",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":whitebox_common",
|
||||
"@whitebox_api_repo//api:aead_whitebox",
|
||||
"@whitebox_api_repo//api:result",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "license_whitebox",
|
||||
srcs = [
|
||||
"license_whitebox.cc",
|
||||
],
|
||||
deps = [
|
||||
":whitebox_common",
|
||||
"@whitebox_api_repo//api:license_whitebox",
|
||||
"@whitebox_api_repo//api:result",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "test_data",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"test_data.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"test_data_aead_init.h",
|
||||
"test_data_license_init.h",
|
||||
],
|
||||
deps = [
|
||||
"@whitebox_api_repo//api:test_data",
|
||||
"@whitebox_api_repo//crypto_utils:rsa_test_keys",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "aead_whitebox_test",
|
||||
size = "small",
|
||||
timeout = "moderate",
|
||||
deps = [
|
||||
":aead_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:aead_whitebox_test",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "license_whitebox_test",
|
||||
size = "small",
|
||||
timeout = "moderate",
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:license_whitebox_test",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "aead_whitebox_benchmark",
|
||||
size = "small",
|
||||
deps = [
|
||||
":aead_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:aead_whitebox_benchmark",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "license_whitebox_benchmark",
|
||||
size = "large",
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:license_whitebox_benchmark",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "license_whitebox_golden_data",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"license_whitebox_golden_data_init_data.cc",
|
||||
],
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
"@whitebox_api_repo//api:license_whitebox_golden_data",
|
||||
],
|
||||
)
|
||||
0
whitebox-dev/tools/PLACEHOLDER
Normal file
0
whitebox-dev/tools/PLACEHOLDER
Normal file
111
whitebox-prod/WORKSPACE
Normal file
111
whitebox-prod/WORKSPACE
Normal file
@@ -0,0 +1,111 @@
|
||||
# Copyright 2020 Google LLC. All Rights Reserved.
|
||||
|
||||
workspace(name = "whitebox_prod")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
local_repository(
|
||||
name = "whitebox_api_repo",
|
||||
path = "../whitebox",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "glog_repo",
|
||||
commit = "3ba8976592274bc1f907c402ce22558011d6fc5e", # 2020-02-16
|
||||
remote = "https://github.com/google/glog.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "com_github_gflags_gflags",
|
||||
commit = "2e227c3daae2ea8899f49858a23f3d318ea39b57", # 2020-01-15
|
||||
remote = "https://github.com/gflags/gflags.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "abseil_repo",
|
||||
commit = "fcb104594b0bb4b8ac306cb2f55ecdad40974683", # 2018-12-04
|
||||
remote = "https://github.com/abseil/abseil-cpp.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "boringssl_repo",
|
||||
commit = "14164f6fef47b7ebd97cdb0cea1624eabd6fe6b8", # 2018-11-26
|
||||
remote = "https://github.com/google/boringssl.git",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "googletest_repo",
|
||||
commit = "b6cd405286ed8635ece71c72f118e659f4ade3fb", # 2019-01-04
|
||||
remote = "https://github.com/google/googletest.git",
|
||||
)
|
||||
|
||||
# We use "com_google_protobuf" instead of "protobuf_repo" because Bazel's proto
|
||||
# rules implicitly depend on @com_google_protobuf. See
|
||||
# https://bazel.build/blog/2017/02/27/protocol-buffers.html.
|
||||
git_repository(
|
||||
name = "com_google_protobuf",
|
||||
remote = "https://github.com/google/protobuf.git",
|
||||
tag = "v3.8.0",
|
||||
)
|
||||
|
||||
# bazel_skylib is required by google protobuf.
|
||||
git_repository(
|
||||
name = "bazel_skylib",
|
||||
remote = "https://github.com/bazelbuild/bazel-skylib.git",
|
||||
tag = "1.0.2",
|
||||
)
|
||||
|
||||
# Protobuf library support. Not included in the recent protobuf release.
|
||||
http_archive(
|
||||
name = "zlib",
|
||||
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
|
||||
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
|
||||
strip_prefix = "zlib-1.2.11",
|
||||
urls = ["https://zlib.net/zlib-1.2.11.tar.gz"],
|
||||
)
|
||||
|
||||
# ODK
|
||||
new_git_repository(
|
||||
name = "odk_repo",
|
||||
build_file = "@whitebox_api_repo//external:odk.BUILD",
|
||||
commit = "bee799748752fac84d9c3ecd549aa54f72c88d02",
|
||||
remote = "https://widevine-partner.googlesource.com/oemcrypto_core_message.git",
|
||||
repo_mapping = {"@whitebox" : "@whitebox_api_repo"}
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "glog",
|
||||
actual = "@glog_repo//:glog",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gflags",
|
||||
actual = "@com_github_gflags_gflags//:gflags",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "boringssl",
|
||||
actual = "@boringssl_repo//:crypto",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gtest",
|
||||
actual = "@googletest_repo//:gtest",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gtest_main",
|
||||
actual = "@googletest_repo//:gtest_main",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "protobuf",
|
||||
actual = "@com_google_protobuf//:protobuf",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "odk",
|
||||
actual = "@odk_repo//:odk",
|
||||
)
|
||||
109
whitebox-prod/impl/BUILD
Normal file
109
whitebox-prod/impl/BUILD
Normal file
@@ -0,0 +1,109 @@
|
||||
# Copyright 2020 Google LLC. All Rights Reserved.
|
||||
|
||||
package(default_visibility = [
|
||||
"//visibility:private",
|
||||
])
|
||||
|
||||
cc_library(
|
||||
name = "whitebox_common",
|
||||
srcs = [
|
||||
"common_whitebox.cc",
|
||||
"get_random_bytes.cc",
|
||||
],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "aead_whitebox",
|
||||
srcs = [
|
||||
"aead_whitebox.cc",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":whitebox_common",
|
||||
"@whitebox_api_repo//api:aead_whitebox",
|
||||
"@whitebox_api_repo//api:result",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "license_whitebox",
|
||||
srcs = [
|
||||
"license_whitebox.cc",
|
||||
],
|
||||
deps = [
|
||||
":whitebox_common",
|
||||
"@whitebox_api_repo//api:license_whitebox",
|
||||
"@whitebox_api_repo//api:result",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "test_data",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"test_data.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"test_data_aead_init.h",
|
||||
"test_data_license_init.h",
|
||||
],
|
||||
deps = [
|
||||
"@whitebox_api_repo//api:test_data",
|
||||
"@whitebox_api_repo//crypto_utils:rsa_test_keys",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "aead_whitebox_test",
|
||||
size = "small",
|
||||
timeout = "moderate",
|
||||
deps = [
|
||||
":aead_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:aead_whitebox_test",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "license_whitebox_test",
|
||||
size = "small",
|
||||
timeout = "moderate",
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:license_whitebox_test",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "aead_whitebox_benchmark",
|
||||
size = "small",
|
||||
deps = [
|
||||
":aead_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:aead_whitebox_benchmark",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "license_whitebox_benchmark",
|
||||
size = "large",
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
":test_data",
|
||||
"@whitebox_api_repo//api:license_whitebox_benchmark",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "license_whitebox_golden_data",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"license_whitebox_golden_data_init_data.cc",
|
||||
],
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
"@whitebox_api_repo//api:license_whitebox_golden_data",
|
||||
],
|
||||
)
|
||||
0
whitebox-prod/tools/PLACEHOLDER
Normal file
0
whitebox-prod/tools/PLACEHOLDER
Normal file
172
whitebox/.clang-format
Normal file
172
whitebox/.clang-format
Normal file
@@ -0,0 +1,172 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Chromium
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: true
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
@@ -122,6 +122,7 @@ cc_library(
|
||||
"license_whitebox_decrypt_test.cc",
|
||||
"license_whitebox_get_secret_string_test.cc",
|
||||
"license_whitebox_masked_decrypt_test.cc",
|
||||
"license_whitebox_process_license_response_core_message_test.cc",
|
||||
"license_whitebox_process_license_response_test.cc",
|
||||
"license_whitebox_sign_license_request_test.cc",
|
||||
"license_whitebox_sign_renewal_request_test.cc",
|
||||
@@ -144,23 +145,6 @@ cc_library(
|
||||
],
|
||||
)
|
||||
|
||||
# TODO(jrummell): Move sources into "license_whitebox_test" once all
|
||||
# implementations support core_message.
|
||||
cc_library(
|
||||
name = "license_whitebox_core_message_test",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"license_whitebox_process_license_response_core_message_test.cc",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
":license_whitebox_test",
|
||||
":test_license_builder",
|
||||
"//chromium_deps/testing",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "license_whitebox_benchmark",
|
||||
testonly = True,
|
||||
@@ -186,3 +170,16 @@ cc_library(
|
||||
"//crypto_utils:crypto_util",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "license_whitebox_golden_data",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"license_whitebox_golden_data_test.cc",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":license_whitebox",
|
||||
"//chromium_deps/testing",
|
||||
],
|
||||
)
|
||||
@@ -127,14 +127,20 @@ WB_License_SignLicenseRequest(const WB_License_Whitebox* whitebox,
|
||||
// null, if |message| was null, if |message_size| was zero, if |message| did
|
||||
// not conform to the expected format, if |signature| was null, if
|
||||
// |signature_size| was incorrect, if |session_key| was null, if
|
||||
// |session_key_size| was incorrect, if |session_key| could not be unwrapped
|
||||
// correctly, if |license_request| was null, or if |license_request_size| was
|
||||
// zero.
|
||||
// |session_key_size| was incorrect, if |license_request| was null, or if
|
||||
// |license_request_size| was zero.
|
||||
//
|
||||
// WB_RESULT_INVALID_SIGNATURE if |message|'s signature does not match
|
||||
// |signature|.
|
||||
// |signature| or if |session_key| could not be unwrapped correctly (and
|
||||
// interferes with verification).
|
||||
//
|
||||
// WB_RESULT_INVALID_STATE if a license has already been loaded.
|
||||
//
|
||||
// Notes:
|
||||
// We allow a modified session key to be used. Using it will cause message
|
||||
// verification to fail (therefore we return WB_RESULT_INVALID_SIGNATURE).
|
||||
// Doing this was found to allow for better hardening of the license processing
|
||||
// code.
|
||||
WB_API WB_Result
|
||||
WB_License_ProcessLicenseResponse(WB_License_Whitebox* whitebox,
|
||||
const uint8_t* core_message,
|
||||
@@ -35,19 +35,19 @@ class LicenseWhiteboxDecryptTest : public LicenseWhiteboxTestBase {
|
||||
|
||||
builder.AddContentKey(golden_data_.CBCCryptoKey().level,
|
||||
golden_data_.CBCCryptoKey().id,
|
||||
golden_data_.CBCCryptoKey().content->key);
|
||||
golden_data_.CBCCryptoKey().content->key, padding);
|
||||
|
||||
builder.AddContentKey(golden_data_.CTRCryptoKey().level,
|
||||
golden_data_.CTRCryptoKey().id,
|
||||
golden_data_.CTRCryptoKey().content->key);
|
||||
golden_data_.CTRCryptoKey().content->key, padding);
|
||||
|
||||
builder.AddContentKey(golden_data_.CBCDecodeKey().level,
|
||||
golden_data_.CBCDecodeKey().id,
|
||||
golden_data_.CBCDecodeKey().content->key);
|
||||
golden_data_.CBCDecodeKey().content->key, padding);
|
||||
|
||||
builder.AddContentKey(golden_data_.CBCHardwareKey().level,
|
||||
golden_data_.CBCHardwareKey().id,
|
||||
golden_data_.CBCHardwareKey().content->key);
|
||||
golden_data_.CBCHardwareKey().content->key, padding);
|
||||
|
||||
builder.AddOperatorSessionKey(non_content_key_id_);
|
||||
|
||||
343
whitebox/api/license_whitebox_golden_data_test.cc
Normal file
343
whitebox/api/license_whitebox_golden_data_test.cc
Normal file
@@ -0,0 +1,343 @@
|
||||
// Copyright 2020 Google LLC. All Rights Reserved.
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "api/license_whitebox.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace widevine {
|
||||
// This must be defined by the implementation as they are implementation
|
||||
// specific. They must be defined so that they work with the test key used to
|
||||
// generate the license request.
|
||||
extern const uint8_t kLicenseWhiteboxInitData[];
|
||||
extern const size_t kLicenseWhiteboxInitDataSize;
|
||||
|
||||
namespace {
|
||||
|
||||
const uint8_t kMessage[] = {
|
||||
0x0a, 0x2a, 0x0a, 0x10, 0x53, 0xbc, 0x88, 0x54, 0x04, 0xfc, 0x85, 0xbd,
|
||||
0x75, 0xce, 0x15, 0x2a, 0x06, 0xb5, 0x1f, 0xc5, 0x12, 0x10, 0x53, 0xbc,
|
||||
0x88, 0x54, 0x04, 0xfc, 0x85, 0xbd, 0x75, 0xce, 0x15, 0x2a, 0x06, 0xb5,
|
||||
0x1f, 0xc5, 0x1a, 0x00, 0x20, 0x01, 0x28, 0x00, 0x12, 0x12, 0x08, 0x01,
|
||||
0x10, 0x01, 0x18, 0x01, 0x20, 0x80, 0xa3, 0x05, 0x28, 0x80, 0xa3, 0x05,
|
||||
0x30, 0x80, 0xa3, 0x05, 0x1a, 0x66, 0x12, 0x10, 0x94, 0x40, 0xfa, 0xa2,
|
||||
0xd0, 0xe2, 0xa4, 0x80, 0xb4, 0x74, 0x68, 0x91, 0x0a, 0xb9, 0xe4, 0x6a,
|
||||
0x1a, 0x50, 0x30, 0xe2, 0xcb, 0x71, 0xa1, 0x92, 0xb7, 0xc8, 0x3f, 0xd9,
|
||||
0x00, 0x2e, 0xf0, 0xf8, 0xb1, 0xe6, 0x9e, 0x62, 0xca, 0x27, 0xb3, 0xa7,
|
||||
0x26, 0x19, 0x73, 0x9e, 0xf8, 0xc2, 0x8e, 0x6f, 0xea, 0xb3, 0x5b, 0x01,
|
||||
0xa6, 0xe8, 0x9b, 0x84, 0x1b, 0x9e, 0xaf, 0xe2, 0xa1, 0xff, 0x4a, 0xca,
|
||||
0xcf, 0x84, 0x3f, 0x36, 0xaa, 0x17, 0xa6, 0x0a, 0x0a, 0xe2, 0xcc, 0x12,
|
||||
0xb1, 0x9f, 0xac, 0x05, 0xdf, 0xe7, 0x00, 0xad, 0xc4, 0xa5, 0xd4, 0x4d,
|
||||
0x46, 0x01, 0xbb, 0xcc, 0x18, 0x7e, 0x4d, 0xb5, 0x05, 0x2a, 0x20, 0x01,
|
||||
0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0xf1, 0xed,
|
||||
0x57, 0xf4, 0xad, 0x5d, 0x0e, 0x2c, 0xf9, 0x78, 0xc9, 0xe4, 0x4d, 0x2e,
|
||||
0xcc, 0x68, 0x1a, 0x20, 0xd7, 0xf5, 0x15, 0x85, 0x3b, 0x33, 0xea, 0x8e,
|
||||
0x40, 0xef, 0x2a, 0xd0, 0x8f, 0x96, 0x69, 0xb6, 0xf9, 0xdd, 0x63, 0x8f,
|
||||
0x80, 0x7e, 0x68, 0x02, 0xc7, 0x74, 0x55, 0x5d, 0xd4, 0x17, 0x45, 0x09,
|
||||
0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62, 0x02, 0x48, 0x44,
|
||||
0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0xdb, 0x38,
|
||||
0x5d, 0x4a, 0x0d, 0x80, 0x37, 0x42, 0x10, 0x60, 0x0d, 0x24, 0x03, 0xde,
|
||||
0xd0, 0x3c, 0x1a, 0x20, 0x22, 0xab, 0x33, 0xb9, 0xe5, 0x16, 0xa2, 0x6d,
|
||||
0x5a, 0x42, 0x45, 0xd4, 0x0e, 0x47, 0x0c, 0xf3, 0x6c, 0x1f, 0x20, 0xd9,
|
||||
0x0e, 0x79, 0xd7, 0xb7, 0x34, 0xc1, 0xbe, 0xd2, 0x6b, 0x01, 0xff, 0x73,
|
||||
0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62, 0x02, 0x48, 0x44,
|
||||
0x1a, 0x55, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xdd, 0xfb,
|
||||
0x7a, 0x27, 0x34, 0xd4, 0xec, 0xcf, 0x01, 0x9c, 0xbd, 0x84, 0xe3, 0xf0,
|
||||
0xbd, 0xc6, 0x1a, 0x20, 0x11, 0x0c, 0xa2, 0xc3, 0xb8, 0x95, 0xaf, 0x48,
|
||||
0x80, 0x57, 0xd1, 0x39, 0xec, 0xd7, 0x09, 0x5a, 0x95, 0x31, 0xf8, 0x3f,
|
||||
0xa0, 0x6d, 0x9c, 0xad, 0x10, 0x70, 0xa4, 0x6b, 0x6a, 0x5c, 0xca, 0x73,
|
||||
0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62, 0x05, 0x41, 0x55,
|
||||
0x44, 0x49, 0x4f, 0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x12,
|
||||
0x10, 0xcb, 0xac, 0x50, 0x57, 0x81, 0xcd, 0x04, 0xf6, 0x71, 0xb2, 0xc2,
|
||||
0x08, 0x86, 0x12, 0x78, 0x58, 0x1a, 0x20, 0x71, 0x0e, 0xd7, 0xa2, 0x8c,
|
||||
0x64, 0x75, 0x0b, 0x11, 0x9e, 0x48, 0x47, 0x0c, 0x2d, 0x78, 0x48, 0x1c,
|
||||
0x98, 0x2f, 0x14, 0x51, 0x15, 0x2a, 0x05, 0xe8, 0x84, 0x6e, 0x61, 0xc2,
|
||||
0x26, 0x82, 0xe6, 0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62,
|
||||
0x02, 0x48, 0x44, 0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12,
|
||||
0x10, 0xa6, 0xd4, 0xb8, 0x0a, 0x37, 0x46, 0xf6, 0xc8, 0x59, 0x5a, 0x30,
|
||||
0x96, 0x39, 0x16, 0x29, 0x1e, 0x1a, 0x20, 0xff, 0xe7, 0xb2, 0x9e, 0x98,
|
||||
0x40, 0x33, 0xce, 0x9e, 0xcf, 0x85, 0x60, 0x52, 0x43, 0x38, 0xe6, 0x1b,
|
||||
0x07, 0x10, 0xfa, 0x71, 0xa8, 0x66, 0x0f, 0xd6, 0x9a, 0x09, 0xac, 0xb1,
|
||||
0x47, 0xe4, 0x19, 0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62,
|
||||
0x02, 0x53, 0x44, 0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x12,
|
||||
0x10, 0x57, 0x43, 0x24, 0x10, 0x4d, 0xd3, 0xcf, 0x6e, 0xef, 0x37, 0xce,
|
||||
0x5b, 0xba, 0xd1, 0x61, 0x62, 0x1a, 0x20, 0x54, 0xec, 0xbb, 0xc7, 0x4b,
|
||||
0xa6, 0x3f, 0x17, 0xcc, 0x5e, 0xb8, 0x20, 0x41, 0x9e, 0xcf, 0xe2, 0x9f,
|
||||
0x03, 0x9d, 0x79, 0xd0, 0x06, 0x0b, 0x0e, 0x6e, 0xf4, 0x9e, 0x93, 0x92,
|
||||
0x50, 0x19, 0xbd, 0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62,
|
||||
0x02, 0x53, 0x44, 0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x35, 0x12,
|
||||
0x10, 0xd7, 0x93, 0x22, 0x74, 0xf1, 0x0b, 0x61, 0x26, 0x7e, 0x16, 0xd5,
|
||||
0x88, 0x5f, 0x70, 0x2b, 0x3d, 0x1a, 0x20, 0xb2, 0x21, 0xc6, 0xb4, 0x65,
|
||||
0xf1, 0x00, 0x07, 0x11, 0x0e, 0xe4, 0x67, 0x3c, 0xb4, 0x4c, 0xc9, 0xe9,
|
||||
0x82, 0x5e, 0xbc, 0x2a, 0x2a, 0xf0, 0x68, 0x45, 0xfe, 0xd2, 0xce, 0xea,
|
||||
0xae, 0xfb, 0x9a, 0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62,
|
||||
0x02, 0x53, 0x44, 0x1a, 0x52, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x36, 0x12,
|
||||
0x10, 0x96, 0x9e, 0xc6, 0xcb, 0xc0, 0xbf, 0xf5, 0x83, 0xef, 0xc9, 0xe7,
|
||||
0xbb, 0x2a, 0x1a, 0xce, 0x0b, 0x1a, 0x20, 0xe0, 0x23, 0x16, 0x1e, 0x00,
|
||||
0x05, 0xc0, 0xfe, 0x97, 0x47, 0x5f, 0x75, 0x69, 0x8c, 0x09, 0x8b, 0x3e,
|
||||
0x93, 0x1b, 0xa4, 0x84, 0x4b, 0xd3, 0xb1, 0x77, 0xd4, 0x42, 0xee, 0x7e,
|
||||
0xf5, 0xe4, 0x0c, 0x20, 0x02, 0x28, 0x01, 0x32, 0x00, 0x3a, 0x00, 0x62,
|
||||
0x02, 0x53, 0x44, 0x20, 0xb2, 0x88, 0xc6, 0xfa, 0x05, 0x38, 0x00,
|
||||
};
|
||||
const uint8_t kSignature[] = {
|
||||
0x34, 0x7e, 0xc1, 0xa9, 0x3e, 0x1d, 0x66, 0x77, 0x5d, 0xac, 0xe8,
|
||||
0x8b, 0xc0, 0x37, 0x3e, 0x4c, 0x9b, 0xe5, 0x9c, 0x25, 0x04, 0xed,
|
||||
0x3f, 0x66, 0x6e, 0x6c, 0x51, 0x42, 0x57, 0x7f, 0x6c, 0x53,
|
||||
};
|
||||
const uint8_t kSessionKey[] = {
|
||||
0x21, 0xd8, 0x3b, 0x58, 0xda, 0xa9, 0x3a, 0x1c, 0xdb, 0xfb, 0x54, 0xff,
|
||||
0x0d, 0x30, 0xcd, 0x00, 0xff, 0x52, 0xc4, 0xed, 0x5c, 0xf9, 0xc9, 0x1c,
|
||||
0x7b, 0x41, 0x48, 0xc0, 0x98, 0xa9, 0x74, 0x99, 0x79, 0xa0, 0x75, 0xc3,
|
||||
0x50, 0xf0, 0xac, 0xfa, 0xec, 0xc4, 0xc0, 0x34, 0x06, 0x5b, 0xb9, 0xaa,
|
||||
0x6d, 0xcf, 0x71, 0x69, 0xf0, 0x5e, 0x8f, 0x6b, 0x50, 0x9a, 0x16, 0x54,
|
||||
0xa7, 0x72, 0x11, 0x50, 0xf9, 0xec, 0x8d, 0xcc, 0x3a, 0x23, 0x16, 0x84,
|
||||
0x78, 0xea, 0xaa, 0xbd, 0x6f, 0xd9, 0x88, 0x5f, 0xa8, 0x82, 0x3c, 0x05,
|
||||
0x53, 0xe7, 0x76, 0x5f, 0xe3, 0x7a, 0x4a, 0xe5, 0xeb, 0x45, 0x9d, 0x04,
|
||||
0x45, 0xe8, 0x9a, 0x4a, 0x10, 0x02, 0x63, 0x97, 0x35, 0x68, 0x87, 0xc4,
|
||||
0xe3, 0xaa, 0xbd, 0x1b, 0xe7, 0xa2, 0xd4, 0x52, 0xb0, 0xea, 0x2d, 0x2f,
|
||||
0x59, 0x62, 0x7e, 0xb4, 0x6b, 0xe0, 0x06, 0x7a, 0xee, 0x98, 0x21, 0x74,
|
||||
0xec, 0x99, 0x61, 0x55, 0x9b, 0x1d, 0xf9, 0x5d, 0x6f, 0x80, 0x87, 0xdd,
|
||||
0xf3, 0x7b, 0x5d, 0x98, 0xb6, 0x37, 0x6a, 0x0a, 0x83, 0x5e, 0x36, 0x08,
|
||||
0x8a, 0xf4, 0xcd, 0x9e, 0x5c, 0x7d, 0xec, 0xf2, 0x4e, 0x5b, 0x4d, 0xac,
|
||||
0x9a, 0xab, 0xb1, 0x80, 0xc9, 0x58, 0xa0, 0x1d, 0x19, 0x16, 0x0b, 0xd5,
|
||||
0xea, 0xe7, 0xfc, 0xfd, 0x4e, 0x04, 0x98, 0xa1, 0x8d, 0x79, 0xb0, 0xa7,
|
||||
0xb5, 0x44, 0xfc, 0x12, 0xd2, 0x04, 0x7d, 0x53, 0x02, 0xfd, 0x70, 0x21,
|
||||
0xef, 0xfd, 0x64, 0x11, 0x48, 0x03, 0xc4, 0x66, 0x7a, 0x29, 0xc3, 0x83,
|
||||
0xfc, 0xee, 0xad, 0x9a, 0x4c, 0x97, 0x64, 0x0a, 0x9e, 0x72, 0x42, 0xc1,
|
||||
0x1f, 0x32, 0x29, 0x80, 0xcf, 0xb9, 0xdc, 0x1d, 0x81, 0x92, 0x13, 0xfe,
|
||||
0x85, 0x50, 0x53, 0x4a, 0x0a, 0xa2, 0x24, 0x52, 0x26, 0x9a, 0x65, 0x28,
|
||||
0x13, 0x26, 0xae, 0xf3,
|
||||
};
|
||||
const uint8_t kLicenseRequest[] = {
|
||||
0x0a, 0x88, 0x0b, 0x08, 0x01, 0x12, 0xed, 0x09, 0x0a, 0xb0, 0x02, 0x08,
|
||||
0x02, 0x12, 0x10, 0x0c, 0x36, 0x48, 0x86, 0x75, 0xa1, 0x84, 0x53, 0x4d,
|
||||
0xbc, 0x55, 0x96, 0xc9, 0xf4, 0xaf, 0x0a, 0x18, 0x97, 0xe7, 0xdd, 0xf8,
|
||||
0x05, 0x22, 0x8e, 0x02, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
|
||||
0x00, 0xae, 0xa6, 0xa8, 0xea, 0xdd, 0xac, 0x6f, 0xb4, 0x41, 0x47, 0xcb,
|
||||
0x18, 0x81, 0xeb, 0xdf, 0x4f, 0x17, 0xf7, 0x17, 0xc0, 0xab, 0x6f, 0x47,
|
||||
0x50, 0xbf, 0xe4, 0x8c, 0xc9, 0x45, 0x24, 0x5e, 0x1c, 0x2e, 0x86, 0x9f,
|
||||
0xcb, 0x47, 0x05, 0xf9, 0xfe, 0x91, 0x90, 0xaf, 0xbd, 0x22, 0x14, 0x47,
|
||||
0xa7, 0x34, 0x39, 0x79, 0x44, 0xe9, 0x92, 0x83, 0x4a, 0x80, 0xa8, 0x2a,
|
||||
0xe6, 0x9f, 0x2b, 0xb7, 0xda, 0x2a, 0xd2, 0xae, 0x57, 0x5b, 0xfa, 0xb6,
|
||||
0xdf, 0xca, 0x3e, 0xb1, 0xb8, 0x42, 0x0b, 0xde, 0x46, 0x36, 0xdb, 0x42,
|
||||
0x33, 0x8b, 0xda, 0x5c, 0x60, 0x44, 0x7c, 0x99, 0xb4, 0x98, 0xb4, 0x1e,
|
||||
0xd8, 0x25, 0x6d, 0x67, 0x84, 0xc9, 0x67, 0xde, 0x05, 0xe6, 0x06, 0xb5,
|
||||
0xb5, 0xca, 0xbc, 0xfa, 0xb0, 0xa7, 0x46, 0x29, 0x3f, 0x63, 0x47, 0x9d,
|
||||
0x70, 0x8d, 0xa2, 0x8d, 0x22, 0xc6, 0xeb, 0x06, 0xd4, 0x5c, 0x3b, 0x62,
|
||||
0x98, 0xc7, 0xda, 0x16, 0x8f, 0x17, 0x59, 0xd5, 0xcb, 0xd1, 0x5d, 0xe3,
|
||||
0xe1, 0x07, 0xe6, 0x97, 0x87, 0xf4, 0x22, 0x53, 0xfa, 0xf9, 0xa9, 0xf5,
|
||||
0xeb, 0xd7, 0x55, 0xdf, 0x32, 0x2d, 0x4e, 0x07, 0x86, 0x25, 0x44, 0x93,
|
||||
0xd6, 0xf7, 0xc6, 0xf9, 0x78, 0x91, 0x24, 0x1e, 0xd4, 0x6b, 0xe3, 0x4a,
|
||||
0xff, 0x4a, 0x3a, 0xb9, 0x89, 0x90, 0x61, 0x87, 0xb9, 0x41, 0x45, 0x02,
|
||||
0xfd, 0xd0, 0xc5, 0x5a, 0x98, 0x41, 0x88, 0xa4, 0xe3, 0xe2, 0xa2, 0x9d,
|
||||
0x9a, 0x90, 0x3f, 0x44, 0x8e, 0x3a, 0xe1, 0xd1, 0xe9, 0x79, 0x9a, 0xc6,
|
||||
0xe2, 0x7c, 0x8e, 0x9c, 0x3d, 0xb2, 0xe0, 0x26, 0x5a, 0x46, 0x13, 0xc8,
|
||||
0x43, 0x9f, 0xf7, 0x51, 0x7e, 0xbb, 0x55, 0x6d, 0xcc, 0x97, 0x38, 0xdb,
|
||||
0xa4, 0x4b, 0x96, 0x40, 0xe5, 0x2d, 0x8f, 0x43, 0xe3, 0x21, 0x15, 0xda,
|
||||
0x34, 0x97, 0x7a, 0x9e, 0xbb, 0x02, 0x03, 0x01, 0x00, 0x01, 0x28, 0xe8,
|
||||
0x3d, 0x48, 0x01, 0x12, 0x80, 0x02, 0xa2, 0x05, 0x30, 0x91, 0xed, 0xc2,
|
||||
0x17, 0xfd, 0x92, 0x5c, 0x69, 0x1f, 0xb4, 0x82, 0x35, 0x75, 0xcb, 0x48,
|
||||
0x22, 0x07, 0x54, 0x72, 0x05, 0x86, 0x2e, 0xa1, 0x98, 0xc9, 0x46, 0x07,
|
||||
0xc9, 0x26, 0x6b, 0x05, 0x56, 0xa2, 0xa6, 0x5b, 0xe3, 0xba, 0x80, 0xd0,
|
||||
0x01, 0xb3, 0xbd, 0x9f, 0x7b, 0x15, 0xe3, 0xe6, 0xad, 0x85, 0xe6, 0x92,
|
||||
0x35, 0xec, 0x9b, 0x18, 0x7e, 0x1d, 0x39, 0x93, 0xfb, 0x0b, 0x2c, 0xe8,
|
||||
0xa0, 0xee, 0x6e, 0x27, 0x8f, 0x08, 0x99, 0xc7, 0xd6, 0x08, 0x1f, 0xe5,
|
||||
0xd4, 0x9b, 0x30, 0x83, 0x31, 0xf8, 0x49, 0x05, 0x9b, 0xa0, 0x30, 0xaa,
|
||||
0xc1, 0x61, 0xd4, 0xec, 0x81, 0x28, 0xe1, 0x80, 0x17, 0x09, 0xdc, 0x35,
|
||||
0xb8, 0xdc, 0xd3, 0x46, 0x7b, 0xa6, 0xad, 0x44, 0x90, 0x17, 0x99, 0x8e,
|
||||
0x43, 0xd4, 0x35, 0x00, 0x98, 0x6c, 0xe5, 0xc3, 0x2e, 0xad, 0x80, 0xa6,
|
||||
0x35, 0x3e, 0xed, 0xb2, 0x22, 0xe0, 0xad, 0x8a, 0xd0, 0x1a, 0x5e, 0x27,
|
||||
0x29, 0xe2, 0xd9, 0x01, 0x2d, 0xf3, 0xe8, 0xb8, 0xa5, 0x6d, 0x8b, 0xfb,
|
||||
0x1c, 0x8e, 0x77, 0xa1, 0xe0, 0x8e, 0x64, 0x1b, 0xfb, 0x3a, 0x05, 0x2f,
|
||||
0x96, 0x6f, 0xe7, 0x86, 0xff, 0x75, 0x8f, 0xdf, 0x3d, 0xf4, 0x2d, 0x7a,
|
||||
0xfc, 0x76, 0x0d, 0xf1, 0xde, 0x60, 0xe7, 0x4b, 0xc1, 0x87, 0xb0, 0x3f,
|
||||
0xa3, 0xe6, 0x37, 0xf1, 0xf0, 0x0a, 0x9e, 0x99, 0xe2, 0x7f, 0x6a, 0x99,
|
||||
0xe1, 0xde, 0x2c, 0x23, 0x8d, 0xc6, 0x2d, 0xe8, 0x4d, 0x4a, 0x2b, 0x02,
|
||||
0xf2, 0xc1, 0xea, 0xae, 0x9d, 0x2f, 0xb3, 0xee, 0x84, 0xe9, 0xb8, 0xe4,
|
||||
0x7b, 0x62, 0x47, 0x9c, 0xf0, 0xed, 0x80, 0x37, 0xcf, 0x92, 0xc5, 0xae,
|
||||
0xbb, 0x32, 0x31, 0xb4, 0xd7, 0xc4, 0xce, 0xa3, 0x4e, 0xb6, 0xd6, 0xe9,
|
||||
0x72, 0x5f, 0xd1, 0xe5, 0xa0, 0xf1, 0xfb, 0x79, 0xb1, 0xa8, 0x1a, 0xb4,
|
||||
0x05, 0x0a, 0xae, 0x02, 0x08, 0x01, 0x12, 0x10, 0x65, 0x80, 0x2c, 0x9b,
|
||||
0x62, 0x5e, 0x5a, 0x31, 0x9c, 0x33, 0xdc, 0x1c, 0xb7, 0xc3, 0xc6, 0xd4,
|
||||
0x18, 0xe3, 0xa5, 0xbd, 0xd0, 0x05, 0x22, 0x8e, 0x02, 0x30, 0x82, 0x01,
|
||||
0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb8, 0x05, 0x02, 0x04, 0x3c, 0x2a,
|
||||
0x8a, 0x0f, 0xd8, 0xd2, 0x5c, 0x61, 0x3e, 0x1e, 0x3e, 0x3b, 0x5e, 0x34,
|
||||
0x9f, 0x33, 0x2f, 0x04, 0x51, 0x6a, 0x75, 0x10, 0xd3, 0x80, 0x21, 0xa5,
|
||||
0x62, 0x9b, 0x9a, 0xa0, 0x27, 0xae, 0xad, 0x3c, 0x75, 0x9b, 0x7a, 0xfe,
|
||||
0x70, 0xbe, 0xd6, 0x5f, 0x3d, 0xf6, 0x86, 0x0f, 0xf5, 0xeb, 0x60, 0xb9,
|
||||
0x83, 0xa3, 0xff, 0xa3, 0x3f, 0xde, 0x06, 0xf3, 0xb7, 0x30, 0x14, 0xdf,
|
||||
0xc8, 0x45, 0xab, 0x37, 0x1c, 0x66, 0x00, 0x56, 0x2e, 0x9d, 0x90, 0x4f,
|
||||
0x84, 0x2b, 0x8b, 0xa4, 0xa5, 0xd9, 0x20, 0x0f, 0xfa, 0x3e, 0xd4, 0x5d,
|
||||
0x70, 0x55, 0x20, 0xa5, 0xc3, 0x72, 0xa8, 0x89, 0xf9, 0xe3, 0x14, 0x38,
|
||||
0x62, 0x34, 0xc6, 0x89, 0x7a, 0xe6, 0x55, 0x85, 0x1f, 0xcd, 0x9a, 0xdb,
|
||||
0x4e, 0xf9, 0x12, 0x6c, 0x78, 0x38, 0x6e, 0xa9, 0x3b, 0xcb, 0x25, 0xba,
|
||||
0x3e, 0xc4, 0x75, 0xc5, 0x5c, 0x60, 0x8e, 0x77, 0x1c, 0x76, 0x3a, 0xb0,
|
||||
0x25, 0x06, 0xf9, 0xb0, 0x72, 0x52, 0xd6, 0xab, 0xf7, 0xea, 0x64, 0xb1,
|
||||
0xeb, 0xde, 0x7b, 0x95, 0xc6, 0x40, 0x76, 0x90, 0x53, 0x3b, 0xd6, 0x89,
|
||||
0x0b, 0x92, 0x74, 0xc1, 0x60, 0x66, 0xf7, 0x4f, 0xc4, 0x01, 0xea, 0x35,
|
||||
0x5f, 0x0a, 0x02, 0x10, 0x68, 0x14, 0xd4, 0x9b, 0xf0, 0xc8, 0x9e, 0x6e,
|
||||
0x1f, 0x8d, 0xb2, 0xa4, 0x78, 0x41, 0xcd, 0x0d, 0xad, 0x79, 0x32, 0x96,
|
||||
0xa1, 0x07, 0xc3, 0x62, 0x23, 0x40, 0x4f, 0x2b, 0xf1, 0xfc, 0xa1, 0x6f,
|
||||
0xd0, 0xa4, 0xb9, 0x82, 0x63, 0x4d, 0xb6, 0x24, 0x07, 0xf8, 0xf1, 0x4a,
|
||||
0xca, 0xe3, 0xb0, 0x5a, 0x03, 0x8b, 0xd3, 0xe4, 0xbb, 0xba, 0xe4, 0x39,
|
||||
0x1b, 0xbf, 0xa7, 0xa4, 0x7f, 0xb9, 0xd0, 0x1d, 0xe8, 0x57, 0xea, 0x88,
|
||||
0xe5, 0xe3, 0x6e, 0xe3, 0x6e, 0x24, 0x58, 0x59, 0xfc, 0x0f, 0x02, 0x03,
|
||||
0x01, 0x00, 0x01, 0x28, 0xe8, 0x3d, 0x12, 0x80, 0x03, 0x7e, 0x06, 0x58,
|
||||
0x1a, 0x01, 0x91, 0x84, 0xab, 0x57, 0x2a, 0xfd, 0xca, 0xdd, 0xd0, 0x3f,
|
||||
0x16, 0x1c, 0xe6, 0x82, 0x00, 0xf8, 0xe6, 0xf8, 0xad, 0x16, 0x19, 0x47,
|
||||
0x36, 0x0b, 0xc8, 0xd4, 0x9c, 0x0d, 0x68, 0x00, 0x9b, 0x1c, 0x46, 0x44,
|
||||
0xf9, 0xb3, 0xf3, 0xfb, 0x6d, 0xdf, 0xd9, 0x2e, 0xf9, 0x2d, 0xe6, 0x2d,
|
||||
0x41, 0xd4, 0x59, 0xd2, 0x9d, 0x81, 0xbf, 0xae, 0xf3, 0x97, 0x0a, 0x3a,
|
||||
0x39, 0xd2, 0x5b, 0x26, 0x62, 0xec, 0xb0, 0x3b, 0x2d, 0xa7, 0xb6, 0x83,
|
||||
0x02, 0xfa, 0xa6, 0xdd, 0x98, 0xd9, 0x5a, 0x14, 0x3c, 0xc8, 0xc1, 0xcb,
|
||||
0x6a, 0xdd, 0xa7, 0x6d, 0x2e, 0xe9, 0xc3, 0x72, 0x3f, 0xaf, 0x95, 0xa2,
|
||||
0x9c, 0xdc, 0x3e, 0x96, 0x8b, 0x68, 0x21, 0xa9, 0x1c, 0x05, 0x1c, 0xa2,
|
||||
0x80, 0xa8, 0x66, 0x69, 0x71, 0x0a, 0x1a, 0xd7, 0xa4, 0x4b, 0xf9, 0x21,
|
||||
0x80, 0x27, 0x46, 0x0d, 0xf6, 0x94, 0xe2, 0xe9, 0x27, 0x03, 0x96, 0xdf,
|
||||
0x22, 0x19, 0x63, 0xf2, 0x1e, 0xe6, 0xaa, 0x22, 0x0a, 0x5e, 0xe4, 0xa4,
|
||||
0xd0, 0xfe, 0xb3, 0xd5, 0x3e, 0xb5, 0x73, 0x2f, 0x8f, 0x91, 0xe9, 0xa9,
|
||||
0x6b, 0x3b, 0x8b, 0xe2, 0x84, 0xc5, 0x13, 0x39, 0xea, 0x28, 0x4d, 0x4d,
|
||||
0x0e, 0xdd, 0x55, 0xb6, 0xad, 0x56, 0xf7, 0x41, 0x64, 0x20, 0xe0, 0x5e,
|
||||
0x05, 0x9f, 0x97, 0x34, 0xa9, 0x6b, 0xe2, 0x5a, 0xa4, 0x45, 0x60, 0xdb,
|
||||
0xa8, 0xc3, 0x87, 0x55, 0xa4, 0x2a, 0x82, 0xbd, 0x7f, 0x88, 0xed, 0xd1,
|
||||
0x9d, 0xf3, 0x46, 0xa6, 0x67, 0xb3, 0x3b, 0x81, 0x14, 0xc7, 0x6a, 0x88,
|
||||
0x38, 0xc4, 0x23, 0xd8, 0x24, 0xa5, 0x0b, 0x23, 0x25, 0x1a, 0x08, 0x81,
|
||||
0x36, 0xd6, 0xe8, 0xf4, 0x75, 0x29, 0x9d, 0x2a, 0xfd, 0x46, 0xce, 0xa5,
|
||||
0x1b, 0x5c, 0xbd, 0xf7, 0x89, 0xa5, 0x72, 0x12, 0x5c, 0xd2, 0x4f, 0xbb,
|
||||
0x81, 0x3b, 0x38, 0x7a, 0x10, 0xcd, 0x2a, 0x30, 0xe3, 0x44, 0x76, 0x34,
|
||||
0xab, 0x34, 0x08, 0xf9, 0x6b, 0x9c, 0xf3, 0xd9, 0x88, 0x96, 0xd4, 0x05,
|
||||
0xf3, 0xf5, 0x40, 0xd9, 0xc5, 0x79, 0x62, 0x76, 0x0f, 0xcd, 0x17, 0x7c,
|
||||
0xdd, 0x10, 0x1e, 0xb8, 0xa4, 0x14, 0x8b, 0x9c, 0x29, 0xce, 0xd5, 0xea,
|
||||
0xd6, 0x45, 0xa9, 0x5b, 0x69, 0x8f, 0x1c, 0xdc, 0x6e, 0x1d, 0xb6, 0x67,
|
||||
0x8b, 0x85, 0x07, 0x41, 0x86, 0x08, 0x0d, 0x68, 0xd1, 0x3c, 0xd3, 0x7e,
|
||||
0x07, 0xb1, 0x6d, 0xe3, 0x70, 0xcd, 0x9a, 0xfb, 0x9b, 0x25, 0x56, 0x4a,
|
||||
0x73, 0xa3, 0x0e, 0x2a, 0xf8, 0x08, 0x5e, 0xa3, 0x7d, 0x31, 0x0c, 0x47,
|
||||
0x4f, 0x0e, 0x67, 0xac, 0x00, 0xca, 0x99, 0x2a, 0x52, 0x96, 0xfa, 0xed,
|
||||
0xad, 0x7a, 0xa0, 0x6e, 0xcd, 0x79, 0x0f, 0x1e, 0x3d, 0x42, 0x65, 0x58,
|
||||
0xfa, 0x98, 0x38, 0x3e, 0x3c, 0xd2, 0xed, 0x48, 0x30, 0x1a, 0x1b, 0x0a,
|
||||
0x11, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72,
|
||||
0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x06, 0x78, 0x38, 0x36, 0x2d,
|
||||
0x36, 0x34, 0x1a, 0x16, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e,
|
||||
0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x06, 0x47, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x1a, 0x17, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x09, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65,
|
||||
0x43, 0x44, 0x4d, 0x1a, 0x16, 0x0a, 0x0d, 0x70, 0x6c, 0x61, 0x74, 0x66,
|
||||
0x6f, 0x72, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x05, 0x4c, 0x69,
|
||||
0x6e, 0x75, 0x78, 0x1a, 0x24, 0x0a, 0x14, 0x77, 0x69, 0x64, 0x65, 0x76,
|
||||
0x69, 0x6e, 0x65, 0x5f, 0x63, 0x64, 0x6d, 0x5f, 0x76, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x12, 0x0c, 0x34, 0x2e, 0x31, 0x30, 0x2e, 0x31, 0x36,
|
||||
0x38, 0x36, 0x2e, 0x39, 0x36, 0x32, 0x08, 0x08, 0x00, 0x10, 0x00, 0x18,
|
||||
0x01, 0x20, 0x00, 0x12, 0x3f, 0x0a, 0x3d, 0x0a, 0x27, 0x08, 0x01, 0x12,
|
||||
0x01, 0x30, 0x1a, 0x0d, 0x77, 0x69, 0x64, 0x65, 0x76, 0x69, 0x6e, 0x65,
|
||||
0x5f, 0x74, 0x65, 0x73, 0x74, 0x22, 0x0a, 0x32, 0x30, 0x31, 0x35, 0x5f,
|
||||
0x74, 0x65, 0x61, 0x72, 0x73, 0x2a, 0x05, 0x41, 0x55, 0x44, 0x49, 0x4f,
|
||||
0x10, 0x01, 0x1a, 0x10, 0x53, 0xbc, 0x88, 0x54, 0x04, 0xfc, 0x85, 0xbd,
|
||||
0x75, 0xce, 0x15, 0x2a, 0x06, 0xb5, 0x1f, 0xc5, 0x18, 0x01, 0x20, 0xb2,
|
||||
0x88, 0xc6, 0xfa, 0x05, 0x30, 0x15,
|
||||
};
|
||||
|
||||
const size_t kMessageSize = sizeof(kMessage);
|
||||
const size_t kLicenseRequestSize = sizeof(kLicenseRequest);
|
||||
const size_t kSignatureSize = sizeof(kSignature);
|
||||
const size_t kSessionKeySize = sizeof(kSessionKey);
|
||||
|
||||
// The pointer for core message must be non-null, but the length needs to be
|
||||
// zero.
|
||||
const uint8_t kCoreMessage[] = {0};
|
||||
const size_t kCoreMessageSize = 0;
|
||||
|
||||
const uint8_t kPlaintext[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const size_t kPlaintextSize = sizeof(kPlaintext);
|
||||
|
||||
// Generated with:
|
||||
// openssl aes-128-cbc -e -in clean -K 78a1dc0646119707e903514d8a00735f -iv
|
||||
// 00000000000000000000000000000000 | xxd -i
|
||||
const uint8_t kCiphertext[] = {
|
||||
0xef, 0x21, 0x57, 0x2d, 0xe1, 0x08, 0xc6, 0x3c,
|
||||
0x54, 0x7d, 0x3d, 0xde, 0x92, 0x2e, 0x5c, 0xe0,
|
||||
|
||||
0x79, 0x52, 0xb5, 0xc1, 0x76, 0x3e, 0xdf, 0x73,
|
||||
0x5b, 0x05, 0xe8, 0x20, 0xe6, 0xa3, 0x22, 0x49,
|
||||
|
||||
0xc7, 0xa5, 0x9f, 0xd5, 0x76, 0x6b, 0x20, 0xd3,
|
||||
0x21, 0x52, 0xe6, 0xc6, 0x9b, 0x22, 0xb0, 0xb3,
|
||||
|
||||
0xf8, 0x0d, 0x58, 0xdd, 0xb2, 0x37, 0x7d, 0x7e,
|
||||
0xe3, 0xaf, 0xaf, 0x82, 0x7b, 0xb8, 0x69, 0x12,
|
||||
|
||||
// Drop the padding at the end of the ciphertext.
|
||||
// 0x40, 0x03, 0x23, 0x83, 0x2f, 0x65, 0xda, 0x81,
|
||||
// 0x78, 0x46, 0xa6, 0xa8, 0xa4, 0x2c, 0x86, 0x75,
|
||||
};
|
||||
const size_t kCiphertextSize = sizeof(kCiphertext);
|
||||
|
||||
// The key associated with this id is: 78a1dc0646119707e903514d8a00735f
|
||||
const uint8_t kKeyId[] = {
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31,
|
||||
};
|
||||
const size_t kKeyIdSize = sizeof(kKeyId);
|
||||
|
||||
const uint8_t kIv[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const size_t kIvSize = sizeof(kIv);
|
||||
} // namespace
|
||||
|
||||
class LicenseWhiteboxDecryptGoldenData : public ::testing::Test {
|
||||
protected:
|
||||
void TearDown() override { WB_License_Delete(whitebox_); }
|
||||
|
||||
WB_License_Whitebox* whitebox_ = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(LicenseWhiteboxDecryptGoldenData, CryptoKeyWithCbcDataInCbcMode) {
|
||||
ASSERT_EQ(WB_License_Create(kLicenseWhiteboxInitData,
|
||||
kLicenseWhiteboxInitDataSize, &whitebox_),
|
||||
WB_RESULT_OK);
|
||||
|
||||
ASSERT_EQ(WB_License_ProcessLicenseResponse(
|
||||
whitebox_, kCoreMessage, kCoreMessageSize, kMessage,
|
||||
kMessageSize, kSignature, kSignatureSize, kSessionKey,
|
||||
kSessionKeySize, kLicenseRequest, kLicenseRequestSize),
|
||||
WB_RESULT_OK);
|
||||
|
||||
size_t plaintext_size = kCiphertextSize;
|
||||
std::vector<uint8_t> plaintext(plaintext_size);
|
||||
ASSERT_EQ(WB_License_Decrypt(whitebox_, WB_CIPHER_MODE_CBC, kKeyId,
|
||||
kKeyIdSize, kCiphertext, kCiphertextSize, kIv,
|
||||
kIvSize, plaintext.data(), &plaintext_size),
|
||||
WB_RESULT_OK);
|
||||
|
||||
plaintext.resize(plaintext_size);
|
||||
|
||||
const std::vector<uint8_t> golden_plaintext(kPlaintext,
|
||||
kPlaintext + kPlaintextSize);
|
||||
|
||||
ASSERT_EQ(golden_plaintext, plaintext);
|
||||
}
|
||||
|
||||
} // namespace widevine
|
||||
@@ -17,6 +17,12 @@ namespace widevine {
|
||||
class LicenseWhiteboxProcessLicenseResponseTest
|
||||
: public LicenseWhiteboxTestBase {
|
||||
protected:
|
||||
// No content keys. No signing keys.
|
||||
void UseLicenseWithNoKeys() {
|
||||
TestLicenseBuilder builder;
|
||||
builder.Build(*public_key_, &license_);
|
||||
}
|
||||
|
||||
void UseLicenseWithoutSigningKey() {
|
||||
TestLicenseBuilder builder;
|
||||
builder.AddStubbedContentKey();
|
||||
@@ -94,6 +100,20 @@ TEST_F(LicenseWhiteboxProcessLicenseResponseTest,
|
||||
WB_RESULT_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
TEST_F(LicenseWhiteboxProcessLicenseResponseTest,
|
||||
InvalidParameterWithNoKeys) {
|
||||
UseLicenseWithNoKeys();
|
||||
|
||||
ASSERT_EQ(
|
||||
WB_License_ProcessLicenseResponse(
|
||||
whitebox_, license_.core_message.data(), license_.core_message.size(),
|
||||
license_.message.data(), license_.message.size(),
|
||||
license_.signature.data(), license_.signature.size(),
|
||||
license_.session_key.data(), license_.session_key.size(),
|
||||
license_.request.data(), license_.request.size()),
|
||||
WB_RESULT_OK);
|
||||
}
|
||||
|
||||
class LicenseWhiteboxProcessLicenseResponseErrorTest
|
||||
: public LicenseWhiteboxProcessLicenseResponseTest {
|
||||
protected:
|
||||
@@ -150,6 +170,24 @@ TEST_F(LicenseWhiteboxProcessLicenseResponseErrorTest,
|
||||
WB_RESULT_INVALID_SIGNATURE);
|
||||
}
|
||||
|
||||
// If the session key is modified, unwrapping it will fail. Therefore, we will
|
||||
// know that the parameter is invalid (compared to a modified license request).
|
||||
// However, it was found that allowing the error to propagate was a better
|
||||
// implementation solution, so we allow "invalid signature" to be returned.
|
||||
TEST_F(LicenseWhiteboxProcessLicenseResponseErrorTest,
|
||||
InvalidSignatureForModifedSessionKey) {
|
||||
Modify(&license_.session_key);
|
||||
|
||||
ASSERT_EQ(
|
||||
WB_License_ProcessLicenseResponse(
|
||||
whitebox_, license_.core_message.data(), license_.core_message.size(),
|
||||
license_.message.data(), license_.message.size(),
|
||||
license_.signature.data(), license_.signature.size(),
|
||||
license_.session_key.data(), license_.session_key.size(),
|
||||
license_.request.data(), license_.request.size()),
|
||||
WB_RESULT_INVALID_SIGNATURE);
|
||||
}
|
||||
|
||||
TEST_F(LicenseWhiteboxProcessLicenseResponseErrorTest,
|
||||
InvalidParameterForNullWhitebox) {
|
||||
ASSERT_EQ(
|
||||
@@ -228,22 +266,6 @@ TEST_F(LicenseWhiteboxProcessLicenseResponseErrorTest,
|
||||
WB_RESULT_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
// If the session key is modified, unwrapping it will fail. Therefore, we will
|
||||
// know that the parameter is invalid (compared to a modified license request).
|
||||
TEST_F(LicenseWhiteboxProcessLicenseResponseErrorTest,
|
||||
InvalidParameterForModifedSessionKey) {
|
||||
Modify(&license_.session_key);
|
||||
|
||||
ASSERT_EQ(
|
||||
WB_License_ProcessLicenseResponse(
|
||||
whitebox_, license_.core_message.data(), license_.core_message.size(),
|
||||
license_.message.data(), license_.message.size(),
|
||||
license_.signature.data(), license_.signature.size(),
|
||||
license_.session_key.data(), license_.session_key.size(),
|
||||
license_.request.data(), license_.request.size()),
|
||||
WB_RESULT_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
TEST_F(LicenseWhiteboxProcessLicenseResponseErrorTest,
|
||||
InvalidParameterForNullLicenseRequest) {
|
||||
ASSERT_EQ(WB_License_ProcessLicenseResponse(
|
||||
@@ -25,6 +25,6 @@ cc_library(
|
||||
"measurements.h",
|
||||
],
|
||||
deps = [
|
||||
"//chromium_deps/base:glog",
|
||||
"//chromium_deps/base:glog",
|
||||
],
|
||||
)
|
||||
@@ -5,7 +5,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"check.h",
|
||||
"check_op.h",
|
||||
"logging.h"
|
||||
"logging.h",
|
||||
],
|
||||
strip_include_prefix = "//chromium_deps",
|
||||
visibility = ["//visibility:public"],
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user