diff options
author | tholenst <tholenst@google.com> | 2022-12-02 00:13:41 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-12-02 00:15:24 -0800 |
commit | 91e705a1f389002813ffbab54165b90a81eaa945 (patch) | |
tree | 7602c9146bdeb1d78b7e94c086e6c3352d925ca1 /cc/proto_keyset_format.h | |
parent | dd907f08890a8003e0249990151882faf6b9282c (diff) | |
download | tink-91e705a1f389002813ffbab54165b90a81eaa945.tar.gz |
Add methods SerializeKeysetToProtoKeysetFormat, ParseKeysetFromProtoKeysetFormat, ParseKeysetWithoutSecretFromProtoKeysetFormat, SerializeKeysetWithoutSecretToProtoKeysetFormat.
PiperOrigin-RevId: 492397520
Diffstat (limited to 'cc/proto_keyset_format.h')
-rw-r--r-- | cc/proto_keyset_format.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/cc/proto_keyset_format.h b/cc/proto_keyset_format.h new file mode 100644 index 000000000..cab89ebf9 --- /dev/null +++ b/cc/proto_keyset_format.h @@ -0,0 +1,56 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef TINK_PROTO_KEYSET_FORMAT_H_ +#define TINK_PROTO_KEYSET_FORMAT_H_ + +#include <string> + +#include "absl/strings/string_view.h" +#include "tink/keyset_handle.h" +#include "tink/secret_key_access_token.h" +#include "tink/util/secret_data.h" + +namespace crypto { +namespace tink { + +// Serializes a keyset into a binary string in "ProtoKeysetFormat". +// This function can serialize both keyset with or without secret key material. +crypto::tink::util::StatusOr<util::SecretData> +SerializeKeysetToProtoKeysetFormat(const KeysetHandle& keyset_handle, + SecretKeyAccessToken token); + +// Parses a keyset from a binary string in "ProtoKeysetFormat". +// This function can parse both keyset with or without secret key material. +crypto::tink::util::StatusOr<KeysetHandle> ParseKeysetFromProtoKeysetFormat( + absl::string_view serialized_keyset, SecretKeyAccessToken token); + +// Serializes a keyset into a binary string in "ProtoKeysetFormat". +// This function will fail if the keyset contains secret key material. +crypto::tink::util::StatusOr<std::string> +SerializeKeysetWithoutSecretToProtoKeysetFormat( + const KeysetHandle& keyset_handle); + +// Parses a keyset from a binary string in "ProtoKeysetFormat". +// This function will fail if the keyset contains secret key material. +crypto::tink::util::StatusOr<KeysetHandle> +ParseKeysetWithoutSecretFromProtoKeysetFormat( + absl::string_view serialized_keyset); + + +} // namespace tink +} // namespace crypto +#endif // TINK_PROTO_KEYSET_FORMAT_H_ |