Abstraction of private key in crypto transformation. More...
#include <private-key.hpp>
Classes | |
class | Error |
class | Impl |
Public Types | |
typedef function< int(char *buf, size_t bufSize, bool shouldConfirm)> | PasswordCallback |
Callback for application to handle password input. More... | |
Public Member Functions | |
PrivateKey () | |
Create a private key instance. More... | |
~PrivateKey () | |
void | loadPkcs1 (const uint8_t *buf, size_t size) |
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 (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, 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 (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 (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, 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 (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 (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 | 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... | |
ConstBufferPtr | derivePublicKey () const |
ConstBufferPtr | decrypt (const uint8_t *cipherText, size_t cipherLen) const |
Friends | |
class | SignerFilter |
Abstraction of private key in crypto transformation.
Definition at line 38 of file private-key.hpp.
typedef function<int(char* buf, size_t bufSize, bool shouldConfirm)> ndn::security::transform::PrivateKey::PasswordCallback |
Callback for application to handle password input.
Password should be stored in buf
and should not be longer than size
. It is recommended to ask the user to verify the passphrase if shouldConfirm
is true, e.g., by prompting for the password twice.
Definition at line 60 of file private-key.hpp.
ndn::security::transform::PrivateKey::PrivateKey | ( | ) |
Create a private key instance.
One must call loadXXXX(...) to load private key.
Definition at line 61 of file private-key.cpp.
References ~PrivateKey().
|
default |
Referenced by PrivateKey().
void ndn::security::transform::PrivateKey::loadPkcs1 | ( | const uint8_t * | buf, |
size_t | size | ||
) |
Load the private key in PKCS#1 format from a buffer buf
.
Definition at line 69 of file private-key.cpp.
References ENSURE_PRIVATE_KEY_LOADED, and ndn::security::detail::Bio::get().
Referenced by loadPkcs1(), and loadPkcs1Base64().
void ndn::security::transform::PrivateKey::loadPkcs1 | ( | std::istream & | is | ) |
Load the private key in PKCS#1 format from a stream is
.
Definition at line 80 of file private-key.cpp.
References ndn::OBufferStream::buf(), loadPkcs1(), and ndn::security::transform::streamSink().
void ndn::security::transform::PrivateKey::loadPkcs1Base64 | ( | const uint8_t * | buf, |
size_t | size | ||
) |
Load the private key in base64-encoded PKCS#1 format from a buffer buf
.
Definition at line 88 of file private-key.cpp.
References ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), loadPkcs1(), and ndn::security::transform::streamSink().
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 96 of file private-key.cpp.
References ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), loadPkcs1(), and ndn::security::transform::streamSink().
void ndn::security::transform::PrivateKey::loadPkcs8 | ( | const uint8_t * | buf, |
size_t | size, | ||
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 104 of file private-key.cpp.
References ENSURE_PRIVATE_KEY_LOADED, and ndn::security::detail::Bio::get().
Referenced by loadPkcs8(), and loadPkcs8Base64().
void ndn::security::transform::PrivateKey::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
.
The default password callback is provided by OpenSSL
Definition at line 124 of file private-key.cpp.
References ENSURE_PRIVATE_KEY_LOADED, ndn::security::detail::Bio::get(), and ndn::security::transform::passwordCallback().
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 139 of file private-key.cpp.
References ndn::OBufferStream::buf(), loadPkcs8(), and ndn::security::transform::streamSink().
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 147 of file private-key.cpp.
References ndn::OBufferStream::buf(), loadPkcs8(), and ndn::security::transform::streamSink().
void ndn::security::transform::PrivateKey::loadPkcs8Base64 | ( | const uint8_t * | buf, |
size_t | size, | ||
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 155 of file private-key.cpp.
References ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), loadPkcs8(), and ndn::security::transform::streamSink().
void ndn::security::transform::PrivateKey::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
.
The default password callback is provided by OpenSSL
Definition at line 163 of file private-key.cpp.
References ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), loadPkcs8(), and ndn::security::transform::streamSink().
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 171 of file private-key.cpp.
References ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), loadPkcs8(), and ndn::security::transform::streamSink().
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 179 of file private-key.cpp.
References ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), loadPkcs8(), and ndn::security::transform::streamSink().
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 187 of file private-key.cpp.
References ndn::security::transform::streamSink().
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 193 of file private-key.cpp.
References ndn::security::transform::base64Encode(), and ndn::security::transform::streamSink().
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 199 of file private-key.cpp.
References ndn::security::transform::streamSink().
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 205 of file private-key.cpp.
References ndn::security::transform::streamSink().
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 211 of file private-key.cpp.
References ndn::security::transform::base64Encode(), and ndn::security::transform::streamSink().
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 217 of file private-key.cpp.
References ndn::security::transform::base64Encode(), and ndn::security::transform::streamSink().
ConstBufferPtr ndn::security::transform::PrivateKey::derivePublicKey | ( | ) | const |
Definition at line 223 of file private-key.cpp.
References ENSURE_PRIVATE_KEY_LOADED.
ConstBufferPtr ndn::security::transform::PrivateKey::decrypt | ( | const uint8_t * | cipherText, |
size_t | cipherLen | ||
) | const |
cipherText
decrypted using the private key.Only RSA encryption is supported for now.
Definition at line 240 of file private-key.cpp.
References ENSURE_PRIVATE_KEY_LOADED, ndn::security::detail::EvpPkeyCtx::get(), ndn::security::detail::Bio::get(), and ndn::security::transform::passwordCallback().
|
friend |
Definition at line 51 of file private-key.hpp.