ndn-cxx: NDN C++ Library 0.9.0-33-g832ea91d
Loading...
Searching...
No Matches
public-key.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2024 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#ifndef NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
23#define NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
24
28
30
34class PublicKey : noncopyable
35{
36public:
37 class Error : public std::runtime_error
38 {
39 public:
40 using std::runtime_error::runtime_error;
41 };
42
43public:
49 PublicKey();
50
52
57 getKeyType() const;
58
62 size_t
63 getKeySize() const;
64
68 void
69 loadPkcs8(span<const uint8_t> buf);
70
74 void
75 loadPkcs8(std::istream& is);
76
80 void
81 loadPkcs8Base64(span<const uint8_t> buf);
82
86 void
87 loadPkcs8Base64(std::istream& is);
88
92 void
93 savePkcs8(std::ostream& os) const;
94
98 void
99 savePkcs8Base64(std::ostream& os) const;
100
107 encrypt(span<const uint8_t> plainText) const;
108
109private:
110 friend class VerifierFilter;
111
117 void*
118 getEvpPkey() const;
119
121 toPkcs8() const;
122
124 rsaEncrypt(span<const uint8_t> plainText) const;
125
126private:
127 class Impl;
128 const unique_ptr<Impl> m_impl;
129};
130
131} // namespace ndn::security::transform
132
133#endif // NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
Abstraction of a public key in crypto transformations.
void loadPkcs8Base64(span< const uint8_t > buf)
Load the public key in base64-encoded PKCS#8 format from a buffer buf.
void loadPkcs8(span< const uint8_t > buf)
Load the public key in PKCS#8 format from a buffer buf.
KeyType getKeyType() const
Return the type of the public key.
void savePkcs8Base64(std::ostream &os) const
Save the public key in base64-encoded PKCS#8 format into a stream os.
ConstBufferPtr encrypt(span< const uint8_t > plainText) const
void savePkcs8(std::ostream &os) const
Save the public key in PKCS#8 format into a stream os.
size_t getKeySize() const
Return the size of the public key in bits.
PublicKey()
Create an empty public key instance.
The module to verify signatures.
Common includes and macros used throughout the library.
KeyType
The type of a cryptographic key.
std::shared_ptr< const Buffer > ConstBufferPtr
Definition buffer.hpp:140