ifm3d
crypto.h
1 // -*- c++ -*-
2 /*
3  * Copyright 2025-present ifm electronic, gmbh
4  * SPDX-License-Identifier: Apache-2
5  */
6 
7 #ifndef IFM3D_CRYPTO_CRYPTO_H
8 #define IFM3D_CRYPTO_CRYPTO_H
9 
10 #include <cstdint>
11 #include <optional>
12 #include <string>
13 #include <vector>
14 
15 namespace ifm3d
16 {
17  class SealedBox
18  {
19  public:
20  SealedBox() = default;
21  SealedBox(const SealedBox&) = default;
22  SealedBox(SealedBox&&) = delete;
23  SealedBox& operator=(const SealedBox&) = default;
24  SealedBox& operator=(SealedBox&&) = delete;
25  SealedBox(const std::vector<uint8_t>& public_key,
26  const std::optional<const std::vector<uint8_t>>& private_key =
27  std::nullopt);
28 
29  ~SealedBox();
30 
31  std::vector<uint8_t> Encrypt(const std::string& plaintext);
32  std::string Decrypt(const std::vector<uint8_t>& ciphertext);
33 
34  private:
35  std::vector<uint8_t> _public_key;
36  std::optional<std::vector<uint8_t>> _private_key;
37  };
38 
39  std::vector<uint8_t> random_nonce();
40 
41 } // end: namespace ifm3d
42 
43 #endif // IFM3D_CRYPTO_CRYPTO_H
ifm3d::SealedBox
Definition: crypto.h:17