102#ifndef CRYPTOPP_CRYPTLIB_H 
  103#define CRYPTOPP_CRYPTLIB_H 
  111#if CRYPTOPP_MSC_VERSION 
  112# pragma warning(push) 
  113# pragma warning(disable: 4127 4189 4505 4702) 
  114# if (CRYPTOPP_MSC_VERSION >= 1933) 
  115#  pragma warning(disable: 5264) 
  139template <
typename ENUM_TYPE, 
int VALUE>
 
  142    static ENUM_TYPE ToEnum() {
return static_cast<ENUM_TYPE
>(VALUE);}
 
 
  191    const char *
what() 
const throw() {
return (m_what.c_str());}
 
  193    const std::string &
GetWhat()
 const {
return m_what;}
 
  195    void SetWhat(
const std::string &s) {m_what = s;}
 
  202    ErrorType m_errorType;
 
 
  268    OS_Error(
ErrorType errorType, 
const std::string &s, 
const std::string& operation, 
int errorCode)
 
  269        : 
Exception(errorType, s), m_operation(operation), m_errorCode(errorCode) {}
 
 
  277    std::string m_operation;
 
 
  341        ValueTypeMismatch(
const std::string &name, 
const std::type_info &stored, 
const std::type_info &retrieving)
 
  342            : 
InvalidArgument(
"NameValuePairs: type mismatch for '" + name + 
"', stored '" + stored.name() + 
"', trying to retrieve '" + retrieving.name() + 
"'")
 
  343            , m_stored(stored), m_retrieving(retrieving) {}
 
 
  354        const std::type_info &m_stored;
 
  355        const std::type_info &m_retrieving;
 
 
  364        return GetValue((std::string(
"ThisObject:")+
typeid(T).name()).c_str(), 
object);
 
 
  373        return GetValue((std::string(
"ThisPointer:")+
typeid(T).name()).c_str(), ptr);
 
 
  400        bool result = 
GetValue(name, value);
 
  402        if (result) {
return value;}
 
 
  410        {std::string result; 
GetValue(
"ValueNames", result); 
return result;}
 
 
  476            throw InvalidArgument(std::string(className) + 
": missing required parameter '" + name + 
"'");
 
 
  491            throw InvalidArgument(std::string(className) + 
": missing required parameter '" + name + 
"'");
 
 
  504    CRYPTOPP_DLL 
virtual bool GetVoidValue(
const char *name, 
const std::type_info &valueType, 
void *pValue) 
const =0;
 
 
  508#if CRYPTOPP_DOXYGEN_PROCESSING 
  543#if CRYPTOPP_DOXYGEN_PROCESSING 
  551DOCUMENTED_NAMESPACE_BEGIN(
Name)
 
  553DOCUMENTED_NAMESPACE_END
 
  566DOCUMENTED_NAMESPACE_BEGIN(
Weak)
 
  568DOCUMENTED_NAMESPACE_END
 
  573DOCUMENTED_NAMESPACE_BEGIN(
NaCl)
 
  575DOCUMENTED_NAMESPACE_END
 
 
  580DOCUMENTED_NAMESPACE_BEGIN(
Test)
 
  582DOCUMENTED_NAMESPACE_END
 
 
  678        {
return keylength == GetValidKeyLength(keylength);}
 
 
  704    void SetKeyWithIV(
const byte *key, 
size_t length, 
const byte *iv, 
size_t ivLength);
 
  714        {SetKeyWithIV(key, length, iv, IVSize());}
 
 
  767        {
throw NotImplemented(GetAlgorithm().AlgorithmName() + 
": this object doesn't support resynchronization");}
 
 
  789        CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(ivLength);
 
  790        throw NotImplemented(GetAlgorithm().AlgorithmName() + 
": this object doesn't support resynchronization");
 
 
  807    virtual const Algorithm & GetAlgorithm() 
const =0;
 
  814    virtual void UncheckedSetKey(
const byte *key, 
unsigned int length, 
const NameValuePairs ¶ms) =0;
 
  819    void ThrowIfInvalidKeyLength(
size_t length);
 
  826    void ThrowIfResynchronizable();
 
  835    void ThrowIfInvalidIV(
const byte *iv);
 
  840    size_t ThrowIfInvalidIVLength(
int length);
 
  847    const byte * GetIVAndThrowIfInvalid(
const NameValuePairs ¶ms, 
size_t &size);
 
  851    inline void AssertValidKeyLength(
size_t length)
 const 
 
  885        {ProcessAndXorBlock(inBlock, NULLPTR, outBlock);}
 
 
  894        {ProcessAndXorBlock(inoutBlock, NULLPTR, inoutBlock);}
 
 
  922        BT_InBlockIsCounter=1,
 
  924        BT_DontIncrementInOutPointers=2,
 
  928        BT_ReverseDirection=8,
 
  930        BT_AllowParallel=16};
 
 
 
  995    virtual void ProcessData(
byte *outString, 
const byte *inString, 
size_t length) =0;
 
 1009    virtual size_t ProcessLastBlock(
byte *outString, 
size_t outLength, 
const byte *inString, 
size_t inLength);
 
 1066        {ProcessData(inoutString, inoutString, length);}
 
 
 1074        {ProcessData(outString, inString, length);}
 
 
 1080        {ProcessData(&input, &input, 1); 
return input;}
 
 
 1093        CRYPTOPP_UNUSED(pos);
 
 1095        throw NotImplemented(
"StreamTransformation: this object doesn't support random access");
 
 
 
 1130    virtual void Update(
const byte *input, 
size_t length) =0;
 
 1148        {TruncatedFinal(digest, DigestSize());}
 
 
 1153        {TruncatedFinal(NULLPTR, 0);}
 
 
 1162    unsigned int TagSize()
 const {
return DigestSize();}
 
 1194        {Update(input, length); Final(digest);}
 
 
 1206        {
return TruncatedVerify(digest, DigestSize());}
 
 
 1221    virtual bool VerifyDigest(
const byte *digest, 
const byte *input, 
size_t length)
 
 1222        {Update(input, length); 
return Verify(digest);}
 
 
 1244        {Update(input, length); TruncatedFinal(digest, digestSize);}
 
 
 1275        {Update(input, length); 
return TruncatedVerify(digest, digestLength);}
 
 
 1282    void ThrowIfInvalidTruncatedSize(
size_t size) 
const;
 
 
 1290    const Algorithm & GetAlgorithm()
 const {
return *
this;}
 
 
 1298    const Algorithm & GetAlgorithm()
 const {
return *
this;}
 
 
 1306    const Algorithm & GetAlgorithm()
 const {
return *
this;}
 
 
 1336        explicit BadState(
const std::string &name, 
const char *message) : 
Exception(OTHER_ERROR, name + 
": " + message) {}
 
 1337        explicit BadState(
const std::string &name, 
const char *function, 
const char *state) : 
Exception(OTHER_ERROR, name + 
": " + function + 
" was called before " + state) {}
 
 
 1382    virtual void EncryptAndAuthenticate(
byte *ciphertext, 
byte *mac, 
size_t macSize, 
const byte *iv, 
int ivLength, 
const byte *header, 
size_t headerLength, 
const byte *message, 
size_t messageLength);
 
 1399    virtual bool DecryptAndVerify(
byte *message, 
const byte *mac, 
size_t macSize, 
const byte *iv, 
int ivLength, 
const byte *header, 
size_t headerLength, 
const byte *ciphertext, 
size_t ciphertextLength);
 
 1428    virtual void UncheckedSpecifyDataLengths(
lword headerLength, 
lword messageLength, 
lword footerLength)
 
 1429        {CRYPTOPP_UNUSED(headerLength); CRYPTOPP_UNUSED(messageLength); CRYPTOPP_UNUSED(footerLength);}
 
 
 1454        CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(length);
 
 1455        throw NotImplemented(
"RandomNumberGenerator: IncorporateEntropy not implemented");
 
 
 1515    template <
class IT> 
void Shuffle(IT begin, IT end)
 
 1518        for (; begin != end; ++begin)
 
 1519            std::iter_swap(begin, begin + GenerateWord32(0, 
static_cast<word32>(end-begin-1)));
 
 
 
 1554        return keylength == GetValidDerivedLength(keylength);
 
 
 1581    virtual const Algorithm & GetAlgorithm() 
const =0;
 
 1586    void ThrowIfInvalidDerivedKeyLength(
size_t length) 
const;
 
 
 1603class WaitObjectContainer;
 
 1624    virtual void GetWaitObjects(WaitObjectContainer &container, CallStack 
const& callStack) =0;
 
 1630    bool Wait(
unsigned long milliseconds, CallStack 
const& callStack);
 
 
 1678        size_t Put(
byte inByte, 
bool blocking=
true)
 
 1679            {
return Put(&inByte, 1, blocking);}
 
 
 1688        size_t Put(
const byte *inString, 
size_t length, 
bool blocking=
true)
 
 1689            {
return Put2(inString, length, 0, blocking);}
 
 
 1726            {size=0; 
return NULLPTR;}
 
 
 1741            {
return PutModifiable2(inString, length, 0, blocking);}
 
 
 1749            {
return !!Put2(NULLPTR, 0, propagation < 0 ? -1 : propagation+1, blocking);}
 
 
 1762        size_t PutMessageEnd(
const byte *inString, 
size_t length, 
int propagation=-1, 
bool blocking=
true)
 
 1763            {
return Put2(inString, length, propagation < 0 ? -1 : propagation+1, blocking);}
 
 
 1773        virtual size_t Put2(
const byte *inString, 
size_t length, 
int messageEnd, 
bool blocking) =0;
 
 1783        virtual size_t PutModifiable2(
byte *inString, 
size_t length, 
int messageEnd, 
bool blocking)
 
 1784            {
return Put2(inString, length, messageEnd, blocking);}
 
 
 1822            CRYPTOPP_UNUSED(parameters);
 
 1823            throw NotImplemented(
"BufferedTransformation: this object can't be reinitialized");
 
 
 1838            {CRYPTOPP_UNUSED(blocking); 
return false;}
 
 
 1869        virtual bool Flush(
bool hardFlush, 
int propagation=-1, 
bool blocking=
true);
 
 1887            {CRYPTOPP_UNUSED(propagation);}
 
 
 1916        virtual size_t Get(
byte &outByte);
 
 1923        virtual size_t Get(
byte *outString, 
size_t getMax);
 
 1930        virtual size_t Peek(
byte &outByte) 
const;
 
 1938        virtual size_t Peek(
byte *outString, 
size_t peekMax) 
const;
 
 1997            {TransferTo2(target, transferMax, channel); 
return transferMax;}
 
 
 2019            {
return CopyRangeTo(target, 0, copyMax, channel);}
 
 
 2032            {
lword i = position; CopyRangeTo2(target, i, i+copyMax, channel); 
return i-position;}
 
 
 2077            {TransferMessagesTo2(target, count, channel); 
return count;}
 
 
 2099            {TransferAllTo2(target, channel);}
 
 
 2199        size_t ChannelPut(
const std::string &channel, 
byte inByte, 
bool blocking=
true)
 
 2200            {
return ChannelPut(channel, &inByte, 1, blocking);}
 
 
 2209        size_t ChannelPut(
const std::string &channel, 
const byte *inString, 
size_t length, 
bool blocking=
true)
 
 2210            {
return ChannelPut2(channel, inString, length, 0, blocking);}
 
 
 2220            {
return ChannelPutModifiable2(channel, inString, length, 0, blocking);}
 
 
 2258            {
return !!ChannelPut2(channel, NULLPTR, 0, propagation < 0 ? -1 : propagation+1, blocking);}
 
 
 2269        size_t ChannelPutMessageEnd(
const std::string &channel, 
const byte *inString, 
size_t length, 
int propagation=-1, 
bool blocking=
true)
 
 2270            {
return ChannelPut2(channel, inString, length, propagation < 0 ? -1 : propagation+1, blocking);}
 
 
 2292        virtual size_t ChannelPut2(
const std::string &channel, 
const byte *inString, 
size_t length, 
int messageEnd, 
bool blocking);
 
 2301        virtual size_t ChannelPutModifiable2(
const std::string &channel, 
byte *inString, 
size_t length, 
int messageEnd, 
bool blocking);
 
 2311        virtual bool ChannelFlush(
const std::string &channel, 
bool hardFlush, 
int propagation=-1, 
bool blocking=
true);
 
 2363            throw NotImplemented(
"BufferedTransformation: this object is not attachable");
 
 
 2374    static int DecrementPropagation(
int propagation)
 
 2375        {
return propagation != 0 ? propagation - 1 : 0;}
 
 
 2433        {
if (!Validate(rng, level)) 
throw InvalidMaterial(
"CryptoMaterial: this object contains invalid values");}
 
 
 2445        {CRYPTOPP_UNUSED(bt); 
throw NotImplemented(
"CryptoMaterial: this object does not support saving");}
 
 
 2462        {CRYPTOPP_UNUSED(bt); 
throw NotImplemented(
"CryptoMaterial: this object does not support loading");}
 
 
 2478        CRYPTOPP_UNUSED(precomputationStorage); 
CRYPTOPP_ASSERT(!SupportsPrecomputation());
 
 2479        throw NotImplemented(
"CryptoMaterial: this object does not support precomputation");
 
 
 2487        {CRYPTOPP_UNUSED(storedPrecomputation); 
CRYPTOPP_ASSERT(!SupportsPrecomputation()); 
throw NotImplemented(
"CryptoMaterial: this object does not support precomputation");}
 
 
 2494        {CRYPTOPP_UNUSED(storedPrecomputation); 
CRYPTOPP_ASSERT(!SupportsPrecomputation()); 
throw NotImplemented(
"CryptoMaterial: this object does not support precomputation");}
 
 
 2500#if defined(__SUNPRO_CC) 
 2505    char m_sunCCworkaround;
 
 
 2526        CRYPTOPP_UNUSED(rng); CRYPTOPP_UNUSED(params);
 
 2527        throw NotImplemented(
"GeneratableCryptoMaterial: this object does not support key/parameter generation");
 
 
 
 2583        {AccessMaterial().
Load(bt);}
 
 2590        {GetMaterial().Save(bt);}
 
 
 2605        {
return AccessPublicKey();}
 
 
 2609        {
return GetPublicKey();}
 
 
 
 2723        const byte *plaintext, 
size_t plaintextLength,
 
 
 2757        const byte *ciphertext, 
size_t ciphertextLength,
 
 2783        {
return Decrypt(rng, ciphertext, FixedCiphertextLength(), plaintext, parameters);}
 
 
 
 2823        {CRYPTOPP_UNUSED(recoverablePartLength); 
return SignatureLength();}
 
 
 
 2870        {
throw NotImplemented(
"PK_MessageAccumulator: DigestSize() should not be called");}
 
 
 2875        CRYPTOPP_UNUSED(digest); CRYPTOPP_UNUSED(digestSize);
 
 2876        throw NotImplemented(
"PK_MessageAccumulator: TruncatedFinal() should not be called");
 
 
 
 2936        const byte *nonrecoverableMessage, 
size_t nonrecoverableMessageLength, 
byte *signature) 
const;
 
 
 2981        const byte *signature, 
size_t signatureLen) 
const;
 
 3008        const byte *nonrecoverableMessage, 
size_t nonrecoverableMessageLength,
 
 3009        const byte *signature, 
size_t signatureLength) 
const;
 
 
 3068    virtual bool Agree(
byte *agreedValue, 
const byte *privateKey, 
const byte *otherPublicKey, 
bool validateOtherPublicKey=
true) 
const =0;
 
 
 3160        const byte *staticPrivateKey, 
const byte *ephemeralPrivateKey,
 
 3161        const byte *staticOtherPublicKey, 
const byte *ephemeralOtherPublicKey,
 
 3162        bool validateStaticOtherPublicKey=
true) 
const =0;
 
 
 3188class ProtocolSession
 
 3195        ProtocolError(ErrorType errorType, 
const std::string &s) : 
Exception(errorType, s) {}
 
 3200    class UnexpectedMethodCall : 
public Exception 
 3203        UnexpectedMethodCall(
const std::string &s) : 
Exception(OTHER_ERROR, s) {}
 
 3206    virtual ~ProtocolSession() {}
 
 3208    ProtocolSession() : m_rng(NULLPTR), m_throwOnProtocolError(true), m_validState(false) {}
 
 3212    bool GetThrowOnProtocolError()
 const {
return m_throwOnProtocolError;}
 
 3213    void SetThrowOnProtocolError(
bool throwOnProtocolError) {m_throwOnProtocolError = throwOnProtocolError;}
 
 3215    bool HasValidState()
 const {
return m_validState;}
 
 3217    virtual bool OutgoingMessageAvailable() 
const =0;
 
 3218    virtual unsigned int GetOutgoingMessageLength() 
const =0;
 
 3219    virtual void GetOutgoingMessage(
byte *message) =0;
 
 3221    virtual bool LastMessageProcessed() 
const =0;
 
 3222    virtual void ProcessIncomingMessage(
const byte *message, 
unsigned int messageLength) =0;
 
 3226    void CheckAndHandleInvalidState() 
const;
 
 3227    void SetValidState(
bool valid) {m_validState = valid;}
 
 3232    bool m_throwOnProtocolError, m_validState;
 
 3235class KeyAgreementSession : 
public ProtocolSession
 
 3238    virtual ~KeyAgreementSession() {}
 
 3240    virtual unsigned int GetAgreedValueLength() 
const =0;
 
 3241    virtual void GetAgreedValue(
byte *agreedValue) 
const =0;
 
 3244class PasswordAuthenticatedKeyAgreementSession : 
public KeyAgreementSession
 
 3247    virtual ~PasswordAuthenticatedKeyAgreementSession() {}
 
 3250        const byte *myId, 
unsigned int myIdLength,
 
 3251        const byte *counterPartyId, 
unsigned int counterPartyIdLength,
 
 3252        const byte *passwordOrVerifier, 
unsigned int passwordOrVerifierLength);
 
 3260    virtual ~PasswordAuthenticatedKeyAgreementDomain() {}
 
 3266    virtual unsigned int GetPasswordVerifierLength(
const byte *password, 
unsigned int passwordLength) 
const =0;
 
 3267    virtual void GeneratePasswordVerifier(
RandomNumberGenerator &rng, 
const byte *userId, 
unsigned int userIdLength, 
const byte *password, 
unsigned int passwordLength, 
byte *verifier) 
const =0;
 
 3269    enum RoleFlags {CLIENT=1, SERVER=2, INITIATOR=4, RESPONDER=8};
 
 3271    virtual bool IsValidRole(
unsigned int role) =0;
 
 3272    virtual PasswordAuthenticatedKeyAgreementSession * CreateProtocolSession(
unsigned int role) 
const =0;
 
 3380#if CRYPTOPP_MSC_VERSION 
 3381# pragma warning(pop) 
bool operator==(const OID &lhs, const OID &rhs)
Compare two OIDs for equality.
 
Interface for encoding and decoding ASN1 objects.
 
virtual void DEREncode(BufferedTransformation &bt) const =0
Encode this object into a BufferedTransformation.
 
virtual void BEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
 
virtual void BERDecode(BufferedTransformation &bt)=0
Decode this object from a BufferedTransformation.
 
Interface for all crypto algorithms.
 
Algorithm(bool checkSelfTestStatus=true)
Interface for all crypto algorithms.
 
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
 
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
 
Interface for asymmetric algorithms.
 
virtual const CryptoMaterial & GetMaterial() const =0
Retrieves a reference to CryptoMaterial.
 
virtual CryptoMaterial & AccessMaterial()=0
Retrieves a reference to CryptoMaterial.
 
Interface for domains of authenticated key agreement protocols.
 
virtual void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0
Generate static private key in this domain.
 
virtual unsigned int StaticPrivateKeyLength() const =0
Provides the size of the static private key.
 
virtual unsigned int EphemeralPublicKeyLength() const =0
Provides the size of ephemeral public key.
 
virtual unsigned int EphemeralPrivateKeyLength() const =0
Provides the size of ephemeral private key.
 
virtual void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0
Generate a static public key from a private key in this domain.
 
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
 
virtual void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0
Generate ephemeral public key.
 
virtual unsigned int StaticPublicKeyLength() const =0
Provides the size of the static public key.
 
virtual void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0
Generate ephemeral private key.
 
virtual bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const =0
Derive agreed value.
 
virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a static private/public key pair.
 
virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate private/public key pair.
 
Exception thrown when the object is in the wrong state for the operation.
 
Interface for authenticated encryption modes of operation.
 
virtual lword MaxHeaderLength() const =0
Provides the maximum length of AAD that can be input.
 
virtual lword MaxFooterLength() const
Provides the maximum length of AAD.
 
virtual void EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *message, size_t messageLength)
Encrypts and calculates a MAC in one call.
 
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
 
void SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength=0)
Prescribes the data lengths.
 
virtual lword MaxMessageLength() const =0
Provides the maximum length of encrypted data.
 
virtual bool DecryptAndVerify(byte *message, const byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *ciphertext, size_t ciphertextLength)
Decrypts and verifies a MAC in one call.
 
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
 
virtual bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
 
Exception thrown when an ASN.1 BER decoing error is encountered.
 
Interface for one direction (encryption or decryption) of a block cipher.
 
Flush(true) was called but it can't completely flush its buffers.
 
CannotFlush(const std::string &s)
Construct an CannotFlush.
 
Interface for certificates.
 
Interface for cloning objects.
 
virtual Clonable * Clone() const
Copies this object.
 
Exception thrown when invalid crypto material is detected.
 
Interface for crypto material.
 
virtual void Save(BufferedTransformation &bt) const
Saves a key to a BufferedTransformation.
 
virtual void AssignFrom(const NameValuePairs &source)=0
Assign values to this object.
 
virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation)
Retrieve previously saved precomputation.
 
virtual bool SupportsPrecomputation() const
Determines whether the object supports precomputation.
 
virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const
Save precomputation for later use.
 
virtual void Precompute(unsigned int precomputationStorage)
Perform precomputation.
 
void DoQuickSanityCheck() const
Perform a quick sanity check.
 
virtual bool Validate(RandomNumberGenerator &rng, unsigned int level) const =0
Check this object for errors.
 
virtual void Load(BufferedTransformation &bt)
Loads a key from a BufferedTransformation.
 
virtual void ThrowIfInvalid(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
 
Interface for crypto parameters.
 
Base class for all exceptions thrown by the library.
 
void SetErrorType(ErrorType errorType)
Sets the error type for the exceptions.
 
void SetWhat(const std::string &s)
Sets the error string for the exception.
 
Exception(ErrorType errorType, const std::string &s)
Construct a new Exception.
 
ErrorType
Error types or categories.
 
@ CANNOT_FLUSH
BufferedTransformation received a Flush(true) signal but can't flush buffers.
 
@ NOT_IMPLEMENTED
A method was called which was not implemented.
 
@ INVALID_DATA_FORMAT
Input data was received that did not conform to expected format.
 
@ DATA_INTEGRITY_CHECK_FAILED
Data integerity check, such as CRC or MAC, failed.
 
@ INVALID_ARGUMENT
An invalid argument was detected.
 
@ IO_ERROR
Error reading from input device or writing to output device.
 
const char * what() const
Retrieves a C-string describing the exception.
 
ErrorType GetErrorType() const
Retrieves the error type for the exception.
 
const std::string & GetWhat() const
Retrieves a string describing the exception.
 
Interface for crypto material.
 
void GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize)
Generate a random key or crypto parameters.
 
virtual void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms=g_nullNameValuePairs)
Generate a random key or crypto parameters.
 
Multiple precision integer with arithmetic operations.
 
An invalid argument was detected.
 
InvalidArgument(const std::string &s)
Construct an InvalidArgument.
 
A decryption filter encountered invalid ciphertext.
 
InvalidCiphertext(const std::string &s)
Construct an InvalidCiphertext.
 
Interface for key agreement algorithms.
 
virtual CryptoParameters & AccessCryptoParameters()=0
Retrieves a reference to Crypto Parameters.
 
virtual const CryptoParameters & GetCryptoParameters() const
Retrieves a reference to Crypto Parameters.
 
CryptoMaterial & AccessMaterial()
Retrieves a reference to Crypto Parameters.
 
const CryptoMaterial & GetMaterial() const
Retrieves a reference to Crypto Parameters.
 
Interface for key derivation functions.
 
virtual size_t MinDerivedKeyLength() const
Determine minimum number of bytes.
 
virtual void SetParameters(const NameValuePairs ¶ms)
Set or change parameters.
 
virtual size_t DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const NameValuePairs ¶ms=g_nullNameValuePairs) const =0
Derive a key from a seed.
 
virtual size_t MaxDerivedKeyLength() const
Determine maximum number of bytes.
 
virtual bool IsValidDerivedLength(size_t keylength) const
Returns whether keylength is a valid key length.
 
virtual size_t GetValidDerivedLength(size_t keylength) const =0
Returns a valid key length for the derivation function.
 
virtual std::string AlgorithmName() const =0
Provides the name of this algorithm.
 
Interface for message authentication codes.
 
Thrown when an unexpected type is encountered.
 
const std::type_info & GetRetrievingTypeInfo() const
Provides the retrieveing type.
 
ValueTypeMismatch(const std::string &name, const std::type_info &stored, const std::type_info &retrieving)
Construct a ValueTypeMismatch.
 
const std::type_info & GetStoredTypeInfo() const
Provides the stored type.
 
Interface for retrieving values given their names.
 
virtual CRYPTOPP_DLL bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Get a named value.
 
CRYPTOPP_DLL word64 GetWord64ValueWithDefault(const char *name, word64 defaultValue) const
Get a named value with type word64, with default.
 
bool GetThisObject(T &object) const
Get a copy of this object or subobject.
 
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
 
bool GetValue(const char *name, T &value) const
Get a named value.
 
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
 
CRYPTOPP_DLL bool GetWord64Value(const char *name, word64 &value) const
Get a named value with type word64.
 
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
 
static CRYPTOPP_DLL void ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)
Ensures an expected name and type is present.
 
CRYPTOPP_DLL void GetRequiredIntParameter(const char *className, const char *name, int &value) const
Retrieves a required name/value pair.
 
bool GetThisPointer(T *&ptr) const
Get a pointer to this object.
 
CRYPTOPP_DLL std::string GetValueNames() const
Get a list of value names that can be retrieved.
 
void GetRequiredParameter(const char *className, const char *name, T &value) const
Retrieves a required name/value pair.
 
A method was called which was not implemented.
 
NotImplemented(const std::string &s)
Construct an NotImplemented.
 
The operating system reported an error.
 
OS_Error(ErrorType errorType, const std::string &s, const std::string &operation, int errorCode)
Construct an OS_Error.
 
const std::string & GetOperation() const
Retrieve the operating system API that reported the error.
 
int GetErrorCode() const
Retrieve the error code returned by the operating system.
 
Interface for public-key encryptors and decryptors.
 
virtual bool ParameterSupported(const char *name) const =0
Determines whether this object supports the use of a named parameter.
 
virtual size_t FixedMaxPlaintextLength() const
Provides the maximum plaintext length given a fixed ciphertext length.
 
virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0
Provides the maximum length of plaintext for a given ciphertext length.
 
virtual size_t CiphertextLength(size_t plaintextLength) const =0
Calculate the length of ciphertext given length of plaintext.
 
virtual size_t FixedCiphertextLength() const
Provides the fixed ciphertext length, if one exists.
 
Interface for public-key decryptors.
 
virtual BufferedTransformation * CreateDecryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment=NULL, const NameValuePairs ¶meters=g_nullNameValuePairs) const
Create a new decryption filter.
 
DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *ciphertext, byte *plaintext, const NameValuePairs ¶meters=g_nullNameValuePairs) const
Decrypt a fixed size ciphertext.
 
virtual DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters=g_nullNameValuePairs) const =0
Decrypt a byte string.
 
Exception thrown when trying to encrypt plaintext of invalid length.
 
Interface for public-key encryptors.
 
virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment=NULL, const NameValuePairs ¶meters=g_nullNameValuePairs) const
Create a new encryption filter.
 
virtual void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters=g_nullNameValuePairs) const =0
Encrypt a byte string.
 
Interface for accumulating messages to be signed or verified.
 
void TruncatedFinal(byte *digest, size_t digestSize)
 
unsigned int DigestSize() const
 
Exception throw when the private or public key has a length that can't be used.
 
Exception throw when the private or public key is too short to sign or verify.
 
Interface for public-key signers and verifiers.
 
virtual bool AllowNonrecoverablePart() const =0
Determines whether the non-recoverable message part can be signed.
 
virtual bool RecoverablePartFirst() const =0
Determines whether the recoverable part must be input before the non-recoverable part.
 
virtual size_t MaxRecoverableLength() const =0
Provides the length of longest message that can be recovered.
 
virtual size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const =0
Provides the length of longest message that can be recovered from a signature of given length.
 
virtual size_t MaxSignatureLength(size_t recoverablePartLength=0) const
Provides the maximum signature length produced given the length of the recoverable message part.
 
virtual bool SignatureUpfront() const
Determines whether the signature must be input before the message.
 
virtual size_t SignatureLength() const =0
Provides the signature length if it only depends on the key.
 
virtual bool IsProbabilistic() const =0
Determines whether a signature scheme requires a random number generator.
 
Interface for public-key signers.
 
virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const
Sign a recoverable message.
 
virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const =0
Input a recoverable message to an accumulator.
 
virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const
Sign and delete the messageAccumulator.
 
virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const
Sign a message.
 
virtual PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const =0
Create a new HashTransformation to accumulate the message to be signed.
 
virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const =0
Sign and restart messageAccumulator.
 
Interface for public-key signature verifiers.
 
virtual PK_MessageAccumulator * NewVerificationAccumulator() const =0
Create a new HashTransformation to accumulate the message to be verified.
 
virtual bool VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLen) const
Check whether input signature is a valid signature for input message.
 
virtual DecodingResult RecoverMessage(byte *recoveredMessage, const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, const byte *signature, size_t signatureLength) const
Recover a message from its signature.
 
virtual bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const =0
Check whether messageAccumulator contains a valid signature and message, and restart messageAccumulat...
 
virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const =0
Input signature into a message accumulator.
 
virtual DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const =0
Recover a message from its signature.
 
virtual DecodingResult Recover(byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const
Recover a message from its signature.
 
virtual bool Verify(PK_MessageAccumulator *messageAccumulator) const
Check whether messageAccumulator contains a valid signature and message.
 
Interface for asymmetric algorithms using private keys.
 
virtual PrivateKey & AccessPrivateKey()=0
Retrieves a reference to a Private Key.
 
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Private Key.
 
virtual const PrivateKey & GetPrivateKey() const
Retrieves a reference to a Private Key.
 
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Private Key.
 
Interface for private keys.
 
Interface for asymmetric algorithms using public keys.
 
virtual PublicKey & AccessPublicKey()=0
Retrieves a reference to a Public Key.
 
virtual const PublicKey & GetPublicKey() const
Retrieves a reference to a Public Key.
 
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Public Key.
 
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Public Key.
 
Interface for public keys.
 
Interface for random number generators.
 
virtual void DiscardBytes(size_t n)
Generate and discard n bytes.
 
virtual word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL)
Generate a random 32 bit word in the range min to max, inclusive.
 
virtual byte GenerateByte()
Generate new random byte and return it.
 
virtual void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
 
virtual bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
 
virtual void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length)
Generate random bytes into a BufferedTransformation.
 
virtual unsigned int GenerateBit()
Generate new random bit and return it.
 
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
 
void Shuffle(IT begin, IT end)
Randomly shuffle the specified array.
 
Interface for domains of simple key agreement protocols.
 
virtual void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0
Generate a public key from a private key in this domain.
 
virtual unsigned int PublicKeyLength() const =0
Provides the size of the public key.
 
virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0
Derive agreed value.
 
virtual unsigned int PrivateKeyLength() const =0
Provides the size of the private key.
 
virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a private/public key pair.
 
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
 
virtual void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0
Generate private key in this domain.
 
Interface for algorithms that take byte strings as keys.
 
void SetKeyWithRounds(const byte *key, size_t length, int rounds)
Sets or reset the key of this object.
 
virtual size_t MinKeyLength() const =0
Returns smallest valid key length.
 
virtual void GetNextIV(RandomNumberGenerator &rng, byte *iv)
Retrieves a secure IV for the next message.
 
virtual bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
 
void SetKeyWithIV(const byte *key, size_t length, const byte *iv, size_t ivLength)
Sets or reset the key of this object.
 
bool IsResynchronizable() const
Determines if the object can be resynchronized.
 
virtual IV_Requirement IVRequirement() const =0
Minimal requirement for secure IVs.
 
IV_Requirement
Secure IVs requirements as enumerated values.
 
@ RANDOM_IV
The IV must be random and possibly predictable.
 
@ INTERNALLY_GENERATED_IV
The IV is set by the object.
 
@ UNPREDICTABLE_RANDOM_IV
The IV must be random and unpredictable.
 
virtual unsigned int MaxIVLength() const
Provides the maximum size of an IV.
 
virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs)
Sets or reset the key of this object.
 
bool CanUseRandomIVs() const
Determines if the object can use random IVs.
 
virtual size_t GetValidKeyLength(size_t keylength) const =0
Returns a valid key length for the algorithm.
 
virtual unsigned int MinIVLength() const
Provides the minimum size of an IV.
 
bool CanUsePredictableIVs() const
Determines if the object can use random but possibly predictable IVs.
 
void SetKeyWithIV(const byte *key, size_t length, const byte *iv)
Sets or reset the key of this object.
 
virtual unsigned int IVSize() const
Returns length of the IV accepted by this object.
 
virtual size_t MaxKeyLength() const =0
Returns largest valid key length.
 
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
 
virtual size_t DefaultKeyLength() const =0
Returns default key length.
 
unsigned int DefaultIVLength() const
Provides the default size of an IV.
 
bool CanUseStructuredIVs() const
Determines if the object can use structured IVs.
 
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
 
Interface for objects that can be waited on.
 
virtual unsigned int GetMaxWaitObjectCount() const =0
Maximum number of wait objects that this object can return.
 
virtual void GetWaitObjects(WaitObjectContainer &container, CallStack const &callStack)=0
Retrieves waitable objects.
 
bool Wait(unsigned long milliseconds, CallStack const &callStack)
Wait on this object.
 
Library configuration file.
 
#define CRYPTOPP_API
Win32 calling convention.
 
const lword LWORD_MAX
Large word type max value.
 
unsigned int word32
32-bit unsigned datatype
 
unsigned short word16
16-bit unsigned datatype
 
unsigned long long word64
64-bit unsigned datatype
 
word64 lword
Large word type.
 
#define CRYPTOPP_VERSION
Full library version.
 
int HeaderVersion()
Specifies the runtime version of the library.
 
CipherDir
Specifies a direction for a cipher to operate.
 
@ ENCRYPTION
the cipher is performing encryption
 
@ DECRYPTION
the cipher is performing decryption
 
int LibraryVersion(...)
Specifies the build-time version of the library.
 
const unsigned long INFINITE_TIME
Represents infinite time.
 
CRYPTOPP_DLL BufferedTransformation & TheBitBucket()
An input discarding BufferedTransformation.
 
CRYPTOPP_DLL RandomNumberGenerator & NullRNG()
Random Number Generator that does not produce random numbers.
 
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
 
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
 
ByteOrder
Provides the byte ordering.
 
@ LITTLE_ENDIAN_ORDER
byte order is little-endian
 
@ BIG_ENDIAN_ORDER
byte order is big-endian
 
EnumToType< ByteOrder, LITTLE_ENDIAN_ORDER > LittleEndian
Provides a constant for LittleEndian.
 
EnumToType< ByteOrder, BIG_ENDIAN_ORDER > BigEndian
Provides a constant for BigEndian.
 
const std::string AAD_CHANNEL
Channel for additional authenticated data.
 
Crypto++ library namespace.
 
Namespace containing NaCl library functions.
 
Namespace containing value name definitions.
 
Namespace containing testing and benchmark classes.
 
Namespace containing weak and wounded algorithms.
 
Returns a decoding results.
 
DecodingResult(size_t len)
Constructs a DecodingResult.
 
bool operator!=(const DecodingResult &rhs) const
Compare two DecodingResult.
 
bool operator==(const DecodingResult &rhs) const
Compare two DecodingResult.
 
DecodingResult()
Constructs a DecodingResult.
 
bool isValidCoding
Flag to indicate the decoding is valid.
 
size_t messageLength
Recovered message length if isValidCoding is true, undefined otherwise.
 
Converts an enumeration to a type suitable for use as a template parameter.
 
Interface for password based key derivation functions.
 
Debugging and diagnostic assertions.
 
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.