Skip to content

Commit

Permalink
Support registering HKDF-PRF proto serialization in immutable registr…
Browse files Browse the repository at this point in the history
…ies.

PiperOrigin-RevId: 696639810
Change-Id: I35ae25622a959d48342f4e1c7b11eae2c34b9d72
  • Loading branch information
willinois authored and copybara-github committed Nov 14, 2024
1 parent 3ecf4ba commit 7c8a16e
Show file tree
Hide file tree
Showing 8 changed files with 893 additions and 70 deletions.
23 changes: 1 addition & 22 deletions tink/prf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -371,33 +371,12 @@ cc_library(

cc_library(
name = "hkdf_prf_proto_serialization",
srcs = ["hkdf_prf_proto_serialization.cc"],
hdrs = ["hkdf_prf_proto_serialization.h"],
include_prefix = "tink/prf",
deps = [
":hkdf_prf_key",
":hkdf_prf_parameters",
"//proto:common_cc_proto",
"//proto:hkdf_prf_cc_proto",
"//proto:tink_cc_proto",
"//tink:partial_key_access",
"//tink:restricted_data",
"//tink:secret_key_access_token",
"//tink/internal:call_with_core_dump_protection",
"//tink/internal:key_parser",
"//tink/internal:key_serializer",
"//tink/internal:mutable_serialization_registry",
"//tink/internal:parameters_parser",
"//tink/internal:parameters_serializer",
"//tink/internal:proto_key_serialization",
"//tink/internal:proto_parameters_serialization",
"//tink/util:secret_data",
"//tink/util:secret_proto",
"//tink/prf/internal:hkdf_prf_proto_serialization_impl",
"//tink/util:status",
"//tink/util:statusor",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:optional",
],
)

Expand Down
23 changes: 1 addition & 22 deletions tink/prf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,32 +347,11 @@ tink_cc_library(
tink_cc_library(
NAME hkdf_prf_proto_serialization
SRCS
hkdf_prf_proto_serialization.cc
hkdf_prf_proto_serialization.h
DEPS
tink::prf::hkdf_prf_key
tink::prf::hkdf_prf_parameters
absl::status
absl::string_view
absl::optional
tink::core::partial_key_access
tink::core::restricted_data
tink::core::secret_key_access_token
tink::internal::call_with_core_dump_protection
tink::internal::key_parser
tink::internal::key_serializer
tink::internal::mutable_serialization_registry
tink::internal::parameters_parser
tink::internal::parameters_serializer
tink::internal::proto_key_serialization
tink::internal::proto_parameters_serialization
tink::util::secret_data
tink::util::secret_proto
tink::prf::internal::hkdf_prf_proto_serialization_impl
tink::util::status
tink::util::statusor
tink::proto::common_cc_proto
tink::proto::hkdf_prf_cc_proto
tink::proto::tink_cc_proto
)

# tests
Expand Down
10 changes: 8 additions & 2 deletions tink/prf/hkdf_prf_proto_serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
#ifndef TINK_PRF_HKDF_PRF_PROTO_SERIALIZATION_H_
#define TINK_PRF_HKDF_PRF_PROTO_SERIALIZATION_H_

#include "tink/internal/mutable_serialization_registry.h"
#include "tink/prf/internal/hkdf_prf_proto_serialization_impl.h"
#include "tink/util/status.h"

namespace crypto {
namespace tink {

// Registers proto parsers and serializers for HKDF-PRF parameters and keys.
crypto::tink::util::Status RegisterHkdfPrfProtoSerialization();
// Registers proto parsers and serializers for HKDF-PRF parameters and keys into
// global serialization registry.
inline crypto::tink::util::Status RegisterHkdfPrfProtoSerialization() {
return internal::RegisterHkdfPrfProtoSerializationWithMutableRegistry(
internal::MutableSerializationRegistry::GlobalInstance());
}

} // namespace tink
} // namespace crypto
Expand Down
64 changes: 64 additions & 0 deletions tink/prf/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,39 @@ cc_library(
],
)

cc_library(
name = "hkdf_prf_proto_serialization_impl",
srcs = ["hkdf_prf_proto_serialization_impl.cc"],
hdrs = ["hkdf_prf_proto_serialization_impl.h"],
include_prefix = "tink/prf/internal",
deps = [
"//proto:common_cc_proto",
"//proto:hkdf_prf_cc_proto",
"//proto:tink_cc_proto",
"//tink:partial_key_access",
"//tink:restricted_data",
"//tink:secret_key_access_token",
"//tink/internal:call_with_core_dump_protection",
"//tink/internal:key_parser",
"//tink/internal:key_serializer",
"//tink/internal:mutable_serialization_registry",
"//tink/internal:parameters_parser",
"//tink/internal:parameters_serializer",
"//tink/internal:proto_key_serialization",
"//tink/internal:proto_parameters_serialization",
"//tink/internal:serialization_registry",
"//tink/prf:hkdf_prf_key",
"//tink/prf:hkdf_prf_parameters",
"//tink/util:secret_data",
"//tink/util:secret_proto",
"//tink/util:status",
"//tink/util:statusor",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:optional",
],
)

# tests

cc_test(
Expand Down Expand Up @@ -122,3 +155,34 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "hkdf_prf_proto_serialization_impl_test",
srcs = ["hkdf_prf_proto_serialization_impl_test.cc"],
deps = [
":hkdf_prf_proto_serialization_impl",
"//proto:common_cc_proto",
"//proto:hkdf_prf_cc_proto",
"//proto:tink_cc_proto",
"//tink:insecure_secret_key_access_testonly",
"//tink:key",
"//tink:parameters",
"//tink:partial_key_access",
"//tink:restricted_data",
"//tink/internal:mutable_serialization_registry",
"//tink/internal:proto_key_serialization",
"//tink/internal:proto_parameters_serialization",
"//tink/internal:serialization",
"//tink/internal:serialization_registry",
"//tink/prf:hkdf_prf_key",
"//tink/prf:hkdf_prf_parameters",
"//tink/subtle:random",
"//tink/util:statusor",
"//tink/util:test_matchers",
"//tink/util:test_util",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest_main",
],
)
63 changes: 63 additions & 0 deletions tink/prf/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,38 @@ tink_cc_library(
tink::proto::tink_cc_proto
)

tink_cc_library(
NAME hkdf_prf_proto_serialization_impl
SRCS
hkdf_prf_proto_serialization_impl.cc
hkdf_prf_proto_serialization_impl.h
DEPS
absl::status
absl::string_view
absl::optional
tink::core::partial_key_access
tink::core::restricted_data
tink::core::secret_key_access_token
tink::internal::call_with_core_dump_protection
tink::internal::key_parser
tink::internal::key_serializer
tink::internal::mutable_serialization_registry
tink::internal::parameters_parser
tink::internal::parameters_serializer
tink::internal::proto_key_serialization
tink::internal::proto_parameters_serialization
tink::internal::serialization_registry
tink::prf::hkdf_prf_key
tink::prf::hkdf_prf_parameters
tink::util::secret_data
tink::util::secret_proto
tink::util::status
tink::util::statusor
tink::proto::common_cc_proto
tink::proto::hkdf_prf_cc_proto
tink::proto::tink_cc_proto
)

# tests

tink_cc_test(
Expand Down Expand Up @@ -117,3 +149,34 @@ tink_cc_test(
tink::proto::aes_cmac_prf_cc_proto
tink::proto::tink_cc_proto
)

tink_cc_test(
NAME hkdf_prf_proto_serialization_impl_test
SRCS
hkdf_prf_proto_serialization_impl_test.cc
DEPS
tink::prf::internal::hkdf_prf_proto_serialization_impl
gmock
absl::status
absl::string_view
absl::optional
tink::core::insecure_secret_key_access_testonly
tink::core::key
tink::core::parameters
tink::core::partial_key_access
tink::core::restricted_data
tink::internal::mutable_serialization_registry
tink::internal::proto_key_serialization
tink::internal::proto_parameters_serialization
tink::internal::serialization
tink::internal::serialization_registry
tink::prf::hkdf_prf_key
tink::prf::hkdf_prf_parameters
tink::subtle::random
tink::util::statusor
tink::util::test_matchers
tink::util::test_util
tink::proto::common_cc_proto
tink::proto::hkdf_prf_cc_proto
tink::proto::tink_cc_proto
)
Loading

0 comments on commit 7c8a16e

Please sign in to comment.