#include <OTAsymmetricKey.hpp>
|
virtual OTAsymmetricKey * | ClonePubKey () const |
|
virtual EXPORT | ~OTAsymmetricKey () |
|
virtual void | Release () |
|
void | Release_AsymmetricKey () |
|
void | ReleaseKey () |
|
bool | IsEmpty () const |
|
bool | IsPublic () const |
|
bool | IsPrivate () const |
|
void | SetAsPublic () |
|
void | SetAsPrivate () |
|
virtual bool | CalculateID (OTIdentifier &theOutput) const |
|
bool | LoadPrivateKey (const OTString &strFoldername, const OTString &strFilename, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr) |
|
bool | LoadPublicKey (const OTString &strFoldername, const OTString &strFilename) |
|
virtual bool | LoadPublicKeyFromPGPKey (const OTASCIIArmor &strKey)=0 |
|
virtual bool | LoadPrivateKeyFromCertString (const OTString &strCert, bool bEscaped=true, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr)=0 |
|
virtual bool | LoadPublicKeyFromCertString (const OTString &strCert, bool bEscaped=true, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr)=0 |
|
bool | LoadPublicKeyFromCertFile (const OTString &strFoldername, const OTString &strFilename, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr) |
|
virtual bool | SaveCertToString (OTString &strOutput, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr) const =0 |
|
virtual bool | SavePrivateKeyToString (OTString &strOutput, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr) const =0 |
|
virtual bool | ReEncryptPrivateKey (const OTPassword &theExportPassword, bool bImporting) const =0 |
|
EXPORT bool | GetPublicKey (OTASCIIArmor &strKey) const |
|
EXPORT bool | GetPublicKey (OTString &strKey, bool bEscaped=true) const |
|
EXPORT bool | SetPublicKey (const OTASCIIArmor &strKey) |
|
EXPORT bool | SetPublicKey (const OTString &strKey, bool bEscaped=false) |
|
bool | GetPrivateKey (OTString &strKey, bool bEscaped=true) const |
|
bool | GetPrivateKey (OTASCIIArmor &strKey) const |
|
bool | SetPrivateKey (const OTString &strKey, bool bEscaped=false) |
|
bool | SetPrivateKey (const OTASCIIArmor &strKey) |
|
Definition at line 203 of file OTAsymmetricKey.hpp.
opentxs::OTAsymmetricKey::OTAsymmetricKey |
( |
| ) |
|
|
protected |
Definition at line 994 of file OTAsymmetricKey.cpp.
OTASCIIArmor * m_p_ascKey
OTSignatureMetadata * m_pMetadata
opentxs::OTAsymmetricKey::~OTAsymmetricKey |
( |
| ) |
|
|
virtual |
bool opentxs::OTAsymmetricKey::CalculateID |
( |
OTIdentifier & |
theOutput | ) |
const |
|
virtual |
Definition at line 763 of file OTAsymmetricKey.cpp.
767 const char* szFunc =
"OTAsymmetricKey::CalculateID";
772 otErr << szFunc <<
": Error: !IsPublic() (This function should only be "
773 "called on a public key.)\n";
777 OTString strPublicKey;
780 if (!bGotPublicKey) {
781 otErr << szFunc <<
": Error getting public key.\n";
785 bool bSuccessCalculateDigest = theOutput.CalculateDigest(strPublicKey);
787 if (!bSuccessCalculateDigest) {
789 otErr << szFunc <<
": Error calculating digest of public key.\n";
EXPORT bool GetPublicKey(OTASCIIArmor &strKey) const
OTLOG_IMPORT OTLogStream otErr
Definition at line 173 of file OTAsymmetricKey.cpp.
181 OTASCIIArmor ascTransfer;
static EXPORT OTAsymmetricKey * KeyFactory()
OTSignatureMetadata * m_pMetadata
EXPORT bool GetPublicKey(OTASCIIArmor &strKey) const
Definition at line 224 of file OTAsymmetricKey.cpp.
227 const char* szFunc =
"OTAsymmetricKey::GetPasswordCallback";
229 #if defined(OT_TEST_PASSWORD)
230 otInfo << szFunc <<
": WARNING, OT_TEST_PASSWORD *is* defined. The "
231 "internal 'C'-based password callback was just "
232 "requested by OT (to pass to OpenSSL). So, returning "
233 "the default_pass_cb password callback, which will "
234 "automatically return "
235 "the 'test' password to OpenSSL, if/when it calls that "
236 "callback function.\n";
241 <<
": FYI, the internal 'C'-based password callback is now "
242 "being returning to OT, "
243 "which is passing it to OpenSSL "
244 "during a crypto operation. (If OpenSSL invokes it, then we "
245 "should see other logs after this from when it triggers "
246 "whatever password-collection dialog is provided at startup "
247 "by the (probably Java) OTAPI client.)\n";
EXPORT OT_OPENSSL_CALLBACK souped_up_pass_cb
EXPORT OT_OPENSSL_CALLBACK default_pass_cb
static OT_OPENSSL_CALLBACK * s_pwCallback
static void SetPasswordCallback(OT_OPENSSL_CALLBACK *pCallback)
OTLOG_IMPORT OTLogStream otInfo
static bool IsPasswordCallbackSet()
OTLOG_IMPORT OTLogStream otLog5
OTCaller * opentxs::OTAsymmetricKey::GetPasswordCaller |
( |
| ) |
|
|
static |
Definition at line 321 of file OTAsymmetricKey.cpp.
323 const char* szFunc =
"OTAsymmetricKey::GetPasswordCaller";
325 otLog4 << szFunc <<
": FYI, this was just called by souped_up_pass_cb "
326 "(which must have just been called by OpenSSL.) "
327 "Returning s_pCaller == "
328 << ((
nullptr ==
s_pCaller) ?
"nullptr" :
"VALID POINTER")
329 <<
" (Hopefully NOT nullptr, so the "
330 "custom password dialog can be triggered.)\n";
OTLOG_IMPORT OTLogStream otLog4
static OTCaller * s_pCaller
bool opentxs::OTAsymmetricKey::GetPrivateKey |
( |
OTString & |
strKey, |
|
|
bool |
bEscaped = true |
|
) |
| const |
Definition at line 908 of file OTAsymmetricKey.cpp.
910 OTASCIIArmor theArmor;
914 strKey.Concatenate(
"- -----BEGIN ENCRYPTED PRIVATE KEY-----\n"
916 "- -----END ENCRYPTED PRIVATE KEY-----\n",
920 strKey.Concatenate(
"-----BEGIN ENCRYPTED PRIVATE KEY-----\n"
922 "-----END ENCRYPTED PRIVATE KEY-----\n",
928 otErr <<
"OTAsymmetricKey::GetPrivateKey: Error: "
929 "GetPrivateKey(armored) returned false. (Returning false.)\n";
bool GetPrivateKey(OTString &strKey, bool bEscaped=true) const
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::GetPrivateKey |
( |
OTASCIIArmor & |
strKey | ) |
const |
bool opentxs::OTAsymmetricKey::GetPublicKey |
( |
OTASCIIArmor & |
strKey | ) |
const |
Definition at line 840 of file OTAsymmetricKey.cpp.
843 "OTAsymmetricKey::GetPublicKey: ASSERT: IsPublic()\n");
OTASCIIArmor * m_p_ascKey
#define OT_ASSERT_MSG(x, s)
bool opentxs::OTAsymmetricKey::GetPublicKey |
( |
OTString & |
strKey, |
|
|
bool |
bEscaped = true |
|
) |
| const |
Definition at line 800 of file OTAsymmetricKey.cpp.
802 OTASCIIArmor theArmor;
817 "- -----BEGIN PUBLIC KEY-----\n"
819 "- -----END PUBLIC KEY-----\n",
824 "-----BEGIN PUBLIC KEY-----\n"
826 "-----END PUBLIC KEY-----\n",
832 otErr <<
"OTAsymmetricKey::GetPublicKey: Error: GetPublicKey(armored) "
833 "returned false. (Returning false.)\n";
EXPORT bool GetPublicKey(OTASCIIArmor &strKey) const
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::IsEmpty |
( |
| ) |
const |
|
inline |
static bool opentxs::OTAsymmetricKey::IsPasswordCallbackSet |
( |
| ) |
|
|
inlinestatic |
bool opentxs::OTAsymmetricKey::IsPrivate |
( |
| ) |
const |
|
inline |
bool opentxs::OTAsymmetricKey::IsPublic |
( |
| ) |
const |
|
inline |
Definition at line 154 of file OTAsymmetricKey.cpp.
158 #if defined(OT_CRYPTO_USING_OPENSSL)
159 pKey =
new OTAsymmetricKey_OpenSSL;
160 #elif defined(OT_CRYPTO_USING_GPG)
162 otErr << __FUNCTION__ <<
": Open-Transactions doesn't support GPG (yet), "
163 "so it's impossible to instantiate a key.\n";
165 otErr << __FUNCTION__
166 <<
": Open-Transactions isn't built with any crypto engine, "
167 "so it's impossible to instantiate a key.\n";
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::LoadPrivateKey |
( |
const OTString & |
strFoldername, |
|
|
const OTString & |
strFilename, |
|
|
const OTString * |
pstrReason = nullptr , |
|
|
const OTPassword * |
pImportPassword = nullptr |
|
) |
| |
Definition at line 1174 of file OTAsymmetricKey.cpp.
1187 const char* szFoldername = strFoldername.Get();
1188 const char* szFilename = strFilename.Get();
1194 otOut <<
"OTAsymmetricKey::LoadPrivateKey: Unable to find private key "
1196 << szFilename <<
"\n";
1206 szFoldername, szFilename));
1208 if (strFileContents.length() < 2) {
1209 otErr <<
"OTAsymmetricKey::LoadPrivateKey: Error reading file: "
1214 const OTString strCert(strFileContents),
1215 strReason(
nullptr == pstrReason ?
"OTAsymmetricKey::LoadPrivateKey"
static EXPORT const char * PathSeparator()
OTLOG_IMPORT OTLogStream otOut
virtual bool LoadPrivateKeyFromCertString(const OTString &strCert, bool bEscaped=true, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr)=0
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
OTLOG_IMPORT OTLogStream otErr
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
virtual bool opentxs::OTAsymmetricKey::LoadPrivateKeyFromCertString |
( |
const OTString & |
strCert, |
|
|
bool |
bEscaped = true , |
|
|
const OTString * |
pstrReason = nullptr , |
|
|
const OTPassword * |
pImportPassword = nullptr |
|
) |
| |
|
pure virtual |
bool opentxs::OTAsymmetricKey::LoadPublicKey |
( |
const OTString & |
strFoldername, |
|
|
const OTString & |
strFilename |
|
) |
| |
Definition at line 1224 of file OTAsymmetricKey.cpp.
1235 OTASCIIArmor theArmor;
1237 if (theArmor.LoadFromFile(strFoldername, strFilename)) {
1239 otLog4 <<
"Success setting public key from OTASCIIArmor in "
1240 "OTAsymmetricKey::LoadPublicKey.\n";
1244 otErr <<
"Unable to convert from OTASCIIArmor to public key in "
1245 "OTAsymmetricKey::LoadPublicKey: " << strFilename <<
"\n";
1251 <<
"Unable to read pubkey file in OTAsymmetricKey::LoadPublicKey: "
1252 << strFilename <<
"\n";
OTLOG_IMPORT OTLogStream otLog4
EXPORT bool SetPublicKey(const OTASCIIArmor &strKey)
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::LoadPublicKeyFromCertFile |
( |
const OTString & |
strFoldername, |
|
|
const OTString & |
strFilename, |
|
|
const OTString * |
pstrReason = nullptr , |
|
|
const OTPassword * |
pImportPassword = nullptr |
|
) |
| |
Definition at line 1258 of file OTAsymmetricKey.cpp.
1267 const char* szFoldername = strFoldername.Get();
1268 const char* szFilename = strFilename.Get();
1274 otErr << __FUNCTION__ <<
": File does not exist: " << szFoldername
1281 szFoldername, szFilename));
1283 if (strFileContents.length() < 2) {
1284 otErr << __FUNCTION__ <<
": Error reading file: " << szFoldername
1289 const OTString strCert(strFileContents);
1292 strCert,
false, pstrReason,
virtual bool LoadPublicKeyFromCertString(const OTString &strCert, bool bEscaped=true, const OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr)=0
static EXPORT const char * PathSeparator()
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
OTLOG_IMPORT OTLogStream otErr
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
virtual bool opentxs::OTAsymmetricKey::LoadPublicKeyFromCertString |
( |
const OTString & |
strCert, |
|
|
bool |
bEscaped = true , |
|
|
const OTString * |
pstrReason = nullptr , |
|
|
const OTPassword * |
pImportPassword = nullptr |
|
) |
| |
|
pure virtual |
virtual bool opentxs::OTAsymmetricKey::LoadPublicKeyFromPGPKey |
( |
const OTASCIIArmor & |
strKey | ) |
|
|
pure virtual |
virtual bool opentxs::OTAsymmetricKey::ReEncryptPrivateKey |
( |
const OTPassword & |
theExportPassword, |
|
|
bool |
bImporting |
|
) |
| const |
|
pure virtual |
void opentxs::OTAsymmetricKey::Release |
( |
| ) |
|
|
virtual |
void opentxs::OTAsymmetricKey::Release_AsymmetricKey |
( |
| ) |
|
void opentxs::OTAsymmetricKey::ReleaseKey |
( |
| ) |
|
void opentxs::OTAsymmetricKey::ReleaseKeyLowLevel |
( |
| ) |
|
|
protected |
virtual void opentxs::OTAsymmetricKey::ReleaseKeyLowLevel_Hook |
( |
| ) |
const |
|
protectedpure virtual |
virtual bool opentxs::OTAsymmetricKey::SaveCertToString |
( |
OTString & |
strOutput, |
|
|
const OTString * |
pstrReason = nullptr , |
|
|
const OTPassword * |
pImportPassword = nullptr |
|
) |
| const |
|
pure virtual |
virtual bool opentxs::OTAsymmetricKey::SavePrivateKeyToString |
( |
OTString & |
strOutput, |
|
|
const OTString * |
pstrReason = nullptr , |
|
|
const OTPassword * |
pImportPassword = nullptr |
|
) |
| const |
|
pure virtual |
void opentxs::OTAsymmetricKey::SetAsPrivate |
( |
| ) |
|
|
inline |
void opentxs::OTAsymmetricKey::SetAsPublic |
( |
| ) |
|
|
inline |
Definition at line 201 of file OTAsymmetricKey.cpp.
203 const char* szFunc =
"OTAsymmetricKey::SetPasswordCallback";
206 otOut << szFunc <<
": WARNING: re-setting the password callback (one "
207 "was already there)...\n";
209 otWarn << szFunc <<
": FYI, setting the password callback to a "
210 "non-nullptr pointer (which is what we want.)\n";
212 if (
nullptr == pCallback)
214 <<
": WARNING, setting the password callback to nullptr! "
215 "(OpenSSL will thus "
216 "be forced to ask for the passphase on the console, "
217 "until this is called "
218 "again and set properly.)\n";
OTLOG_IMPORT OTLogStream otOut
static OT_OPENSSL_CALLBACK * s_pwCallback
OTLOG_IMPORT OTLogStream otWarn
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::SetPasswordCaller |
( |
OTCaller & |
theCaller | ) |
|
|
static |
Definition at line 280 of file OTAsymmetricKey.cpp.
282 const char* szFunc =
"OTAsymmetricKey::SetPasswordCaller";
285 <<
": Attempting to set the password caller... "
286 "(the Java code has passed us its custom password dialog object "
287 "for later use if/when the "
288 "OT 'C'-based password callback is triggered by openssl.)\n";
290 if (!theCaller.isCallbackSet()) {
291 otErr << szFunc <<
": ERROR: OTCaller::setCallback() "
292 "MUST be called first, with an OTCallback-extended "
293 "object passed to it,\n"
294 "BEFORE calling this function with that OTCaller. "
295 "(Returning false.)\n";
301 <<
": WARNING: Setting the password caller again, even though "
302 "it was apparently ALREADY set... (Meaning Java has probably "
303 "erroneously called this twice, "
304 "possibly passing the same OTCaller both times.)\n";
313 <<
": FYI, Successfully set the password caller object from "
314 "Java, and set the souped_up_pass_cb in C for OpenSSL (which "
316 "that Java object when the time is right.) Returning true.\n";
static OTCaller * s_pCaller
EXPORT OT_OPENSSL_CALLBACK souped_up_pass_cb
OTLOG_IMPORT OTLogStream otLog3
static void SetPasswordCallback(OT_OPENSSL_CALLBACK *pCallback)
OTLOG_IMPORT OTLogStream otWarn
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::SetPrivateKey |
( |
const OTString & |
strKey, |
|
|
bool |
bEscaped = false |
|
) |
| |
Definition at line 953 of file OTAsymmetricKey.cpp.
961 OTASCIIArmor theArmor;
962 const char* szPrivateKeyStarts =
"-----BEGIN ENCRYPTED PRIVATE KEY-----";
963 if (theArmor.LoadFromString(const_cast<OTString&>(strKey), bEscaped,
bool SetPrivateKey(const OTString &strKey, bool bEscaped=false)
bool opentxs::OTAsymmetricKey::SetPrivateKey |
( |
const OTASCIIArmor & |
strKey | ) |
|
Definition at line 977 of file OTAsymmetricKey.cpp.
void ReleaseKeyLowLevel()
OTASCIIArmor * m_p_ascKey
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
bool opentxs::OTAsymmetricKey::SetPublicKey |
( |
const OTASCIIArmor & |
strKey | ) |
|
Definition at line 884 of file OTAsymmetricKey.cpp.
void ReleaseKeyLowLevel()
OTASCIIArmor * m_p_ascKey
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
bool opentxs::OTAsymmetricKey::SetPublicKey |
( |
const OTString & |
strKey, |
|
|
bool |
bEscaped = false |
|
) |
| |
Definition at line 861 of file OTAsymmetricKey.cpp.
868 OTASCIIArmor theArmor;
870 if (theArmor.LoadFromString(const_cast<OTString&>(strKey), bEscaped)) {
874 otErr <<
"OTAsymmetricKey::SetPublicKey: Error: failed loading "
875 "ascii-armored contents from bookended string:\n\n" << strKey
EXPORT bool SetPublicKey(const OTASCIIArmor &strKey)
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OTAsymmetricKey::m_bIsPrivateKey |
|
protected |
bool opentxs::OTAsymmetricKey::m_bIsPublicKey |
|
protected |
Timer opentxs::OTAsymmetricKey::m_timer |
|
protected |
OTCaller * opentxs::OTAsymmetricKey::s_pCaller = nullptr |
|
staticprotected |
The documentation for this class was generated from the following files: