133 #ifndef OPENTXS_CORE_CRYPTO_OTCRYPTO_HPP
134 #define OPENTXS_CORE_CRYPTO_OTCRYPTO_HPP
136 #include "../OTPayload.hpp"
137 #include "../OTString.hpp"
138 #include "../util/Assert.hpp"
147 class OTAsymmetricKey;
151 class OTPasswordData;
162 static bool GetSetAll();
164 static bool GetSetValue(
OTSettings& config, std::string strKeyName,
165 int32_t nDefaultValue,
const int32_t*& out_nValue);
167 static const int32_t& GetValue(
const int32_t*& pValue);
169 static const int32_t* sp_nIterationCount;
170 static const int32_t* sp_nSymmetricSaltSize;
171 static const int32_t* sp_nSymmetricKeySize;
172 static const int32_t* sp_nSymmetricKeySizeMax;
173 static const int32_t* sp_nSymmetricIvSize;
174 static const int32_t* sp_nSymmetricBufferSize;
175 static const int32_t* sp_nPublicKeysize;
176 static const int32_t* sp_nPublicKeysizeMax;
177 static const int32_t* sp_nDigest1Size;
178 static const int32_t* sp_nDigest2Size;
212 EXPORT OTCrypto_Decrypt_Output(
OTPassword& thePassword);
213 EXPORT OTCrypto_Decrypt_Output(
OTPayload& thePayload);
215 EXPORT
void swap(OTCrypto_Decrypt_Output& other);
217 EXPORT OTCrypto_Decrypt_Output&
operator=(
218 OTCrypto_Decrypt_Output other);
221 uint32_t lAppendSize)
const;
235 static int32_t s_nCount;
251 bool bRepeat =
false)
const;
253 const char* szPrompt)
const;
257 uint32_t nNewSize)
const = 0;
268 bool IsBase62(
const std::string& str)
const;
277 bool bLineBreaks =
true)
const;
279 bool bLineBreaks =
true)
const;
283 virtual char*
Base64Encode(
const uint8_t* input, int32_t in_len,
284 bool bLineBreaks)
const = 0;
292 virtual uint8_t*
Base64Decode(
const char* input,
size_t* out_len,
293 bool bLineBreaks)
const = 0;
319 uint32_t uIterations,
324 uint32_t uIterations,
335 uint32_t lInputLength,
338 OTPayload& theEncryptedOutput)
const = 0;
344 uint32_t lInputLength,
379 const std::string& strCertFileContents,
385 const std::string& strCertFileContents,
const OTSignature& theSignature,
389 EXPORT
void Init()
const;
400 #if defined(OT_CRYPTO_USING_GPG)
404 #elif defined(OT_CRYPTO_USING_OPENSSL)
424 uint32_t nNewSize)
const;
440 virtual char*
Base64Encode(
const uint8_t* input, int32_t in_len,
441 bool bLineBreaks)
const;
443 virtual uint8_t*
Base64Decode(
const char* input,
size_t* out_len,
444 bool bLineBreaks)
const;
454 uint32_t uIterations,
459 uint32_t uIterations,
467 uint32_t lInputLength,
476 uint32_t lInputLength,
507 const std::string& strCertFileContents,
513 const std::string& strCertFileContents,
522 #else // Apparently NO crypto engine is defined!
526 #endif // if defined (OT_CRYPTO_USING_OPENSSL), elif defined
586 #endif // OPENTXS_CORE_CRYPTO_OTCRYPTO_HPP
static EXPORT OTCrypto * It()
virtual void Cleanup_Override() const
virtual bool CalculateDigest(const OTString &strInput, const OTString &strHashAlgorithm, OTIdentifier &theOutput) const
static EXPORT uint32_t SymmetricIvSize()
virtual bool SignContract(const OTString &strContractUnsigned, const OTAsymmetricKey &theKey, OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr)=0
virtual bool RandomizeMemory(uint8_t *szDestination, uint32_t nNewSize) const =0
virtual bool Encrypt(const OTPassword &theRawSymmetricKey, const char *szInput, uint32_t lInputLength, const OTPayload &theIV, OTPayload &theEncryptedOutput) const =0
virtual OTPassword * InstantiateBinarySecret() const =0
static EXPORT uint32_t IterationCount()
EXPORT bool GetPasswordFromConsole(OTPassword &theOutput, bool bRepeat=false) const
virtual void SetIDFromBase62String(const OTString &strInput, OTIdentifier &theOutput) const
virtual bool Decrypt(const OTPassword &theRawSymmetricKey, const char *szInput, uint32_t lInputLength, const OTPayload &theIV, OTCrypto_Decrypt_Output theDecryptedOutput) const
virtual bool SignContract(const OTString &strContractUnsigned, const OTAsymmetricKey &theKey, OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr)
virtual void Init_Override() const
virtual OTPassword * DeriveNewKey(const OTPassword &userPassword, const OTPayload &dataSalt, uint32_t uIterations, OTPayload &dataCheckHash) const
EXPORT bool Concatenate(const void *pAppendData, uint32_t lAppendSize) const
virtual bool VerifySignature(const OTString &strContractToVerify, const OTAsymmetricKey &theKey, const OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr) const =0
virtual OTPassword * InstantiateBinarySecret() const
virtual bool RandomizeMemory(uint8_t *szDestination, uint32_t nNewSize) const
static EXPORT uint32_t SymmetricSaltSize()
void thread_setup() const
static EXPORT uint32_t SymmetricKeySizeMax()
EXPORT bool GetPasswordFromConsoleLowLevel(OTPassword &theOutput, const char *szPrompt) const
static EXPORT uint32_t Digest1Size()
virtual ~OTCrypto_OpenSSL()
virtual uint8_t * Base64Decode(const char *input, size_t *out_len, bool bLineBreaks) const
virtual bool Encrypt(const OTPassword &theRawSymmetricKey, const char *szInput, uint32_t lInputLength, const OTPayload &theIV, OTPayload &theEncryptedOutput) const
virtual void Cleanup_Override() const
static std::mutex * s_arrayMutex
static EXPORT uint32_t SymmetricBufferSize()
bool IsBase62(const std::string &str) const
virtual bool Base64Encode(const OTData &theInput, OTString &strOutput, bool bLineBreaks=true) const
EXPORT ~OTCrypto_Decrypt_Output()
EXPORT void swap(OTCrypto_Decrypt_Output &other)
std::multimap< std::string, OTAsymmetricKey * > mapOfAsymmetricKeys
virtual bool Seal(mapOfAsymmetricKeys &RecipPubKeys, const OTString &theInput, OTData &dataOutput) const
virtual bool Seal(mapOfAsymmetricKeys &RecipPubKeys, const OTString &theInput, OTData &dataOutput) const =0
static EXPORT uint32_t PublicKeysizeMax()
virtual bool Open(OTData &dataInput, const OTPseudonym &theRecipient, OTString &theOutput, const OTPasswordData *pPWData=nullptr) const =0
virtual bool CalculateDigest(const OTString &strInput, const OTString &strHashAlgorithm, OTIdentifier &theOutput) const =0
EXPORT OTCrypto_Decrypt_Output & operator=(OTCrypto_Decrypt_Output other)
void thread_cleanup() const
static EXPORT uint32_t Digest2Size()
virtual bool Decrypt(const OTPassword &theRawSymmetricKey, const char *szInput, uint32_t lInputLength, const OTPayload &theIV, OTCrypto_Decrypt_Output theDecryptedOutput) const =0
EXPORT void Release_Envelope_Decrypt_Output() const
static EXPORT uint32_t PublicKeysize()
EXPORT void Cleanup() const
virtual bool Base64Decode(const OTString &strInput, OTData &theOutput, bool bLineBreaks=true) const
virtual void SetBase62StringFromID(const OTIdentifier &theInput, OTString &strOutput) const
virtual void Init_Override() const
virtual char * Base64Encode(const uint8_t *input, int32_t in_len, bool bLineBreaks) const
virtual bool VerifySignature(const OTString &strContractToVerify, const OTAsymmetricKey &theKey, const OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr) const
virtual bool Open(OTData &dataInput, const OTPseudonym &theRecipient, OTString &theOutput, const OTPasswordData *pPWData=nullptr) const
virtual void SetBase62StringFromID(const OTIdentifier &theInput, OTString &strOutput) const =0
virtual OTPassword * DeriveNewKey(const OTPassword &userPassword, const OTPayload &dataSalt, uint32_t uIterations, OTPayload &dataCheckHash) const =0
virtual OTPassword * DeriveKey(const OTPassword &userPassword, const OTPayload &dataSalt, uint32_t uIterations, const OTPayload &dataCheckHash=OTPayload()) const =0
virtual void SetIDFromBase62String(const OTString &strInput, OTIdentifier &theOutput) const =0
virtual OTPassword * DeriveKey(const OTPassword &userPassword, const OTPayload &dataSalt, uint32_t uIterations, const OTPayload &dataCheckHash=OTPayload()) const
static EXPORT uint32_t SymmetricKeySize()