Abstraction of private key in crypto transformation. More...
#include <ndn-cxx/security/transform/private-key.hpp>
Classes | |
class | Error |
Public Types | |
using | PasswordCallback = std::function< int(char *buf, size_t bufSize, bool shouldConfirm)> |
Callback for application to handle password input. More... | |
Public Member Functions | |
PrivateKey () | |
Creates an empty private key instance. More... | |
~PrivateKey () | |
ConstBufferPtr | decrypt (const uint8_t *cipherText, size_t cipherLen) const |
ConstBufferPtr | decrypt (span< const uint8_t > cipherText) const |
ConstBufferPtr | derivePublicKey () const |
ConstBufferPtr | getKeyDigest (DigestAlgorithm algo) const |
Returns a digest of the private key. More... | |
size_t | getKeySize () const |
Returns the size of the private key in bits. More... | |
KeyType | getKeyType () const |
Returns the type of the private key. More... | |
void | loadPkcs1 (const uint8_t *buf, size_t size) |
Load the private key in PKCS#1 format from a buffer buf . More... | |
void | loadPkcs1 (span< const uint8_t > buf) |
Load the private key in PKCS#1 format from a buffer buf . More... | |
void | loadPkcs1 (std::istream &is) |
Load the private key in PKCS#1 format from a stream is . More... | |
void | loadPkcs1Base64 (const uint8_t *buf, size_t size) |
Load the private key in base64-encoded PKCS#1 format from a buffer buf . More... | |
void | loadPkcs1Base64 (span< const uint8_t > buf) |
Load the private key in base64-encoded PKCS#1 format from a buffer buf . More... | |
void | loadPkcs1Base64 (std::istream &is) |
Load the private key in base64-encoded PKCS#1 format from a stream is . More... | |
void | loadPkcs8 (const uint8_t *buf, size_t size, PasswordCallback pwCallback=nullptr) |
Load the private key in encrypted PKCS#8 format from a buffer buf with passphrase obtained from pwCallback . More... | |
void | loadPkcs8 (span< const uint8_t > buf, const char *pw, size_t pwLen) |
Load the private key in encrypted PKCS#8 format from a buffer buf with passphrase pw . More... | |
void | loadPkcs8 (span< const uint8_t > buf, PasswordCallback pwCallback=nullptr) |
Load the private key in encrypted PKCS#8 format from a buffer buf with passphrase obtained from pwCallback . More... | |
void | loadPkcs8 (std::istream &is, const char *pw, size_t pwLen) |
Load the private key in encrypted PKCS#8 format from a stream is with passphrase pw . More... | |
void | loadPkcs8 (std::istream &is, PasswordCallback pwCallback=nullptr) |
Load the private key in encrypted PKCS#8 format from a stream is with passphrase obtained from pwCallback . More... | |
void | loadPkcs8Base64 (const uint8_t *buf, size_t size, PasswordCallback pwCallback=nullptr) |
Load the private key in encrypted PKCS#8 format from a buffer buf with passphrase obtained from pwCallback . More... | |
void | loadPkcs8Base64 (span< const uint8_t > buf, const char *pw, size_t pwLen) |
Load the private key in base64-encoded encrypted PKCS#8 format from a buffer buf with passphrase pw . More... | |
void | loadPkcs8Base64 (span< const uint8_t > buf, PasswordCallback pwCallback=nullptr) |
Load the private key in encrypted PKCS#8 format from a buffer buf with passphrase obtained from pwCallback . More... | |
void | loadPkcs8Base64 (std::istream &is, const char *pw, size_t pwLen) |
Load the private key in base64-encoded encrypted PKCS#8 format from a stream is with passphrase pw . More... | |
void | loadPkcs8Base64 (std::istream &is, PasswordCallback pwCallback=nullptr) |
Load the private key in base64-encoded encrypted PKCS#8 format from a stream is with passphrase obtained from pwCallback . More... | |
void | loadRaw (KeyType type, const uint8_t *buf, size_t size) |
Load a raw private key from a buffer buf . More... | |
void | loadRaw (KeyType type, span< const uint8_t > buf) |
Load a raw private key from a buffer buf . More... | |
void | savePkcs1 (std::ostream &os) const |
Save the private key in PKCS#1 format into a stream os . More... | |
void | savePkcs1Base64 (std::ostream &os) const |
Save the private key in base64-encoded PKCS#1 format into a stream os . More... | |
void | savePkcs8 (std::ostream &os, const char *pw, size_t pwLen) const |
Save the private key in encrypted PKCS#8 format into a stream os . More... | |
void | savePkcs8 (std::ostream &os, PasswordCallback pwCallback=nullptr) const |
Save the private key in encrypted PKCS#8 format into a stream os with passphrase obtained from pwCallback . More... | |
void | savePkcs8Base64 (std::ostream &os, const char *pw, size_t pwLen) const |
Save the private key in base64-encoded encrypted PKCS#8 format into a stream os . More... | |
void | savePkcs8Base64 (std::ostream &os, PasswordCallback pwCallback=nullptr) const |
Save the private key in base64-encoded encrypted PKCS#8 format into a stream os with passphrase obtained from pwCallback . More... | |
Friends | |
unique_ptr< PrivateKey > | generatePrivateKey (const KeyParams &) |
Generate a private key according to keyParams . More... | |
class | SignerFilter |
class | VerifierFilter |
Abstraction of private key in crypto transformation.
Definition at line 38 of file private-key.hpp.
using ndn::security::transform::PrivateKey::PasswordCallback = std::function<int(char* buf, size_t bufSize, bool shouldConfirm)> |
Callback for application to handle password input.
The password must be written to buf
and must not be longer than bufSize
chars. It is recommended to ask the user to verify the password if shouldConfirm
is true, e.g., by prompting for it twice. The callback must return the number of characters in the password or 0 if an error occurred.
Definition at line 55 of file private-key.hpp.
ndn::security::transform::PrivateKey::PrivateKey | ( | ) |
Creates an empty private key instance.
One must call loadXXXX(...)
to load a private key.
Definition at line 82 of file private-key.cpp.
|
default |
|
inline |
cipherText
decrypted using this private key. Only RSA encryption is supported for now.
Definition at line 312 of file private-key.hpp.
ConstBufferPtr ndn::security::transform::PrivateKey::decrypt | ( | span< const uint8_t > | cipherText | ) | const |
cipherText
decrypted using this private key.Only RSA encryption is supported for now.
Definition at line 360 of file private-key.cpp.
ConstBufferPtr ndn::security::transform::PrivateKey::derivePublicKey | ( | ) | const |
Definition at line 344 of file private-key.cpp.
ConstBufferPtr ndn::security::transform::PrivateKey::getKeyDigest | ( | DigestAlgorithm | algo | ) | const |
Returns a digest of the private key.
Definition at line 129 of file private-key.cpp.
size_t ndn::security::transform::PrivateKey::getKeySize | ( | ) | const |
Returns the size of the private key in bits.
Definition at line 108 of file private-key.cpp.
KeyType ndn::security::transform::PrivateKey::getKeyType | ( | ) | const |
Returns the type of the private key.
Definition at line 90 of file private-key.cpp.
|
inline |
Load the private key in PKCS#1 format from a buffer buf
.
Definition at line 120 of file private-key.hpp.
void ndn::security::transform::PrivateKey::loadPkcs1 | ( | span< const uint8_t > | buf | ) |
Load the private key in PKCS#1 format from a buffer buf
.
Definition at line 183 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs1 | ( | std::istream & | is | ) |
Load the private key in PKCS#1 format from a stream is
.
Definition at line 194 of file private-key.cpp.
|
inline |
Load the private key in base64-encoded PKCS#1 format from a buffer buf
.
Definition at line 143 of file private-key.hpp.
void ndn::security::transform::PrivateKey::loadPkcs1Base64 | ( | span< const uint8_t > | buf | ) |
Load the private key in base64-encoded PKCS#1 format from a buffer buf
.
Definition at line 202 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs1Base64 | ( | std::istream & | is | ) |
Load the private key in base64-encoded PKCS#1 format from a stream is
.
Definition at line 210 of file private-key.cpp.
|
inline |
Load the private key in encrypted PKCS#8 format from a buffer buf
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 179 of file private-key.hpp.
void ndn::security::transform::PrivateKey::loadPkcs8 | ( | span< const uint8_t > | buf, |
const char * | pw, | ||
size_t | pwLen | ||
) |
Load the private key in encrypted PKCS#8 format from a buffer buf
with passphrase pw
.
Definition at line 218 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs8 | ( | span< const uint8_t > | buf, |
PasswordCallback | pwCallback = nullptr |
||
) |
Load the private key in encrypted PKCS#8 format from a buffer buf
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 241 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs8 | ( | std::istream & | is, |
const char * | pw, | ||
size_t | pwLen | ||
) |
Load the private key in encrypted PKCS#8 format from a stream is
with passphrase pw
.
Definition at line 260 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs8 | ( | std::istream & | is, |
PasswordCallback | pwCallback = nullptr |
||
) |
Load the private key in encrypted PKCS#8 format from a stream is
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 268 of file private-key.cpp.
|
inline |
Load the private key in encrypted PKCS#8 format from a buffer buf
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 226 of file private-key.hpp.
void ndn::security::transform::PrivateKey::loadPkcs8Base64 | ( | span< const uint8_t > | buf, |
const char * | pw, | ||
size_t | pwLen | ||
) |
Load the private key in base64-encoded encrypted PKCS#8 format from a buffer buf
with passphrase pw
.
Definition at line 276 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs8Base64 | ( | span< const uint8_t > | buf, |
PasswordCallback | pwCallback = nullptr |
||
) |
Load the private key in encrypted PKCS#8 format from a buffer buf
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 284 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs8Base64 | ( | std::istream & | is, |
const char * | pw, | ||
size_t | pwLen | ||
) |
Load the private key in base64-encoded encrypted PKCS#8 format from a stream is
with passphrase pw
.
Definition at line 292 of file private-key.cpp.
void ndn::security::transform::PrivateKey::loadPkcs8Base64 | ( | std::istream & | is, |
PasswordCallback | pwCallback = nullptr |
||
) |
Load the private key in base64-encoded encrypted PKCS#8 format from a stream is
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 300 of file private-key.cpp.
|
inline |
Load a raw private key from a buffer buf
.
Definition at line 103 of file private-key.hpp.
void ndn::security::transform::PrivateKey::loadRaw | ( | KeyType | type, |
span< const uint8_t > | buf | ||
) |
Load a raw private key from a buffer buf
.
Definition at line 155 of file private-key.cpp.
void ndn::security::transform::PrivateKey::savePkcs1 | ( | std::ostream & | os | ) | const |
Save the private key in PKCS#1 format into a stream os
.
Definition at line 308 of file private-key.cpp.
void ndn::security::transform::PrivateKey::savePkcs1Base64 | ( | std::ostream & | os | ) | const |
Save the private key in base64-encoded PKCS#1 format into a stream os
.
Definition at line 314 of file private-key.cpp.
void ndn::security::transform::PrivateKey::savePkcs8 | ( | std::ostream & | os, |
const char * | pw, | ||
size_t | pwLen | ||
) | const |
Save the private key in encrypted PKCS#8 format into a stream os
.
Definition at line 320 of file private-key.cpp.
void ndn::security::transform::PrivateKey::savePkcs8 | ( | std::ostream & | os, |
PasswordCallback | pwCallback = nullptr |
||
) | const |
Save the private key in encrypted PKCS#8 format into a stream os
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 326 of file private-key.cpp.
void ndn::security::transform::PrivateKey::savePkcs8Base64 | ( | std::ostream & | os, |
const char * | pw, | ||
size_t | pwLen | ||
) | const |
Save the private key in base64-encoded encrypted PKCS#8 format into a stream os
.
Definition at line 332 of file private-key.cpp.
void ndn::security::transform::PrivateKey::savePkcs8Base64 | ( | std::ostream & | os, |
PasswordCallback | pwCallback = nullptr |
||
) | const |
Save the private key in base64-encoded encrypted PKCS#8 format into a stream os
with passphrase obtained from pwCallback
.
The default password callback is provided by OpenSSL
Definition at line 338 of file private-key.cpp.
|
friend |
Generate a private key according to keyParams
.
std::invalid_argument | the specified key type is not supported |
PrivateKey::Error | key generation failed |
Definition at line 539 of file private-key.cpp.
|
friend |
Definition at line 318 of file private-key.hpp.
|
friend |
Definition at line 319 of file private-key.hpp.