diff options
author | Bartosz Przydatek <przydatek@google.com> | 2018-02-08 16:34:23 +0100 |
---|---|---|
committer | Thai Duong <thaidn@google.com> | 2018-02-21 16:50:30 -0800 |
commit | ae4e0353ff822b30f931c82cf8747d3e0baa23fb (patch) | |
tree | 781ee36789e3f9b23fc4b8949d0a4be2e4975429 /cc/binary_keyset_writer.h | |
parent | 2cb6090a11e491dd23b6d62d33324ce724a59202 (diff) | |
download | tink-ae4e0353ff822b30f931c82cf8747d3e0baa23fb.tar.gz |
Adding C++ KeysetWriter.
Bug: 65688580
Change-Id: Ib80ec35b6c00bb35e7fb482b6dc7b753768b32fa
ORIGINAL_AUTHOR=Bartosz Przydatek <przydatek@google.com>
GitOrigin-RevId: 4f7b6d8915ff8f9f276af4421713efb6c190710d
Diffstat (limited to 'cc/binary_keyset_writer.h')
-rw-r--r-- | cc/binary_keyset_writer.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cc/binary_keyset_writer.h b/cc/binary_keyset_writer.h new file mode 100644 index 000000000..3bc810f5e --- /dev/null +++ b/cc/binary_keyset_writer.h @@ -0,0 +1,55 @@ +// Copyright 2018 Google Inc. +// +// 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_BINARY_KEYSET_WRITER_H_ +#define TINK_BINARY_KEYSET_WRITER_H_ + +#include <ostream> + +#include "absl/strings/string_view.h" +#include "cc/keyset_writer.h" +#include "cc/util/status.h" +#include "cc/util/statusor.h" +#include "proto/tink.pb.h" + +namespace crypto { +namespace tink { + +// A KeysetWriter that can write to some destination cleartext +// or encrypted keysets in proto binary wire format, cf. +// https://developers.google.com/protocol-buffers/docs/encoding +class BinaryKeysetWriter : public KeysetWriter { + public: + static crypto::tink::util::StatusOr<std::unique_ptr<BinaryKeysetWriter>> New( + std::unique_ptr<std::ostream> destination_stream); + + crypto::tink::util::Status + Write(const google::crypto::tink::Keyset& keyset) override;; + + crypto::tink::util::Status + Write(const google::crypto::tink::EncryptedKeyset& encrypted_keyset) override; + + private: + BinaryKeysetWriter(std::unique_ptr<std::ostream> destination_stream) + : destination_stream_(std::move(destination_stream)) {} + + std::unique_ptr<std::ostream> destination_stream_; +}; + +} // namespace tink +} // namespace crypto + +#endif // TINK_BINARY_KEYSET_WRITER_H_ |