102 #ifndef CRYPTOPP_CRYPTLIB_H 103 #define CRYPTOPP_CRYPTLIB_H 109 #if CRYPTOPP_MSC_VERSION 110 # pragma warning(push) 111 # pragma warning(disable: 4127 4189 4505 4702) 134 template <
typename ENUM_TYPE,
int VALUE>
137 static ENUM_TYPE ToEnum() {
return static_cast<ENUM_TYPE
>(VALUE);}
186 const char *
what()
const throw() {
return (m_what.c_str());}
188 const std::string &
GetWhat()
const {
return m_what;}
190 void SetWhat(
const std::string &s) {m_what = s;}
197 ErrorType m_errorType;
263 OS_Error(
ErrorType errorType,
const std::string &s,
const std::string& operation,
int errorCode)
264 :
Exception(errorType, s), m_operation(operation), m_errorCode(errorCode) {}
272 std::string m_operation;
336 ValueTypeMismatch(
const std::string &name,
const std::type_info &stored,
const std::type_info &retrieving)
337 :
InvalidArgument(
"NameValuePairs: type mismatch for '" + name +
"', stored '" + stored.name() +
"', trying to retrieve '" + retrieving.name() +
"'")
338 , m_stored(stored), m_retrieving(retrieving) {}
349 const std::type_info &m_stored;
350 const std::type_info &m_retrieving;
359 return GetValue((std::string(
"ThisObject:")+
typeid(T).name()).c_str(),
object);
368 return GetValue((std::string(
"ThisPointer:")+
typeid(T).name()).c_str(), ptr);
395 bool result =
GetValue(name, value);
397 if (result) {
return value;}
405 {std::string result;
GetValue(
"ValueNames", result);
return result;}
471 throw InvalidArgument(std::string(className) +
": missing required parameter '" + name +
"'");
486 throw InvalidArgument(std::string(className) +
": missing required parameter '" + name +
"'");
499 CRYPTOPP_DLL
virtual bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const =0;
503 #if CRYPTOPP_DOXYGEN_PROCESSING 538 #if CRYPTOPP_DOXYGEN_PROCESSING 546 DOCUMENTED_NAMESPACE_BEGIN(
Name)
548 DOCUMENTED_NAMESPACE_END
561 DOCUMENTED_NAMESPACE_BEGIN(
Weak)
563 DOCUMENTED_NAMESPACE_END
568 DOCUMENTED_NAMESPACE_BEGIN(
NaCl)
570 DOCUMENTED_NAMESPACE_END
575 DOCUMENTED_NAMESPACE_BEGIN(
Test)
577 DOCUMENTED_NAMESPACE_END
611 Algorithm(
bool checkSelfTestStatus =
true);
648 virtual size_t MinKeyLength()
const =0;
652 virtual size_t MaxKeyLength()
const =0;
656 virtual size_t DefaultKeyLength()
const =0;
666 virtual size_t GetValidKeyLength(
size_t keylength)
const =0;
673 {
return keylength == GetValidKeyLength(keylength);}
689 void SetKeyWithRounds(
const byte *key,
size_t length,
int rounds);
699 void SetKeyWithIV(
const byte *key,
size_t length,
const byte *iv,
size_t ivLength);
709 {SetKeyWithIV(key, length, iv, IVSize());}
734 virtual IV_Requirement IVRequirement()
const =0;
762 {
throw NotImplemented(GetAlgorithm().AlgorithmName() +
": this object doesn't support resynchronization");}
784 CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(ivLength);
785 throw NotImplemented(GetAlgorithm().AlgorithmName() +
": this object doesn't support resynchronization");
802 virtual const Algorithm & GetAlgorithm()
const =0;
809 virtual void UncheckedSetKey(
const byte *key,
unsigned int length,
const NameValuePairs ¶ms) =0;
814 void ThrowIfInvalidKeyLength(
size_t length);
821 void ThrowIfResynchronizable();
830 void ThrowIfInvalidIV(
const byte *iv);
835 size_t ThrowIfInvalidIVLength(
int length);
846 inline void AssertValidKeyLength(
size_t length)
const 869 virtual void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const =0;
880 {ProcessAndXorBlock(inBlock, NULLPTR, outBlock);}
889 {ProcessAndXorBlock(inoutBlock, NULLPTR, inoutBlock);}
893 virtual unsigned int BlockSize()
const =0;
898 virtual unsigned int OptimalDataAlignment()
const;
907 virtual bool IsForwardTransformation()
const =0;
917 BT_InBlockIsCounter=1,
919 BT_DontIncrementInOutPointers=2,
923 BT_ReverseDirection=8,
925 BT_AllowParallel=16};
935 virtual size_t AdvancedProcessBlocks(
const byte *inBlocks,
const byte *xorBlocks,
byte *outBlocks,
size_t length,
word32 flags)
const;
981 virtual unsigned int OptimalDataAlignment()
const;
990 virtual void ProcessData(
byte *outString,
const byte *inString,
size_t length) =0;
1004 virtual size_t ProcessLastBlock(
byte *outString,
size_t outLength,
const byte *inString,
size_t inLength);
1061 {ProcessData(inoutString, inoutString, length);}
1069 {ProcessData(outString, inString, length);}
1075 {ProcessData(&input, &input, 1);
return input;}
1079 virtual bool IsRandomAccess()
const =0;
1088 CRYPTOPP_UNUSED(pos);
1090 throw NotImplemented(
"StreamTransformation: this object doesn't support random access");
1097 virtual bool IsSelfInverting()
const =0;
1102 virtual bool IsForwardTransformation()
const =0;
1125 virtual void Update(
const byte *input,
size_t length) =0;
1148 {TruncatedFinal(NULLPTR, 0);}
1177 virtual unsigned int OptimalDataAlignment()
const;
1189 {Update(input, length); Final(digest);}
1201 {
return TruncatedVerify(digest,
DigestSize());}
1217 {Update(input, length);
return Verify(digest);}
1226 virtual void TruncatedFinal(
byte *digest,
size_t digestSize) =0;
1239 {Update(input, length); TruncatedFinal(digest, digestSize);}
1253 virtual bool TruncatedVerify(
const byte *digest,
size_t digestLength);
1270 {Update(input, length);
return TruncatedVerify(digest, digestLength);}
1277 void ThrowIfInvalidTruncatedSize(
size_t size)
const;
1285 const Algorithm & GetAlgorithm()
const {
return *
this;}
1293 const Algorithm & GetAlgorithm()
const {
return *
this;}
1301 const Algorithm & GetAlgorithm()
const {
return *
this;}
1331 explicit BadState(
const std::string &name,
const char *message) :
Exception(OTHER_ERROR, name +
": " + message) {}
1332 explicit BadState(
const std::string &name,
const char *
function,
const char *state) :
Exception(OTHER_ERROR, name +
": " +
function +
" was called before " + state) {}
1337 virtual lword MaxHeaderLength()
const =0;
1341 virtual lword MaxMessageLength()
const =0;
1363 void SpecifyDataLengths(
lword headerLength,
lword messageLength,
lword footerLength=0);
1377 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);
1394 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);
1423 virtual void UncheckedSpecifyDataLengths(
lword headerLength,
lword messageLength,
lword footerLength)
1424 {CRYPTOPP_UNUSED(headerLength); CRYPTOPP_UNUSED(messageLength); CRYPTOPP_UNUSED(footerLength);}
1449 CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(length);
1450 throw NotImplemented(
"RandomNumberGenerator: IncorporateEntropy not implemented");
1462 virtual byte GenerateByte();
1469 virtual unsigned int GenerateBit();
1488 virtual void GenerateBlock(
byte *output,
size_t size);
1504 virtual void DiscardBytes(
size_t n);
1510 template <
class IT>
void Shuffle(IT begin, IT end)
1513 for (; begin != end; ++begin)
1514 std::iter_swap(begin, begin + GenerateWord32(0, static_cast<word32>(end-begin-1)));
1533 virtual size_t MinDerivedKeyLength()
const;
1537 virtual size_t MaxDerivedKeyLength()
const;
1542 virtual size_t GetValidDerivedLength(
size_t keylength)
const =0;
1549 return keylength == GetValidDerivedLength(keylength);
1576 virtual const Algorithm & GetAlgorithm()
const =0;
1581 void ThrowIfInvalidDerivedKeyLength(
size_t length)
const;
1598 class WaitObjectContainer;
1609 virtual unsigned int GetMaxWaitObjectCount()
const =0;
1619 virtual void GetWaitObjects(WaitObjectContainer &container, CallStack
const& callStack) =0;
1625 bool Wait(
unsigned long milliseconds, CallStack
const& callStack);
1674 {
return Put(&inByte, 1, blocking);}
1683 size_t Put(
const byte *inString,
size_t length,
bool blocking=
true)
1684 {
return Put2(inString, length, 0, blocking);}
1721 {size=0;
return NULLPTR;}
1736 {
return PutModifiable2(inString, length, 0, blocking);}
1744 {
return !!Put2(NULLPTR, 0, propagation < 0 ? -1 : propagation+1, blocking);}
1758 {
return Put2(inString, length, propagation < 0 ? -1 : propagation+1, blocking);}
1768 virtual size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking) =0;
1779 {
return Put2(inString, length, messageEnd, blocking);}
1800 void GetWaitObjects(WaitObjectContainer &container, CallStack
const& callStack);
1817 CRYPTOPP_UNUSED(parameters);
1818 throw NotImplemented(
"BufferedTransformation: this object can't be reinitialized");
1826 virtual bool IsolatedFlush(
bool hardFlush,
bool blocking) =0;
1833 {CRYPTOPP_UNUSED(blocking);
return false;}
1864 virtual bool Flush(
bool hardFlush,
int propagation=-1,
bool blocking=
true);
1875 virtual bool MessageSeriesEnd(
int propagation=-1,
bool blocking=
true);
1882 {CRYPTOPP_UNUSED(propagation);}
1901 virtual lword MaxRetrievable()
const;
1905 virtual bool AnyRetrievable()
const;
1911 virtual size_t Get(
byte &outByte);
1918 virtual size_t Get(
byte *outString,
size_t getMax);
1925 virtual size_t Peek(
byte &outByte)
const;
1933 virtual size_t Peek(
byte *outString,
size_t peekMax)
const;
1992 {TransferTo2(target, transferMax, channel);
return transferMax;}
2014 {
return CopyRangeTo(target, 0, copyMax, channel);}
2027 {
lword i = position; CopyRangeTo2(target, i, i+copyMax, channel);
return i-position;}
2035 virtual lword TotalBytesRetrievable()
const;
2041 virtual unsigned int NumberOfMessages()
const;
2046 virtual bool AnyMessages()
const;
2052 virtual bool GetNextMessage();
2060 virtual unsigned int SkipMessages(
unsigned int count=UINT_MAX);
2072 {TransferMessagesTo2(target, count, channel);
return count;}
2086 virtual void SkipAll();
2094 {TransferAllTo2(target, channel);}
2195 {
return ChannelPut(channel, &inByte, 1, blocking);}
2204 size_t ChannelPut(
const std::string &channel,
const byte *inString,
size_t length,
bool blocking=
true)
2205 {
return ChannelPut2(channel, inString, length, 0, blocking);}
2215 {
return ChannelPutModifiable2(channel, inString, length, 0, blocking);}
2253 {
return !!ChannelPut2(channel, NULLPTR, 0, propagation < 0 ? -1 : propagation+1, blocking);}
2265 {
return ChannelPut2(channel, inString, length, propagation < 0 ? -1 : propagation+1, blocking);}
2278 virtual byte * ChannelCreatePutSpace(
const std::string &channel,
size_t &size);
2287 virtual size_t ChannelPut2(
const std::string &channel,
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
2296 virtual size_t ChannelPutModifiable2(
const std::string &channel,
byte *inString,
size_t length,
int messageEnd,
bool blocking);
2306 virtual bool ChannelFlush(
const std::string &channel,
bool hardFlush,
int propagation=-1,
bool blocking=
true);
2318 virtual bool ChannelMessageSeriesEnd(
const std::string &channel,
int propagation=-1,
bool blocking=
true);
2323 virtual void SetRetrievalChannel(
const std::string &channel);
2358 throw NotImplemented(
"BufferedTransformation: this object is not attachable");
2369 static int DecrementPropagation(
int propagation)
2370 {
return propagation != 0 ? propagation - 1 : 0;}
2428 {
if (!Validate(rng, level))
throw InvalidMaterial(
"CryptoMaterial: this object contains invalid values");}
2440 {CRYPTOPP_UNUSED(bt);
throw NotImplemented(
"CryptoMaterial: this object does not support saving");}
2457 {CRYPTOPP_UNUSED(bt);
throw NotImplemented(
"CryptoMaterial: this object does not support loading");}
2473 CRYPTOPP_UNUSED(precomputationStorage);
CRYPTOPP_ASSERT(!SupportsPrecomputation());
2474 throw NotImplemented(
"CryptoMaterial: this object does not support precomputation");
2482 {CRYPTOPP_UNUSED(storedPrecomputation);
CRYPTOPP_ASSERT(!SupportsPrecomputation());
throw NotImplemented(
"CryptoMaterial: this object does not support precomputation");}
2489 {CRYPTOPP_UNUSED(storedPrecomputation);
CRYPTOPP_ASSERT(!SupportsPrecomputation());
throw NotImplemented(
"CryptoMaterial: this object does not support precomputation");}
2495 #if defined(__SUNPRO_CC) 2500 char m_sunCCworkaround;
2521 CRYPTOPP_UNUSED(rng); CRYPTOPP_UNUSED(params);
2522 throw NotImplemented(
"GeneratableCryptoMaterial: this object does not support key/parameter generation");
2578 {AccessMaterial().
Load(bt);}
2585 {GetMaterial().Save(bt);}
2600 {
return AccessPublicKey();}
2604 {
return GetPublicKey();}
2608 virtual PublicKey & AccessPublicKey() =0;
2668 virtual size_t MaxPlaintextLength(
size_t ciphertextLength)
const =0;
2673 virtual size_t CiphertextLength(
size_t plaintextLength)
const =0;
2680 virtual bool ParameterSupported(
const char *name)
const =0;
2718 const byte *plaintext,
size_t plaintextLength,
2752 const byte *ciphertext,
size_t ciphertextLength,
2865 {
throw NotImplemented(
"PK_MessageAccumulator: DigestSize() should not be called");}
2870 CRYPTOPP_UNUSED(digest); CRYPTOPP_UNUSED(digestSize);
2871 throw NotImplemented(
"PK_MessageAccumulator: TruncatedFinal() should not be called");
2892 virtual void InputRecoverableMessage(
PK_MessageAccumulator &messageAccumulator,
const byte *recoverableMessage,
size_t recoverableMessageLength)
const =0;
2930 virtual size_t SignMessageWithRecovery(
RandomNumberGenerator &rng,
const byte *recoverableMessage,
size_t recoverableMessageLength,
2931 const byte *nonrecoverableMessage,
size_t nonrecoverableMessageLength,
byte *signature)
const;
2955 virtual void InputSignature(
PK_MessageAccumulator &messageAccumulator,
const byte *signature,
size_t signatureLength)
const =0;
2975 virtual bool VerifyMessage(
const byte *message,
size_t messageLen,
2976 const byte *signature,
size_t signatureLen)
const;
3003 const byte *nonrecoverableMessage,
size_t nonrecoverableMessageLength,
3004 const byte *signature,
size_t signatureLength)
const;
3019 virtual unsigned int AgreedValueLength()
const =0;
3023 virtual unsigned int PrivateKeyLength()
const =0;
3027 virtual unsigned int PublicKeyLength()
const =0;
3063 virtual bool Agree(
byte *agreedValue,
const byte *privateKey,
const byte *otherPublicKey,
bool validateOtherPublicKey=
true)
const =0;
3078 virtual unsigned int AgreedValueLength()
const =0;
3082 virtual unsigned int StaticPrivateKeyLength()
const =0;
3086 virtual unsigned int StaticPublicKeyLength()
const =0;
3112 virtual unsigned int EphemeralPrivateKeyLength()
const =0;
3116 virtual unsigned int EphemeralPublicKeyLength()
const =0;
3154 virtual bool Agree(
byte *agreedValue,
3155 const byte *staticPrivateKey,
const byte *ephemeralPrivateKey,
3156 const byte *staticOtherPublicKey,
const byte *ephemeralOtherPublicKey,
3157 bool validateStaticOtherPublicKey=
true)
const =0;
3183 class ProtocolSession
3190 ProtocolError(ErrorType errorType,
const std::string &s) :
Exception(errorType, s) {}
3195 class UnexpectedMethodCall :
public Exception 3198 UnexpectedMethodCall(
const std::string &s) :
Exception(OTHER_ERROR, s) {}
3201 virtual ~ProtocolSession() {}
3203 ProtocolSession() : m_rng(NULLPTR), m_throwOnProtocolError(true), m_validState(false) {}
3207 bool GetThrowOnProtocolError()
const {
return m_throwOnProtocolError;}
3208 void SetThrowOnProtocolError(
bool throwOnProtocolError) {m_throwOnProtocolError = throwOnProtocolError;}
3210 bool HasValidState()
const {
return m_validState;}
3212 virtual bool OutgoingMessageAvailable()
const =0;
3213 virtual unsigned int GetOutgoingMessageLength()
const =0;
3214 virtual void GetOutgoingMessage(
byte *message) =0;
3216 virtual bool LastMessageProcessed()
const =0;
3217 virtual void ProcessIncomingMessage(
const byte *message,
unsigned int messageLength) =0;
3221 void CheckAndHandleInvalidState()
const;
3222 void SetValidState(
bool valid) {m_validState = valid;}
3227 bool m_throwOnProtocolError, m_validState;
3230 class KeyAgreementSession :
public ProtocolSession
3233 virtual ~KeyAgreementSession() {}
3235 virtual unsigned int GetAgreedValueLength()
const =0;
3236 virtual void GetAgreedValue(
byte *agreedValue)
const =0;
3239 class PasswordAuthenticatedKeyAgreementSession :
public KeyAgreementSession
3242 virtual ~PasswordAuthenticatedKeyAgreementSession() {}
3245 const byte *myId,
unsigned int myIdLength,
3246 const byte *counterPartyId,
unsigned int counterPartyIdLength,
3247 const byte *passwordOrVerifier,
unsigned int passwordOrVerifierLength);
3255 virtual ~PasswordAuthenticatedKeyAgreementDomain() {}
3261 virtual unsigned int GetPasswordVerifierLength(
const byte *password,
unsigned int passwordLength)
const =0;
3262 virtual void GeneratePasswordVerifier(
RandomNumberGenerator &rng,
const byte *userId,
unsigned int userIdLength,
const byte *password,
unsigned int passwordLength,
byte *verifier)
const =0;
3264 enum RoleFlags {CLIENT=1, SERVER=2, INITIATOR=4, RESPONDER=8};
3266 virtual bool IsValidRole(
unsigned int role) =0;
3267 virtual PasswordAuthenticatedKeyAgreementSession * CreateProtocolSession(
unsigned int role)
const =0;
3375 #if CRYPTOPP_MSC_VERSION 3376 # pragma warning(pop)
Base class for all exceptions thrown by the library.
int HeaderVersion()
Specifies the runtime version of the library.
Exception thrown when invalid crypto material is detected.
virtual void Precompute(unsigned int precomputationStorage)
Perform precomputation.
the cipher is performing decryption
const char * DigestSize()
int, in bytes
An invalid argument was detected.
void SetKeyWithIV(const byte *key, size_t length, const byte *iv)
Sets or reset the key of this object.
virtual bool IsValidDerivedLength(size_t keylength) const
Returns whether keylength is a valid key length.
Interface for message authentication codes.
ErrorType
Error types or categories.
NotImplemented(const std::string &s)
Construct an NotImplemented.
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
#define CRYPTOPP_API
Win32 calling convention.
Interface for asymmetric algorithms.
virtual unsigned int MinIVLength() const
Provides the minimum size of an IV.
Namespace containing NaCl library functions.
virtual bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
Interface for public-key encryptors and decryptors.
ByteOrder
Provides the byte ordering.
const char * what() const
Retrieves a C-string describing the exception.
virtual void ThrowIfInvalid(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
The IV is set by the object.
The operating system reported an error.
Interface for authenticated encryption modes of operation.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
const std::type_info & GetStoredTypeInfo() const
Provides the stored type.
virtual void Load(BufferedTransformation &bt)
Loads a key from a BufferedTransformation.
Exception(ErrorType errorType, const std::string &s)
Construct a new Exception.
Exception thrown when the object is in the wrong state for the operation.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to Crypto Parameters.
CRYPTOPP_DLL std::string GetValueNames() const
Get a list of value names that can be retrieved.
Interface for public-key signers.
unsigned int word32
32-bit unsigned datatype
Interface for public-key encryptors.
Converts an enumeration to a type suitable for use as a template parameter.
bool GetThisObject(T &object) const
Get a copy of this object or subobject.
bool CanUseRandomIVs() const
Determines if the object can use random IVs.
CipherDir
Specifies a direction for a cipher to operate.
CRYPTOPP_DLL bool GetWord64Value(const char *name, word64 &value) const
Get a named value with type word64.
DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *ciphertext, byte *plaintext, const NameValuePairs ¶meters=g_nullNameValuePairs) const
Decrypt a fixed size ciphertext.
Flush(true) was called but it can't completely flush its buffers.
Thrown when an unexpected type is encountered.
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Private Key.
Interface for asymmetric algorithms using private keys.
virtual bool IsProbabilistic() const =0
Determines whether a signature scheme requires a random number generator.
ValueTypeMismatch(const std::string &name, const std::type_info &stored, const std::type_info &retrieving)
Construct a ValueTypeMismatch.
virtual bool AllowNonrecoverablePart() const =0
Determines whether the non-recoverable message part can be signed.
virtual Clonable * Clone() const
Copies this object.
EnumToType< ByteOrder, LITTLE_ENDIAN_ORDER > LittleEndian
Provides a constant for LittleEndian.
Library configuration file.
Interface for random number generators.
#define CRYPTOPP_VERSION
Full library version.
size_t messageLength
Recovered message length if isValidCoding is true, undefined otherwise.
virtual const PublicKey & GetPublicKey() const
Retrieves a reference to a Public Key.
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.
virtual size_t SignatureLength() const =0
Provides the signature length if it only depends on the key.
CRYPTOPP_DLL void GetRequiredIntParameter(const char *className, const char *name, int &value) const
Retrieves a required name/value pair.
OS_Error(ErrorType errorType, const std::string &s, const std::string &operation, int errorCode)
Construct an OS_Error.
Interface for private keys.
Interface for cloning objects.
virtual size_t FixedCiphertextLength() const
Provides the fixed ciphertext length, if one exists.
bool operator==(const OID &lhs, const OID &rhs)
Compare two OIDs for equality.
Data integerity check, such as CRC or MAC, failed.
byte order is little-endian
Interface for one direction (encryption or decryption) of a block cipher.
virtual CRYPTOPP_DLL bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Get a named value.
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
void SetWhat(const std::string &s)
Sets the error string for the exception.
Interface for objects that can be waited on.
the cipher is performing encryption
virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const
Save precomputation for later use.
const std::type_info & GetRetrievingTypeInfo() const
Provides the retrieveing type.
virtual size_t MaxRecoverableLength() const =0
Provides the length of longest message that can be recovered.
void DoQuickSanityCheck() const
Perform a quick sanity check.
Interface for domains of simple key agreement protocols.
virtual unsigned int GetMaxWaitObjectCount() const =0
Maximum number of wait objects that this object can return.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Private Key.
bool CanUsePredictableIVs() const
Determines if the object can use random but possibly predictable IVs.
Returns a decoding results.
virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation)
Retrieve previously saved precomputation.
Exception thrown when trying to encrypt plaintext of invalid length.
CRYPTOPP_DLL RandomNumberGenerator & NullRNG()
Random Number Generator that does not produce random numbers.
Input data was received that did not conform to expected format.
Interface for public-key decryptors.
virtual void GetWaitObjects(WaitObjectContainer &container, CallStack const &callStack)=0
Retrieves waitable objects.
A method was called which was not implemented.
Exception throw when the private or public key is too short to sign or verify.
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
virtual bool Validate(RandomNumberGenerator &rng, unsigned int level) const =0
Check this object for errors.
bool operator!=(const DecodingResult &rhs) const
Compare two DecodingResult.
virtual unsigned int MaxIVLength() const
Provides the maximum size of an IV.
unsigned int DigestSize() const
virtual bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
CRYPTOPP_DLL word64 GetWord64ValueWithDefault(const char *name, word64 defaultValue) const
Get a named value with type word64, with default.
Interface for encoding and decoding ASN1 objects.
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
unsigned long long word64
64-bit unsigned datatype
DecodingResult()
Constructs a DecodingResult.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Multiple precision integer with arithmetic operations.
DecodingResult(size_t len)
Constructs a DecodingResult.
Exception throw when the private or public key has a length that can't be used.
Interface for algorithms that take byte strings as keys.
bool operator==(const DecodingResult &rhs) const
Compare two DecodingResult.
CannotFlush(const std::string &s)
Construct an CannotFlush.
Interface for asymmetric algorithms using public keys.
virtual unsigned int IVSize() const
Returns length of the IV accepted by this object.
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...
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Namespace containing testing and benchmark classes.
virtual bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
bool CanUseStructuredIVs() const
Determines if the object can use structured IVs.
Interface for public-key signers and verifiers.
const std::string & GetOperation() const
Retrieve the operating system API that reported the error.
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
int GetErrorCode() const
Retrieve the error code returned by the operating system.
const char * BlockSize()
int, in bytes
const unsigned long INFINITE_TIME
Represents infinite time.
ErrorType GetErrorType() const
Retrieves the error type for the exception.
void GetRequiredParameter(const char *className, const char *name, T &value) const
Retrieves a required name/value pair.
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
Interface for all crypto algorithms.
unsigned short word16
16-bit unsigned datatype
Interface for accumulating messages to be signed or verified.
unsigned int DefaultIVLength() const
Provides the default size of an IV.
word64 lword
Large word type.
A decryption filter encountered invalid ciphertext.
Interface for key agreement algorithms.
unsigned char byte
8-bit unsigned datatype
IV_Requirement
Secure IVs requirements as enumerated values.
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Public Key.
virtual const CryptoParameters & GetCryptoParameters() const
Retrieves a reference to Crypto Parameters.
Interface for public-key signature verifiers.
void Shuffle(IT begin, IT end)
Randomly shuffle the specified array.
const lword LWORD_MAX
Large word type max value.
Debugging and diagnostic assertions.
InvalidArgument(const std::string &s)
Construct an InvalidArgument.
Interface for crypto material.
Interface for certificates.
virtual void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms=g_nullNameValuePairs)
Generate a random key or crypto parameters.
Interface for password based key derivation functions.
CryptoMaterial & AccessMaterial()
Retrieves a reference to Crypto Parameters.
An invalid argument was detected.
Interface for crypto material.
virtual bool RecoverablePartFirst() const =0
Determines whether the recoverable part must be input before the non-recoverable part.
Interface for crypto prameters.
bool GetThisPointer(T *&ptr) const
Get a pointer to this object.
CRYPTOPP_DLL BufferedTransformation & TheBitBucket()
An input discarding BufferedTransformation.
bool isValidCoding
Flag to indicate the decoding is valid.
Namespace containing value name definitions.
BufferedTransformation received a Flush(true) signal but can't flush buffers.
void SetErrorType(ErrorType errorType)
Sets the error type for the exceptions.
int LibraryVersion(...)
Specifies the build-time version of the library.
Interface for public keys.
Crypto++ library namespace.
bool GetValue(const char *name, T &value) const
Get a named value.
The IV must be random and unpredictable.
bool IsResynchronizable() const
Determines if the object can be resynchronized.
Interface for domains of authenticated key agreement protocols.
void TruncatedFinal(byte *digest, size_t digestSize)
A method was called which was not implemented.
const std::string AAD_CHANNEL
Channel for additional authenticated data.
virtual void BEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
Error reading from input device or writing to output device.
virtual void Save(BufferedTransformation &bt) const
Saves a key to a BufferedTransformation.
virtual bool SupportsPrecomputation() const
Determines whether the object supports precomputation.
virtual lword MaxFooterLength() const
Provides the maximum length of AAD.
virtual const PrivateKey & GetPrivateKey() const
Retrieves a reference to a Private Key.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Public Key.
virtual size_t MaxSignatureLength(size_t recoverablePartLength=0) const
Provides the maximum signature length produced given the length of the recoverable message part...
EnumToType< ByteOrder, BIG_ENDIAN_ORDER > BigEndian
Provides a constant for BigEndian.
Namespace containing weak and wounded algorithms.
virtual bool SignatureUpfront() const
Determines whether the signature must be input before the message.
virtual void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
InvalidCiphertext(const std::string &s)
Construct an InvalidCiphertext.
Interface for key derivation functions.
virtual size_t FixedMaxPlaintextLength() const
Provides the maximum plaintext length given a fixed ciphertext length.
Interface for retrieving values given their names.
Exception thrown when an ASN.1 BER decoing error is encountered.
The IV must be random and possibly predictable.
const std::string & GetWhat() const
Retrieves a string describing the exception.