diff --git a/src/libs/3rdparty/botan/botan.pro b/src/libs/3rdparty/botan/botan.pro new file mode 100644 index 00000000000..5712a1b40b7 --- /dev/null +++ b/src/libs/3rdparty/botan/botan.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += src \ No newline at end of file diff --git a/src/libs/3rdparty/botan/build/botan/adler32.h b/src/libs/3rdparty/botan/build/botan/adler32.h new file mode 100644 index 00000000000..98a28bc81da --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/adler32.h @@ -0,0 +1,35 @@ +/* +* Adler32 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ADLER32_H__ +#define BOTAN_ADLER32_H__ + +#include + +namespace Botan { + +/* +* Adler32 +*/ +class BOTAN_DLL Adler32 : public HashFunction + { + public: + void clear() throw() { S1 = 1; S2 = 0; } + std::string name() const { return "Adler32"; } + HashFunction* clone() const { return new Adler32; } + Adler32() : HashFunction(4) { clear(); } + ~Adler32() { clear(); } + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + void hash(const byte[], u32bit); + u16bit S1, S2; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/aes.h b/src/libs/3rdparty/botan/build/botan/aes.h new file mode 100644 index 00000000000..05e2e3123ab --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/aes.h @@ -0,0 +1,81 @@ +/** +* AES +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_AES_H__ +#define BOTAN_AES_H__ + +#include + +namespace Botan { + +/** +* Rijndael aka AES +*/ +class BOTAN_DLL AES : public BlockCipher + { + public: + void clear() throw(); + std::string name() const { return "AES"; } + BlockCipher* clone() const { return new AES; } + AES() : BlockCipher(16, 16, 32, 8) { ROUNDS = 14; } + AES(u32bit); + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + static u32bit S(u32bit); + + static const byte SE[256]; + static const byte SD[256]; + static const u32bit TE[1024]; + static const u32bit TD[1024]; + + u32bit ROUNDS; + + SecureBuffer EK; + SecureBuffer ME; + + SecureBuffer DK; + SecureBuffer MD; + }; + +/** +* AES-128 +*/ +class BOTAN_DLL AES_128 : public AES + { + public: + std::string name() const { return "AES-128"; } + BlockCipher* clone() const { return new AES_128; } + AES_128() : AES(16) {} + }; + +/** +* AES-192 +*/ +class BOTAN_DLL AES_192 : public AES + { + public: + std::string name() const { return "AES-192"; } + BlockCipher* clone() const { return new AES_192; } + AES_192() : AES(24) {} + }; + +/** +* AES-256 +*/ +class BOTAN_DLL AES_256 : public AES + { + public: + std::string name() const { return "AES-256"; } + BlockCipher* clone() const { return new AES_256; } + AES_256() : AES(32) {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/alg_id.h b/src/libs/3rdparty/botan/build/botan/alg_id.h new file mode 100644 index 00000000000..4a1ad2f30dd --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/alg_id.h @@ -0,0 +1,49 @@ +/* +* Algorithm Identifier +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ALGORITHM_IDENTIFIER_H__ +#define BOTAN_ALGORITHM_IDENTIFIER_H__ + +#include +#include +#include + +namespace Botan { + +/* +* Algorithm Identifier +*/ +class BOTAN_DLL AlgorithmIdentifier : public ASN1_Object + { + public: + enum Encoding_Option { USE_NULL_PARAM }; + + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + AlgorithmIdentifier() {} + AlgorithmIdentifier(const OID&, Encoding_Option); + AlgorithmIdentifier(const std::string&, Encoding_Option); + + AlgorithmIdentifier(const OID&, const MemoryRegion&); + AlgorithmIdentifier(const std::string&, const MemoryRegion&); + + OID oid; + SecureVector parameters; + }; + +/* +* Comparison Operations +*/ +bool BOTAN_DLL operator==(const AlgorithmIdentifier&, + const AlgorithmIdentifier&); +bool BOTAN_DLL operator!=(const AlgorithmIdentifier&, + const AlgorithmIdentifier&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/algo_cache.h b/src/libs/3rdparty/botan/build/botan/algo_cache.h new file mode 100644 index 00000000000..17ea9964a1c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/algo_cache.h @@ -0,0 +1,224 @@ +/** +* An algorithm cache (used by Algorithm_Factory) +*/ + +#ifndef BOTAN_ALGORITHM_CACHE_TEMPLATE_H__ +#define BOTAN_ALGORITHM_CACHE_TEMPLATE_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/** +* @param prov_name a provider name +* @return weight for this provider +*/ +u32bit static_provider_weight(const std::string& prov_name); + +/** +* Algorithm_Cache (used by Algorithm_Factory) +*/ +template +class Algorithm_Cache + { + public: + const T* get(const std::string& algo_spec, + const std::string& pref_provider); + + /** + * Add a new algorithm implementation to the cache + */ + void add(T* algo, + const std::string& requested_name, + const std::string& provider_name); + + /** + * Set the preferred provider + */ + void set_preferred_provider(const std::string& algo_spec, + const std::string& provider); + + /** + * Return the list of providers of this algorithm + */ + std::vector providers_of(const std::string& algo_name); + + Algorithm_Cache(Mutex* m) : mutex(m) {} + ~Algorithm_Cache(); + private: + typedef typename std::map >::iterator + algorithms_iterator; + + typedef typename std::map::iterator provider_iterator; + + algorithms_iterator find_algorithm(const std::string& algo_spec); + + Mutex* mutex; + std::map aliases; + std::map pref_providers; + std::map > algorithms; + }; + +/** +* Look for an algorithm implementation in the cache, also checking aliases +* Assumes object lock is held +*/ +template +typename Algorithm_Cache::algorithms_iterator +Algorithm_Cache::find_algorithm(const std::string& algo_spec) + { + algorithms_iterator algo = algorithms.find(algo_spec); + + // Not found? Check if a known alias + if(algo == algorithms.end()) + { + std::map::const_iterator alias = + aliases.find(algo_spec); + + if(alias != aliases.end()) + algo = algorithms.find(alias->second); + } + + return algo; + } + +/** +* Look for an algorithm implementation by a particular provider +*/ +template +const T* Algorithm_Cache::get(const std::string& algo_spec, + const std::string& requested_provider) + { + Mutex_Holder lock(mutex); + + algorithms_iterator algo = find_algorithm(algo_spec); + if(algo == algorithms.end()) // algo not found at all (no providers) + return 0; + + // If a provider is requested specifically, return it or fail entirely + if(requested_provider != "") + { + provider_iterator prov = algo->second.find(requested_provider); + if(prov != algo->second.end()) + return prov->second; + return 0; + } + + const T* prototype = 0; + std::string prototype_provider; + u32bit prototype_prov_weight = 0; + + const std::string pref_provider = search_map(pref_providers, algo_spec); + + for(provider_iterator i = algo->second.begin(); i != algo->second.end(); ++i) + { + const std::string prov_name = i->first; + const u32bit prov_weight = static_provider_weight(prov_name); + + // preferred prov exists, return immediately + if(prov_name == pref_provider) + return i->second; + + if(prototype == 0 || prov_weight > prototype_prov_weight) + { + prototype = i->second; + prototype_provider = i->first; + prototype_prov_weight = prov_weight; + } + } + + return prototype; + } + +/** +* Add an implementation to the cache +*/ +template +void Algorithm_Cache::add(T* algo, + const std::string& requested_name, + const std::string& provider) + { + if(!algo) + return; + + Mutex_Holder lock(mutex); + + delete algorithms[algo->name()][provider]; + algorithms[algo->name()][provider] = algo; + + if(algo->name() != requested_name && + aliases.find(requested_name) == aliases.end()) + { + aliases[requested_name] = algo->name(); + } + } + +/** +* Find the providers of this algo (if any) +*/ +template std::vector +Algorithm_Cache::providers_of(const std::string& algo_name) + { + Mutex_Holder lock(mutex); + + std::vector providers; + + algorithms_iterator algo = find_algorithm(algo_name); + + if(algo != algorithms.end()) + { + provider_iterator provider = algo->second.begin(); + + while(provider != algo->second.end()) + { + providers.push_back(provider->first); + ++provider; + } + } + + return providers; + } + +/** +* Set the preferred provider for an algorithm +*/ +template +void Algorithm_Cache::set_preferred_provider(const std::string& algo_spec, + const std::string& provider) + { + Mutex_Holder lock(mutex); + + pref_providers[algo_spec] = provider; + } + +/** +* Algorithm_Cache Destructor +*/ +template +Algorithm_Cache::~Algorithm_Cache() + { + algorithms_iterator algo = algorithms.begin(); + + while(algo != algorithms.end()) + { + provider_iterator provider = algo->second.begin(); + + while(provider != algo->second.end()) + { + delete provider->second; + ++provider; + } + + ++algo; + } + + delete mutex; + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/algo_factory.h b/src/libs/3rdparty/botan/build/botan/algo_factory.h new file mode 100644 index 00000000000..73e592013e5 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/algo_factory.h @@ -0,0 +1,132 @@ +/** +* Algorithm Factory +* (C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ALGORITHM_FACTORY_H__ +#define BOTAN_ALGORITHM_FACTORY_H__ + +#include +#include +#include + +namespace Botan { + +/** +* Forward declarations (don't need full definitions here) +*/ +class BlockCipher; +class StreamCipher; +class HashFunction; +class MessageAuthenticationCode; + +template class Algorithm_Cache; + +class Engine; + +/** +* Algorithm Factory +*/ +class BOTAN_DLL Algorithm_Factory + { + public: + /** + * Constructor + * @param engines_in the list of engines to use + * @param mf a mutex factory + */ + Algorithm_Factory(const std::vector& engines_in, + Mutex_Factory& mf); + + /** + * Destructor + */ + ~Algorithm_Factory(); + + /* + * Provider management + */ + std::vector providers_of(const std::string& algo_spec); + + void set_preferred_provider(const std::string& algo_spec, + const std::string& provider); + + /* + * Block cipher operations + */ + const BlockCipher* + prototype_block_cipher(const std::string& algo_spec, + const std::string& provider = ""); + + BlockCipher* make_block_cipher(const std::string& algo_spec, + const std::string& provider = ""); + + void add_block_cipher(BlockCipher* hash, const std::string& provider); + + /* + * Stream cipher operations + */ + const StreamCipher* + prototype_stream_cipher(const std::string& algo_spec, + const std::string& provider = ""); + + StreamCipher* make_stream_cipher(const std::string& algo_spec, + const std::string& provider = ""); + + void add_stream_cipher(StreamCipher* hash, const std::string& provider); + + /* + * Hash function operations + */ + const HashFunction* + prototype_hash_function(const std::string& algo_spec, + const std::string& provider = ""); + + HashFunction* make_hash_function(const std::string& algo_spec, + const std::string& provider = ""); + + void add_hash_function(HashFunction* hash, const std::string& provider); + + /* + * MAC operations + */ + const MessageAuthenticationCode* + prototype_mac(const std::string& algo_spec, + const std::string& provider = ""); + + MessageAuthenticationCode* make_mac(const std::string& algo_spec, + const std::string& provider = ""); + + void add_mac(MessageAuthenticationCode* mac, + const std::string& provider); + + /* + * Deprecated + */ + class BOTAN_DLL Engine_Iterator + { + public: + class Engine* next() { return af.get_engine_n(n++); } + Engine_Iterator(const Algorithm_Factory& a) : af(a) { n = 0; } + private: + const Algorithm_Factory& af; + u32bit n; + }; + friend class Engine_Iterator; + + private: + class Engine* get_engine_n(u32bit) const; + + std::vector engines; + + Algorithm_Cache* block_cipher_cache; + Algorithm_Cache* stream_cipher_cache; + Algorithm_Cache* hash_cache; + Algorithm_Cache* mac_cache; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/allocate.h b/src/libs/3rdparty/botan/build/botan/allocate.h new file mode 100644 index 00000000000..180f2c02141 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/allocate.h @@ -0,0 +1,37 @@ +/* +* Allocator +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ALLOCATOR_H__ +#define BOTAN_ALLOCATOR_H__ + +#include +#include + +namespace Botan { + +/* +* Allocator Interface +*/ +class BOTAN_DLL Allocator + { + public: + static Allocator* get(bool); + + virtual void* allocate(u32bit) = 0; + virtual void deallocate(void*, u32bit) = 0; + + virtual std::string type() const = 0; + + virtual void init() {} + virtual void destroy() {} + + virtual ~Allocator() {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/arc4.h b/src/libs/3rdparty/botan/build/botan/arc4.h new file mode 100644 index 00000000000..aa2cea7fea5 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/arc4.h @@ -0,0 +1,41 @@ +/* +* ARC4 +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ARC4_H__ +#define BOTAN_ARC4_H__ + +#include +#include + +namespace Botan { + +/* +* ARC4 +*/ +class BOTAN_DLL ARC4 : public StreamCipher + { + public: + void clear() throw(); + std::string name() const; + StreamCipher* clone() const { return new ARC4(SKIP); } + ARC4(u32bit = 0); + ~ARC4() { clear(); } + private: + void cipher(const byte[], byte[], u32bit); + void key_schedule(const byte[], u32bit); + void generate(); + + const u32bit SKIP; + + SecureBuffer buffer; + SecureBuffer state; + u32bit X, Y, position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/asn1_int.h b/src/libs/3rdparty/botan/build/botan/asn1_int.h new file mode 100644 index 00000000000..619f45b5334 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/asn1_int.h @@ -0,0 +1,108 @@ +/* +* ASN.1 Internals +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ASN1_H__ +#define BOTAN_ASN1_H__ + +#include +#include + +namespace Botan { + +/* +* ASN.1 Type and Class Tags +*/ +enum ASN1_Tag { + UNIVERSAL = 0x00, + APPLICATION = 0x40, + CONTEXT_SPECIFIC = 0x80, + PRIVATE = 0xC0, + + CONSTRUCTED = 0x20, + + EOC = 0x00, + BOOLEAN = 0x01, + INTEGER = 0x02, + BIT_STRING = 0x03, + OCTET_STRING = 0x04, + NULL_TAG = 0x05, + OBJECT_ID = 0x06, + ENUMERATED = 0x0A, + SEQUENCE = 0x10, + SET = 0x11, + + UTF8_STRING = 0x0C, + NUMERIC_STRING = 0x12, + PRINTABLE_STRING = 0x13, + T61_STRING = 0x14, + IA5_STRING = 0x16, + VISIBLE_STRING = 0x1A, + BMP_STRING = 0x1E, + + UTC_TIME = 0x17, + GENERALIZED_TIME = 0x18, + + NO_OBJECT = 0xFF00, + DIRECTORY_STRING = 0xFF01 +}; + +/* +* Basic ASN.1 Object Interface +*/ +class BOTAN_DLL ASN1_Object + { + public: + virtual void encode_into(class DER_Encoder&) const = 0; + virtual void decode_from(class BER_Decoder&) = 0; + virtual ~ASN1_Object() {} + }; + +/* +* BER Encoded Object +*/ +class BOTAN_DLL BER_Object + { + public: + void assert_is_a(ASN1_Tag, ASN1_Tag); + + ASN1_Tag type_tag, class_tag; + SecureVector value; + }; + +/* +* ASN.1 Utility Functions +*/ +class DataSource; + +namespace ASN1 { + +SecureVector put_in_sequence(const MemoryRegion&); +std::string to_string(const BER_Object&); +bool maybe_BER(DataSource&); + +} + +/* +* General BER Decoding Error Exception +*/ +struct BER_Decoding_Error : public Decoding_Error + { + BER_Decoding_Error(const std::string&); + }; + +/* +* Exception For Incorrect BER Taggings +*/ +struct BER_Bad_Tag : public BER_Decoding_Error + { + BER_Bad_Tag(const std::string&, ASN1_Tag); + BER_Bad_Tag(const std::string&, ASN1_Tag, ASN1_Tag); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/asn1_obj.h b/src/libs/3rdparty/botan/build/botan/asn1_obj.h new file mode 100644 index 00000000000..ea21c475f1e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/asn1_obj.h @@ -0,0 +1,160 @@ +/* +* Common ASN.1 Objects +* (C) 1999-2007 Jack Lloyd +* 2007 Yves Jerschow +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ASN1_OBJ_H__ +#define BOTAN_ASN1_OBJ_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/* +* Attribute +*/ +class BOTAN_DLL Attribute : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + OID oid; + MemoryVector parameters; + + Attribute() {} + Attribute(const OID&, const MemoryRegion&); + Attribute(const std::string&, const MemoryRegion&); + }; + +/* +* X.509 Time +*/ +class BOTAN_DLL X509_Time : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + std::string as_string() const; + std::string readable_string() const; + bool time_is_set() const; + + s32bit cmp(const X509_Time&) const; + + void set_to(const std::string&); + void set_to(const std::string&, ASN1_Tag); + + X509_Time(u64bit); + X509_Time(const std::string& = ""); + X509_Time(const std::string&, ASN1_Tag); + private: + bool passes_sanity_check() const; + u32bit year, month, day, hour, minute, second; + ASN1_Tag tag; + }; + +/* +* Simple String +*/ +class BOTAN_DLL ASN1_String : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + std::string value() const; + std::string iso_8859() const; + + ASN1_Tag tagging() const; + + ASN1_String(const std::string& = ""); + ASN1_String(const std::string&, ASN1_Tag); + private: + std::string iso_8859_str; + ASN1_Tag tag; + }; + +/* +* Distinguished Name +*/ +class BOTAN_DLL X509_DN : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + std::multimap get_attributes() const; + std::vector get_attribute(const std::string&) const; + + std::multimap contents() const; + + void add_attribute(const std::string&, const std::string&); + void add_attribute(const OID&, const std::string&); + + static std::string deref_info_field(const std::string&); + + void do_decode(const MemoryRegion&); + MemoryVector get_bits() const; + + X509_DN(); + X509_DN(const std::multimap&); + X509_DN(const std::multimap&); + private: + std::multimap dn_info; + MemoryVector dn_bits; + }; + +/* +* Alternative Name +*/ +class BOTAN_DLL AlternativeName : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + std::multimap contents() const; + + void add_attribute(const std::string&, const std::string&); + std::multimap get_attributes() const; + + void add_othername(const OID&, const std::string&, ASN1_Tag); + std::multimap get_othernames() const; + + bool has_items() const; + + AlternativeName(const std::string& = "", const std::string& = "", + const std::string& = "", const std::string& = ""); + private: + std::multimap alt_info; + std::multimap othernames; + }; + +/* +* Comparison Operations +*/ +bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&); + +bool BOTAN_DLL operator==(const X509_DN&, const X509_DN&); +bool BOTAN_DLL operator!=(const X509_DN&, const X509_DN&); +bool BOTAN_DLL operator<(const X509_DN&, const X509_DN&); + +/* +* Helper Functions +*/ +bool BOTAN_DLL is_string_type(ASN1_Tag); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/asn1_oid.h b/src/libs/3rdparty/botan/build/botan/asn1_oid.h new file mode 100644 index 00000000000..e6d077beeac --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/asn1_oid.h @@ -0,0 +1,96 @@ +/* +* ASN.1 OID +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ASN1_OID_H__ +#define BOTAN_ASN1_OID_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents ASN.1 object identifiers. +*/ +class BOTAN_DLL OID : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + /** + * Find out whether this OID is empty + * @return true is no OID value is set + */ + bool is_empty() const { return id.size() == 0; } + + /** + * Get this OID as list (vector) of its components. + * @return a vector representing this OID + */ + std::vector get_id() const { return id; } + + /** + * Get this OID as a string + * @return a string representing this OID + */ + std::string as_string() const; + + /** + * Compare two OIDs. + * @return true if they are equal, false otherwise + */ + bool operator==(const OID&) const; + + /** + * Reset this instance to an empty OID. + */ + void clear(); + + /** + * Add a component to this OID. + * @param new_comp the new component to add to the end of this OID + * @return a reference to *this + */ + OID& operator+=(u32bit new_comp); + + /** + * Construct an OID from a string. + * @param str a string in the form "a.b.c" etc., where a,b,c are numbers + */ + OID(const std::string& str = ""); + private: + std::vector id; + }; + +/** +* Append another component onto the OID. +* @param oid the OID to add the new component to +* @param new_comp the new component to add +*/ +OID operator+(const OID& oid, u32bit new_comp); + +/** +* Compare two OIDs. +* @param a the first OID +* @param b the second OID +* @return true if a is not equal to b +*/ +bool operator!=(const OID& a, const OID& b); + +/** +* Compare two OIDs. +* @param a the first OID +* @param b the second OID +* @return true if a is lexicographically smaller than b +*/ +bool operator<(const OID& a, const OID& b); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/auto_rng.h b/src/libs/3rdparty/botan/build/botan/auto_rng.h new file mode 100644 index 00000000000..f18f8e5cd5f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/auto_rng.h @@ -0,0 +1,44 @@ +/* +* Auto Seeded RNG +* (C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_AUTO_SEEDING_RNG_H__ +#define BOTAN_AUTO_SEEDING_RNG_H__ + +#include +#include + +namespace Botan { + +/** +* RNG that attempts to seed itself +*/ +class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator + { + public: + void randomize(byte out[], u32bit len) + { rng->randomize(out, len); } + bool is_seeded() const + { return rng->is_seeded(); } + void clear() throw() { rng->clear(); } + std::string name() const + { return "AutoSeeded(" + rng->name() + ")"; } + + void reseed(u32bit poll_bits = 256) { rng->reseed(poll_bits); } + void add_entropy_source(EntropySource* es) + { rng->add_entropy_source(es); } + void add_entropy(const byte in[], u32bit len) + { rng->add_entropy(in, len); } + + AutoSeeded_RNG(u32bit poll_bits = 256); + ~AutoSeeded_RNG() { delete rng; } + private: + RandomNumberGenerator* rng; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/base64.h b/src/libs/3rdparty/botan/build/botan/base64.h new file mode 100644 index 00000000000..aca02da14a7 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/base64.h @@ -0,0 +1,94 @@ +/* +* Base64 Encoder/Decoder +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BASE64_H__ +#define BOTAN_BASE64_H__ + +#include + +namespace Botan { + +/** +* This class represents a Base64 encoder. +*/ +class BOTAN_DLL Base64_Encoder : public Filter + { + public: + static void encode(const byte in[3], byte out[4]); + + /** + * Input a part of a message to the encoder. + * @param input the message to input as a byte array + * @param length the length of the byte array input + */ + void write(const byte input[], u32bit length); + + /** + * Inform the Encoder that the current message shall be closed. + */ + void end_msg(); + + /** + * Create a base64 encoder. + * @param breaks whether to use line breaks in the Streamcipheroutput + * @param length the length of the lines of the output + * @param t_n whether to use a trailing newline + */ + Base64_Encoder(bool breaks = false, u32bit length = 72, + bool t_n = false); + private: + void encode_and_send(const byte[], u32bit); + void do_output(const byte[], u32bit); + static const byte BIN_TO_BASE64[64]; + + const u32bit line_length; + const bool trailing_newline; + SecureVector in, out; + u32bit position, counter; + }; + +/** +* This object represents a Base64 decoder. +*/ +class BOTAN_DLL Base64_Decoder : public Filter + { + public: + static void decode(const byte input[4], byte output[3]); + + static bool is_valid(byte); + + /** + * Input a part of a message to the decoder. + * @param input the message to input as a byte array + * @param length the length of the byte array input + */ + void write(const byte input[], u32bit length); + + /** + * Inform the Encoder that the current message shall be closed. + */ + void end_msg(); + + /** + * Create a base64 encoder. + * @param checking the type of checking that shall be performed by + * the decoder + */ + Base64_Decoder(Decoder_Checking checking = NONE); + private: + void decode_and_send(const byte[], u32bit); + void handle_bad_char(byte); + static const byte BASE64_TO_BIN[256]; + + const Decoder_Checking checking; + SecureVector in, out; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/basefilt.h b/src/libs/3rdparty/botan/build/botan/basefilt.h new file mode 100644 index 00000000000..75625abb09c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/basefilt.h @@ -0,0 +1,99 @@ +/* +* Basic Filters +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BASEFILT_H__ +#define BOTAN_BASEFILT_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents Filter chains. A Filter chain is an ordered +* concatenation of Filters, the input to a Chain sequentially passes +* through all the Filters contained in the Chain. +*/ + +class BOTAN_DLL Chain : public Fanout_Filter + { + public: + void write(const byte input[], u32bit length) { send(input, length); } + + /** + * Construct a chain of up to four filters. The filters are set + * up in the same order as the arguments. + */ + Chain(Filter* = 0, Filter* = 0, Filter* = 0, Filter* = 0); + + /** + * Construct a chain from range of filters + * @param filter_arr the list of filters + * @param length how many filters + */ + Chain(Filter* filter_arr[], u32bit length); + }; + +/** +* This class represents a fork filter, whose purpose is to fork the +* flow of data. It causes an input message to result in n messages at +* the end of the filter, where n is the number of forks. +*/ +class BOTAN_DLL Fork : public Fanout_Filter + { + public: + void write(const byte input[], u32bit length) { send(input, length); } + void set_port(u32bit n) { Fanout_Filter::set_port(n); } + + /** + * Construct a Fork filter with up to four forks. + */ + Fork(Filter*, Filter*, Filter* = 0, Filter* = 0); + + /** + * Construct a Fork from range of filters + * @param filter_arr the list of filters + * @param length how many filters + */ + Fork(Filter* filter_arr[], u32bit length); + }; + +/** +* This class represents keyed filters, i.e. filters that have to be +* fed with a key in order to function. +*/ +class BOTAN_DLL Keyed_Filter : public Filter + { + public: + + /** + * Set the key of this filter. + * @param key the key to set + */ + virtual void set_key(const SymmetricKey& key); + + /** + * Set the initialization vector of this filter. + * @param iv the initialization vector to set + */ + virtual void set_iv(const InitializationVector&) {} + + /** + * Check whether a key length is valid for this filter. + * @param length the key length to be checked for validity + * @return true if the key length is valid, false otherwise + */ + virtual bool valid_keylength(u32bit length) const; + + Keyed_Filter() { base_ptr = 0; } + protected: + SymmetricAlgorithm* base_ptr; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/benchmark.h b/src/libs/3rdparty/botan/build/botan/benchmark.h new file mode 100644 index 00000000000..272cfdfa22d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/benchmark.h @@ -0,0 +1,59 @@ +/** +* Runtime benchmarking +* (C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RUNTIME_BENCHMARK_H__ +#define BOTAN_RUNTIME_BENCHMARK_H__ + +#include +#include +#include +#include +#include + +/** +* Choose some sort of default timer implementation to use, since some +* (like hardware tick counters and current Win32 timer) are not +* reliable for benchmarking. +*/ +#if defined(BOTAN_HAS_TIMER_POSIX) + #include +#elif defined(BOTAN_HAS_TIMER_UNIX) + #include +#endif + +namespace Botan { + +#if defined(BOTAN_HAS_TIMER_POSIX) + typedef POSIX_Timer Default_Benchmark_Timer; +#elif defined(BOTAN_HAS_TIMER_UNIX) + typedef Unix_Timer Default_Benchmark_Timer; +#else + /* I have not had good success using clock(), the results seem + * pretty bogus, but as a last resort it works. + */ + typedef ANSI_Clock_Timer Default_Benchmark_Timer; +#endif + +/** +* Algorithm benchmark +* @param name the name of the algorithm to test (cipher, hash, or MAC) +* @param milliseconds total time for the benchmark to run +* @param timer the timer to use +* @param rng the rng to use to generate random inputs +* @param af the algorithm factory used to create objects +* @return results a map from provider to speed in mebibytes per second +*/ +std::map +algorithm_benchmark(const std::string& name, + u32bit milliseconds, + Timer& timer, + RandomNumberGenerator& rng, + Algorithm_Factory& af); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/ber_dec.h b/src/libs/3rdparty/botan/build/botan/ber_dec.h new file mode 100644 index 00000000000..2e38af30187 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/ber_dec.h @@ -0,0 +1,122 @@ +/* +* BER Decoder +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BER_DECODER_H__ +#define BOTAN_BER_DECODER_H__ + +#include +#include + +namespace Botan { + +/* +* BER Decoding Object +*/ +class BOTAN_DLL BER_Decoder + { + public: + BER_Object get_next_object(); + void push_back(const BER_Object&); + + bool more_items() const; + BER_Decoder& verify_end(); + BER_Decoder& discard_remaining(); + + BER_Decoder start_cons(ASN1_Tag, ASN1_Tag = UNIVERSAL); + BER_Decoder& end_cons(); + + BER_Decoder& raw_bytes(MemoryRegion&); + + BER_Decoder& decode_null(); + BER_Decoder& decode(bool&); + BER_Decoder& decode(u32bit&); + BER_Decoder& decode(class BigInt&); + BER_Decoder& decode(MemoryRegion&, ASN1_Tag); + + BER_Decoder& decode(bool&, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + BER_Decoder& decode(u32bit&, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + BER_Decoder& decode(class BigInt&, + ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + BER_Decoder& decode(MemoryRegion&, ASN1_Tag, + ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + + BER_Decoder& decode(class ASN1_Object&); + + template + BER_Decoder& decode_optional(T&, ASN1_Tag, ASN1_Tag, const T& = T()); + + template + BER_Decoder& decode_list(std::vector&, bool = true); + + BER_Decoder& decode_optional_string(MemoryRegion&, + ASN1_Tag, u16bit); + + BER_Decoder(DataSource&); + BER_Decoder(const byte[], u32bit); + BER_Decoder(const MemoryRegion&); + BER_Decoder(const BER_Decoder&); + ~BER_Decoder(); + private: + BER_Decoder& operator=(const BER_Decoder&) { return (*this); } + + BER_Decoder* parent; + DataSource* source; + BER_Object pushed; + mutable bool owns; + }; + +/* +* Decode an OPTIONAL or DEFAULT element +*/ +template +BER_Decoder& BER_Decoder::decode_optional(T& out, + ASN1_Tag type_tag, + ASN1_Tag class_tag, + const T& default_value) + { + BER_Object obj = get_next_object(); + + if(obj.type_tag == type_tag && obj.class_tag == class_tag) + { + if(class_tag & CONSTRUCTED) + BER_Decoder(obj.value).decode(out).verify_end(); + else + { + push_back(obj); + decode(out, type_tag, class_tag); + } + } + else + { + out = default_value; + push_back(obj); + } + + return (*this); + } + +/* +* Decode a list of homogenously typed values +*/ +template +BER_Decoder& BER_Decoder::decode_list(std::vector& vec, bool clear_it) + { + if(clear_it) + vec.clear(); + + while(more_items()) + { + T value; + decode(value); + vec.push_back(value); + } + return (*this); + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/bigint.h b/src/libs/3rdparty/botan/build/botan/bigint.h new file mode 100644 index 00000000000..16a1bba96a0 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/bigint.h @@ -0,0 +1,534 @@ +/* +* BigInt +* (C) 1999-2008 Jack Lloyd +* 2007 FlexSecure +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BIGINT_H__ +#define BOTAN_BIGINT_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** + * Big Integer representation. This class defines an integer type, + * that can be very big. Additionally some helper functions are + * defined to work more comfortably. + + */ +class BOTAN_DLL BigInt + { + public: + /** + * Base-Enumerator (currently 8,10,16 and 256 are defined) + */ + enum Base { Octal = 8, Decimal = 10, Hexadecimal = 16, Binary = 256 }; + + /** + * Sign symbol definitions for positive and negative numbers + */ + enum Sign { Negative = 0, Positive = 1 }; + + /** + * Number types (Powers of 2) + */ + enum NumberType { Power2 }; + + /** + * DivideByZero Exception + */ + struct DivideByZero : public Exception + { DivideByZero() : Exception("BigInt divide by zero") {} }; + + /************* + * operators + *************/ + + /** + * += Operator + * @param y the BigInt to add to the local value + */ + BigInt& operator+=(const BigInt& y); + + /** + * -= Operator + * @param y the BigInt to subtract from the local value + */ + BigInt& operator-=(const BigInt& y); + + /** + * *= Operator + * @param y the BigInt to multiply with the local value + */ + BigInt& operator*=(const BigInt& y); + + /** + * /= Operator + * @param y the BigInt to divide the local value by + */ + BigInt& operator/=(const BigInt& y); + + /** + * %= Operator, modulo operator. + * @param y the modulus to reduce the local value by + */ + BigInt& operator%=(const BigInt& y); + + /** + * %= Operator + * @param y the modulus (word) to reduce the local value by + */ + word operator%=(word y); + + /** + * <<= Operator + * @param y the amount of bits to shift the local value left + */ + BigInt& operator<<=(u32bit y); + + /** + * >>= Operator + * @param y the amount of bits to shift the local value right + */ + BigInt& operator>>=(u32bit y); + + /** + * ++ Operator + */ + BigInt& operator++() { return (*this += 1); } + + /** + * -- Operator + */ + BigInt& operator--() { return (*this -= 1); } + + /** + * ++ Operator (postfix) + */ + BigInt operator++(int) { BigInt x = (*this); ++(*this); return x; } + + /** + * -- Operator (postfix) + */ + BigInt operator--(int) { BigInt x = (*this); --(*this); return x; } + + /** + * - Operator + */ + BigInt operator-() const; + + /** + * ! Operator + */ + bool operator !() const { return (!is_nonzero()); } + + /** + * [] Operator (array access) + */ + word& operator[](u32bit i) { return reg[i]; } + + /** + * [] Operator (array access) + */ + word operator[](u32bit i) const { return reg[i]; } + + /** + * Zeroize the BigInt + */ + void clear() { get_reg().clear(); } + + /************* + * functions + ************/ + + /** + * Compare *this to another BigInt. + * @param n the BigInt value to compare to the local value. + * @param check_signs Include sign in comparison? + * @result if (thisn) return 1, if both + * values are identical return 0. + */ + s32bit cmp(const BigInt& n, bool check_signs = true) const; + + /** + * Test if the integer has an even value + * @result true, if the integer an even value, false otherwise + */ + bool is_even() const { return (get_bit(0) == 0); } + + /** + * Test if the integer has an odd value + * @result true, if the integer an odd value, false otherwise + */ + bool is_odd() const { return (get_bit(0) == 1); } + + /** + * Test if the integer is not zero. + * @result true, if the integer has a non-zero value, false otherwise + */ + bool is_nonzero() const { return (!is_zero()); } + + /** + * Test if the integer is zero. + * @result true, if the integer has the value zero, false otherwise + */ + bool is_zero() const + { + const u32bit sw = sig_words(); + + for(u32bit i = 0; i != sw; ++i) + if(reg[i]) + return false; + return true; + } + + /** + * Set bit at specified position + * @param n bit position to set + */ + void set_bit(u32bit n); + + /** + * Clear bit at specified position + * @param n bit position to clear + */ + void clear_bit(u32bit n); + + /** + * Clear all but the lowest n bits + * @param n amount of bits to keep + */ + void mask_bits(u32bit n); + + /** + * Return bit value at specified position + * @param n the bit offset to test + * @result true, if the bit at position n is set, false otherwise + */ + bool get_bit(u32bit n) const; + + /** + * Return (a maximum of) 32 bits of the complete value + * @param offset the offset to start extracting + * @param length amount of bits to extract (starting at offset) + * @result the integer extracted from the register starting at + * offset with specified length + */ + u32bit get_substring(u32bit offset, u32bit length) const; + + byte byte_at(u32bit) const; + + /** + * Return the word at a specified position of the internal register + * @param n position in the register + * @return the value at position n + */ + word word_at(u32bit n) const + { return ((n < size()) ? reg[n] : 0); } + + /** + * Return the integer as an unsigned 32bit-integer-value. If the + * value is negative OR to big to be stored in 32bits, this + * function will throw an exception. + * @result a 32bit-integer + */ + u32bit to_u32bit() const; + + /** + * Tests if the sign of the integer is negative. + * @result true, if the integer has a negative sign, + */ + bool is_negative() const { return (sign() == Negative); } + + /** + * Tests if the sign of the integer is positive. + * @result true, if the integer has a positive sign, + */ + bool is_positive() const { return (sign() == Positive); } + + /** + * Return the sign of the integer + * @result the sign of the integer + */ + Sign sign() const { return (signedness); } + + /** + * Return the opposite sign of the represented integer value + * @result the opposite sign of the represented integer value + */ + Sign reverse_sign() const; + + /** + * Flip (change!) the sign of the integer to its opposite value + */ + void flip_sign(); + + /** + * Set sign of the integer + * @param sign new Sign to set + */ + void set_sign(Sign sign); + + /** + * Give absolute (positive) value of the integer + * @result absolute (positive) value of the integer + */ + BigInt abs() const; + + /** + * Give size of internal register + * @result size of internal register in words + */ + u32bit size() const { return get_reg().size(); } + + /** + * Give significant words of the represented integer value + * @result significant words of the represented integer value + */ + u32bit sig_words() const + { + const word* x = reg.begin(); + u32bit sig = reg.size(); + + while(sig && (x[sig-1] == 0)) + sig--; + return sig; + } + + /** + * Give byte-length of the integer + * @result byte-length of the represented integer value + */ + u32bit bytes() const; + + /** + * Get the bit-length of the integer. + * @result bit-length of the represented integer value + */ + u32bit bits() const; + + /** + * Return a pointer to the big integer word register. + * @result a pointer to the start of the internal register of + * the integer value + */ + const word* data() const { return reg.begin(); } + + /** + * return a reference to the internal register containing the value + * @result a reference to the word-array (SecureVector) + * with the internal register value (containing the integer + * value) + */ + SecureVector& get_reg() { return reg; } + + /** + * return a const reference to the internal register containing the value + * @result a const reference to the word-array (SecureVector) + * with the internal register value (containing the integer + * value) + */ + const SecureVector& get_reg() const { return reg; } + + /** + * Increase internal register buffer by n words + * @param n increase by n words + */ + void grow_reg(u32bit n); + + void grow_to(u32bit n); + + /** + * Fill BigInt with a random number with size of bitsize + * @param rng the random number generator to use + * @param bitsize number of bits the created random value should have + */ + void randomize(RandomNumberGenerator& rng, u32bit bitsize = 0); + + /** + * Store BigInt-value in a given byte array + * @param buf destination byte array for the integer value + */ + void binary_encode(byte buf[]) const; + + /** + * Read integer value from a byte array with given size + * @param buf byte array buffer containing the integer + * @param length size of buf + */ + void binary_decode(const byte buf[], u32bit length); + + /** + * Read integer value from a byte array (MemoryRegion) + * @param buf the BigInt value to compare to the local value. + */ + void binary_decode(const MemoryRegion& buf); + + u32bit encoded_size(Base = Binary) const; + + /** + @param rng a random number generator + @result a random integer between min and max + */ + static BigInt random_integer(RandomNumberGenerator& rng, + const BigInt& min, const BigInt& max); + + /** + * Encode the integer value from a BigInt to a SecureVector of bytes + * @param n the BigInt to use as integer source + * @param base number-base of resulting byte array representation + * @result SecureVector of bytes containing the integer with given base + */ + static SecureVector encode(const BigInt& n, Base base = Binary); + + /** + * Encode the integer value from a BigInt to a byte array + * @param buf destination byte array for the encoded integer + * value with given base + * @param n the BigInt to use as integer source + * @param base number-base of resulting byte array representation + */ + static void encode(byte buf[], const BigInt& n, Base base = Binary); + + /** + * Create a BigInt from an integer in a byte array + * @param buf the BigInt value to compare to the local value. + * @param length size of buf + * @param base number-base of the integer in buf + * @result BigInt-representing the given integer read from the byte array + */ + static BigInt decode(const byte buf[], u32bit length, + Base base = Binary); + + static BigInt decode(const MemoryRegion&, Base = Binary); + + /** + * Encode a Big Integer to a byte array according to IEEE1363. + * @param n the Big Integer to encode + * @param bytes the length of the resulting SecureVector + * @result a SecureVector containing the encoded Big Integer + */ + static SecureVector encode_1363(const BigInt& n, u32bit bytes); + + /** + * Swap BigInt-value with given BigInt. + * @param bigint the BigInt to swap values with + */ + void swap(BigInt& bigint); + + /** + * constructors + */ + + /** + * Create empty BigInt + */ + BigInt() { signedness = Positive; } + + /** + * Create BigInt from 64bit-Integer value + * @param n 64bit-integer + */ + BigInt(u64bit n); + + /** + * Copy-Constructor: clone given BigInt + * @param bigint the BigInt to clone + */ + BigInt(const BigInt& bigint); + + /** + * Create BigInt from a string. + * If the string starts with 0x the rest of the string will be + * interpreted as hexadecimal digits. + * If the string starts with 0 and the second character is NOT + * an 'x' the string will be interpreted as octal digits. + * If the string starts with non-zero digit, it will be + * interpreted as a decimal number. + * @param str the string to parse for an integer value + */ + BigInt(const std::string& str); + + /** + * Create a BigInt from an integer in a byte array + * @param buf the BigInt value to compare to the local value. + * @param length size of buf + * @param base number-base of the integer in buf + */ + BigInt(const byte buf[], u32bit length, Base base = Binary); + + /** + * Create a random BigInt of the specified size + * @param rng random number generator + * @param bits size in bits + */ + BigInt(RandomNumberGenerator& rng, u32bit bits); + + /** + * Create BigInt from unsigned 32 bit integer value and an + * also specify the sign of the value + * @param n integer value + */ + BigInt(Sign, u32bit n); + + /** + * Create a number of the specified type and size + * @param type the type of number to create + * @param n the size + */ + BigInt(NumberType type, u32bit n); + + private: + SecureVector reg; + Sign signedness; + }; + +/* +* Arithmetic Operators +*/ +BigInt BOTAN_DLL operator+(const BigInt&, const BigInt&); +BigInt BOTAN_DLL operator-(const BigInt&, const BigInt&); +BigInt BOTAN_DLL operator*(const BigInt&, const BigInt&); +BigInt BOTAN_DLL operator/(const BigInt&, const BigInt&); +BigInt BOTAN_DLL operator%(const BigInt&, const BigInt&); +word BOTAN_DLL operator%(const BigInt&, word); +BigInt BOTAN_DLL operator<<(const BigInt&, u32bit); +BigInt BOTAN_DLL operator>>(const BigInt&, u32bit); + +/* +* Comparison Operators +*/ +inline bool operator==(const BigInt& a, const BigInt& b) + { return (a.cmp(b) == 0); } +inline bool operator!=(const BigInt& a, const BigInt& b) + { return (a.cmp(b) != 0); } +inline bool operator<=(const BigInt& a, const BigInt& b) + { return (a.cmp(b) <= 0); } +inline bool operator>=(const BigInt& a, const BigInt& b) + { return (a.cmp(b) >= 0); } +inline bool operator<(const BigInt& a, const BigInt& b) + { return (a.cmp(b) < 0); } +inline bool operator>(const BigInt& a, const BigInt& b) + { return (a.cmp(b) > 0); } + +/* +* I/O Operators +*/ +BOTAN_DLL std::ostream& operator<<(std::ostream&, const BigInt&); +BOTAN_DLL std::istream& operator>>(std::istream&, BigInt&); + +} + +namespace std { + +inline void swap(Botan::BigInt& a, Botan::BigInt& b) { a.swap(b); } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/bit_ops.h b/src/libs/3rdparty/botan/build/botan/bit_ops.h new file mode 100644 index 00000000000..c02ec536fe2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/bit_ops.h @@ -0,0 +1,91 @@ +/* +* Bit/Word Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BIT_OPS_H__ +#define BOTAN_BIT_OPS_H__ + +#include + +namespace Botan { + +/* +* Return true iff arg is 2**n for some n > 0 +* T should be an unsigned integer type +*/ +template +inline bool power_of_2(T arg) + { + return ((arg != 0 && arg != 1) && ((arg & (arg-1)) == 0)); + } + +/* +* Return the index of the highest set bit +* T is an unsigned integer type +*/ +template +inline u32bit high_bit(T n) + { + for(u32bit i = 8*sizeof(T); i > 0; --i) + if((n >> (i - 1)) & 0x01) + return i; + return 0; + } + +/* +* Return the index of the lowest set bit +*/ +template +inline u32bit low_bit(T n) + { + for(u32bit i = 0; i != 8*sizeof(T); ++i) + if((n >> i) & 0x01) + return (i + 1); + return 0; + } + +/* +* Return the number of significant bytes in n +*/ +template +inline u32bit significant_bytes(T n) + { + for(u32bit j = 0; j != sizeof(T); ++j) + if(get_byte(j, n)) + return sizeof(T)-j; + return 0; + } + +/* +* Return the Hamming weight of n +*/ +template +inline u32bit hamming_weight(T n) + { + const byte NIBBLE_WEIGHTS[] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; + + u32bit weight = 0; + for(u32bit i = 0; i != 2*sizeof(T); ++i) + weight += NIBBLE_WEIGHTS[(n >> (4*i)) & 0x0F]; + return weight; + } + +/* +* Count the trailing zero bits in n +*/ +template +inline u32bit ctz(T n) + { + for(u32bit i = 0; i != 8*sizeof(T); ++i) + if((n >> i) & 0x01) + return i; + return 8*sizeof(T); + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/blinding.h b/src/libs/3rdparty/botan/build/botan/blinding.h new file mode 100644 index 00000000000..5f7f9e6b7dc --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/blinding.h @@ -0,0 +1,34 @@ +/* +* Blinder +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BLINDER_H__ +#define BOTAN_BLINDER_H__ + +#include +#include + +namespace Botan { + +/* +* Blinding Function Object +*/ +class BOTAN_DLL Blinder + { + public: + BigInt blind(const BigInt&) const; + BigInt unblind(const BigInt&) const; + + Blinder() {} + Blinder(const BigInt&, const BigInt&, const BigInt&); + private: + Modular_Reducer reducer; + mutable BigInt e, d; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/block_cipher.h b/src/libs/3rdparty/botan/build/botan/block_cipher.h new file mode 100644 index 00000000000..01c45af0421 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/block_cipher.h @@ -0,0 +1,100 @@ +/** +* Block Cipher Base Class +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BLOCK_CIPHER_H__ +#define BOTAN_BLOCK_CIPHER_H__ + +#include + +namespace Botan { + +/** +* This class represents a block cipher object. +* +* It would be very useful to extend this interface to support the +* encryption of multiple blocks at a time. This could help +* performance, wrt cache effects in the software implementations, and +* could be a big deal when supporting block ciphers implemented as +* hardware devices. It could be used by implementations of ECB, and +* more importantly counter mode (which most designs are moving to, due +* to the parallelism possible in counter mode which is not the case +* with feedback-based modes like CBC). +* +* Probable future API here: +* virtual void encrypt_n(const byte in[], byte out[], +* u32bit blocks) const = 0; +* virtual void decrypt_n(const byte in[], byte out[], +* u32bit blocks) const = 0; +*/ +class BOTAN_DLL BlockCipher : public SymmetricAlgorithm + { + public: + /** + * The block size of this algorithm. + */ + const u32bit BLOCK_SIZE; + + /** + * Encrypt a block. + * @param in The plaintext block to be encrypted as a byte array. + * Must be of length BLOCK_SIZE. + * @param out The byte array designated to hold the encrypted block. + * Must be of length BLOCK_SIZE. + */ + void encrypt(const byte in[], byte out[]) const { enc(in, out); } + + /** + * Decrypt a block. + * @param in The ciphertext block to be decypted as a byte array. + * Must be of length BLOCK_SIZE. + * @param out The byte array designated to hold the decrypted block. + * Must be of length BLOCK_SIZE. + */ + void decrypt(const byte in[], byte out[]) const { dec(in, out); } + + /** + * Encrypt a block. + * @param in The plaintext block to be encrypted as a byte array. + * Must be of length BLOCK_SIZE. Will hold the result when the function + * has finished. + */ + void encrypt(byte block[]) const { enc(block, block); } + + /** + * Decrypt a block. + * @param in The ciphertext block to be decrypted as a byte array. + * Must be of length BLOCK_SIZE. Will hold the result when the function + * has finished. + */ + void decrypt(byte block[]) const { dec(block, block); } + + /** + * Get a new object representing the same algorithm as *this + */ + virtual BlockCipher* clone() const = 0; + + /** + * Zeroize internal state + */ + virtual void clear() throw() = 0; + + BlockCipher(u32bit block_size, + u32bit key_min, + u32bit key_max = 0, + u32bit key_mod = 1) : + SymmetricAlgorithm(key_min, key_max, key_mod), + BLOCK_SIZE(block_size) {} + + virtual ~BlockCipher() {} + private: + virtual void enc(const byte[], byte[]) const = 0; + virtual void dec(const byte[], byte[]) const = 0; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/blowfish.h b/src/libs/3rdparty/botan/build/botan/blowfish.h new file mode 100644 index 00000000000..f0f26418d2f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/blowfish.h @@ -0,0 +1,40 @@ +/* +* Blowfish +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BLOWFISH_H__ +#define BOTAN_BLOWFISH_H__ + +#include + +namespace Botan { + +/* +* Blowfish +*/ +class BOTAN_DLL Blowfish : public BlockCipher + { + public: + void clear() throw(); + std::string name() const { return "Blowfish"; } + BlockCipher* clone() const { return new Blowfish; } + Blowfish() : BlockCipher(8, 1, 56) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + void generate_sbox(u32bit[], u32bit, u32bit&, u32bit&) const; + + static const u32bit P_INIT[18]; + static const u32bit S_INIT[1024]; + + SecureBuffer S; + SecureBuffer P; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/botan.h b/src/libs/3rdparty/botan/build/botan/botan.h new file mode 100644 index 00000000000..3fa131216e1 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/botan.h @@ -0,0 +1,18 @@ +/** +* A vague catch all include file for Botan +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include +#include +#include +#include + +#include + +#if defined(BOTAN_HAS_AUTO_SEEDING_RNG) + #include +#endif diff --git a/src/libs/3rdparty/botan/build/botan/bswap.h b/src/libs/3rdparty/botan/build/botan/bswap.h new file mode 100644 index 00000000000..ec1e8143585 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/bswap.h @@ -0,0 +1,62 @@ +/* +* Byte Swapping Operations +* (C) 1999-2008 Jack Lloyd +* (C) 2007 Yves Jerschow +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BYTE_SWAP_H__ +#define BOTAN_BYTE_SWAP_H__ + +#include +#include + +namespace Botan { + +/* +* Byte Swapping Functions +*/ +inline u16bit reverse_bytes(u16bit input) + { + return rotate_left(input, 8); + } + +inline u32bit reverse_bytes(u32bit input) + { +#if BOTAN_USE_GCC_INLINE_ASM && \ + (defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64)) + + /* GCC-style inline assembly for x86 or x86-64 */ + asm("bswapl %0" : "=r" (input) : "0" (input)); + return input; + +#elif defined(_MSC_VER) && defined(BOTAN_TARGET_ARCH_IS_IA32) + /* Visual C++ inline asm for 32-bit x86, by Yves Jerschow */ + __asm mov eax, input; + __asm bswap eax; + +#else + /* Generic implementation */ + input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); + return rotate_left(input, 16); +#endif + } + +inline u64bit reverse_bytes(u64bit input) + { +#if BOTAN_USE_GCC_INLINE_ASM && defined(BOTAN_TARGET_ARCH_IS_AMD64) + asm("bswapq %0" : "=r" (input) : "0" (input)); + return input; +#else + u32bit hi = ((input >> 40) & 0x00FF00FF) | ((input >> 24) & 0xFF00FF00); + u32bit lo = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); + hi = (hi << 16) | (hi >> 16); + lo = (lo << 16) | (lo >> 16); + return (static_cast(lo) << 32) | hi; +#endif + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/buf_comp.h b/src/libs/3rdparty/botan/build/botan/buf_comp.h new file mode 100644 index 00000000000..3f1e90bad3e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/buf_comp.h @@ -0,0 +1,126 @@ +/** +* BufferedComputation +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BUFFERED_COMPUTATION_H__ +#define BOTAN_BUFFERED_COMPUTATION_H__ + +#include + +namespace Botan { + +/** +* This class represents any kind of computation which +* uses an internal state, +* such as hash functions. +*/ +class BOTAN_DLL BufferedComputation + { + public: + + /** + * The length of the output of this function in bytes. + */ + const u32bit OUTPUT_LENGTH; + + /** + * Add new input to process. + * @param in the input to process as a byte array + * @param the length of the byte array + */ + void update(const byte in[], u32bit length) { add_data(in, length); } + + /** + * Add new input to process. + * @param in the input to process as a MemoryRegion + */ + void update(const MemoryRegion& in) { add_data(in, in.size()); } + + /** + * Add new input to process. + * @param str the input to process as a std::string. Will be interpreted + * as a byte array based on + * the strings encoding. + */ + void update(const std::string& str) + { + add_data(reinterpret_cast(str.data()), str.size()); + } + + /** + * Process a single byte. + * @param in the byte to process + */ + void update(byte in) { add_data(&in, 1); } + + /** + * Complete the computation and retrieve the + * final result. + * @param out The byte array to be filled with the result. + * Must be of length OUTPUT_LENGTH. + */ + void final(byte out[]) { final_result(out); } + + /** + * Complete the computation and retrieve the + * final result. + * @return a SecureVector holding the result + */ + SecureVector final() + { + SecureVector output(OUTPUT_LENGTH); + final_result(output); + return output; + } + + /** + * Update and finalize computation. Does the same as calling update() + * and final() consecutively. + * @param in the input to process as a byte array + * @param length the length of the byte array + * @result the result of the call to final() + */ + SecureVector process(const byte in[], u32bit length) + { + add_data(in, length); + return final(); + } + + /** + * Update and finalize computation. Does the same as calling update() + * and final() consecutively. + * @param in the input to process + * @result the result of the call to final() + */ + SecureVector process(const MemoryRegion& in) + { + add_data(in, in.size()); + return final(); + } + + /** + * Update and finalize computation. Does the same as calling update() + * and final() consecutively. + * @param in the input to process as a string + * @result the result of the call to final() + */ + SecureVector process(const std::string& in) + { + update(in); + return final(); + } + + BufferedComputation(u32bit out_len) : OUTPUT_LENGTH(out_len) {} + virtual ~BufferedComputation() {} + private: + BufferedComputation& operator=(const BufferedComputation&); + virtual void add_data(const byte[], u32bit) = 0; + virtual void final_result(byte[]) = 0; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/buf_filt.h b/src/libs/3rdparty/botan/build/botan/buf_filt.h new file mode 100644 index 00000000000..ce3dbc926b8 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/buf_filt.h @@ -0,0 +1,39 @@ +/* +* Buffering Filter +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BUFFERING_FILTER_H__ +#define BOTAN_BUFFERING_FILTER_H__ + +#include + +namespace Botan { + +/** +* Buffering_Filter: This class represents filters for operations that +* maintain an internal state. +*/ + +class BOTAN_DLL Buffering_Filter : public Filter + { + public: + void write(const byte[], u32bit); + virtual void end_msg(); + Buffering_Filter(u32bit, u32bit = 0); + virtual ~Buffering_Filter() {} + protected: + virtual void initial_block(const byte[]) {} + virtual void main_block(const byte[]) = 0; + virtual void final_block(const byte[], u32bit) = 0; + private: + const u32bit INITIAL_BLOCK_SIZE, BLOCK_SIZE; + SecureVector initial, block; + u32bit initial_block_pos, block_pos; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/build.h b/src/libs/3rdparty/botan/build/botan/build.h new file mode 100644 index 00000000000..99fc231dba6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/build.h @@ -0,0 +1,39 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BOTAN_BUILD_CONFIG_H_QT +#define BOTAN_BUILD_CONFIG_H_QT + +#include + +#if defined(Q_OS_WIN) +# include "build_windows.h" +#endif + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/build_windows.h b/src/libs/3rdparty/botan/build/botan/build_windows.h new file mode 100644 index 00000000000..2ac5852a395 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/build_windows.h @@ -0,0 +1,335 @@ + +#ifndef BOTAN_BUILD_CONFIG_H__ +#define BOTAN_BUILD_CONFIG_H__ + +/* This file was automatically generated Mon Jan 11 14:51:24 2010 UTC */ + +#define BOTAN_VERSION_MAJOR 1 +#define BOTAN_VERSION_MINOR 8 +#define BOTAN_VERSION_PATCH 8 + +#ifndef BOTAN_DLL + #define BOTAN_DLL __declspec(dllexport) +#endif + +/* Chunk sizes */ +#define BOTAN_DEFAULT_BUFFER_SIZE 4096 +#define BOTAN_MEM_POOL_CHUNK_SIZE 64*1024 + +/* BigInt toggles */ +#define BOTAN_MP_WORD_BITS 32 +#define BOTAN_KARAT_MUL_THRESHOLD 32 +#define BOTAN_KARAT_SQR_THRESHOLD 32 +#define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64 + +/* PK key consistency checking toggles */ +#define BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD 1 +#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD 1 +#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE 1 + +/* Should we use GCC-style inline assembler? */ +#if !defined(BOTAN_USE_GCC_INLINE_ASM) && defined(__GNUG__) + #define BOTAN_USE_GCC_INLINE_ASM 1 +#endif + +#ifndef BOTAN_USE_GCC_INLINE_ASM + #define BOTAN_USE_GCC_INLINE_ASM 0 +#endif + +/* Target identification and feature test macros */ +#define BOTAN_TARGET_OS_IS_WINDOWS +#define BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK + +#define BOTAN_TARGET_ARCH_IS_IA64 +#define BOTAN_TARGET_UNALIGNED_LOADSTOR_OK 0 + + + +/* Module definitions */ +#define BOTAN_HAS_ADLER32 +#define BOTAN_HAS_AES +#define BOTAN_HAS_ALGORITHM_FACTORY +#define BOTAN_HAS_ANSI_X919_MAC +#define BOTAN_HAS_ARC4 +#define BOTAN_HAS_ASN1 +#define BOTAN_HAS_AUTO_SEEDING_RNG +#define BOTAN_HAS_BASE64_CODEC +#define BOTAN_HAS_BIGINT +#define BOTAN_HAS_BIGINT_MATH +#define BOTAN_HAS_BLOCK_CIPHER +#define BOTAN_HAS_BLOWFISH +#define BOTAN_HAS_CAST +#define BOTAN_HAS_CBC +#define BOTAN_HAS_CBC_MAC +#define BOTAN_HAS_CFB +#define BOTAN_HAS_CIPHER_MODEBASE +#define BOTAN_HAS_CIPHER_MODE_PADDING +#define BOTAN_HAS_CMAC +#define BOTAN_HAS_CMS +#define BOTAN_HAS_CRC24 +#define BOTAN_HAS_CRC32 +#define BOTAN_HAS_CRYPTO_BOX +#define BOTAN_HAS_CTR +#define BOTAN_HAS_CTS +#define BOTAN_HAS_DEFAULT_ENGINE +#define BOTAN_HAS_DES +#define BOTAN_HAS_DIFFIE_HELLMAN +#define BOTAN_HAS_DLIES +#define BOTAN_HAS_DL_GROUP +#define BOTAN_HAS_DL_PUBLIC_KEY_FAMILY +#define BOTAN_HAS_DSA +#define BOTAN_HAS_EAX +#define BOTAN_HAS_ECB +#define BOTAN_HAS_ELGAMAL +#define BOTAN_HAS_EME1 +#define BOTAN_HAS_EME_PKCS1v15 +#define BOTAN_HAS_EMSA1 +#define BOTAN_HAS_EMSA1_BSI +#define BOTAN_HAS_EMSA2 +#define BOTAN_HAS_EMSA3 +#define BOTAN_HAS_EMSA4 +#define BOTAN_HAS_EMSA_RAW +#define BOTAN_HAS_ENGINES +#define BOTAN_HAS_ENTROPY_SRC_CAPI +#define BOTAN_HAS_ENTROPY_SRC_WIN32 +#define BOTAN_HAS_FILTERS +#define BOTAN_HAS_FORK_256 +#define BOTAN_HAS_GOST_28147_89 +#define BOTAN_HAS_GOST_34_11 +#define BOTAN_HAS_HASH_ID +#define BOTAN_HAS_HAS_160 +#define BOTAN_HAS_HEX_CODEC +#define BOTAN_HAS_HMAC +#define BOTAN_HAS_HMAC_RNG +#define BOTAN_HAS_IDEA +#define BOTAN_HAS_IF_PUBLIC_KEY_FAMILY +#define BOTAN_HAS_KASUMI +#define BOTAN_HAS_KDF1 +#define BOTAN_HAS_KDF2 +#define BOTAN_HAS_KDF_BASE +#define BOTAN_HAS_KEYPAIR_TESTING +#define BOTAN_HAS_LIBSTATE_MODULE +#define BOTAN_HAS_LION +#define BOTAN_HAS_LUBY_RACKOFF +#define BOTAN_HAS_MARS +#define BOTAN_HAS_MD2 +#define BOTAN_HAS_MD4 +#define BOTAN_HAS_MD5 +#define BOTAN_HAS_MDX_HASH_FUNCTION +#define BOTAN_HAS_MGF1 +#define BOTAN_HAS_MISTY1 +#define BOTAN_HAS_MUTEX_NOOP +#define BOTAN_HAS_MUTEX_WIN32 +#define BOTAN_HAS_MUTEX_WRAPPERS +#define BOTAN_HAS_NOEKEON +#define BOTAN_HAS_NYBERG_RUEPPEL +#define BOTAN_HAS_OFB +#define BOTAN_HAS_OID_LOOKUP +#define BOTAN_HAS_OPENPGP_CODEC +#define BOTAN_HAS_PARALLEL_HASH +#define BOTAN_HAS_PASSWORD_BASED_ENCRYPTION +#define BOTAN_HAS_PBE_PKCS_V15 +#define BOTAN_HAS_PBE_PKCS_V20 +#define BOTAN_HAS_PBKDF1 +#define BOTAN_HAS_PBKDF2 +#define BOTAN_HAS_PEM_CODEC +#define BOTAN_HAS_PGPS2K +#define BOTAN_HAS_PK_PADDING +#define BOTAN_HAS_PUBLIC_KEY_CRYPTO +#define BOTAN_HAS_RANDPOOL +#define BOTAN_HAS_RC2 +#define BOTAN_HAS_RC5 +#define BOTAN_HAS_RC6 +#define BOTAN_HAS_RIPEMD_128 +#define BOTAN_HAS_RIPEMD_160 +#define BOTAN_HAS_RSA +#define BOTAN_HAS_RUNTIME_BENCHMARKING +#define BOTAN_HAS_RW +#define BOTAN_HAS_SAFER +#define BOTAN_HAS_SALSA20 +#define BOTAN_HAS_SEED +#define BOTAN_HAS_SELFTESTS +#define BOTAN_HAS_SERPENT +#define BOTAN_HAS_SHA1 +#define BOTAN_HAS_SHA2 +#define BOTAN_HAS_SKEIN_512 +#define BOTAN_HAS_SKIPJACK +#define BOTAN_HAS_SQUARE +#define BOTAN_HAS_SSL3_MAC +#define BOTAN_HAS_SSL_V3_PRF +#define BOTAN_HAS_STREAM_CIPHER +#define BOTAN_HAS_TEA +#define BOTAN_HAS_TIGER +#define BOTAN_HAS_TIMER +#define BOTAN_HAS_TIMER_WIN32 +#define BOTAN_HAS_TLS_V10_PRF +#define BOTAN_HAS_TURING +#define BOTAN_HAS_TWOFISH +#define BOTAN_HAS_UTIL_FUNCTIONS +#define BOTAN_HAS_WHIRLPOOL +#define BOTAN_HAS_WID_WAKE +#define BOTAN_HAS_X509 +#define BOTAN_HAS_X931_RNG +#define BOTAN_HAS_X942_PRF +#define BOTAN_HAS_XTEA +#define BOTAN_HAS_XTS + +/* Local configuration options */ + + +/* +kheimric@deepburner ran 'E:\dev\creator\src\libs\3rdparty\botan\configure.py --cc=msvc --os=windows --cpu=ia64 --disable-asm' + +Target +------- +Compiler: cl.exe /O2 +Arch: ia64/ia64 +OS: windows + +Modules +------- +adler32 (Adler32) +aes (AES) +algo_factory (Algorithm Factory) +alloc (Allocator) +arc4 (ARC4) +asn1 (ASN.1/BER/DER module) +auto_rng (Auto-seeded Random Number Generator) +base64 (Base64 Codec) +benchmark (Benchmarking) +bigint (BigInt) +block (Block Ciphers) +blowfish (Blowfish) +buf_comp (Buffered Computation) +cast (CAST) +cbc (CBC block cipher mode) +cbc_mac (CBC-MAC) +cfb (CFB block cipher mode) +cmac (CMAC) +cms (CMS) +crc24 (CRC-24) +crc32 (CRC-32) +cryptoapi_rng (Win32 CryptoAPI Entropy Source) +cryptobox (Crypto Box) +ctr (CTR block cipher mode) +cts (CTS block cipher mode) +datastor (Datastore) +def_engine (Default Engine) +des (DES) +dh (Diffie-Hellman Key Agreement) +dl_algo (Discrete Logarithm PK Algorithms) +dl_group (DL Group) +dlies (DLIES) +dsa (DSA) +eax (EAX block cipher mode) +ecb (ECB block cipher mode) +elgamal (ElGamal) +eme1 (EME1) +eme_pkcs (PKCSv1 v1.5 EME) +emsa1 (EMSA1) +emsa1_bsi (EMSA1 (BSI variant)) +emsa2 (EMSA2) +emsa3 (EMSA3) +emsa4 (EMSA4) +emsa_raw (EMSA-Raw) +engine (Engines) +entropy (Entropy Sources) +filters (Pipe/Filter) +fork256 (FORK-256) +gost_28147 (GOST 28147-89) +gost_3411 (GOST 34.11) +has160 (HAS-160) +hash (Hash Functions) +hash_id (Hash Function Identifiers) +hex (Hex Codec) +hmac (HMAC) +hmac_rng (HMAC RNG) +idea (IDEA) +if_algo (Integer Factorization Algorithms) +kasumi (Kasumi) +kdf (KDF Base Class) +kdf1 (KDF1) +kdf2 (KDF2) +keypair (Keypair Testing) +libstate (Botan Libstate Module) +lion (Lion) +lubyrack (Luby-Rackoff) +mac (Message Authentication Codes) +mars (MARS) +md2 (MD2) +md4 (MD4) +md5 (MD5) +mdx_hash (MDx Hash Base) +mem_pool (Memory Pool Allocator) +mgf1 (MGF1) +misty1 (MISTY-1) +mode_pad (Cipher Mode Padding Method) +modes (Cipher Mode Base Class) +monty_generic (Montgomery Reduction) +mp_generic (MPI Core (C++)) +mulop_generic (BigInt Multiply-Add) +mutex (Mutex Wrappers) +noekeon (Noekeon) +noop_mutex (No-Op Mutex) +nr (Nyberg-Rueppel) +numbertheory (Math Functions) +ofb (OFB block cipher mode) +oid_lookup (OID Lookup) +openpgp (OpenPGP Codec) +par_hash (Parallel Hash) +pbe (PBE Base) +pbes1 (PKCS5 v1.5 PBE) +pbes2 (PKCS5 v2.0 PBE) +pbkdf1 (Pbkdf1) +pbkdf2 (Pbkdf2) +pem (PEM Codec) +pgps2k (Pgps2k) +pk_codecs (PK codecs (PKCS8, X.509)) +pk_pad (Public Key EME/EMSA Padding Modes) +pubkey (Public Key Base) +randpool (Randpool RNG) +rc2 (RC2) +rc5 (RC5) +rc6 (RC6) +rmd128 (RIPEMD-128) +rmd160 (RIPEMD-160) +rng (Random Number Generators) +rsa (RSA) +rw (Rabin-Williams) +s2k (String to Key Functions) +safer (SAFER) +salsa20 (Salsa20) +seed (SEED) +selftest (Selftests) +serpent (Serpent) +sha1 (SHA-1) +sha2 (SHA-2 (224, 256, 384, 512)) +skein (Skein) +skipjack (Skipjack) +square (Square) +ssl3mac (SSLv3 MAC) +ssl_prf (SSLv3 PRF) +stream (Stream Ciphers) +sym_algo (Symmetric Algorithms) +system_alloc (Default (Malloc) Allocators) +tea (TEA) +tiger (Tiger) +timer (Timer Base Class) +tls_prf (TLS v1.0 PRF) +turing (Turing) +twofish (Twofish) +utils (Utility Functions) +whirlpool (Whirlpool) +wid_wake (WiderWake) +win32_crit_section (Win32 Mutex) +win32_query_perf_ctr (Win32 Timer) +win32_stats (Win32 Entropy Source) +x509 (X.509) +x919_mac (ANSI X9.19 MAC) +x931_rng (ANSI X9.31 PRNG) +x942_prf (X942 PRF) +xtea (XTEA) +xts (XTS block cipher mode) +*/ + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cast128.h b/src/libs/3rdparty/botan/build/botan/cast128.h new file mode 100644 index 00000000000..68048148239 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cast128.h @@ -0,0 +1,47 @@ +/* +* CAST-128 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CAST128_H__ +#define BOTAN_CAST128_H__ + +#include + +namespace Botan { + +/* +* CAST-128 +*/ +class BOTAN_DLL CAST_128 : public BlockCipher + { + public: + void clear() throw() { MK.clear(); RK.clear(); } + std::string name() const { return "CAST-128"; } + BlockCipher* clone() const { return new CAST_128; } + CAST_128() : BlockCipher(8, 11, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + static void key_schedule(u32bit[16], u32bit[4]); + + static const u32bit S5[256]; + static const u32bit S6[256]; + static const u32bit S7[256]; + static const u32bit S8[256]; + + SecureBuffer MK, RK; + }; + +extern const u32bit CAST_SBOX1[256]; +extern const u32bit CAST_SBOX2[256]; +extern const u32bit CAST_SBOX3[256]; +extern const u32bit CAST_SBOX4[256]; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cast256.h b/src/libs/3rdparty/botan/build/botan/cast256.h new file mode 100644 index 00000000000..cd48edd5e75 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cast256.h @@ -0,0 +1,44 @@ +/* +* CAST-256 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CAST256_H__ +#define BOTAN_CAST256_H__ + +#include + +namespace Botan { + +/* +* CAST-256 +*/ +class BOTAN_DLL CAST_256 : public BlockCipher + { + public: + void clear() throw() { MK.clear(); RK.clear(); } + std::string name() const { return "CAST-256"; } + BlockCipher* clone() const { return new CAST_256; } + CAST_256() : BlockCipher(16, 4, 32, 4) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + static const u32bit KEY_MASK[192]; + static const byte KEY_ROT[32]; + + SecureBuffer MK; + SecureBuffer RK; + }; + +extern const u32bit CAST_SBOX1[256]; +extern const u32bit CAST_SBOX2[256]; +extern const u32bit CAST_SBOX3[256]; +extern const u32bit CAST_SBOX4[256]; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cbc.h b/src/libs/3rdparty/botan/build/botan/cbc.h new file mode 100644 index 00000000000..a926ac18061 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cbc.h @@ -0,0 +1,55 @@ +/* +* CBC Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CBC_H__ +#define BOTAN_CBC_H__ + +#include +#include + +namespace Botan { + +/* +* CBC Encryption +*/ +class BOTAN_DLL CBC_Encryption : public BlockCipherMode + { + public: + CBC_Encryption(BlockCipher*, BlockCipherModePaddingMethod*); + CBC_Encryption(BlockCipher*, BlockCipherModePaddingMethod*, + const SymmetricKey&, const InitializationVector&); + + ~CBC_Encryption() { delete padder; } + private: + std::string name() const; + void write(const byte[], u32bit); + void end_msg(); + const BlockCipherModePaddingMethod* padder; + }; + +/* +* CBC Decryption +*/ +class BOTAN_DLL CBC_Decryption : public BlockCipherMode + { + public: + CBC_Decryption(BlockCipher*, BlockCipherModePaddingMethod*); + CBC_Decryption(BlockCipher*, BlockCipherModePaddingMethod*, + const SymmetricKey&, const InitializationVector&); + + ~CBC_Decryption() { delete padder; } + private: + std::string name() const; + void write(const byte[], u32bit); + void end_msg(); + const BlockCipherModePaddingMethod* padder; + SecureVector temp; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cbc_mac.h b/src/libs/3rdparty/botan/build/botan/cbc_mac.h new file mode 100644 index 00000000000..d17d792d3a1 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cbc_mac.h @@ -0,0 +1,40 @@ +/* +* CBC-MAC +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CBC_MAC_H__ +#define BOTAN_CBC_MAC_H__ + +#include +#include + +namespace Botan { + +/* +* CBC-MAC +*/ +class BOTAN_DLL CBC_MAC : public MessageAuthenticationCode + { + public: + void clear() throw(); + std::string name() const; + MessageAuthenticationCode* clone() const; + + CBC_MAC(BlockCipher* e); + ~CBC_MAC(); + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + void key_schedule(const byte[], u32bit); + + BlockCipher* e; + SecureVector state; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/certstor.h b/src/libs/3rdparty/botan/build/botan/certstor.h new file mode 100644 index 00000000000..d5004e366c2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/certstor.h @@ -0,0 +1,39 @@ +/* +* Certificate Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CERT_STORE_H__ +#define BOTAN_CERT_STORE_H__ + +#include +#include + +namespace Botan { + +/* +* Certificate Store Interface +*/ +class BOTAN_DLL Certificate_Store + { + public: + virtual std::vector + by_SKID(const MemoryRegion&) const = 0; + + virtual std::vector by_name(const std::string&) const; + virtual std::vector by_email(const std::string&) const; + virtual std::vector by_dn(const X509_DN&) const; + + virtual std::vector + get_crls_for(const X509_Certificate&) const; + + virtual Certificate_Store* clone() const = 0; + + virtual ~Certificate_Store() {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cfb.h b/src/libs/3rdparty/botan/build/botan/cfb.h new file mode 100644 index 00000000000..7810c00e455 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cfb.h @@ -0,0 +1,47 @@ +/* +* CFB Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CFB_H__ +#define BOTAN_CFB_H__ + +#include + +namespace Botan { + +/* +* CFB Encryption +*/ +class BOTAN_DLL CFB_Encryption : public BlockCipherMode + { + public: + CFB_Encryption(BlockCipher*, u32bit = 0); + CFB_Encryption(BlockCipher*, const SymmetricKey&, + const InitializationVector&, u32bit = 0); + private: + void write(const byte[], u32bit); + void feedback(); + const u32bit FEEDBACK_SIZE; + }; + +/* +* CFB Decryption +*/ +class BOTAN_DLL CFB_Decryption : public BlockCipherMode + { + public: + CFB_Decryption(BlockCipher*, u32bit = 0); + CFB_Decryption(BlockCipher*, const SymmetricKey&, + const InitializationVector&, u32bit = 0); + private: + void write(const byte[], u32bit); + void feedback(); + const u32bit FEEDBACK_SIZE; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/charset.h b/src/libs/3rdparty/botan/build/botan/charset.h new file mode 100644 index 00000000000..eebb1997db9 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/charset.h @@ -0,0 +1,44 @@ +/* +* Character Set Handling +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CHARSET_H__ +#define BOTAN_CHARSET_H__ + +#include +#include + +namespace Botan { + +/** +* The different charsets (nominally) supported by Botan. +*/ +enum Character_Set { + LOCAL_CHARSET, + UCS2_CHARSET, + UTF8_CHARSET, + LATIN1_CHARSET +}; + +namespace Charset { + +/* +* Character Set Handling +*/ +std::string transcode(const std::string&, Character_Set, Character_Set); + +bool is_digit(char); +bool is_space(char); +bool caseless_cmp(char, char); + +byte char2digit(char); +char digit2char(byte); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cmac.h b/src/libs/3rdparty/botan/build/botan/cmac.h new file mode 100644 index 00000000000..5a6deb7b0bc --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cmac.h @@ -0,0 +1,44 @@ +/* +* CMAC +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CMAC_H__ +#define BOTAN_CMAC_H__ + +#include +#include + +namespace Botan { + +/* +* CMAC +*/ +class BOTAN_DLL CMAC : public MessageAuthenticationCode + { + public: + void clear() throw(); + std::string name() const; + MessageAuthenticationCode* clone() const; + + static SecureVector poly_double(const MemoryRegion& in, + byte polynomial); + + CMAC(BlockCipher* e); + ~CMAC(); + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + void key_schedule(const byte[], u32bit); + + BlockCipher* e; + SecureVector buffer, state, B, P; + u32bit position; + byte polynomial; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cms_dec.h b/src/libs/3rdparty/botan/build/botan/cms_dec.h new file mode 100644 index 00000000000..75b61c9cb3c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cms_dec.h @@ -0,0 +1,65 @@ +/* +* CMS Decoding +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CMS_DECODER_H__ +#define BOTAN_CMS_DECODER_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/* +* CMS Decoding Operation +*/ +class BOTAN_DLL CMS_Decoder + { + public: + enum Status { GOOD, BAD, NO_KEY, FAILURE }; + + enum Content_Type { DATA, UNKNOWN, COMPRESSED, ENVELOPED, SIGNED, + AUTHENTICATED, DIGESTED }; + + Status layer_status() const; + Content_Type layer_type() const; + std::string layer_info() const; + std::string layer_algo() const; + std::string get_data() const; + std::vector get_certs() const; + std::vector get_crls() const; + + void next_layer() { decode_layer(); } + + void add_key(PKCS8_PrivateKey*); + + CMS_Decoder(DataSource&, const X509_Store&, User_Interface&, + PKCS8_PrivateKey* = 0); + private: + std::string get_passphrase(const std::string&); + void read_econtent(BER_Decoder&); + void initial_read(DataSource&); + void decode_layer(); + void decompress(BER_Decoder&); + + User_Interface& ui; + + X509_Store store; + std::vector passphrases; + std::vector keys; + + OID type, next_type; + SecureVector data; + Status status; + std::string info; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cms_enc.h b/src/libs/3rdparty/botan/build/botan/cms_enc.h new file mode 100644 index 00000000000..6fdd2b7264f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cms_enc.h @@ -0,0 +1,92 @@ +/* +* CMS Encoding +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CMS_ENCODER_H__ +#define BOTAN_CMS_ENCODER_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* CMS Encoding Operation +*/ +class BOTAN_DLL CMS_Encoder + { + public: + + void encrypt(RandomNumberGenerator&, + const X509_Certificate&, const std::string = ""); + + void encrypt(RandomNumberGenerator& rng, + const std::string&, const std::string& = ""); + + void encrypt(RandomNumberGenerator& rng, + const SymmetricKey&, const std::string& = ""); + + void authenticate(const X509_Certificate&, const std::string& = ""); + void authenticate(const std::string&, const std::string& = ""); + void authenticate(const SymmetricKey&, const std::string& = ""); + + void sign(const X509_Certificate& cert, + const PKCS8_PrivateKey& key, + RandomNumberGenerator& rng, + const std::vector& cert_chain, + const std::string& hash, + const std::string& padding); + + void digest(const std::string& = ""); + + void compress(const std::string&); + static bool can_compress_with(const std::string&); + + SecureVector get_contents(); + std::string PEM_contents(); + + void set_data(const std::string&); + void set_data(const byte[], u32bit); + + CMS_Encoder(const std::string& str) { set_data(str); } + CMS_Encoder(const byte buf[], u32bit length) { set_data(buf, length); } + private: + void add_layer(const std::string&, DER_Encoder&); + + void encrypt_ktri(RandomNumberGenerator&, + const X509_Certificate&, PK_Encrypting_Key*, + const std::string&); + void encrypt_kari(RandomNumberGenerator&, + const X509_Certificate&, X509_PublicKey*, + const std::string&); + + SecureVector do_encrypt(RandomNumberGenerator& rng, + const SymmetricKey&, const std::string&); + + static SecureVector make_econtent(const SecureVector&, + const std::string&); + + static SymmetricKey setup_key(RandomNumberGenerator& rng, + const std::string&); + + static SecureVector wrap_key(RandomNumberGenerator& rng, + const std::string&, + const SymmetricKey&, + const SymmetricKey&); + + static SecureVector encode_params(const std::string&, + const SymmetricKey&, + const InitializationVector&); + + SecureVector data; + std::string type; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/crc24.h b/src/libs/3rdparty/botan/build/botan/crc24.h new file mode 100644 index 00000000000..bca4d0e8965 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/crc24.h @@ -0,0 +1,34 @@ +/* +* CRC24 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CRC24_H__ +#define BOTAN_CRC24_H__ + +#include + +namespace Botan { + +/* +* CRC24 +*/ +class BOTAN_DLL CRC24 : public HashFunction + { + public: + void clear() throw() { crc = 0xB704CE; } + std::string name() const { return "CRC24"; } + HashFunction* clone() const { return new CRC24; } + CRC24() : HashFunction(3) { clear(); } + ~CRC24() { clear(); } + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + u32bit crc; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/crc32.h b/src/libs/3rdparty/botan/build/botan/crc32.h new file mode 100644 index 00000000000..390fb100eac --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/crc32.h @@ -0,0 +1,34 @@ +/* +* CRC32 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CRC32_H__ +#define BOTAN_CRC32_H__ + +#include + +namespace Botan { + +/* +* CRC32 +*/ +class BOTAN_DLL CRC32 : public HashFunction + { + public: + void clear() throw() { crc = 0xFFFFFFFF; } + std::string name() const { return "CRC32"; } + HashFunction* clone() const { return new CRC32; } + CRC32() : HashFunction(4) { clear(); } + ~CRC32() { clear(); } + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + u32bit crc; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/crl_ent.h b/src/libs/3rdparty/botan/build/botan/crl_ent.h new file mode 100644 index 00000000000..050356c8445 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/crl_ent.h @@ -0,0 +1,78 @@ +/* +* CRL Entry +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CRL_ENTRY_H__ +#define BOTAN_CRL_ENTRY_H__ + +#include + +namespace Botan { + +/** +* This class represents CRL entries +*/ +class BOTAN_DLL CRL_Entry : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + /** + * Get the serial number of the certificate associated with this entry. + * @return the certificate's serial number + */ + MemoryVector serial_number() const { return serial; } + + /** + * Get the revocation date of the certificate associated with this entry + * @return the certificate's revocation date + */ + X509_Time expire_time() const { return time; } + + /** + * Get the entries reason code + * @return the reason code + */ + CRL_Code reason_code() const { return reason; } + + /** + * Construct an empty CRL entry. + */ + CRL_Entry(bool throw_on_unknown_critical_extension = false); + + /** + * Construct an CRL entry. + * @param cert the certificate to revoke + * @param reason the reason code to set in the entry + */ + CRL_Entry(const X509_Certificate&, CRL_Code = UNSPECIFIED); + + private: + bool throw_on_unknown_critical; + MemoryVector serial; + X509_Time time; + CRL_Code reason; + }; + +/** +* Test two CRL entries for equality in all fields. +*/ +BOTAN_DLL bool operator==(const CRL_Entry&, const CRL_Entry&); + +/** +* Test two CRL entries for inequality in at least one field. +*/ +BOTAN_DLL bool operator!=(const CRL_Entry&, const CRL_Entry&); + +/** +* Order two entries based on the revocation date. +*/ +BOTAN_DLL bool operator<(const CRL_Entry&, const CRL_Entry&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cryptobox.h b/src/libs/3rdparty/botan/build/botan/cryptobox.h new file mode 100644 index 00000000000..a30cb244aed --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cryptobox.h @@ -0,0 +1,42 @@ +/* +* Cryptobox Message Routines +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CRYPTOBOX_H__ +#define BOTAN_CRYPTOBOX_H__ + +#include +#include + +namespace Botan { + +namespace CryptoBox { + +/** +* Encrypt a message +* @param input the input data +* @param input_len the length of input in bytes +* @param passphrase the passphrase used to encrypt the message +* @param rng a ref to a random number generator, such as AutoSeeded_RNG +*/ +BOTAN_DLL std::string encrypt(const byte input[], u32bit input_len, + const std::string& passphrase, + RandomNumberGenerator& rng); + +/** +* Decrypt a message encrypted with CryptoBox::encrypt +* @param input the input data +* @param input_len the length of input in bytes +* @param passphrase the passphrase used to encrypt the message +*/ +BOTAN_DLL std::string decrypt(const byte input[], u32bit input_len, + const std::string& passphrase); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/ctr.h b/src/libs/3rdparty/botan/build/botan/ctr.h new file mode 100644 index 00000000000..aa0db57618b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/ctr.h @@ -0,0 +1,31 @@ +/* +* CTR Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_COUNTER_MODE_H__ +#define BOTAN_COUNTER_MODE_H__ + +#include +#include + +namespace Botan { + +/* +* CTR-BE Mode +*/ +class BOTAN_DLL CTR_BE : public BlockCipherMode + { + public: + CTR_BE(BlockCipher*); + CTR_BE(BlockCipher*, const SymmetricKey&, const InitializationVector&); + private: + void write(const byte[], u32bit); + void increment_counter(); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/cts.h b/src/libs/3rdparty/botan/build/botan/cts.h new file mode 100644 index 00000000000..9b17203f318 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/cts.h @@ -0,0 +1,60 @@ +/* +* CTS Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CTS_H__ +#define BOTAN_CTS_H__ + +#include +#include + +namespace Botan { + +/* +* CTS Encryption +*/ +class BOTAN_DLL CTS_Encryption : public BlockCipherMode + { + public: + CTS_Encryption(BlockCipher* ciph) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) {} + + CTS_Encryption(BlockCipher* ciph, + const SymmetricKey& key, + const InitializationVector& iv) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) + { set_key(key); set_iv(iv); } + private: + void write(const byte[], u32bit); + void end_msg(); + void encrypt(const byte[]); + }; + +/* +* CTS Decryption +*/ +class BOTAN_DLL CTS_Decryption : public BlockCipherMode + { + public: + CTS_Decryption(BlockCipher* ciph) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) + { temp.create(BLOCK_SIZE); } + + CTS_Decryption(BlockCipher* ciph, + const SymmetricKey& key, + const InitializationVector& iv) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) + { set_key(key); set_iv(iv); temp.create(BLOCK_SIZE); } + private: + void write(const byte[], u32bit); + void end_msg(); + void decrypt(const byte[]); + SecureVector temp; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/data_snk.h b/src/libs/3rdparty/botan/build/botan/data_snk.h new file mode 100644 index 00000000000..61ddf6e0d84 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/data_snk.h @@ -0,0 +1,65 @@ +/* +* DataSink +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DATA_SINK_H__ +#define BOTAN_DATA_SINK_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents abstract data sink objects. +*/ +class BOTAN_DLL DataSink : public Filter + { + public: + bool attachable() { return false; } + DataSink() {} + virtual ~DataSink() {} + private: + DataSink& operator=(const DataSink&) { return (*this); } + DataSink(const DataSink&); + }; + +/** +* This class represents a data sink which writes its output to a stream. +*/ +class BOTAN_DLL DataSink_Stream : public DataSink + { + public: + void write(const byte[], u32bit); + + /** + * Construct a DataSink_Stream from a stream. + * @param stream the stream to write to + * @param name identifier + */ + DataSink_Stream(std::ostream& stream, + const std::string& name = ""); + + /** + * Construct a DataSink_Stream from a stream. + * @param file the name of the file to open a stream to + * @param use_binary indicates whether to treat the file + * as a binary file or not + */ + DataSink_Stream(const std::string& filename, + bool use_binary = false); + + ~DataSink_Stream(); + private: + const std::string identifier; + const bool owner; + + std::ostream* sink; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/data_src.h b/src/libs/3rdparty/botan/build/botan/data_src.h new file mode 100644 index 00000000000..e16217e0fbb --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/data_src.h @@ -0,0 +1,150 @@ +/* +* DataSource +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DATA_SRC_H__ +#define BOTAN_DATA_SRC_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents an abstract data source object. +*/ +class BOTAN_DLL DataSource + { + public: + /** + * Read from the source. Moves the internal offset so that + * every call to read will return a new portion of the source. + * @param out the byte array to write the result to + * @param length the length of the byte array out + * @return the length in bytes that was actually read and put + * into out + */ + virtual u32bit read(byte out[], u32bit length) = 0; + + /** + * Read from the source but do not modify the internal offset. Consecutive + * calls to peek() will return portions of the source starting at the same + * position. + * @param out the byte array to write the output to + * @param length the length of the byte array out + * @return the length in bytes that was actually read and put + * into out + */ + virtual u32bit peek(byte out[], u32bit length, + u32bit peek_offset) const = 0; + + /** + * Test whether the source still has data that can be read. + * @return true if there is still data to read, false otherwise + */ + virtual bool end_of_data() const = 0; + /** + * return the id of this data source + * @return the std::string representing the id of this data source + */ + virtual std::string id() const { return ""; } + + /** + * Read one byte. + * @param the byte to read to + * @return the length in bytes that was actually read and put + * into out + */ + u32bit read_byte(byte& out); + + /** + * Peek at one byte. + * @param the byte to read to + * @return the length in bytes that was actually read and put + * into out + */ + u32bit peek_byte(byte& out) const; + + /** + * Discard the next N bytes of the data + * @param N the number of bytes to discard + * @return the number of bytes actually discarded + */ + u32bit discard_next(u32bit N); + + DataSource() {} + virtual ~DataSource() {} + private: + DataSource& operator=(const DataSource&) { return (*this); } + DataSource(const DataSource&); + }; + +/** +* This class represents a Memory-Based DataSource +*/ +class BOTAN_DLL DataSource_Memory : public DataSource + { + public: + u32bit read(byte[], u32bit); + u32bit peek(byte[], u32bit, u32bit) const; + bool end_of_data() const; + + /** + * Construct a memory source that reads from a string + * @param in the string to read from + */ + DataSource_Memory(const std::string& in); + + /** + * Construct a memory source that reads from a byte array + * @param in the byte array to read from + * @param length the length of the byte array + */ + DataSource_Memory(const byte in[], u32bit length); + + /** + * Construct a memory source that reads from a MemoryRegion + * @param in the MemoryRegion to read from + */ + DataSource_Memory(const MemoryRegion& in); + private: + SecureVector source; + u32bit offset; + }; + +/** +* This class represents a Stream-Based DataSource. +*/ +class BOTAN_DLL DataSource_Stream : public DataSource + { + public: + u32bit read(byte[], u32bit); + u32bit peek(byte[], u32bit, u32bit) const; + bool end_of_data() const; + std::string id() const; + + DataSource_Stream(std::istream&, const std::string& id = ""); + + /** + * Construct a Stream-Based DataSource from file + * @param file the name of the file + * @param use_binary whether to treat the file as binary or not + */ + DataSource_Stream(const std::string& file, bool use_binary = false); + + ~DataSource_Stream(); + private: + const std::string identifier; + const bool owner; + + std::istream* source; + u32bit total_read; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/datastor.h b/src/libs/3rdparty/botan/build/botan/datastor.h new file mode 100644 index 00000000000..7ee626fda2c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/datastor.h @@ -0,0 +1,61 @@ +/* +* Data Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DATA_STORE_H__ +#define BOTAN_DATA_STORE_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/** +* Data Store +*/ +class BOTAN_DLL Data_Store + { + public: + class BOTAN_DLL Matcher + { + public: + virtual bool operator()(const std::string&, + const std::string&) const = 0; + + virtual std::pair + transform(const std::string&, const std::string&) const; + + virtual ~Matcher() {} + }; + + bool operator==(const Data_Store&) const; + + std::multimap + search_with(const Matcher&) const; + + std::vector get(const std::string&) const; + + std::string get1(const std::string&) const; + + MemoryVector get1_memvec(const std::string&) const; + u32bit get1_u32bit(const std::string&, u32bit = 0) const; + + bool has_value(const std::string&) const; + + void add(const std::multimap&); + void add(const std::string&, const std::string&); + void add(const std::string&, u32bit); + void add(const std::string&, const MemoryRegion&); + private: + std::multimap contents; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/def_eng.h b/src/libs/3rdparty/botan/build/botan/def_eng.h new file mode 100644 index 00000000000..2d71454802e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/def_eng.h @@ -0,0 +1,83 @@ +/* +* Default Engine +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DEFAULT_ENGINE_H__ +#define BOTAN_DEFAULT_ENGINE_H__ + +#include + +namespace Botan { + +/* +* Default Engine +*/ +class BOTAN_DLL Default_Engine : public Engine + { + public: + std::string provider_name() const { return "core"; } + +#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) + IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&) const; +#endif + +#if defined(BOTAN_HAS_DSA) + DSA_Operation* dsa_op(const DL_Group&, const BigInt&, + const BigInt&) const; +#endif + +#if defined(BOTAN_HAS_NYBERG_RUEPPEL) + NR_Operation* nr_op(const DL_Group&, const BigInt&, const BigInt&) const; +#endif + +#if defined(BOTAN_HAS_ELGAMAL) + ELG_Operation* elg_op(const DL_Group&, const BigInt&, + const BigInt&) const; +#endif + +#if defined(BOTAN_HAS_DIFFIE_HELLMAN) + DH_Operation* dh_op(const DL_Group&, const BigInt&) const; +#endif + +#if defined(BOTAN_HAS_ECDSA) + virtual ECDSA_Operation* ecdsa_op(const EC_Domain_Params&, + const BigInt&, + const PointGFp&) const; +#endif + +#if defined(BOTAN_HAS_ECKAEG) + virtual ECKAEG_Operation* eckaeg_op(const EC_Domain_Params&, + const BigInt&, + const PointGFp&) const; +#endif + + Modular_Exponentiator* mod_exp(const BigInt&, + Power_Mod::Usage_Hints) const; + + virtual bool can_add_algorithms() { return true; } + + Keyed_Filter* get_cipher(const std::string&, Cipher_Dir, + Algorithm_Factory&); + + private: + BlockCipher* find_block_cipher(const SCAN_Name&, + Algorithm_Factory&) const; + + StreamCipher* find_stream_cipher(const SCAN_Name&, + Algorithm_Factory&) const; + + HashFunction* find_hash(const SCAN_Name& reqeust, + Algorithm_Factory&) const; + + MessageAuthenticationCode* find_mac(const SCAN_Name& reqeust, + Algorithm_Factory&) const; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/def_powm.h b/src/libs/3rdparty/botan/build/botan/def_powm.h new file mode 100644 index 00000000000..472c865c373 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/def_powm.h @@ -0,0 +1,64 @@ +/* +* Modular Exponentiation +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DEFAULT_MODEXP_H__ +#define BOTAN_DEFAULT_MODEXP_H__ + +#include +#include +#include + +namespace Botan { + +/* +* Fixed Window Exponentiator +*/ +class BOTAN_DLL Fixed_Window_Exponentiator : public Modular_Exponentiator + { + public: + void set_exponent(const BigInt&); + void set_base(const BigInt&); + BigInt execute() const; + + Modular_Exponentiator* copy() const + { return new Fixed_Window_Exponentiator(*this); } + + Fixed_Window_Exponentiator(const BigInt&, Power_Mod::Usage_Hints); + private: + Modular_Reducer reducer; + BigInt exp; + u32bit window_bits; + std::vector g; + Power_Mod::Usage_Hints hints; + }; + +/* +* Montgomery Exponentiator +*/ +class BOTAN_DLL Montgomery_Exponentiator : public Modular_Exponentiator + { + public: + void set_exponent(const BigInt&); + void set_base(const BigInt&); + BigInt execute() const; + + Modular_Exponentiator* copy() const + { return new Montgomery_Exponentiator(*this); } + + Montgomery_Exponentiator(const BigInt&, Power_Mod::Usage_Hints); + private: + BigInt exp, modulus; + BigInt R2, R_mod; + std::vector g; + word mod_prime; + u32bit mod_words, exp_bits, window_bits; + Power_Mod::Usage_Hints hints; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/defalloc.h b/src/libs/3rdparty/botan/build/botan/defalloc.h new file mode 100644 index 00000000000..627e8df7055 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/defalloc.h @@ -0,0 +1,43 @@ +/* +* Basic Allocators +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BASIC_ALLOC_H__ +#define BOTAN_BASIC_ALLOC_H__ + +#include + +namespace Botan { + +/* +* Malloc Allocator +*/ +class BOTAN_DLL Malloc_Allocator : public Allocator + { + public: + void* allocate(u32bit); + void deallocate(void*, u32bit); + + std::string type() const { return "malloc"; } + }; + +/* +* Locking Allocator +*/ +class BOTAN_DLL Locking_Allocator : public Pooling_Allocator + { + public: + Locking_Allocator(Mutex* m) : Pooling_Allocator(m) {} + + std::string type() const { return "locking"; } + private: + void* alloc_block(u32bit); + void dealloc_block(void*, u32bit); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/der_enc.h b/src/libs/3rdparty/botan/build/botan/der_enc.h new file mode 100644 index 00000000000..23b5297e56b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/der_enc.h @@ -0,0 +1,91 @@ +/* +* DER Encoder +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DER_ENCODER_H__ +#define BOTAN_DER_ENCODER_H__ + +#include +#include + +namespace Botan { + +/* +* General DER Encoding Object +*/ +class BOTAN_DLL DER_Encoder + { + public: + SecureVector get_contents(); + + DER_Encoder& start_cons(ASN1_Tag, ASN1_Tag = UNIVERSAL); + DER_Encoder& end_cons(); + + DER_Encoder& start_explicit(u16bit); + DER_Encoder& end_explicit(); + + DER_Encoder& raw_bytes(const byte[], u32bit); + DER_Encoder& raw_bytes(const MemoryRegion&); + + DER_Encoder& encode_null(); + DER_Encoder& encode(bool); + DER_Encoder& encode(u32bit); + DER_Encoder& encode(const class BigInt&); + DER_Encoder& encode(const MemoryRegion&, ASN1_Tag); + DER_Encoder& encode(const byte[], u32bit, ASN1_Tag); + + DER_Encoder& encode(bool, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + DER_Encoder& encode(u32bit, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + DER_Encoder& encode(const class BigInt&, ASN1_Tag, + ASN1_Tag = CONTEXT_SPECIFIC); + DER_Encoder& encode(const MemoryRegion&, ASN1_Tag, + ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + DER_Encoder& encode(const byte[], u32bit, ASN1_Tag, + ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC); + + template + DER_Encoder& encode_optional(const T& value, const T& default_value) + { + if(value != default_value) + encode(value); + return (*this); + } + + template + DER_Encoder& encode_list(const std::vector& values) + { + for(u32bit j = 0; j != values.size(); ++j) + encode(values[j]); + return (*this); + } + + DER_Encoder& encode(const class ASN1_Object&); + DER_Encoder& encode_if(bool, DER_Encoder&); + + DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, const byte[], u32bit); + DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, const MemoryRegion&); + DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, const std::string&); + DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, byte); + private: + class DER_Sequence + { + public: + ASN1_Tag tag_of() const; + SecureVector get_contents(); + void add_bytes(const byte[], u32bit); + DER_Sequence(ASN1_Tag, ASN1_Tag); + private: + ASN1_Tag type_tag, class_tag; + SecureVector contents; + std::vector< SecureVector > set_contents; + }; + SecureVector contents; + std::vector subsequences; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/des.h b/src/libs/3rdparty/botan/build/botan/des.h new file mode 100644 index 00000000000..6fa59de5e06 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/des.h @@ -0,0 +1,70 @@ +/* +* DES +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DES_H__ +#define BOTAN_DES_H__ + +#include + +namespace Botan { + +/* +* DES +*/ +class BOTAN_DLL DES : public BlockCipher + { + public: + void clear() throw() { round_key.clear(); } + std::string name() const { return "DES"; } + BlockCipher* clone() const { return new DES; } + DES() : BlockCipher(8, 8) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer round_key; + }; + +/* +* Triple DES +*/ +class BOTAN_DLL TripleDES : public BlockCipher + { + public: + void clear() throw() { round_key.clear(); } + std::string name() const { return "TripleDES"; } + BlockCipher* clone() const { return new TripleDES; } + TripleDES() : BlockCipher(8, 16, 24, 8) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer round_key; + }; + +/* +* DES Tables +*/ +extern const u32bit DES_SPBOX1[256]; +extern const u32bit DES_SPBOX2[256]; +extern const u32bit DES_SPBOX3[256]; +extern const u32bit DES_SPBOX4[256]; +extern const u32bit DES_SPBOX5[256]; +extern const u32bit DES_SPBOX6[256]; +extern const u32bit DES_SPBOX7[256]; +extern const u32bit DES_SPBOX8[256]; + +extern const u64bit DES_IPTAB1[256]; +extern const u64bit DES_IPTAB2[256]; +extern const u64bit DES_FPTAB1[256]; +extern const u64bit DES_FPTAB2[256]; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/desx.h b/src/libs/3rdparty/botan/build/botan/desx.h new file mode 100644 index 00000000000..49ecc2421b0 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/desx.h @@ -0,0 +1,35 @@ +/* +* DESX +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DESX_H__ +#define BOTAN_DESX_H__ + +#include + +namespace Botan { + +/* +* DESX +*/ +class BOTAN_DLL DESX : public BlockCipher + { + public: + void clear() throw() { des.clear(); K1.clear(); K2.clear(); } + std::string name() const { return "DESX"; } + BlockCipher* clone() const { return new DESX; } + DESX() : BlockCipher(8, 24) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + SecureBuffer K1, K2; + DES des; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dh.h b/src/libs/3rdparty/botan/build/botan/dh.h new file mode 100644 index 00000000000..fa558bce258 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dh.h @@ -0,0 +1,80 @@ +/* +* Diffie-Hellman +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DIFFIE_HELLMAN_H__ +#define BOTAN_DIFFIE_HELLMAN_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents Diffie-Hellman public keys. +*/ +class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey + { + public: + std::string algo_name() const { return "DH"; } + + MemoryVector public_value() const; + u32bit max_input_bits() const; + + DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; } + + /** + * Construct an uninitialized key. Use this constructor if you wish + * to decode an encoded key into the new instance. + */ + DH_PublicKey() {} + + /** + * Construct a public key with the specified parameters. + * @param grp the DL group to use in the key + * @param y the public value y + */ + DH_PublicKey(const DL_Group& grp, const BigInt& y); + private: + void X509_load_hook(); + }; + +/** +* This class represents Diffie-Hellman private keys. +*/ +class BOTAN_DLL DH_PrivateKey : public DH_PublicKey, + public PK_Key_Agreement_Key, + public virtual DL_Scheme_PrivateKey + { + public: + SecureVector derive_key(const byte other[], u32bit length) const; + SecureVector derive_key(const DH_PublicKey& other) const; + SecureVector derive_key(const BigInt& other) const; + + MemoryVector public_value() const; + + /** + * Construct an uninitialized key. Use this constructor if you wish + * to decode an encoded key into the new instance. + */ + DH_PrivateKey() {} + + /** + * Construct a private key with predetermined value. + * @param rng random number generator to use + * @param grp the group to be used in the key + * @param x the key's secret value (or if zero, generate a new key) + */ + DH_PrivateKey(RandomNumberGenerator& rng, const DL_Group& grp, + const BigInt& x = 0); + private: + void PKCS8_load_hook(RandomNumberGenerator& rng, bool = false); + DH_Core core; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dh_core.h b/src/libs/3rdparty/botan/build/botan/dh_core.h new file mode 100644 index 00000000000..91b50a27af1 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dh_core.h @@ -0,0 +1,38 @@ +/* +* DH Core +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DH_CORE_H__ +#define BOTAN_DH_CORE_H__ + +#include +#include + +namespace Botan { + +/* +* DH Core +*/ +class BOTAN_DLL DH_Core + { + public: + BigInt agree(const BigInt&) const; + + DH_Core& operator=(const DH_Core&); + + DH_Core() { op = 0; } + DH_Core(const DH_Core&); + DH_Core(RandomNumberGenerator& rng, + const DL_Group&, const BigInt&); + ~DH_Core() { delete op; } + private: + DH_Operation* op; + Blinder blinder; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dh_op.h b/src/libs/3rdparty/botan/build/botan/dh_op.h new file mode 100644 index 00000000000..50f3d782561 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dh_op.h @@ -0,0 +1,45 @@ +/* +* DH Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DH_OPS_H__ +#define BOTAN_DH_OPS_H__ + +#include +#include +#include + +namespace Botan { + +/* +* DH Operation Interface +*/ +class BOTAN_DLL DH_Operation + { + public: + virtual BigInt agree(const BigInt&) const = 0; + virtual DH_Operation* clone() const = 0; + virtual ~DH_Operation() {} + }; + +/* +* Botan's Default DH Operation +*/ +class BOTAN_DLL Default_DH_Op : public DH_Operation + { + public: + BigInt agree(const BigInt& i) const { return powermod_x_p(i); } + DH_Operation* clone() const { return new Default_DH_Op(*this); } + + Default_DH_Op(const DL_Group& group, const BigInt& x) : + powermod_x_p(x, group.get_p()) {} + private: + Fixed_Exponent_Power_Mod powermod_x_p; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/divide.h b/src/libs/3rdparty/botan/build/botan/divide.h new file mode 100644 index 00000000000..9445b137b7c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/divide.h @@ -0,0 +1,19 @@ +/* +* Division +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DIVISON_ALGORITHM_H__ +#define BOTAN_DIVISON_ALGORITHM_H__ + +#include + +namespace Botan { + +void BOTAN_DLL divide(const BigInt&, const BigInt&, BigInt&, BigInt&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dl_algo.h b/src/libs/3rdparty/botan/build/botan/dl_algo.h new file mode 100644 index 00000000000..256ce96ee2f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dl_algo.h @@ -0,0 +1,116 @@ +/* +* DL Scheme +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DL_ALGO_H__ +#define BOTAN_DL_ALGO_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +* This class represents discrete logarithm (DL) public keys. +*/ +class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key + { + public: + bool check_key(RandomNumberGenerator& rng, bool) const; + + /** + * Get the DL domain parameters of this key. + * @return the DL domain parameters of this key + */ + const DL_Group& get_domain() const { return group; } + + /** + * Get the public value y with y = g^x mod p where x is the secret key. + */ + const BigInt& get_y() const { return y; } + + /** + * Get the prime p of the underlying DL group. + * @return the prime p + */ + const BigInt& group_p() const { return group.get_p(); } + + /** + * Get the prime q of the underlying DL group. + * @return the prime q + */ + const BigInt& group_q() const { return group.get_q(); } + + /** + * Get the generator g of the underlying DL group. + * @return the generator g + */ + const BigInt& group_g() const { return group.get_g(); } + + /** + * Get the underlying groups encoding format. + * @return the encoding format + */ + virtual DL_Group::Format group_format() const = 0; + + /** + * Get an X509 encoder for this key. + * @return an encoder usable to encode this key. + */ + X509_Encoder* x509_encoder() const; + + /** + * Get an X509 decoder for this key. + * @return an decoder usable to decode a DL key and store the + * values in this instance. + */ + X509_Decoder* x509_decoder(); + protected: + BigInt y; + DL_Group group; + private: + virtual void X509_load_hook() {} + }; + +/** +* This class represents discrete logarithm (DL) private keys. +*/ +class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey, + public virtual Private_Key + { + public: + bool check_key(RandomNumberGenerator& rng, bool) const; + + /** + * Get the secret key x. + * @return the secret key + */ + const BigInt& get_x() const { return x; } + + /** + * Get an PKCS#8 encoder for this key. + * @return an encoder usable to encode this key. + */ + PKCS8_Encoder* pkcs8_encoder() const; + + /** + * Get an PKCS#8 decoder for this key. + * @param rng the rng to use + * @return an decoder usable to decode a DL key and store the + * values in this instance. + */ + PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator& rng); + protected: + BigInt x; + private: + virtual void PKCS8_load_hook(RandomNumberGenerator&, bool = false) {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dl_group.h b/src/libs/3rdparty/botan/build/botan/dl_group.h new file mode 100644 index 00000000000..a84a85f872f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dl_group.h @@ -0,0 +1,162 @@ +/* +* Discrete Logarithm Group +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DL_PARAM_H__ +#define BOTAN_DL_PARAM_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents discrete logarithm groups. It holds a prime p, +* a prime q = (p-1)/2 and g = x^((p-1)/q) mod p. +*/ +class BOTAN_DLL DL_Group + { + public: + /** + * Get the prime p. + * @return the prime p + */ + const BigInt& get_p() const; + + /** + * Get the prime q. + * @return the prime q + */ + const BigInt& get_q() const; + + /** + * Get the base g. + * @return the base g + */ + const BigInt& get_g() const; + + /** + * The DL group encoding format variants. + */ + enum Format { + ANSI_X9_42, + ANSI_X9_57, + PKCS_3, + + DSA_PARAMETERS = ANSI_X9_57, + DH_PARAMETERS = ANSI_X9_42, + X942_DH_PARAMETERS = ANSI_X9_42, + PKCS3_DH_PARAMETERS = PKCS_3 + }; + + /** + * Determine the prime creation for DL groups. + */ + enum PrimeType { Strong, Prime_Subgroup, DSA_Kosherizer }; + + /** + * Perform validity checks on the group. + * @param rng the rng to use + * @param strong whether to perform stronger by lengthier tests + * @return true if the object is consistent, false otherwise + */ + bool verify_group(RandomNumberGenerator& rng, bool strong) const; + + /** + * Encode this group into a string using PEM encoding. + * @param format the encoding format + * @return the string holding the PEM encoded group + */ + std::string PEM_encode(Format format) const; + + /** + * Encode this group into a string using DER encoding. + * @param format the encoding format + * @return the string holding the DER encoded group + */ + SecureVector DER_encode(Format format) const; + + /** + * Decode a DER/BER encoded group into this instance. + * @param src a DataSource providing the encoded group + * @param format the format of the encoded group + */ + void BER_decode(DataSource& src, Format format); + + /** + * Decode a PEM encoded group into this instance. + * @param src a DataSource providing the encoded group + */ + void PEM_decode(DataSource& src); + + /** + * Construct a DL group with uninitialized internal value. + * Use this constructor is you wish to set the groups values + * from a DER or PEM encoded group. + */ + DL_Group(); + + /** + * Construct a DL group that is registered in the configuration. + * @param name the name that is configured in the global configuration + * for the desired group. If no configuration file is specified, + * the default values from the file policy.cpp will be used. For instance, + * use "modp/ietf/768" as name. + */ + DL_Group(const std::string& name); + + /** + * Create a new group randomly. + * @param rng the random number generator to use + * @param type specifies how the creation of primes p and q shall + * be performed. If type=Strong, then p will be determined as a + * safe prime, and q will be chosen as (p-1)/2. If + * type=Prime_Subgroup and qbits = 0, then the size of q will be + * determined according to the estimated difficulty of the DL + * problem. If type=DSA_Kosherizer, DSA primes will be created. + * @param pbits the number of bits of p + * @param qbits the number of bits of q. Leave it as 0 to have + * the value determined according to pbits. + */ + DL_Group(RandomNumberGenerator& rng, PrimeType type, + u32bit pbits, u32bit qbits = 0); + + /** + * Create a DSA group with a given seed. + * @param rng the random number generator to use + * @param seed the seed to use to create the random primes + * @param pbits the desired bit size of the prime p + * @param qbits the desired bit size of the prime q. + */ + DL_Group(RandomNumberGenerator& rng, const MemoryRegion& seed, + u32bit pbits = 1024, u32bit qbits = 0); + + /** + * Create a DL group. The prime q will be determined according to p. + * @param p the prime p + * @param g the base g + */ + DL_Group(const BigInt& p, const BigInt& g); + + /** + * Create a DL group. + * @param p the prime p + * @param q the prime q + * @param g the base g + */ + DL_Group(const BigInt& p, const BigInt& q, const BigInt& g); + private: + static BigInt make_dsa_generator(const BigInt&, const BigInt&); + + void init_check() const; + void initialize(const BigInt&, const BigInt&, const BigInt&); + bool initialized; + BigInt p, q, g; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dlies.h b/src/libs/3rdparty/botan/build/botan/dlies.h new file mode 100644 index 00000000000..88a22b9de07 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dlies.h @@ -0,0 +1,69 @@ +/* +* DLIES +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DLIES_H__ +#define BOTAN_DLIES_H__ + +#include +#include +#include + +namespace Botan { + +/* +* DLIES Encryption +*/ +class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor + { + public: + DLIES_Encryptor(const PK_Key_Agreement_Key&, + KDF* kdf, + MessageAuthenticationCode* mac, + u32bit mac_key_len = 20); + + ~DLIES_Encryptor(); + + void set_other_key(const MemoryRegion&); + private: + SecureVector enc(const byte[], u32bit, + RandomNumberGenerator&) const; + u32bit maximum_input_size() const; + + const PK_Key_Agreement_Key& key; + SecureVector other_key; + + KDF* kdf; + MessageAuthenticationCode* mac; + u32bit mac_keylen; + }; + +/* +* DLIES Decryption +*/ +class BOTAN_DLL DLIES_Decryptor : public PK_Decryptor + { + public: + DLIES_Decryptor(const PK_Key_Agreement_Key&, + KDF* kdf, + MessageAuthenticationCode* mac, + u32bit mac_key_len = 20); + + ~DLIES_Decryptor(); + + private: + SecureVector dec(const byte[], u32bit) const; + + const PK_Key_Agreement_Key& key; + + KDF* kdf; + MessageAuthenticationCode* mac; + u32bit mac_keylen; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dsa.h b/src/libs/3rdparty/botan/build/botan/dsa.h new file mode 100644 index 00000000000..4c9b708f4cd --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dsa.h @@ -0,0 +1,62 @@ +/* +* DSA +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DSA_H__ +#define BOTAN_DSA_H__ + +#include +#include + +namespace Botan { + +/* +* DSA Public Key +*/ +class BOTAN_DLL DSA_PublicKey : public PK_Verifying_wo_MR_Key, + public virtual DL_Scheme_PublicKey + { + public: + std::string algo_name() const { return "DSA"; } + + DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; } + u32bit message_parts() const { return 2; } + u32bit message_part_size() const; + + bool verify(const byte[], u32bit, const byte[], u32bit) const; + u32bit max_input_bits() const; + + DSA_PublicKey() {} + DSA_PublicKey(const DL_Group&, const BigInt&); + protected: + DSA_Core core; + private: + void X509_load_hook(); + }; + +/* +* DSA Private Key +*/ +class BOTAN_DLL DSA_PrivateKey : public DSA_PublicKey, + public PK_Signing_Key, + public virtual DL_Scheme_PrivateKey + { + public: + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; + + bool check_key(RandomNumberGenerator& rng, bool) const; + + DSA_PrivateKey() {} + DSA_PrivateKey(RandomNumberGenerator&, const DL_Group&, + const BigInt& = 0); + private: + void PKCS8_load_hook(RandomNumberGenerator& rng, bool = false); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dsa_core.h b/src/libs/3rdparty/botan/build/botan/dsa_core.h new file mode 100644 index 00000000000..8bb16211f29 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dsa_core.h @@ -0,0 +1,37 @@ +/* +* DSA Core +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DSA_CORE_H__ +#define BOTAN_DSA_CORE_H__ + +#include +#include + +namespace Botan { + +/* +* DSA Core +*/ +class BOTAN_DLL DSA_Core + { + public: + SecureVector sign(const byte[], u32bit, const BigInt&) const; + bool verify(const byte[], u32bit, const byte[], u32bit) const; + + DSA_Core& operator=(const DSA_Core&); + + DSA_Core() { op = 0; } + DSA_Core(const DSA_Core&); + DSA_Core(const DL_Group&, const BigInt&, const BigInt& = 0); + ~DSA_Core() { delete op; } + private: + DSA_Operation* op; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/dsa_op.h b/src/libs/3rdparty/botan/build/botan/dsa_op.h new file mode 100644 index 00000000000..0b112c6a1b4 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/dsa_op.h @@ -0,0 +1,53 @@ +/* +* DSA Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_DSA_OPS_H__ +#define BOTAN_DSA_OPS_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* DSA Operation +*/ +class BOTAN_DLL DSA_Operation + { + public: + virtual bool verify(const byte[], u32bit, + const byte[], u32bit) const = 0; + virtual SecureVector sign(const byte[], u32bit, + const BigInt&) const = 0; + virtual DSA_Operation* clone() const = 0; + virtual ~DSA_Operation() {} + }; + +/* +* Botan's Default DSA Operation +*/ +class BOTAN_DLL Default_DSA_Op : public DSA_Operation + { + public: + bool verify(const byte[], u32bit, const byte[], u32bit) const; + SecureVector sign(const byte[], u32bit, const BigInt&) const; + + DSA_Operation* clone() const { return new Default_DSA_Op(*this); } + + Default_DSA_Op(const DL_Group&, const BigInt&, const BigInt&); + private: + const BigInt x, y; + const DL_Group group; + Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; + Modular_Reducer mod_p, mod_q; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/eax.h b/src/libs/3rdparty/botan/build/botan/eax.h new file mode 100644 index 00000000000..1bb2e510d18 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/eax.h @@ -0,0 +1,85 @@ +/* +* EAX Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EAX_H__ +#define BOTAN_EAX_H__ + +#include +#include +#include + +namespace Botan { + +/* +* EAX Base Class +*/ +class BOTAN_DLL EAX_Base : public Keyed_Filter + { + public: + void set_key(const SymmetricKey&); + void set_iv(const InitializationVector&); + void set_header(const byte[], u32bit); + std::string name() const; + + bool valid_keylength(u32bit) const; + + ~EAX_Base() { delete cipher; delete mac; } + protected: + EAX_Base(BlockCipher*, u32bit); + void start_msg(); + void increment_counter(); + + const u32bit TAG_SIZE, BLOCK_SIZE; + BlockCipher* cipher; + MessageAuthenticationCode* mac; + SecureVector nonce_mac, header_mac, state, buffer; + u32bit position; + }; + +/* +* EAX Encryption +*/ +class BOTAN_DLL EAX_Encryption : public EAX_Base + { + public: + EAX_Encryption(BlockCipher* ciph, u32bit tag_size = 0) : + EAX_Base(ciph, tag_size) {} + + EAX_Encryption(BlockCipher* ciph, const SymmetricKey& key, + const InitializationVector& iv, + u32bit tag_size) : EAX_Base(ciph, tag_size) + { + set_key(key); + set_iv(iv); + } + private: + void write(const byte[], u32bit); + void end_msg(); + }; + +/* +* EAX Decryption +*/ +class BOTAN_DLL EAX_Decryption : public EAX_Base + { + public: + EAX_Decryption(BlockCipher* ciph, u32bit tag_size = 0); + + EAX_Decryption(BlockCipher* ciph, const SymmetricKey& key, + const InitializationVector& iv, + u32bit tag_size = 0); + private: + void write(const byte[], u32bit); + void do_write(const byte[], u32bit); + void end_msg(); + SecureVector queue; + u32bit queue_start, queue_end; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/ecb.h b/src/libs/3rdparty/botan/build/botan/ecb.h new file mode 100644 index 00000000000..5230f9b14b6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/ecb.h @@ -0,0 +1,73 @@ +/* +* ECB Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ECB_H__ +#define BOTAN_ECB_H__ + +#include +#include +#include + +namespace Botan { + +/* +* ECB +*/ +class BOTAN_DLL ECB : public BlockCipherMode + { + protected: + ECB(BlockCipher* ciph, BlockCipherModePaddingMethod* pad) : + BlockCipherMode(ciph, "ECB", 0), padder(pad) {} + ~ECB() { delete padder; } + + std::string name() const; + BlockCipherModePaddingMethod* padder; + private: + bool valid_iv_size(u32bit) const; + }; + +/* +* ECB Encryption +*/ +class BOTAN_DLL ECB_Encryption : public ECB + { + public: + ECB_Encryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad) : + ECB(ciph, pad) {} + + ECB_Encryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad, + const SymmetricKey& key) : + ECB(ciph, pad) { set_key(key); } + private: + void write(const byte[], u32bit); + void end_msg(); + }; + +/* +* ECB Decryption +*/ +class BOTAN_DLL ECB_Decryption : public ECB + { + public: + ECB_Decryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad) : + ECB(ciph, pad) {} + + ECB_Decryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad, + const SymmetricKey& key) : + ECB(ciph, pad) { set_key(key); } + private: + void write(const byte[], u32bit); + void end_msg(); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/elg_core.h b/src/libs/3rdparty/botan/build/botan/elg_core.h new file mode 100644 index 00000000000..a7768a6aeeb --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/elg_core.h @@ -0,0 +1,44 @@ +/* +* ElGamal Core +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ELGAMAL_CORE_H__ +#define BOTAN_ELGAMAL_CORE_H__ + +#include +#include +#include + +namespace Botan { + +/* +* ElGamal Core +*/ +class BOTAN_DLL ELG_Core + { + public: + SecureVector encrypt(const byte[], u32bit, const BigInt&) const; + SecureVector decrypt(const byte[], u32bit) const; + + ELG_Core& operator=(const ELG_Core&); + + ELG_Core() { op = 0; } + ELG_Core(const ELG_Core&); + + ELG_Core(const DL_Group&, const BigInt&); + ELG_Core(RandomNumberGenerator&, const DL_Group&, + const BigInt&, const BigInt&); + + ~ELG_Core() { delete op; } + private: + ELG_Operation* op; + Blinder blinder; + u32bit p_bytes; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/elg_op.h b/src/libs/3rdparty/botan/build/botan/elg_op.h new file mode 100644 index 00000000000..39ed897f497 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/elg_op.h @@ -0,0 +1,52 @@ +/* +* ElGamal Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ELGAMAL_OPS_H__ +#define BOTAN_ELGAMAL_OPS_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* ElGamal Operation +*/ +class BOTAN_DLL ELG_Operation + { + public: + virtual SecureVector encrypt(const byte[], u32bit, + const BigInt&) const = 0; + virtual BigInt decrypt(const BigInt&, const BigInt&) const = 0; + virtual ELG_Operation* clone() const = 0; + virtual ~ELG_Operation() {} + }; + +/* +* Botan's Default ElGamal Operation +*/ +class BOTAN_DLL Default_ELG_Op : public ELG_Operation + { + public: + SecureVector encrypt(const byte[], u32bit, const BigInt&) const; + BigInt decrypt(const BigInt&, const BigInt&) const; + + ELG_Operation* clone() const { return new Default_ELG_Op(*this); } + + Default_ELG_Op(const DL_Group&, const BigInt&, const BigInt&); + private: + const BigInt p; + Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; + Fixed_Exponent_Power_Mod powermod_x_p; + Modular_Reducer mod_p; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/elgamal.h b/src/libs/3rdparty/botan/build/botan/elgamal.h new file mode 100644 index 00000000000..93e640f0963 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/elgamal.h @@ -0,0 +1,59 @@ +/* +* ElGamal +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ELGAMAL_H__ +#define BOTAN_ELGAMAL_H__ + +#include +#include + +namespace Botan { + +/* +* ElGamal Public Key +*/ +class BOTAN_DLL ElGamal_PublicKey : public PK_Encrypting_Key, + public virtual DL_Scheme_PublicKey + { + public: + std::string algo_name() const { return "ElGamal"; } + DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; } + + SecureVector encrypt(const byte[], u32bit, + RandomNumberGenerator& rng) const; + u32bit max_input_bits() const; + + ElGamal_PublicKey() {} + ElGamal_PublicKey(const DL_Group&, const BigInt&); + protected: + ELG_Core core; + private: + void X509_load_hook(); + }; + +/* +* ElGamal Private Key +*/ +class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey, + public PK_Decrypting_Key, + public virtual DL_Scheme_PrivateKey + { + public: + SecureVector decrypt(const byte[], u32bit) const; + + bool check_key(RandomNumberGenerator& rng, bool) const; + + ElGamal_PrivateKey() {} + ElGamal_PrivateKey(RandomNumberGenerator&, const DL_Group&, + const BigInt& = 0); + private: + void PKCS8_load_hook(RandomNumberGenerator&, bool = false); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/eme.h b/src/libs/3rdparty/botan/build/botan/eme.h new file mode 100644 index 00000000000..321c1d01e3a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/eme.h @@ -0,0 +1,42 @@ +/* +* EME Classes +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__ +#define BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__ + +#include +#include + +namespace Botan { + +/* +* Encoding Method for Encryption +*/ +class BOTAN_DLL EME + { + public: + virtual u32bit maximum_input_size(u32bit) const = 0; + + SecureVector encode(const byte[], u32bit, u32bit, + RandomNumberGenerator&) const; + SecureVector encode(const MemoryRegion&, u32bit, + RandomNumberGenerator&) const; + + SecureVector decode(const byte[], u32bit, u32bit) const; + SecureVector decode(const MemoryRegion&, u32bit) const; + + virtual ~EME() {} + private: + virtual SecureVector pad(const byte[], u32bit, u32bit, + RandomNumberGenerator&) const = 0; + + virtual SecureVector unpad(const byte[], u32bit, u32bit) const = 0; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/eme1.h b/src/libs/3rdparty/botan/build/botan/eme1.h new file mode 100644 index 00000000000..4df5c5f1cd7 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/eme1.h @@ -0,0 +1,45 @@ +/* +* EME1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EME1_H__ +#define BOTAN_EME1_H__ + +#include +#include +#include + +namespace Botan { + +/* +* EME1 +*/ +class BOTAN_DLL EME1 : public EME + { + public: + u32bit maximum_input_size(u32bit) const; + + /** + EME1 constructor. Hash will be deleted by ~EME1 (when mgf is deleted) + + P is an optional label. Normally empty. + */ + EME1(HashFunction* hash, const std::string& P = ""); + + ~EME1() { delete mgf; } + private: + SecureVector pad(const byte[], u32bit, u32bit, + RandomNumberGenerator&) const; + SecureVector unpad(const byte[], u32bit, u32bit) const; + + const u32bit HASH_LENGTH; + SecureVector Phash; + MGF* mgf; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/eme_pkcs.h b/src/libs/3rdparty/botan/build/botan/eme_pkcs.h new file mode 100644 index 00000000000..1aeedf5d79b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/eme_pkcs.h @@ -0,0 +1,30 @@ +/* +* EME PKCS#1 v1.5 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EME_PKCS1_H__ +#define BOTAN_EME_PKCS1_H__ + +#include + +namespace Botan { + +/* +* EME_PKCS1v15 +*/ +class BOTAN_DLL EME_PKCS1v15 : public EME + { + public: + u32bit maximum_input_size(u32bit) const; + private: + SecureVector pad(const byte[], u32bit, u32bit, + RandomNumberGenerator&) const; + SecureVector unpad(const byte[], u32bit, u32bit) const; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa.h b/src/libs/3rdparty/botan/build/botan/emsa.h new file mode 100644 index 00000000000..e2491e40f7d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa.h @@ -0,0 +1,36 @@ +/* +* EMSA Classes +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PUBKEY_EMSA_H__ +#define BOTAN_PUBKEY_EMSA_H__ + +#include +#include + +namespace Botan { + +/* +* Encoding Method for Signatures, Appendix +*/ +class BOTAN_DLL EMSA + { + public: + virtual void update(const byte[], u32bit) = 0; + virtual SecureVector raw_data() = 0; + + virtual SecureVector encoding_of(const MemoryRegion&, + u32bit, + RandomNumberGenerator& rng) = 0; + + virtual bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw() = 0; + virtual ~EMSA() {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa1.h b/src/libs/3rdparty/botan/build/botan/emsa1.h new file mode 100644 index 00000000000..a5dac07e26d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa1.h @@ -0,0 +1,41 @@ +/* +* EMSA1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EMSA1_H__ +#define BOTAN_EMSA1_H__ + +#include +#include + +namespace Botan { + +/* +* EMSA1 +*/ +class BOTAN_DLL EMSA1 : public EMSA + { + public: + EMSA1(HashFunction* h) : hash(h) {} + ~EMSA1() { delete hash; } + protected: + const HashFunction* hash_ptr() const { return hash; } + private: + void update(const byte[], u32bit); + SecureVector raw_data(); + + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator& rng); + + bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw(); + + HashFunction* hash; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa1_bsi.h b/src/libs/3rdparty/botan/build/botan/emsa1_bsi.h new file mode 100644 index 00000000000..ec86d40e259 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa1_bsi.h @@ -0,0 +1,32 @@ +/* +* EMSA1 BSI Variant +* (C) 1999-2008 Jack Lloyd +* 2007 FlexSecure GmbH +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EMSA1_BSI_H__ +#define BOTAN_EMSA1_BSI_H__ + +#include + +namespace Botan { + +/** +EMSA1_BSI is a variant of EMSA1 specified by the BSI. It accepts only +hash values which are less or equal than the maximum key length. The +implementation comes from InSiTo +*/ +class BOTAN_DLL EMSA1_BSI : public EMSA1 + { + public: + EMSA1_BSI(HashFunction* hash) : EMSA1(hash) {} + private: + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator& rng); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa2.h b/src/libs/3rdparty/botan/build/botan/emsa2.h new file mode 100644 index 00000000000..76888d1f6b5 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa2.h @@ -0,0 +1,41 @@ +/* +* EMSA2 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EMSA2_H__ +#define BOTAN_EMSA2_H__ + +#include +#include + +namespace Botan { + +/* +* EMSA2 +*/ +class BOTAN_DLL EMSA2 : public EMSA + { + public: + EMSA2(HashFunction* hash); + ~EMSA2() { delete hash; } + private: + void update(const byte[], u32bit); + SecureVector raw_data(); + + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator& rng); + + bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw(); + + SecureVector empty_hash; + HashFunction* hash; + byte hash_id; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa3.h b/src/libs/3rdparty/botan/build/botan/emsa3.h new file mode 100644 index 00000000000..301f2142a93 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa3.h @@ -0,0 +1,65 @@ +/* +* EMSA3 and EMSA3_Raw +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EMSA3_H__ +#define BOTAN_EMSA3_H__ + +#include +#include + +namespace Botan { + +/** +* EMSA3 +* aka PKCS #1 v1.5 signature padding +* aka PKCS #1 block type 1 +*/ +class BOTAN_DLL EMSA3 : public EMSA + { + public: + EMSA3(HashFunction*); + ~EMSA3(); + + void update(const byte[], u32bit); + + SecureVector raw_data(); + + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator& rng); + + bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw(); + private: + HashFunction* hash; + SecureVector hash_id; + }; + +/** +* EMSA3_Raw which is EMSA3 without a hash or digest id (which +* according to QCA docs is "identical to PKCS#11's CKM_RSA_PKCS +* mechanism", something I have not confirmed) +*/ +class BOTAN_DLL EMSA3_Raw : public EMSA + { + public: + void update(const byte[], u32bit); + + SecureVector raw_data(); + + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator& rng); + + bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw(); + + private: + SecureVector message; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa4.h b/src/libs/3rdparty/botan/build/botan/emsa4.h new file mode 100644 index 00000000000..b716178a97b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa4.h @@ -0,0 +1,43 @@ +/* +* EMSA4 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EMSA4_H__ +#define BOTAN_EMSA4_H__ + +#include +#include +#include + +namespace Botan { + +/* +* EMSA4 +*/ +class BOTAN_DLL EMSA4 : public EMSA + { + public: + EMSA4(HashFunction*); + EMSA4(HashFunction*, u32bit); + + ~EMSA4() { delete hash; delete mgf; } + private: + void update(const byte[], u32bit); + SecureVector raw_data(); + + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator& rng); + bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw(); + + u32bit SALT_SIZE; + HashFunction* hash; + const MGF* mgf; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/emsa_raw.h b/src/libs/3rdparty/botan/build/botan/emsa_raw.h new file mode 100644 index 00000000000..1b0ad516eda --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/emsa_raw.h @@ -0,0 +1,34 @@ +/* +* EMSA-Raw +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EMSA_RAW_H__ +#define BOTAN_EMSA_RAW_H__ + +#include + +namespace Botan { + +/* +* EMSA-Raw +*/ +class BOTAN_DLL EMSA_Raw : public EMSA + { + private: + void update(const byte[], u32bit); + SecureVector raw_data(); + + SecureVector encoding_of(const MemoryRegion&, u32bit, + RandomNumberGenerator&); + bool verify(const MemoryRegion&, const MemoryRegion&, + u32bit) throw(); + + SecureVector message; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/engine.h b/src/libs/3rdparty/botan/build/botan/engine.h new file mode 100644 index 00000000000..66a159e38c8 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/engine.h @@ -0,0 +1,140 @@ +/* +* Engine +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ENGINE_H__ +#define BOTAN_ENGINE_H__ + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) + #include +#endif + +#if defined(BOTAN_HAS_DSA) + #include +#endif + +#if defined(BOTAN_HAS_DIFFIE_HELLMAN) + #include +#endif + +#if defined(BOTAN_HAS_NYBERG_RUEPPEL) + #include +#endif + +#if defined(BOTAN_HAS_ELGAMAL) + #include +#endif + +#if defined(BOTAN_HAS_ECDSA) + #include + #include +#endif + +#if defined(BOTAN_HAS_ECKAEG) + #include + #include +#endif + +namespace Botan { + +class Algorithm_Factory; +class Keyed_Filter; + +/* +* Engine Base Class +*/ +class BOTAN_DLL Engine + { + public: + virtual ~Engine() {} + + virtual std::string provider_name() const = 0; + + // Lookup functions + virtual BlockCipher* + find_block_cipher(const SCAN_Name&, Algorithm_Factory&) const + { return 0; } + + virtual StreamCipher* + find_stream_cipher(const SCAN_Name&, Algorithm_Factory&) const + { return 0; } + + virtual HashFunction* + find_hash(const SCAN_Name&, Algorithm_Factory&) const + { return 0; } + + virtual MessageAuthenticationCode* + find_mac(const SCAN_Name&, Algorithm_Factory&) const + { return 0; } + + virtual Modular_Exponentiator* + mod_exp(const BigInt&, Power_Mod::Usage_Hints) const + { return 0; } + + virtual Keyed_Filter* get_cipher(const std::string&, + Cipher_Dir, + Algorithm_Factory&) + { return 0; } + +#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) + virtual IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&) const + { return 0; } +#endif + +#if defined(BOTAN_HAS_DSA) + virtual DSA_Operation* dsa_op(const DL_Group&, const BigInt&, + const BigInt&) const + { return 0; } +#endif + +#if defined(BOTAN_HAS_NYBERG_RUEPPEL) + virtual NR_Operation* nr_op(const DL_Group&, const BigInt&, + const BigInt&) const + { return 0; } +#endif + +#if defined(BOTAN_HAS_ELGAMAL) + virtual ELG_Operation* elg_op(const DL_Group&, const BigInt&, + const BigInt&) const + { return 0; } +#endif + +#if defined(BOTAN_HAS_DIFFIE_HELLMAN) + virtual DH_Operation* dh_op(const DL_Group&, const BigInt&) const + { return 0; } +#endif + +#if defined(BOTAN_HAS_ECDSA) + virtual ECDSA_Operation* ecdsa_op(const EC_Domain_Params&, + const BigInt&, + const PointGFp&) const + { return 0; } +#endif + +#if defined(BOTAN_HAS_ECKAEG) + virtual ECKAEG_Operation* eckaeg_op(const EC_Domain_Params&, + const BigInt&, + const PointGFp&) const + { return 0; } +#endif + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/entropy_src.h b/src/libs/3rdparty/botan/build/botan/entropy_src.h new file mode 100644 index 00000000000..a1a53fafb72 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/entropy_src.h @@ -0,0 +1,95 @@ +/** +* EntropySource +* (C) 2008-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ENTROPY_SOURCE_BASE_H__ +#define BOTAN_ENTROPY_SOURCE_BASE_H__ + +#include +#include +#include + +namespace Botan { + +/** +* Class used to accumulate the poll results of EntropySources +*/ +class Entropy_Accumulator + { + public: + Entropy_Accumulator(u32bit goal) : + entropy_goal(goal), collected_bits(0) {} + + virtual ~Entropy_Accumulator() {} + + /** + @return cached I/O buffer for repeated polls + */ + MemoryRegion& get_io_buffer(u32bit size) + { io_buffer.create(size); return io_buffer; } + + u32bit bits_collected() const + { return static_cast(collected_bits); } + + bool polling_goal_achieved() const + { return (collected_bits >= entropy_goal); } + + u32bit desired_remaining_bits() const + { + if(collected_bits >= entropy_goal) + return 0; + return static_cast(entropy_goal - collected_bits); + } + + void add(const void* bytes, u32bit length, double entropy_bits_per_byte) + { + add_bytes(reinterpret_cast(bytes), length); + collected_bits += entropy_bits_per_byte * length; + } + + template + void add(const T& v, double entropy_bits_per_byte) + { + add(&v, sizeof(T), entropy_bits_per_byte); + } + private: + virtual void add_bytes(const byte bytes[], u32bit length) = 0; + + SecureVector io_buffer; + u32bit entropy_goal; + double collected_bits; + }; + +class Entropy_Accumulator_BufferedComputation : public Entropy_Accumulator + { + public: + Entropy_Accumulator_BufferedComputation(BufferedComputation& sink, + u32bit goal) : + Entropy_Accumulator(goal), entropy_sink(sink) {} + + private: + virtual void add_bytes(const byte bytes[], u32bit length) + { + entropy_sink.update(bytes, length); + } + + BufferedComputation& entropy_sink; + }; + +/** +* Abstract interface to a source of (hopefully unpredictable) system entropy +*/ +class BOTAN_DLL EntropySource + { + public: + virtual std::string name() const = 0; + virtual void poll(Entropy_Accumulator& accum) = 0; + virtual ~EntropySource() {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/es_capi.h b/src/libs/3rdparty/botan/build/botan/es_capi.h new file mode 100644 index 00000000000..55966d793a8 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/es_capi.h @@ -0,0 +1,33 @@ +/* +* Win32 CAPI EntropySource +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ENTROPY_SRC_WIN32_CAPI_H__ +#define BOTAN_ENTROPY_SRC_WIN32_CAPI_H__ + +#include +#include + +namespace Botan { + +/** +* Win32 CAPI Entropy Source +*/ +class BOTAN_DLL Win32_CAPI_EntropySource : public EntropySource + { + public: + std::string name() const { return "Win32 CryptoGenRandom"; } + + void poll(Entropy_Accumulator& accum); + + Win32_CAPI_EntropySource(const std::string& = ""); + private: + std::vector prov_types; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/es_win32.h b/src/libs/3rdparty/botan/build/botan/es_win32.h new file mode 100644 index 00000000000..0aa9054e3ab --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/es_win32.h @@ -0,0 +1,27 @@ +/** +* Win32 EntropySource +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ENTROPY_SRC_WIN32_H__ +#define BOTAN_ENTROPY_SRC_WIN32_H__ + +#include + +namespace Botan { + +/** +* Win32 Entropy Source +*/ +class BOTAN_DLL Win32_EntropySource : public EntropySource + { + public: + std::string name() const { return "Win32 Statistics"; } + void poll(Entropy_Accumulator& accum); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/exceptn.h b/src/libs/3rdparty/botan/build/botan/exceptn.h new file mode 100644 index 00000000000..a55d842bcca --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/exceptn.h @@ -0,0 +1,197 @@ +/* +* Exceptions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_EXCEPTION_H__ +#define BOTAN_EXCEPTION_H__ + +#include +#include +#include + +namespace Botan { + +/* +* Exception Base Class +*/ +class BOTAN_DLL Exception : public std::exception + { + public: + const char* what() const throw() { return msg.c_str(); } + Exception(const std::string& m = "Unknown error") { set_msg(m); } + virtual ~Exception() throw() {} + protected: + void set_msg(const std::string& m) { msg = "Botan: " + m; } + private: + std::string msg; + }; + +/* +* Invalid_Argument Exception +*/ +struct BOTAN_DLL Invalid_Argument : public Exception + { + Invalid_Argument(const std::string& err = "") : Exception(err) {} + }; + +/* +* Invalid_Key_Length Exception +*/ +struct BOTAN_DLL Invalid_Key_Length : public Invalid_Argument + { + Invalid_Key_Length(const std::string&, u32bit); + }; + +/* +* Invalid_Block_Size Exception +*/ +struct BOTAN_DLL Invalid_Block_Size : public Invalid_Argument + { + Invalid_Block_Size(const std::string&, const std::string&); + }; + +/* +* Invalid_IV_Length Exception +*/ +struct BOTAN_DLL Invalid_IV_Length : public Invalid_Argument + { + Invalid_IV_Length(const std::string&, u32bit); + }; + +/* +* Invalid_State Exception +*/ +struct BOTAN_DLL Invalid_State : public Exception + { + Invalid_State(const std::string& err) : Exception(err) {} + }; + +/* +* PRNG_Unseeded Exception +*/ +struct BOTAN_DLL PRNG_Unseeded : public Invalid_State + { + PRNG_Unseeded(const std::string& algo) : + Invalid_State("PRNG not seeded: " + algo) {} + }; + +/* +* Policy_Violation Exception +*/ +struct BOTAN_DLL Policy_Violation : public Invalid_State + { + Policy_Violation(const std::string& err) : + Invalid_State("Policy violation: " + err) {} + }; + +/* +* Lookup_Error Exception +*/ +struct BOTAN_DLL Lookup_Error : public Exception + { + Lookup_Error(const std::string& err) : Exception(err) {} + }; + +/* +* Algorithm_Not_Found Exception +*/ +struct BOTAN_DLL Algorithm_Not_Found : public Exception + { + Algorithm_Not_Found(const std::string&); + }; + +/* +* Format_Error Exception +*/ +struct BOTAN_DLL Format_Error : public Exception + { + Format_Error(const std::string& err = "") : Exception(err) {} + }; + +/* +* Invalid_Algorithm_Name Exception +*/ +struct BOTAN_DLL Invalid_Algorithm_Name : public Format_Error + { + Invalid_Algorithm_Name(const std::string&); + }; + +/* +* Encoding_Error Exception +*/ +struct BOTAN_DLL Encoding_Error : public Format_Error + { + Encoding_Error(const std::string& name) : + Format_Error("Encoding error: " + name) {} + }; + +/* +* Decoding_Error Exception +*/ +struct BOTAN_DLL Decoding_Error : public Format_Error + { + Decoding_Error(const std::string& name) : + Format_Error("Decoding error: " + name) {} + }; + +/* +* Invalid_OID Exception +*/ +struct BOTAN_DLL Invalid_OID : public Decoding_Error + { + Invalid_OID(const std::string& oid) : + Decoding_Error("Invalid ASN.1 OID: " + oid) {} + }; + +/* +* Stream_IO_Error Exception +*/ +struct BOTAN_DLL Stream_IO_Error : public Exception + { + Stream_IO_Error(const std::string& err) : + Exception("I/O error: " + err) {} + }; + +/* +* Configuration Error Exception +*/ +struct BOTAN_DLL Config_Error : public Format_Error + { + Config_Error(const std::string& err) : + Format_Error("Config error: " + err) {} + Config_Error(const std::string&, u32bit); + }; + +/* +* Integrity Failure Exception +*/ +struct BOTAN_DLL Integrity_Failure : public Exception + { + Integrity_Failure(const std::string& err) : + Exception("Integrity failure: " + err) {} + }; + +/* +* Internal_Error Exception +*/ +struct BOTAN_DLL Internal_Error : public Exception + { + Internal_Error(const std::string& err) : + Exception("Internal error: " + err) {} + }; + +/* +* Self Test Failure Exception +*/ +struct BOTAN_DLL Self_Test_Failure : public Internal_Error + { + Self_Test_Failure(const std::string& err) : + Internal_Error("Self test failed: " + err) {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/filter.h b/src/libs/3rdparty/botan/build/botan/filter.h new file mode 100644 index 00000000000..b13a36650cc --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/filter.h @@ -0,0 +1,113 @@ +/* +* Filter +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_FILTER_H__ +#define BOTAN_FILTER_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents general abstract filter objects. +*/ +class BOTAN_DLL Filter + { + public: + + /** + * Write a portion of a message to this filter. + * @param input the input as a byte array + * @param length the length of the byte array input + */ + virtual void write(const byte input[], u32bit length) = 0; + + /** + * Start a new message. Must be closed by end_msg() before another + * message can be startet. + */ + virtual void start_msg() {} + + /** + * Tell the Filter that the current message shall be ended. + */ + virtual void end_msg() {} + + /** + * Check whether this filter is an attachable filter. + * @return true if this filter is attachable, false otherwise + */ + virtual bool attachable() { return true; } + + /** + * Start a new message in *this and all following filters. Only for + * internal use, not intended for use in client applications. + */ + void new_msg(); + + /** + * End a new message in *this and all following filters. Only for + * internal use, not intended for use in client applications. + */ + void finish_msg(); + + virtual ~Filter() {} + protected: + void send(const byte[], u32bit); + void send(byte input) { send(&input, 1); } + void send(const MemoryRegion& in) { send(in.begin(), in.size()); } + Filter(); + private: + Filter(const Filter&) {} + Filter& operator=(const Filter&) { return (*this); } + + friend class Pipe; + friend class Fanout_Filter; + + u32bit total_ports() const; + u32bit current_port() const { return port_num; } + void set_port(u32bit); + + u32bit owns() const { return filter_owns; } + + void attach(Filter*); + void set_next(Filter*[], u32bit); + Filter* get_next() const; + + SecureVector write_queue; + std::vector next; + u32bit port_num, filter_owns; + + // true if filter belongs to a pipe --> prohibit filter sharing! + bool owned; + }; + +/** +* This is the abstract Fanout_Filter base class. +**/ +class BOTAN_DLL Fanout_Filter : public Filter + { + protected: + void incr_owns() { ++filter_owns; } + + void set_port(u32bit n) { Filter::set_port(n); } + void set_next(Filter* f[], u32bit n) { Filter::set_next(f, n); } + void attach(Filter* f) { Filter::attach(f); } + }; + +/** +* The type of checking to be performed by decoders: +* NONE - no checks, IGNORE_WS - perform checks, but ignore +* whitespaces, FULL_CHECK - perform checks, also complain +* about white spaces. +*/ +enum Decoder_Checking { NONE, IGNORE_WS, FULL_CHECK }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/filters.h b/src/libs/3rdparty/botan/build/botan/filters.h new file mode 100644 index 00000000000..725651f7de6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/filters.h @@ -0,0 +1,189 @@ +/* +* Filters +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_FILTERS_H__ +#define BOTAN_FILTERS_H__ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(BOTAN_HAS_BASE64_CODEC) + #include +#endif + +#if defined(BOTAN_HAS_HEX_CODEC) + #include +#endif + +namespace Botan { + +/** +* Stream Cipher Filter. +*/ +class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter + { + public: + + /** + * Seek in the stream. + * @param position the position to seek ahead + */ + void seek(u32bit position) { cipher->seek(position); } + + /** + * Find out whether the cipher underlying this filter supports + * resyncing. + * @return true if the cipher supports resyncing + */ + bool supports_resync() const { return (cipher->IV_LENGTH != 0); } + + /** + * Set the initialization vector for this filter. + * @param iv the initialization vector to set + */ + void set_iv(const InitializationVector& iv); + void write(const byte[], u32bit); + + /** + * Construct a stream cipher filter. + * @param cipher_obj a cipher object to use + */ + StreamCipher_Filter(StreamCipher* cipher_obj); + + /** + * Construct a stream cipher filter. + * @param cipher the name of the desired cipher + */ + StreamCipher_Filter(const std::string& cipher); + + /** + * Construct a stream cipher filter. + * @param cipher the name of the desired cipher + * @param key the key to use inside this filter + */ + StreamCipher_Filter(const std::string& cipher, const SymmetricKey& key); + + ~StreamCipher_Filter() { delete cipher; } + private: + SecureVector buffer; + StreamCipher* cipher; + }; + +/** +* Hash Filter. +*/ +class BOTAN_DLL Hash_Filter : public Filter + { + public: + void write(const byte input[], u32bit len) { hash->update(input, len); } + void end_msg(); + + /** + * Construct a hash filter. + * @param hash_fun the hash function to use + * @param len the output length of this filter. Leave the default + * value 0 if you want to use the full output of the hashfunction + * hash. Otherwise, specify a smaller value here so that the + * output of the hash algorithm will be cut off. + */ + Hash_Filter(HashFunction* hash_fun, u32bit len = 0) : + OUTPUT_LENGTH(len), hash(hash_fun) {} + + /** + * Construct a hash filter. + * @param request the name of the hash algorithm to use + * @param len the output length of this filter. Leave the default + * value 0 if you want to use the full output of the hashfunction + * hash. Otherwise, specify a smaller value here so that the + * output of the hash algorithm will be cut off. + */ + Hash_Filter(const std::string& request, u32bit len = 0); + + ~Hash_Filter() { delete hash; } + private: + const u32bit OUTPUT_LENGTH; + HashFunction* hash; + }; + +/** +* MessageAuthenticationCode Filter. +*/ +class BOTAN_DLL MAC_Filter : public Keyed_Filter + { + public: + void write(const byte input[], u32bit len) { mac->update(input, len); } + void end_msg(); + + /** + * Construct a MAC filter. The MAC key will be left empty. + * @param mac the MAC to use + * @param len the output length of this filter. Leave the default + * value 0 if you want to use the full output of the + * MAC. Otherwise, specify a smaller value here so that the + * output of the MAC will be cut off. + */ + MAC_Filter(MessageAuthenticationCode* mac_obj, + u32bit out_len = 0) : OUTPUT_LENGTH(out_len) + { + base_ptr = mac = mac_obj; + } + + /** + * Construct a MAC filter. + * @param mac the MAC to use + * @param key the MAC key to use + * @param len the output length of this filter. Leave the default + * value 0 if you want to use the full output of the + * MAC. Otherwise, specify a smaller value here so that the + * output of the MAC will be cut off. + */ + MAC_Filter(MessageAuthenticationCode* mac_obj, + const SymmetricKey& key, + u32bit out_len = 0) : OUTPUT_LENGTH(out_len) + { + base_ptr = mac = mac_obj; + mac->set_key(key); + } + + /** + * Construct a MAC filter. The MAC key will be left empty. + * @param mac the name of the MAC to use + * @param len the output length of this filter. Leave the default + * value 0 if you want to use the full output of the + * MAC. Otherwise, specify a smaller value here so that the + * output of the MAC will be cut off. + */ + MAC_Filter(const std::string& mac, u32bit len = 0); + + /** + * Construct a MAC filter. + * @param mac the name of the MAC to use + * @param key the MAC key to use + * @param len the output length of this filter. Leave the default + * value 0 if you want to use the full output of the + * MAC. Otherwise, specify a smaller value here so that the + * output of the MAC will be cut off. + */ + MAC_Filter(const std::string& mac, const SymmetricKey& key, + u32bit len = 0); + + ~MAC_Filter() { delete mac; } + private: + const u32bit OUTPUT_LENGTH; + MessageAuthenticationCode* mac; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/fork256.h b/src/libs/3rdparty/botan/build/botan/fork256.h new file mode 100644 index 00000000000..70d336cc98b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/fork256.h @@ -0,0 +1,35 @@ +/* +* FORK-256 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_FORK_256_H__ +#define BOTAN_FORK_256_H__ + +#include + +namespace Botan { + +/* +* FORK-256 +*/ +class BOTAN_DLL FORK_256 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "FORK-256"; } + HashFunction* clone() const { return new FORK_256; } + FORK_256() : MDx_HashFunction(32, 64, true, true) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer digest; + SecureBuffer M; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/get_pbe.h b/src/libs/3rdparty/botan/build/botan/get_pbe.h new file mode 100644 index 00000000000..04eda66968f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/get_pbe.h @@ -0,0 +1,33 @@ +/* +* PBE Lookup +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LOOKUP_PBE_H__ +#define BOTAN_LOOKUP_PBE_H__ + +#include +#include + +namespace Botan { + +/** +* Factory function for PBEs. +* @param algo_spec the name of the PBE algorithm to retrieve +* @return a pointer to a PBE with randomly created parameters +*/ +BOTAN_DLL PBE* get_pbe(const std::string&); + +/** +* Factory function for PBEs. +* @param pbe_oid the oid of the desired PBE +* @param params a DataSource providing the DER encoded parameters to use +* @return a pointer to the PBE with the specified parameters +*/ +BOTAN_DLL PBE* get_pbe(const OID&, DataSource&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/gost_28147.h b/src/libs/3rdparty/botan/build/botan/gost_28147.h new file mode 100644 index 00000000000..96d24c6699e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/gost_28147.h @@ -0,0 +1,67 @@ +/* +* GOST 28147-89 +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_GOST_28147_89_H__ +#define BOTAN_GOST_28147_89_H__ + +#include + +namespace Botan { + +class GOST_28147_89_Params; + +/** +* The GOST 28147-89 block cipher uses a set of 4 bit Sboxes, however +* the standard does not actually define these Sboxes; they are +* considered a local configuration issue. Several different sets are +* used. +*/ +class GOST_28147_89_Params + { + public: + byte sbox_entry(u32bit row, u32bit col) const; + + std::string param_name() const { return name; } + + /** + * Default GOST parameters are the ones given in GOST R 34.11 for + * testing purposes; these sboxes are also used by Crypto++, and, + * at least according to Wikipedia, the Central Bank of Russian Federation + */ + GOST_28147_89_Params(const std::string& name = "R3411_94_TestParam"); + private: + const byte* sboxes; + std::string name; + }; + +/** +* GOST 28147-89 +*/ +class BOTAN_DLL GOST_28147_89 : public BlockCipher + { + public: + void clear() throw() { EK.clear(); } + + std::string name() const { return "GOST-28147-89"; } + BlockCipher* clone() const { return new GOST_28147_89(SBOX); } + + GOST_28147_89(const GOST_28147_89_Params& params); + private: + GOST_28147_89(const SecureBuffer& other_SBOX) : + BlockCipher(8, 32), SBOX(other_SBOX) {} + + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer SBOX; + SecureBuffer EK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/gost_3411.h b/src/libs/3rdparty/botan/build/botan/gost_3411.h new file mode 100644 index 00000000000..c6955505245 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/gost_3411.h @@ -0,0 +1,41 @@ +/** +* GOST 34.11 +* (C) 2009 Jack Lloyd +*/ + +#ifndef BOTAN_GOST_3411_H__ +#define BOTAN_GOST_3411_H__ + +#include +#include + +namespace Botan { + +/** +* GOST 34.11 +*/ +class BOTAN_DLL GOST_34_11 : public HashFunction + { + public: + void clear() throw(); + std::string name() const { return "GOST-R-34.11-94" ; } + HashFunction* clone() const { return new GOST_34_11; } + + GOST_34_11(); + protected: + void compress_n(const byte input[], u32bit blocks); + + void add_data(const byte[], u32bit); + void final_result(byte[]); + + GOST_28147_89 cipher; + SecureBuffer buffer; + SecureBuffer sum; + SecureBuffer hash; + u64bit count; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/has160.h b/src/libs/3rdparty/botan/build/botan/has160.h new file mode 100644 index 00000000000..44bb63b9d33 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/has160.h @@ -0,0 +1,35 @@ +/* +* HAS-160 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_HAS_160_H__ +#define BOTAN_HAS_160_H__ + +#include + +namespace Botan { + +/* +* HAS-160 +*/ +class BOTAN_DLL HAS_160 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "HAS-160"; } + HashFunction* clone() const { return new HAS_160; } + HAS_160() : MDx_HashFunction(20, 64, false, true) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer X; + SecureBuffer digest; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/hash.h b/src/libs/3rdparty/botan/build/botan/hash.h new file mode 100644 index 00000000000..a30234be044 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/hash.h @@ -0,0 +1,52 @@ +/** +* Hash Function Base Class +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_HASH_FUNCTION_BASE_CLASS_H__ +#define BOTAN_HASH_FUNCTION_BASE_CLASS_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents hash function (message digest) objects. +*/ +class BOTAN_DLL HashFunction : public BufferedComputation + { + public: + /** + * The hash block size as defined for this algorithm. + */ + const u32bit HASH_BLOCK_SIZE; + + /** + * Get a new object representing the same algorithm as *this + */ + virtual HashFunction* clone() const = 0; + + /** + * Get the name of this algorithm. + * @return the name of this algorithm + */ + virtual std::string name() const = 0; + + /** + * Reset the internal state of this object. + */ + virtual void clear() throw() = 0; + + HashFunction(u32bit hash_len, u32bit block_len = 0) : + BufferedComputation(hash_len), HASH_BLOCK_SIZE(block_len) {} + virtual ~HashFunction() {} + private: + HashFunction& operator=(const HashFunction&); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/hash_id.h b/src/libs/3rdparty/botan/build/botan/hash_id.h new file mode 100644 index 00000000000..847d9106cac --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/hash_id.h @@ -0,0 +1,24 @@ +/* +* Hash Function Identification +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_HASHID_H__ +#define BOTAN_HASHID_H__ + +#include +#include + +namespace Botan { + +/* +* Return the values of various defined HashIDs +*/ +BOTAN_DLL MemoryVector pkcs_hash_id(const std::string&); +BOTAN_DLL byte ieee1363_hash_id(const std::string&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/hex.h b/src/libs/3rdparty/botan/build/botan/hex.h new file mode 100644 index 00000000000..035bf4ef973 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/hex.h @@ -0,0 +1,90 @@ +/* +* Hex Encoder/Decoder +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_HEX_H__ +#define BOTAN_HEX_H__ + +#include + +namespace Botan { + +/** +* This class represents a hex encoder. It encodes byte arrays to hex strings. +*/ +class BOTAN_DLL Hex_Encoder : public Filter + { + public: + /** + * Whether to use uppercase or lowercase letters for the encoded string. + */ + enum Case { Uppercase, Lowercase }; + + /** + Encode a single byte into two hex characters + */ + static void encode(byte in, byte out[2], Case the_case = Uppercase); + + void write(const byte in[], u32bit length); + void end_msg(); + + /** + * Create a hex encoder. + * @param the_case the case to use in the encoded strings. + */ + Hex_Encoder(Case the_case); + + /** + * Create a hex encoder. + * @param newlines should newlines be used + * @param line_length if newlines are used, how long are lines + * @param the_case the case to use in the encoded strings + */ + Hex_Encoder(bool newlines = false, + u32bit line_length = 72, + Case the_case = Uppercase); + private: + void encode_and_send(const byte[], u32bit); + static const byte BIN_TO_HEX_UPPER[16]; + static const byte BIN_TO_HEX_LOWER[16]; + + const Case casing; + const u32bit line_length; + SecureVector in, out; + u32bit position, counter; + }; + +/** +* This class represents a hex decoder. It converts hex strings to byte arrays. +*/ +class BOTAN_DLL Hex_Decoder : public Filter + { + public: + static byte decode(const byte[2]); + static bool is_valid(byte); + + void write(const byte[], u32bit); + void end_msg(); + + /** + * Construct a Hex Decoder using the specified + * character checking. + * @param checking the checking to use during decoding. + */ + Hex_Decoder(Decoder_Checking checking = NONE); + private: + void decode_and_send(const byte[], u32bit); + void handle_bad_char(byte); + static const byte HEX_TO_BIN[256]; + + const Decoder_Checking checking; + SecureVector in, out; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/hmac.h b/src/libs/3rdparty/botan/build/botan/hmac.h new file mode 100644 index 00000000000..932af71fca6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/hmac.h @@ -0,0 +1,38 @@ +/* +* HMAC +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_HMAC_H__ +#define BOTAN_HMAC_H__ + +#include +#include + +namespace Botan { + +/* +* HMAC +*/ +class BOTAN_DLL HMAC : public MessageAuthenticationCode + { + public: + void clear() throw(); + std::string name() const; + MessageAuthenticationCode* clone() const; + + HMAC(HashFunction* hash); + ~HMAC() { delete hash; } + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + void key_schedule(const byte[], u32bit); + HashFunction* hash; + SecureVector i_key, o_key; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/hmac_rng.h b/src/libs/3rdparty/botan/build/botan/hmac_rng.h new file mode 100644 index 00000000000..318e2a931ad --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/hmac_rng.h @@ -0,0 +1,59 @@ +/* +* HMAC RNG +* (C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_HMAC_RNG_H__ +#define BOTAN_HMAC_RNG_H__ + +#include +#include +#include + +namespace Botan { + +/** +HMAC_RNG - based on the design described in "On Extract-then-Expand +Key Derivation Functions and an HMAC-based KDF" by Hugo Krawczyk +(henceforce, 'E-t-E') + +However it actually can be parameterized with any two MAC functions, +not restricted to HMAC (this variation is also described in Krawczyk's +paper), for instance one could use HMAC(SHA-512) as the extractor +and CMAC(AES-256) as the PRF. +*/ +class BOTAN_DLL HMAC_RNG : public RandomNumberGenerator + { + public: + void randomize(byte buf[], u32bit len); + bool is_seeded() const { return seeded; } + void clear() throw(); + std::string name() const; + + void reseed(u32bit poll_bits); + void add_entropy_source(EntropySource* es); + void add_entropy(const byte[], u32bit); + + HMAC_RNG(MessageAuthenticationCode* extractor, + MessageAuthenticationCode* prf); + + ~HMAC_RNG(); + private: + void reseed_with_input(u32bit poll_bits, + const byte input[], u32bit length); + + MessageAuthenticationCode* extractor; + MessageAuthenticationCode* prf; + + std::vector entropy_sources; + bool seeded; + + SecureVector K, io_buffer; + u32bit counter, source_index; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/idea.h b/src/libs/3rdparty/botan/build/botan/idea.h new file mode 100644 index 00000000000..2c53cd0e46d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/idea.h @@ -0,0 +1,34 @@ +/* +* IDEA +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_IDEA_H__ +#define BOTAN_IDEA_H__ + +#include + +namespace Botan { + +/* +* IDEA +*/ +class BOTAN_DLL IDEA : public BlockCipher + { + public: + void clear() throw() { EK.clear(); DK.clear(); } + std::string name() const { return "IDEA"; } + BlockCipher* clone() const { return new IDEA; } + IDEA() : BlockCipher(8, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + SecureBuffer EK, DK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/if_algo.h b/src/libs/3rdparty/botan/build/botan/if_algo.h new file mode 100644 index 00000000000..32a29be49ce --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/if_algo.h @@ -0,0 +1,85 @@ +/* +* IF Scheme +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_IF_ALGO_H__ +#define BOTAN_IF_ALGO_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents public keys +* of integer factorization based (IF) public key schemes. +*/ +class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key + { + public: + bool check_key(RandomNumberGenerator& rng, bool) const; + + /** + * Get n = p * q. + * @return n + */ + const BigInt& get_n() const { return n; } + + /** + * Get the public exponent used by the key. + * @return the public exponent + */ + const BigInt& get_e() const { return e; } + + u32bit max_input_bits() const { return (n.bits() - 1); } + + X509_Encoder* x509_encoder() const; + X509_Decoder* x509_decoder(); + protected: + virtual void X509_load_hook(); + BigInt n, e; + IF_Core core; + }; + +/** +* This class represents public keys +* of integer factorization based (IF) public key schemes. +*/ +class BOTAN_DLL IF_Scheme_PrivateKey : public virtual IF_Scheme_PublicKey, + public virtual Private_Key + { + public: + bool check_key(RandomNumberGenerator& rng, bool) const; + + /** + * Get the first prime p. + * @return the prime p + */ + const BigInt& get_p() const { return p; } + + /** + * Get the second prime q. + * @return the prime q + */ + const BigInt& get_q() const { return q; } + + /** + * Get d with exp * d = 1 mod (p - 1, q - 1). + * @return d + */ + const BigInt& get_d() const { return d; } + + PKCS8_Encoder* pkcs8_encoder() const; + PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator&); + protected: + virtual void PKCS8_load_hook(RandomNumberGenerator&, bool = false); + BigInt d, p, q, d1, d2, c; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/if_core.h b/src/libs/3rdparty/botan/build/botan/if_core.h new file mode 100644 index 00000000000..b7f487706eb --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/if_core.h @@ -0,0 +1,45 @@ +/* +* IF Algorithm Core +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_IF_CORE_H__ +#define BOTAN_IF_CORE_H__ + +#include +#include + +namespace Botan { + +/* +* IF Core +*/ +class BOTAN_DLL IF_Core + { + public: + BigInt public_op(const BigInt&) const; + BigInt private_op(const BigInt&) const; + + IF_Core& operator=(const IF_Core&); + + IF_Core() { op = 0; } + IF_Core(const IF_Core&); + + IF_Core(const BigInt&, const BigInt&); + + IF_Core(RandomNumberGenerator& rng, + const BigInt&, const BigInt&, + const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&, const BigInt&); + + ~IF_Core() { delete op; } + private: + IF_Operation* op; + Blinder blinder; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/if_op.h b/src/libs/3rdparty/botan/build/botan/if_op.h new file mode 100644 index 00000000000..516902fd9bf --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/if_op.h @@ -0,0 +1,52 @@ +/* +* IF Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_IF_OP_H__ +#define BOTAN_IF_OP_H__ + +#include +#include +#include + +namespace Botan { + +/* +* IF Operation +*/ +class BOTAN_DLL IF_Operation + { + public: + virtual BigInt public_op(const BigInt&) const = 0; + virtual BigInt private_op(const BigInt&) const = 0; + virtual IF_Operation* clone() const = 0; + virtual ~IF_Operation() {} + }; + +/* +* Default IF Operation +*/ +class BOTAN_DLL Default_IF_Op : public IF_Operation + { + public: + BigInt public_op(const BigInt& i) const + { return powermod_e_n(i); } + BigInt private_op(const BigInt&) const; + + IF_Operation* clone() const { return new Default_IF_Op(*this); } + + Default_IF_Op(const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&); + private: + Fixed_Exponent_Power_Mod powermod_e_n, powermod_d1_p, powermod_d2_q; + Modular_Reducer reducer; + BigInt c, q; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/init.h b/src/libs/3rdparty/botan/build/botan/init.h new file mode 100644 index 00000000000..254f9458b1f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/init.h @@ -0,0 +1,41 @@ +/** +* Library Initialization +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LIBRARY_INITIALIZER_H__ +#define BOTAN_LIBRARY_INITIALIZER_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents the Library Initialization/Shutdown Object. It +* has to exceed the lifetime of any Botan object used in an +* application. You can call initialize/deinitialize or use +* LibraryInitializer in the RAII style. +*/ +class BOTAN_DLL LibraryInitializer + { + public: + static void initialize(const std::string& options = ""); + + static void deinitialize(); + + /** + * Initialize the library + * @param thread_safe if the library should use a thread-safe mutex + */ + LibraryInitializer(const std::string& options = "") + { LibraryInitializer::initialize(options); } + + ~LibraryInitializer() { LibraryInitializer::deinitialize(); } + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/kasumi.h b/src/libs/3rdparty/botan/build/botan/kasumi.h new file mode 100644 index 00000000000..df49fa9eb48 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/kasumi.h @@ -0,0 +1,36 @@ +/* +* KASUMI +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KASUMI_H__ +#define BOTAN_KASUMI_H__ + +#include + +namespace Botan { + +/* +* KASUMI +*/ +class BOTAN_DLL KASUMI : public BlockCipher + { + public: + void clear() throw() { EK.clear(); } + std::string name() const { return "KASUMI"; } + BlockCipher* clone() const { return new KASUMI; } + + KASUMI() : BlockCipher(8, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer EK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/kdf.h b/src/libs/3rdparty/botan/build/botan/kdf.h new file mode 100644 index 00000000000..70f636b6cb0 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/kdf.h @@ -0,0 +1,60 @@ +/* +* KDF/MGF +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KDF_BASE_H__ +#define BOTAN_KDF_BASE_H__ + +#include +#include + +namespace Botan { + +/* +* Key Derivation Function +*/ +class BOTAN_DLL KDF + { + public: + SecureVector derive_key(u32bit key_len, + const MemoryRegion& secret, + const std::string& salt = "") const; + SecureVector derive_key(u32bit key_len, + const MemoryRegion& secret, + const MemoryRegion& salt) const; + + SecureVector derive_key(u32bit key_len, + const MemoryRegion& secret, + const byte salt[], u32bit salt_len) const; + + SecureVector derive_key(u32bit key_len, + const byte secret[], u32bit secret_len, + const std::string& salt = "") const; + SecureVector derive_key(u32bit key_len, + const byte secret[], u32bit secret_len, + const byte salt[], u32bit salt_len) const; + + virtual ~KDF() {} + private: + virtual SecureVector derive(u32bit, const byte[], u32bit, + const byte[], u32bit) const = 0; + }; + +/* +* Mask Generation Function +*/ +class BOTAN_DLL MGF + { + public: + virtual void mask(const byte in[], u32bit in_len, + byte out[], u32bit out_len) const = 0; + + virtual ~MGF() {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/kdf1.h b/src/libs/3rdparty/botan/build/botan/kdf1.h new file mode 100644 index 00000000000..d657cccc2a6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/kdf1.h @@ -0,0 +1,36 @@ +/* +* KDF1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KDF1_H__ +#define BOTAN_KDF1_H__ + +#include +#include + +namespace Botan { + +/* +* KDF1 +*/ +class BOTAN_DLL KDF1 : public KDF + { + public: + SecureVector derive(u32bit, + const byte secret[], u32bit secret_len, + const byte P[], u32bit P_len) const; + + KDF1(HashFunction* h) : hash(h) {} + KDF1(const KDF1& other) : KDF(), hash(other.hash->clone()) {} + + ~KDF1() { delete hash; } + private: + HashFunction* hash; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/kdf2.h b/src/libs/3rdparty/botan/build/botan/kdf2.h new file mode 100644 index 00000000000..f748bed0f37 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/kdf2.h @@ -0,0 +1,34 @@ +/* +* KDF2 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KDF2_H__ +#define BOTAN_KDF2_H__ + +#include +#include + +namespace Botan { + +/* +* KDF2 +*/ +class BOTAN_DLL KDF2 : public KDF + { + public: + SecureVector derive(u32bit, const byte[], u32bit, + const byte[], u32bit) const; + + KDF2(HashFunction* h) : hash(h) {} + KDF2(const KDF2& other) : KDF(), hash(other.hash->clone()) {} + ~KDF2() { delete hash; } + private: + HashFunction* hash; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/keypair.h b/src/libs/3rdparty/botan/build/botan/keypair.h new file mode 100644 index 00000000000..b1d5c2da099 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/keypair.h @@ -0,0 +1,47 @@ +/* +* Keypair Checks +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KEYPAIR_H__ +#define BOTAN_KEYPAIR_H__ + +#include + +namespace Botan { + +namespace KeyPair { + +/** +* Tests whether the specified encryptor and decryptor are related to each other, +* i.e. whether encrypting with the encryptor and consecutive decryption leads to +* the original plaintext. +* @param rng the rng to use +* @param enc the encryptor to test +* @param dec the decryptor to test +* @throw Self_Test_Failure if the arguments are not related to each other +*/ +BOTAN_DLL void check_key(RandomNumberGenerator& rng, + PK_Encryptor* enc, + PK_Decryptor* dec); + +/** +* Tests whether the specified signer and verifier are related to each other, +* i.e. whether a signature created with the signer and can be +* successfully verified with the verifier. +* @param rng the rng to use +* @param sig the signer to test +* @param ver the verifier to test +* @throw Self_Test_Failure if the arguments are not related to each other +*/ +BOTAN_DLL void check_key(RandomNumberGenerator& rng, + PK_Signer* sig, + PK_Verifier* ver); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/libstate.h b/src/libs/3rdparty/botan/build/botan/libstate.h new file mode 100644 index 00000000000..2493863a984 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/libstate.h @@ -0,0 +1,125 @@ +/* +* Library Internal/Global State +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LIB_STATE_H__ +#define BOTAN_LIB_STATE_H__ + +#include +#include +#include + +#include +#include +#include + +namespace Botan { + +/* +* Global State Container Base +*/ +class BOTAN_DLL Library_State + { + public: + Library_State(); + ~Library_State(); + + void initialize(bool thread_safe); + + Algorithm_Factory& algorithm_factory(); + + Allocator* get_allocator(const std::string& = "") const; + void add_allocator(Allocator*); + void set_default_allocator(const std::string&); + + /** + * Get a parameter value as std::string. + * @param section the section of the desired key + * @param key the desired keys name + * @result the value of the parameter + */ + std::string get(const std::string& section, + const std::string& key) const; + + /** + * Check whether a certain parameter is set + * or not. + * @param section the section of the desired key + * @param key the desired keys name + * @result true if the parameters value is set, + * false otherwise + */ + bool is_set(const std::string& section, const std::string& key) const; + + /** + * Set a configuration parameter. + * @param section the section of the desired key + * @param key the desired keys name + * @param overwrite if set to true, the parameters value + * will be overwritten even if it is already set, otherwise + * no existing values will be overwritten. + */ + void set(const std::string& section, const std::string& key, + const std::string& value, bool overwrite = true); + + /** + * Get a parameters value out of the "conf" section ( + * referred to as option). + * @param key the desired keys name + */ + std::string option(const std::string& key) const; + + /** + * Set an option. + * @param key the key of the option to set + * @param value the value to set + */ + void set_option(const std::string key, const std::string& value); + + /** + * Add a parameter value to the "alias" section. + * @param key the name of the parameter which shall have a new alias + * @param value the new alias + */ + void add_alias(const std::string&, const std::string&); + + /** + * Resolve an alias. + * @param alias the alias to resolve. + * @return what the alias stands for + */ + std::string deref_alias(const std::string&) const; + + class Mutex* get_mutex() const; + private: + void load_default_config(); + + Library_State(const Library_State&) {} + Library_State& operator=(const Library_State&) { return (*this); } + + class Mutex_Factory* mutex_factory; + + std::map config; + class Mutex* config_lock; + + class Mutex* allocator_lock; + std::map alloc_factory; + mutable Allocator* cached_default_allocator; + std::vector allocators; + + Algorithm_Factory* m_algorithm_factory; + }; + +/* +* Global State +*/ +BOTAN_DLL Library_State& global_state(); +BOTAN_DLL void set_global_state(Library_State*); +BOTAN_DLL Library_State* swap_global_state(Library_State*); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/lion.h b/src/libs/3rdparty/botan/build/botan/lion.h new file mode 100644 index 00000000000..5bc4e72c060 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/lion.h @@ -0,0 +1,43 @@ +/* +* Lion +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LION_H__ +#define BOTAN_LION_H__ + +#include +#include +#include + +namespace Botan { + +/* +* Lion +*/ +class BOTAN_DLL Lion : public BlockCipher + { + public: + void clear() throw(); + std::string name() const; + BlockCipher* clone() const; + + Lion(HashFunction*, StreamCipher*, u32bit); + ~Lion() { delete hash; delete cipher; } + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + const u32bit LEFT_SIZE, RIGHT_SIZE; + + HashFunction* hash; + StreamCipher* cipher; + SecureVector key1, key2; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/loadstor.h b/src/libs/3rdparty/botan/build/botan/loadstor.h new file mode 100644 index 00000000000..77ed1554e46 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/loadstor.h @@ -0,0 +1,281 @@ +/* +* Load/Store Operators +* (C) 1999-2007 Jack Lloyd +* 2007 Yves Jerschow +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LOAD_STORE_H__ +#define BOTAN_LOAD_STORE_H__ + +#include +#include +#include + +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + +#if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN) + +#define BOTAN_ENDIAN_N2B(x) (x) +#define BOTAN_ENDIAN_B2N(x) (x) + +#define BOTAN_ENDIAN_N2L(x) reverse_bytes(x) +#define BOTAN_ENDIAN_L2N(x) reverse_bytes(x) + +#elif defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN) + +#define BOTAN_ENDIAN_N2L(x) (x) +#define BOTAN_ENDIAN_L2N(x) (x) + +#define BOTAN_ENDIAN_N2B(x) reverse_bytes(x) +#define BOTAN_ENDIAN_B2N(x) reverse_bytes(x) + +#endif + +#endif + +namespace Botan { + +/* +* Byte Extraction Function +*/ +template inline byte get_byte(u32bit byte_num, T input) + { + return (input >> ((sizeof(T)-1-(byte_num&(sizeof(T)-1))) << 3)); + } + +/* +* Byte to Word Conversions +*/ +inline u16bit make_u16bit(byte i0, byte i1) + { + return ((static_cast(i0) << 8) | i1); + } + +inline u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3) + { + return ((static_cast(i0) << 24) | + (static_cast(i1) << 16) | + (static_cast(i2) << 8) | + (static_cast(i3))); + } + +inline u64bit make_u64bit(byte i0, byte i1, byte i2, byte i3, + byte i4, byte i5, byte i6, byte i7) + { + return ((static_cast(i0) << 56) | + (static_cast(i1) << 48) | + (static_cast(i2) << 40) | + (static_cast(i3) << 32) | + (static_cast(i4) << 24) | + (static_cast(i5) << 16) | + (static_cast(i6) << 8) | + (static_cast(i7))); + } + +/* +* Endian-Specific Word Loading Operations +*/ +template +inline T load_be(const byte in[], u32bit off) + { + in += off * sizeof(T); + T out = 0; + for(u32bit j = 0; j != sizeof(T); j++) + out = (out << 8) | in[j]; + return out; + } + +template +inline T load_le(const byte in[], u32bit off) + { + in += off * sizeof(T); + T out = 0; + for(u32bit j = 0; j != sizeof(T); j++) + out = (out << 8) | in[sizeof(T)-1-j]; + return out; + } + +template<> +inline u16bit load_be(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2B(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u16bit); + return make_u16bit(in[0], in[1]); +#endif + } + +template<> +inline u16bit load_le(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2L(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u16bit); + return make_u16bit(in[1], in[0]); +#endif + } + +template<> +inline u32bit load_be(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2B(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u32bit); + return make_u32bit(in[0], in[1], in[2], in[3]); +#endif + } + +template<> +inline u32bit load_le(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2L(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u32bit); + return make_u32bit(in[3], in[2], in[1], in[0]); +#endif + } + +template<> +inline u64bit load_be(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2B(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u64bit); + return make_u64bit(in[0], in[1], in[2], in[3], + in[4], in[5], in[6], in[7]); +#endif + } + +template<> +inline u64bit load_le(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2L(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u64bit); + return make_u64bit(in[7], in[6], in[5], in[4], + in[3], in[2], in[1], in[0]); +#endif + } + +/* +* Endian-Specific Word Storing Operations +*/ +inline void store_be(u16bit in, byte out[2]) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_B2N(in); +#else + out[0] = get_byte(0, in); + out[1] = get_byte(1, in); +#endif + } + +inline void store_le(u16bit in, byte out[2]) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_L2N(in); +#else + out[0] = get_byte(1, in); + out[1] = get_byte(0, in); +#endif + } + +inline void store_be(u32bit in, byte out[4]) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_B2N(in); +#else + out[0] = get_byte(0, in); + out[1] = get_byte(1, in); + out[2] = get_byte(2, in); + out[3] = get_byte(3, in); +#endif + } + +inline void store_le(u32bit in, byte out[4]) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_L2N(in); +#else + out[0] = get_byte(3, in); + out[1] = get_byte(2, in); + out[2] = get_byte(1, in); + out[3] = get_byte(0, in); +#endif + } + +inline void store_be(u64bit in, byte out[8]) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_B2N(in); +#else + out[0] = get_byte(0, in); + out[1] = get_byte(1, in); + out[2] = get_byte(2, in); + out[3] = get_byte(3, in); + out[4] = get_byte(4, in); + out[5] = get_byte(5, in); + out[6] = get_byte(6, in); + out[7] = get_byte(7, in); +#endif + } + +inline void store_le(u64bit in, byte out[8]) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_L2N(in); +#else + out[0] = get_byte(7, in); + out[1] = get_byte(6, in); + out[2] = get_byte(5, in); + out[3] = get_byte(4, in); + out[4] = get_byte(3, in); + out[5] = get_byte(2, in); + out[6] = get_byte(1, in); + out[7] = get_byte(0, in); +#endif + } + +template +inline void store_le(byte out[], T a, T b) + { + store_le(a, out + (0 * sizeof(T))); + store_le(b, out + (1 * sizeof(T))); + } + +template +inline void store_be(byte out[], T a, T b) + { + store_be(a, out + (0 * sizeof(T))); + store_be(b, out + (1 * sizeof(T))); + } + +template +inline void store_le(byte out[], T a, T b, T c, T d) + { + store_le(a, out + (0 * sizeof(T))); + store_le(b, out + (1 * sizeof(T))); + store_le(c, out + (2 * sizeof(T))); + store_le(d, out + (3 * sizeof(T))); + } + +template +inline void store_be(byte out[], T a, T b, T c, T d) + { + store_be(a, out + (0 * sizeof(T))); + store_be(b, out + (1 * sizeof(T))); + store_be(c, out + (2 * sizeof(T))); + store_be(d, out + (3 * sizeof(T))); + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/look_pk.h b/src/libs/3rdparty/botan/build/botan/look_pk.h new file mode 100644 index 00000000000..27b67dc5be2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/look_pk.h @@ -0,0 +1,78 @@ +/* +* PK Algorithm Lookup +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PK_LOOKUP_H__ +#define BOTAN_PK_LOOKUP_H__ + +#include +#include + +namespace Botan { + +/** +* Public key encryptor factory method. +* @param key the key that will work inside the encryptor +* @param pad determines the algorithm and encoding +* @return the public key encryptor object +*/ +BOTAN_DLL PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key& key, + const std::string& pad); + +/** +* Public key decryptor factory method. +* @param key the key that will work inside the decryptor +* @param pad determines the algorithm and encoding +* @return the public key decryptor object +*/ +BOTAN_DLL PK_Decryptor* get_pk_decryptor(const PK_Decrypting_Key& key, + const std::string& pad); + +/** +* Public key signer factory method. +* @param key the key that will work inside the signer +* @param pad determines the algorithm, encoding and hash algorithm +* @param sig_format the signature format to be used +* @return the public key signer object +*/ +BOTAN_DLL PK_Signer* get_pk_signer(const PK_Signing_Key& key, + const std::string& pad, + Signature_Format = IEEE_1363); + +/** +* Public key verifier factory method. +* @param key the key that will work inside the verifier +* @param pad determines the algorithm, encoding and hash algorithm +* @param sig_format the signature format to be used +* @return the public key verifier object +*/ +BOTAN_DLL PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key& key, + const std::string& pad, + Signature_Format = IEEE_1363); + +/** +* Public key verifier factory method. +* @param key the key that will work inside the verifier +* @param pad determines the algorithm, encoding and hash algorithm +* @param sig_form the signature format to be used +* @return the public key verifier object +*/ +BOTAN_DLL PK_Verifier* get_pk_verifier(const PK_Verifying_wo_MR_Key& key, + const std::string& pad, + Signature_Format sig_form = IEEE_1363); + +/** +* Public key key agreement factory method. +* @param key the key that will work inside the key agreement +* @param pad determines the algorithm, encoding and hash algorithm +* @return the public key verifier object +*/ +BOTAN_DLL PK_Key_Agreement* get_pk_kas(const PK_Key_Agreement_Key& key, + const std::string& pad); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/lookup.h b/src/libs/3rdparty/botan/build/botan/lookup.h new file mode 100644 index 00000000000..0f48dddfb22 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/lookup.h @@ -0,0 +1,239 @@ +/* +* Algorithm Lookup +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LOOKUP_H__ +#define BOTAN_LOOKUP_H__ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace Botan { + +/* +* Retrieve an object from the lookup table +*/ +// NOTE: these functions return internally stored objects, library +// retains ownership + +BOTAN_DLL const BlockCipher* +retrieve_block_cipher(const std::string&); + +BOTAN_DLL const StreamCipher* +retrieve_stream_cipher(const std::string&); + +BOTAN_DLL const HashFunction* +retrieve_hash(const std::string&); + +BOTAN_DLL const MessageAuthenticationCode* +retrieve_mac(const std::string&); + +/* +* Get an algorithm object +*/ +// NOTE: these functions create and return new objects, letting the +// caller assume ownership of them + +/** +* Block cipher factory method. +* @param algo_spec the name of the desired block cipher +* @return a pointer to the block cipher object +*/ +BOTAN_DLL BlockCipher* get_block_cipher(const std::string& name); + + +/** +* Stream cipher factory method. +* @param algo_spec the name of the desired stream cipher +* @return a pointer to the stream cipher object +*/ +BOTAN_DLL StreamCipher* get_stream_cipher(const std::string& name); + +/** +* Hash function factory method. +* @param algo_spec the name of the desired hash function +* @return a pointer to the hash function object +*/ +BOTAN_DLL HashFunction* get_hash(const std::string& name); + +/** +* MAC factory method. +* @param algo_spec the name of the desired MAC +* @return a pointer to the MAC object +*/ +BOTAN_DLL MessageAuthenticationCode* get_mac(const std::string& name); + +/** +* String to key algorithm factory method. +* @param name the name of the desired string to key (S2K) algorithm +* @return a pointer to the string to key algorithm object +*/ +BOTAN_DLL S2K* get_s2k(const std::string& name); + +/* +* Get an EMSA/EME/KDF/MGF function +*/ +// NOTE: these functions create and return new objects, letting the +// caller assume ownership of them + +/** +* Factory method for EME (message-encoding methods for encryption) objects +* @param name the name of the EME to create +* @return a pointer to the desired EME object +*/ +BOTAN_DLL EME* get_eme(const std::string& name); + +/** +* Factory method for EMSA (message-encoding methods for signatures +* with appendix) objects +* @param name the name of the EME to create +* @return a pointer to the desired EME object +*/ +BOTAN_DLL EMSA* get_emsa(const std::string& name); + +/** +* Factory method for KDF (key derivation function) +* @param name the name of the KDF to create +* @return a pointer to the desired KDF object +*/ +BOTAN_DLL KDF* get_kdf(const std::string& name); + +/* +* Get a cipher object +*/ + +/** +* Factory method for general symmetric cipher filters. +* @param algo_spec the name of the desired cipher +* @param key the key to be used for encryption/decryption performed by +* the filter +* @param iv the initialization vector to be used +* @param direction determines whether the filter will be an encrypting or decrypting +* filter +* @return a pointer to the encryption or decryption filter +*/ +BOTAN_DLL Keyed_Filter* get_cipher(const std::string& name, + const SymmetricKey& key, + const InitializationVector& iv, + Cipher_Dir dir); +/** +* Factory method for general symmetric cipher filters. +* @param algo_spec the name of the desired cipher +* @param key the key to be used for encryption/decryption performed by +* the filter +* @param direction determines whether the filter will be an encrypting or decrypting +* filter +* @return a pointer to the encryption or decryption filter +*/ +BOTAN_DLL Keyed_Filter* get_cipher(const std::string& name, + const SymmetricKey& key, + Cipher_Dir dir); + +/** Factory method for general symmetric cipher filters. No key will +* be set in the filter. +* @param algo_spec the name of the desired cipher + +* @param direction determines whether the filter will be an encrypting or +* decrypting filter +* @return a pointer to the encryption or decryption filter +*/ +BOTAN_DLL Keyed_Filter* get_cipher(const std::string& name, Cipher_Dir dir); + +/** +* Check if an algorithm exists. +* @param name the name of the algorithm to check for +* @return true if the algorithm exists, false otherwise +*/ +BOTAN_DLL bool have_algorithm(const std::string& name); + +/** +* Check if a block cipher algorithm exists. +* @param name the name of the algorithm to check for +* @return true if the algorithm exists, false otherwise +*/ +BOTAN_DLL bool have_block_cipher(const std::string& name); + +/** +* Check if a stream cipher algorithm exists. +* @param name the name of the algorithm to check for +* @return true if the algorithm exists, false otherwise +*/ +BOTAN_DLL bool have_stream_cipher(const std::string& name); + +/** +* Check if a hash algorithm exists. +* @param algo_spec the name of the algorithm to check for +* @return true if the algorithm exists, false otherwise +*/ +BOTAN_DLL bool have_hash(const std::string& name); + +/** +* Check if a MAC algorithm exists. +* @param algo_spec the name of the algorithm to check for +* @return true if the algorithm exists, false otherwise +*/ +BOTAN_DLL bool have_mac(const std::string& name); + +/* +* Query information about an algorithm +*/ + +/** +* Find out the block size of a certain symmetric algorithm. +* @param name the name of the algorithm +* @return the block size of the specified algorithm +*/ +BOTAN_DLL u32bit block_size_of(const std::string& name); + +/** +* Find out the output length of a certain symmetric algorithm. +* @param name the name of the algorithm +* @return the output length of the specified algorithm +*/ +BOTAN_DLL u32bit output_length_of(const std::string& name); + +/** +* Find out the whether a certain key length is allowd for a given +* symmetric algorithm. +* @param key_len the key length in question +* @param name the name of the algorithm +* @return true if the key length is valid for that algorithm, false otherwise +*/ +BOTAN_DLL bool valid_keylength_for(u32bit keylen, const std::string& name); + +/** +* Find out the minimum key size of a certain symmetric algorithm. +* @param name the name of the algorithm +* @return the minimum key length of the specified algorithm +*/ +BOTAN_DLL u32bit min_keylength_of(const std::string& name); + +/** +* Find out the maximum key size of a certain symmetric algorithm. +* @param name the name of the algorithm +* @return the maximum key length of the specified algorithm +*/ +BOTAN_DLL u32bit max_keylength_of(const std::string& name); + +/** +* Find out the size any valid key is a multiple of for a certain algorithm. +* @param name the name of the algorithm +* @return the size any valid key is a multiple of +*/ +BOTAN_DLL u32bit keylength_multiple_of(const std::string& name); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/lubyrack.h b/src/libs/3rdparty/botan/build/botan/lubyrack.h new file mode 100644 index 00000000000..ebde31304f4 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/lubyrack.h @@ -0,0 +1,38 @@ +/* +* Luby-Rackoff +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_LUBY_RACKOFF_H__ +#define BOTAN_LUBY_RACKOFF_H__ + +#include +#include + +namespace Botan { + +/* +* Luby-Rackoff +*/ +class BOTAN_DLL LubyRackoff : public BlockCipher + { + public: + void clear() throw(); + std::string name() const; + BlockCipher* clone() const; + + LubyRackoff(HashFunction* hash); + ~LubyRackoff() { delete hash; } + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + HashFunction* hash; + SecureVector K1, K2; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mac.h b/src/libs/3rdparty/botan/build/botan/mac.h new file mode 100644 index 00000000000..3ec5fff5f54 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mac.h @@ -0,0 +1,60 @@ +/** +* Base class for message authentiction codes +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MESSAGE_AUTH_CODE_BASE_H__ +#define BOTAN_MESSAGE_AUTH_CODE_BASE_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents Message Authentication Code (MAC) objects. +*/ +class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation, + public SymmetricAlgorithm + { + public: + /** + * Verify a MAC. + * @param in the MAC to verify as a byte array + * @param length the length of the byte array + * @return true if the MAC is valid, false otherwise + */ + virtual bool verify_mac(const byte[], u32bit); + + /** + * Get a new object representing the same algorithm as *this + */ + virtual MessageAuthenticationCode* clone() const = 0; + + /** + * Get the name of this algorithm. + * @return the name of this algorithm + */ + virtual std::string name() const = 0; + + /** + * Reset the internal state of this object. + */ + virtual void clear() throw() = 0; + + MessageAuthenticationCode(u32bit mac_len, + u32bit key_min, + u32bit key_max = 0, + u32bit key_mod = 1) : + BufferedComputation(mac_len), + SymmetricAlgorithm(key_min, key_max, key_mod) {} + + virtual ~MessageAuthenticationCode() {} + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mars.h b/src/libs/3rdparty/botan/build/botan/mars.h new file mode 100644 index 00000000000..ca49695afca --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mars.h @@ -0,0 +1,38 @@ +/* +* MARS +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MARS_H__ +#define BOTAN_MARS_H__ + +#include + +namespace Botan { + +class BOTAN_DLL MARS : public BlockCipher + { + public: + void clear() throw() { EK.clear(); } + std::string name() const { return "MARS"; } + BlockCipher* clone() const { return new MARS; } + MARS() : BlockCipher(16, 16, 32, 4) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + void encrypt_round(u32bit&, u32bit&, u32bit&, u32bit&, u32bit) const; + void decrypt_round(u32bit&, u32bit&, u32bit&, u32bit&, u32bit) const; + static void forward_mix(u32bit&, u32bit&, u32bit&, u32bit&); + static void reverse_mix(u32bit&, u32bit&, u32bit&, u32bit&); + + static const u32bit SBOX[512]; + SecureBuffer EK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/md2.h b/src/libs/3rdparty/botan/build/botan/md2.h new file mode 100644 index 00000000000..9337c43f4c4 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/md2.h @@ -0,0 +1,37 @@ +/* +* MD2 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MD2_H__ +#define BOTAN_MD2_H__ + +#include + +namespace Botan { + +/* +* MD2 +*/ +class BOTAN_DLL MD2 : public HashFunction + { + public: + void clear() throw(); + std::string name() const { return "MD2"; } + HashFunction* clone() const { return new MD2; } + MD2() : HashFunction(16, 16) { clear(); } + private: + void add_data(const byte[], u32bit); + void hash(const byte[]); + void final_result(byte[]); + + SecureBuffer X; + SecureBuffer checksum, buffer; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/md4.h b/src/libs/3rdparty/botan/build/botan/md4.h new file mode 100644 index 00000000000..df6f2292d8c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/md4.h @@ -0,0 +1,36 @@ +/* +* MD4 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MD4_H__ +#define BOTAN_MD4_H__ + +#include + +namespace Botan { + +/* +* MD4 +*/ +class BOTAN_DLL MD4 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "MD4"; } + HashFunction* clone() const { return new MD4; } + MD4() : MDx_HashFunction(16, 64, false, true) { clear(); } + protected: + void compress_n(const byte input[], u32bit blocks); + void hash_old(const byte[]); + void copy_out(byte[]); + + SecureBuffer M; + SecureBuffer digest; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/md5.h b/src/libs/3rdparty/botan/build/botan/md5.h new file mode 100644 index 00000000000..85f684d8b2c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/md5.h @@ -0,0 +1,35 @@ +/** +* MD5 +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MD5_H__ +#define BOTAN_MD5_H__ + +#include + +namespace Botan { + +/** +* MD5 +*/ +class BOTAN_DLL MD5 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "MD5"; } + HashFunction* clone() const { return new MD5; } + MD5() : MDx_HashFunction(16, 64, false, true) { clear(); } + protected: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer M; + SecureBuffer digest; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mdx_hash.h b/src/libs/3rdparty/botan/build/botan/mdx_hash.h new file mode 100644 index 00000000000..0c3aa780697 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mdx_hash.h @@ -0,0 +1,42 @@ +/** +* MDx Hash Function +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MDX_BASE_H__ +#define BOTAN_MDX_BASE_H__ + +#include + +namespace Botan { + +/** +* MDx Hash Function Base Class +*/ +class BOTAN_DLL MDx_HashFunction : public HashFunction + { + public: + MDx_HashFunction(u32bit, u32bit, bool, bool, u32bit = 8); + virtual ~MDx_HashFunction() {} + protected: + void add_data(const byte[], u32bit); + void final_result(byte output[]); + virtual void compress_n(const byte block[], u32bit block_n) = 0; + + void clear() throw(); + virtual void copy_out(byte[]) = 0; + virtual void write_count(byte[]); + private: + SecureVector buffer; + u64bit count; + u32bit position; + + const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN; + const u32bit COUNT_SIZE; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mem_ops.h b/src/libs/3rdparty/botan/build/botan/mem_ops.h new file mode 100644 index 00000000000..0fcf34ba873 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mem_ops.h @@ -0,0 +1,40 @@ +/* +* Memory Operations +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MEMORY_OPS_H__ +#define BOTAN_MEMORY_OPS_H__ + +#include +#include + +namespace Botan { + +/* +* Memory Manipulation Functions +*/ +template inline void copy_mem(T* out, const T* in, u32bit n) + { std::memmove(out, in, sizeof(T)*n); } + +template inline void clear_mem(T* ptr, u32bit n) + { if(n) std::memset(ptr, 0, sizeof(T)*n); } + +template inline void set_mem(T* ptr, u32bit n, byte val) + { std::memset(ptr, val, sizeof(T)*n); } + +template inline bool same_mem(const T* p1, const T* p2, u32bit n) + { + bool is_same = true; + + for(u32bit i = 0; i != n; ++i) + is_same &= (p1[i] == p2[i]); + + return is_same; + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mem_pool.h b/src/libs/3rdparty/botan/build/botan/mem_pool.h new file mode 100644 index 00000000000..a57800972b2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mem_pool.h @@ -0,0 +1,74 @@ +/* +* Pooling Allocator +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_POOLING_ALLOCATOR_H__ +#define BOTAN_POOLING_ALLOCATOR_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/* +* Pooling Allocator +*/ +class BOTAN_DLL Pooling_Allocator : public Allocator + { + public: + void* allocate(u32bit); + void deallocate(void*, u32bit); + + void destroy(); + + Pooling_Allocator(Mutex*); + ~Pooling_Allocator(); + private: + void get_more_core(u32bit); + byte* allocate_blocks(u32bit); + + virtual void* alloc_block(u32bit) = 0; + virtual void dealloc_block(void*, u32bit) = 0; + + class BOTAN_DLL Memory_Block + { + public: + Memory_Block(void*); + + static u32bit bitmap_size() { return BITMAP_SIZE; } + static u32bit block_size() { return BLOCK_SIZE; } + + bool contains(void*, u32bit) const throw(); + byte* alloc(u32bit) throw(); + void free(void*, u32bit) throw(); + + bool operator<(const Memory_Block& other) const + { + if(buffer < other.buffer && other.buffer < buffer_end) + return false; + return (buffer < other.buffer); + } + private: + typedef u64bit bitmap_type; + static const u32bit BITMAP_SIZE = 8 * sizeof(bitmap_type); + static const u32bit BLOCK_SIZE = 64; + + bitmap_type bitmap; + byte* buffer, *buffer_end; + }; + + std::vector blocks; + std::vector::iterator last_used; + std::vector > allocated; + Mutex* mutex; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mgf1.h b/src/libs/3rdparty/botan/build/botan/mgf1.h new file mode 100644 index 00000000000..799ba7eed7c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mgf1.h @@ -0,0 +1,36 @@ +/* +* MGF1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MGF1_H__ +#define BOTAN_MGF1_H__ + +#include +#include + +namespace Botan { + +/* +* MGF1 (Mask Generation Function) +*/ +class BOTAN_DLL MGF1 : public MGF + { + public: + void mask(const byte[], u32bit, byte[], u32bit) const; + + /** + MGF1 constructor: takes ownership of hash + */ + MGF1(HashFunction* hash); + + ~MGF1(); + private: + HashFunction* hash; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/misty1.h b/src/libs/3rdparty/botan/build/botan/misty1.h new file mode 100644 index 00000000000..62d4f856fa3 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/misty1.h @@ -0,0 +1,35 @@ +/** +* MISTY1 +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MISTY1_H__ +#define BOTAN_MISTY1_H__ + +#include + +namespace Botan { + +/** +* MISTY1 +*/ +class BOTAN_DLL MISTY1 : public BlockCipher + { + public: + void clear() throw() { EK.clear(); DK.clear(); } + std::string name() const { return "MISTY1"; } + BlockCipher* clone() const { return new MISTY1; } + MISTY1(u32bit = 8); + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer EK, DK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mode_pad.h b/src/libs/3rdparty/botan/build/botan/mode_pad.h new file mode 100644 index 00000000000..a486d3c1fc4 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mode_pad.h @@ -0,0 +1,120 @@ +/** +* CBC Padding Methods +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_CBC_PADDING_H__ +#define BOTAN_CBC_PADDING_H__ + +#include +#include + +namespace Botan { + +/** +* Block Cipher Mode Padding Method +* This class is pretty limited, it cannot deal well with +* randomized padding methods, or any padding method that +* wants to add more than one block. For instance, it should +* be possible to define cipher text stealing mode as simply +* a padding mode for CBC, which happens to consume the last +* two block (and requires use of the block cipher). +*/ +class BOTAN_DLL BlockCipherModePaddingMethod + { + public: + /** + * @param block output buffer + * @param size of the block + * @param current_position in the last block + */ + virtual void pad(byte block[], + u32bit size, + u32bit current_position) const = 0; + + /** + * @param block the last block + * @param size the of the block + */ + virtual u32bit unpad(const byte block[], + u32bit size) const = 0; + + /** + * @param block_size of the cipher + * @param position in the current block + * @return number of padding bytes that will be appended + */ + virtual u32bit pad_bytes(u32bit block_size, + u32bit position) const; + + /** + * @param block_size of the cipher + * @return valid block size for this padding mode + */ + virtual bool valid_blocksize(u32bit block_size) const = 0; + + /** + * @return name of the mode + */ + virtual std::string name() const = 0; + + /** + * virtual destructor + */ + virtual ~BlockCipherModePaddingMethod() {} + }; + +/** +* PKCS#7 Padding +*/ +class BOTAN_DLL PKCS7_Padding : public BlockCipherModePaddingMethod + { + public: + void pad(byte[], u32bit, u32bit) const; + u32bit unpad(const byte[], u32bit) const; + bool valid_blocksize(u32bit) const; + std::string name() const { return "PKCS7"; } + }; + +/** +* ANSI X9.23 Padding +*/ +class BOTAN_DLL ANSI_X923_Padding : public BlockCipherModePaddingMethod + { + public: + void pad(byte[], u32bit, u32bit) const; + u32bit unpad(const byte[], u32bit) const; + bool valid_blocksize(u32bit) const; + std::string name() const { return "X9.23"; } + }; + +/** +* One And Zeros Padding +*/ +class BOTAN_DLL OneAndZeros_Padding : public BlockCipherModePaddingMethod + { + public: + void pad(byte[], u32bit, u32bit) const; + u32bit unpad(const byte[], u32bit) const; + bool valid_blocksize(u32bit) const; + std::string name() const { return "OneAndZeros"; } + }; + +/** +* Null Padding +*/ +class BOTAN_DLL Null_Padding : public BlockCipherModePaddingMethod + { + public: + void pad(byte[], u32bit, u32bit) const { return; } + u32bit unpad(const byte[], u32bit size) const { return size; } + u32bit pad_bytes(u32bit, u32bit) const { return 0; } + bool valid_blocksize(u32bit) const { return true; } + std::string name() const { return "NoPadding"; } + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/modebase.h b/src/libs/3rdparty/botan/build/botan/modebase.h new file mode 100644 index 00000000000..173fde58cb0 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/modebase.h @@ -0,0 +1,39 @@ +/* +* Block Cipher Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MODEBASE_H__ +#define BOTAN_MODEBASE_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents an abstract block cipher mode +*/ +class BOTAN_DLL BlockCipherMode : public Keyed_Filter + { + public: + std::string name() const; + + BlockCipherMode(BlockCipher*, const std::string&, + u32bit, u32bit = 0, u32bit = 1); + + virtual ~BlockCipherMode() { delete cipher; } + protected: + void set_iv(const InitializationVector&); + const u32bit BLOCK_SIZE, BUFFER_SIZE, IV_METHOD; + const std::string mode_name; + BlockCipher* cipher; + SecureVector buffer, state; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mp_asm.h b/src/libs/3rdparty/botan/build/botan/mp_asm.h new file mode 100644 index 00000000000..7c18343ef7b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mp_asm.h @@ -0,0 +1,54 @@ +/* +* Lowest Level MPI Algorithms +* (C) 1999-2008 Jack Lloyd +* 2006 Luca Piccarreta +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MP_ASM_H__ +#define BOTAN_MP_ASM_H__ + +#include + +#if (BOTAN_MP_WORD_BITS == 8) + typedef Botan::u16bit dword; +#elif (BOTAN_MP_WORD_BITS == 16) + typedef Botan::u32bit dword; +#elif (BOTAN_MP_WORD_BITS == 32) + typedef Botan::u64bit dword; +#elif (BOTAN_MP_WORD_BITS == 64) + #error BOTAN_MP_WORD_BITS can be 64 only with assembly support +#else + #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64 +#endif + +namespace Botan { + +extern "C" { + +/* +* Word Multiply/Add +*/ +inline word word_madd2(word a, word b, word* c) + { + dword z = (dword)a * b + *c; + *c = (word)(z >> BOTAN_MP_WORD_BITS); + return (word)z; + } + +/* +* Word Multiply/Add +*/ +inline word word_madd3(word a, word b, word c, word* d) + { + dword z = (dword)a * b + c + *d; + *d = (word)(z >> BOTAN_MP_WORD_BITS); + return (word)z; + } + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mp_asmi.h b/src/libs/3rdparty/botan/build/botan/mp_asmi.h new file mode 100644 index 00000000000..21c4db24858 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mp_asmi.h @@ -0,0 +1,191 @@ +/* +* Lowest Level MPI Algorithms +* (C) 1999-2008 Jack Lloyd +* 2006 Luca Piccarreta +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MP_ASM_INTERNAL_H__ +#define BOTAN_MP_ASM_INTERNAL_H__ + +#include + +namespace Botan { + +extern "C" { + +/* +* Word Addition +*/ +inline word word_add(word x, word y, word* carry) + { + word z = x + y; + word c1 = (z < x); + z += *carry; + *carry = c1 | (z < *carry); + return z; + } + +/* +* Eight Word Block Addition, Two Argument +*/ +inline word word8_add2(word x[8], const word y[8], word carry) + { + x[0] = word_add(x[0], y[0], &carry); + x[1] = word_add(x[1], y[1], &carry); + x[2] = word_add(x[2], y[2], &carry); + x[3] = word_add(x[3], y[3], &carry); + x[4] = word_add(x[4], y[4], &carry); + x[5] = word_add(x[5], y[5], &carry); + x[6] = word_add(x[6], y[6], &carry); + x[7] = word_add(x[7], y[7], &carry); + return carry; + } + +/* +* Eight Word Block Addition, Three Argument +*/ +inline word word8_add3(word z[8], const word x[8], + const word y[8], word carry) + { + z[0] = word_add(x[0], y[0], &carry); + z[1] = word_add(x[1], y[1], &carry); + z[2] = word_add(x[2], y[2], &carry); + z[3] = word_add(x[3], y[3], &carry); + z[4] = word_add(x[4], y[4], &carry); + z[5] = word_add(x[5], y[5], &carry); + z[6] = word_add(x[6], y[6], &carry); + z[7] = word_add(x[7], y[7], &carry); + return carry; + } + +/* +* Word Subtraction +*/ +inline word word_sub(word x, word y, word* carry) + { + word t0 = x - y; + word c1 = (t0 > x); + word z = t0 - *carry; + *carry = c1 | (z > t0); + return z; + } + +/* +* Eight Word Block Subtraction, Two Argument +*/ +inline word word8_sub2(word x[4], const word y[4], word carry) + { + x[0] = word_sub(x[0], y[0], &carry); + x[1] = word_sub(x[1], y[1], &carry); + x[2] = word_sub(x[2], y[2], &carry); + x[3] = word_sub(x[3], y[3], &carry); + x[4] = word_sub(x[4], y[4], &carry); + x[5] = word_sub(x[5], y[5], &carry); + x[6] = word_sub(x[6], y[6], &carry); + x[7] = word_sub(x[7], y[7], &carry); + return carry; + } + +/* +* Eight Word Block Subtraction, Three Argument +*/ +inline word word8_sub3(word z[8], const word x[8], + const word y[8], word carry) + { + z[0] = word_sub(x[0], y[0], &carry); + z[1] = word_sub(x[1], y[1], &carry); + z[2] = word_sub(x[2], y[2], &carry); + z[3] = word_sub(x[3], y[3], &carry); + z[4] = word_sub(x[4], y[4], &carry); + z[5] = word_sub(x[5], y[5], &carry); + z[6] = word_sub(x[6], y[6], &carry); + z[7] = word_sub(x[7], y[7], &carry); + return carry; + } + +/* +* Eight Word Block Linear Multiplication +*/ +inline word word8_linmul2(word x[4], word y, word carry) + { + x[0] = word_madd2(x[0], y, &carry); + x[1] = word_madd2(x[1], y, &carry); + x[2] = word_madd2(x[2], y, &carry); + x[3] = word_madd2(x[3], y, &carry); + x[4] = word_madd2(x[4], y, &carry); + x[5] = word_madd2(x[5], y, &carry); + x[6] = word_madd2(x[6], y, &carry); + x[7] = word_madd2(x[7], y, &carry); + return carry; + } + +/* +* Eight Word Block Linear Multiplication +*/ +inline word word8_linmul3(word z[8], const word x[8], word y, word carry) + { + z[0] = word_madd2(x[0], y, &carry); + z[1] = word_madd2(x[1], y, &carry); + z[2] = word_madd2(x[2], y, &carry); + z[3] = word_madd2(x[3], y, &carry); + z[4] = word_madd2(x[4], y, &carry); + z[5] = word_madd2(x[5], y, &carry); + z[6] = word_madd2(x[6], y, &carry); + z[7] = word_madd2(x[7], y, &carry); + return carry; + } + +/* +* Eight Word Block Multiply/Add +*/ +inline word word8_madd3(word z[8], const word x[8], word y, word carry) + { + z[0] = word_madd3(x[0], y, z[0], &carry); + z[1] = word_madd3(x[1], y, z[1], &carry); + z[2] = word_madd3(x[2], y, z[2], &carry); + z[3] = word_madd3(x[3], y, z[3], &carry); + z[4] = word_madd3(x[4], y, z[4], &carry); + z[5] = word_madd3(x[5], y, z[5], &carry); + z[6] = word_madd3(x[6], y, z[6], &carry); + z[7] = word_madd3(x[7], y, z[7], &carry); + return carry; + } + +/* +* Multiply-Add Accumulator +*/ +inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b) + { + word carry = *w0; + *w0 = word_madd2(a, b, &carry); + *w1 += carry; + *w2 += (*w1 < carry) ? 1 : 0; + } + +/* +* Multiply-Add Accumulator +*/ +inline void word3_muladd_2(word* w2, word* w1, word* w0, word a, word b) + { + word carry = 0; + a = word_madd2(a, b, &carry); + b = carry; + + word top = (b >> (BOTAN_MP_WORD_BITS-1)); + b <<= 1; + b |= (a >> (BOTAN_MP_WORD_BITS-1)); + a <<= 1; + + carry = 0; + *w0 = word_add(*w0, a, &carry); + *w1 = word_add(*w1, b, &carry); + *w2 = word_add(*w2, top, &carry); + } + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mp_core.h b/src/libs/3rdparty/botan/build/botan/mp_core.h new file mode 100644 index 00000000000..ea27a77a758 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mp_core.h @@ -0,0 +1,98 @@ +/* +* MPI Algorithms +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MP_CORE_H__ +#define BOTAN_MP_CORE_H__ + +#include + +namespace Botan { + +/* +* The size of the word type, in bits +*/ +const u32bit MP_WORD_BITS = BOTAN_MP_WORD_BITS; + +extern "C" { + +/* +* Addition/Subtraction Operations +*/ +void bigint_add2(word[], u32bit, const word[], u32bit); +void bigint_add3(word[], const word[], u32bit, const word[], u32bit); + +word bigint_add2_nc(word[], u32bit, const word[], u32bit); +word bigint_add3_nc(word[], const word[], u32bit, const word[], u32bit); + +void bigint_sub2(word[], u32bit, const word[], u32bit); +void bigint_sub3(word[], const word[], u32bit, const word[], u32bit); + +/* +* Shift Operations +*/ +void bigint_shl1(word[], u32bit, u32bit, u32bit); +void bigint_shl2(word[], const word[], u32bit, u32bit, u32bit); +void bigint_shr1(word[], u32bit, u32bit, u32bit); +void bigint_shr2(word[], const word[], u32bit, u32bit, u32bit); + +/* +* Simple O(N^2) Multiplication and Squaring +*/ +void bigint_simple_mul(word z[], const word x[], u32bit x_size, + const word y[], u32bit y_size); +void bigint_simple_sqr(word z[], const word x[], u32bit x_size); + +/* +* Linear Multiply +*/ +void bigint_linmul2(word[], u32bit, word); +void bigint_linmul3(word[], const word[], u32bit, word); +void bigint_linmul_add(word[], u32bit, const word[], u32bit, word); + +/* +* Montgomery Reduction +*/ +void bigint_monty_redc(word[], u32bit, const word[], u32bit, word); + +/* +* Misc Utility Operations +*/ +u32bit bigint_divcore(word, word, word, word, word, word); +s32bit bigint_cmp(const word[], u32bit, const word[], u32bit); +word bigint_divop(word, word, word); +word bigint_modop(word, word, word); +void bigint_wordmul(word, word, word*, word*); + +/* +* Comba Multiplication / Squaring +*/ +void bigint_comba_mul4(word[8], const word[4], const word[4]); +void bigint_comba_mul6(word[12], const word[6], const word[6]); +void bigint_comba_mul8(word[16], const word[8], const word[8]); +void bigint_comba_mul16(word[32], const word[16], const word[16]); + +void bigint_comba_sqr4(word[8], const word[4]); +void bigint_comba_sqr6(word[12], const word[6]); +void bigint_comba_sqr8(word[16], const word[8]); +void bigint_comba_sqr8(word[32], const word[16]); +void bigint_comba_sqr16(word[64], const word[32]); + +} + +/* +* High Level Multiplication/Squaring Interfaces +*/ +void bigint_mul(word[], u32bit, word[], + const word[], u32bit, u32bit, + const word[], u32bit, u32bit); + +void bigint_sqr(word[], u32bit, word[], + const word[], u32bit, u32bit); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mp_types.h b/src/libs/3rdparty/botan/build/botan/mp_types.h new file mode 100644 index 00000000000..1648713edd3 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mp_types.h @@ -0,0 +1,33 @@ +/* +* Low Level MPI Types +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MPI_TYPES_H__ +#define BOTAN_MPI_TYPES_H__ + +#include + +namespace Botan { + +#if (BOTAN_MP_WORD_BITS == 8) + typedef byte word; +#elif (BOTAN_MP_WORD_BITS == 16) + typedef u16bit word; +#elif (BOTAN_MP_WORD_BITS == 32) + typedef u32bit word; +#elif (BOTAN_MP_WORD_BITS == 64) + typedef u64bit word; +#else + #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64 +#endif + +const word MP_WORD_MASK = ~static_cast(0); +const word MP_WORD_TOP_BIT = static_cast(1) << (8*sizeof(word) - 1); +const word MP_WORD_MAX = MP_WORD_MASK; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mutex.h b/src/libs/3rdparty/botan/build/botan/mutex.h new file mode 100644 index 00000000000..a04ff83c966 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mutex.h @@ -0,0 +1,56 @@ +/* +* Mutex +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MUTEX_H__ +#define BOTAN_MUTEX_H__ + +#include + +namespace Botan { + +/* +* Mutex Base Class +*/ +class BOTAN_DLL Mutex + { + public: + virtual void lock() = 0; + virtual void unlock() = 0; + virtual ~Mutex() {} + }; + +/* +* Mutex Factory +*/ +class BOTAN_DLL Mutex_Factory + { + public: + virtual Mutex* make() = 0; + virtual ~Mutex_Factory() {} + }; + +/* +* Mutex Holding Class +*/ +class BOTAN_DLL Mutex_Holder + { + public: + Mutex_Holder(Mutex* m) : mux(m) + { + if(!mux) + throw Invalid_Argument("Mutex_Holder: Argument was NULL"); + mux->lock(); + } + + ~Mutex_Holder() { mux->unlock(); } + private: + Mutex* mux; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mux_noop.h b/src/libs/3rdparty/botan/build/botan/mux_noop.h new file mode 100644 index 00000000000..94201cb7c2a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mux_noop.h @@ -0,0 +1,26 @@ +/* +* No-Op Mutex Factory +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_NOOP_MUTEX_FACTORY_H__ +#define BOTAN_NOOP_MUTEX_FACTORY_H__ + +#include + +namespace Botan { + +/* +* No-Op Mutex Factory +*/ +class BOTAN_DLL Noop_Mutex_Factory : public Mutex_Factory + { + public: + Mutex* make(); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/mux_win32.h b/src/libs/3rdparty/botan/build/botan/mux_win32.h new file mode 100644 index 00000000000..a91850e7161 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/mux_win32.h @@ -0,0 +1,26 @@ +/* +* Win32 Mutex +* (C) 2006 Luca Piccarreta +* 2006-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MUTEX_WIN32_H__ +#define BOTAN_MUTEX_WIN32_H__ + +#include + +namespace Botan { + +/* +* Win32 Mutex Factory +*/ +class BOTAN_DLL Win32_Mutex_Factory : public Mutex_Factory + { + public: + Mutex* make(); + }; +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/noekeon.h b/src/libs/3rdparty/botan/build/botan/noekeon.h new file mode 100644 index 00000000000..893892446ee --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/noekeon.h @@ -0,0 +1,37 @@ +/* +* Noekeon +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_NOEKEON_H__ +#define BOTAN_NOEKEON_H__ + +#include + +namespace Botan { + +/* +* Noekeon +*/ +class BOTAN_DLL Noekeon : public BlockCipher + { + public: + void clear() throw(); + std::string name() const { return "Noekeon"; } + BlockCipher* clone() const { return new Noekeon; } + Noekeon() : BlockCipher(16, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + static const byte RC[17]; + + SecureBuffer EK, DK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/nr.h b/src/libs/3rdparty/botan/build/botan/nr.h new file mode 100644 index 00000000000..144c5ec2af2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/nr.h @@ -0,0 +1,63 @@ +/* +* Nyberg-Rueppel +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_NYBERG_RUEPPEL_H__ +#define BOTAN_NYBERG_RUEPPEL_H__ + +#include +#include + +namespace Botan { + +/* +* Nyberg-Rueppel Public Key +*/ +class BOTAN_DLL NR_PublicKey : public PK_Verifying_with_MR_Key, + public virtual DL_Scheme_PublicKey + { + public: + std::string algo_name() const { return "NR"; } + + SecureVector verify(const byte[], u32bit) const; + u32bit max_input_bits() const; + + DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; } + u32bit message_parts() const { return 2; } + u32bit message_part_size() const; + + NR_PublicKey() {} + NR_PublicKey(const DL_Group&, const BigInt&); + protected: + NR_Core core; + private: + void X509_load_hook(); + }; + +/* +* Nyberg-Rueppel Private Key +*/ +class BOTAN_DLL NR_PrivateKey : public NR_PublicKey, + public PK_Signing_Key, + public virtual DL_Scheme_PrivateKey + { + public: + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; + + bool check_key(RandomNumberGenerator& rng, bool) const; + + NR_PrivateKey() {} + + NR_PrivateKey(RandomNumberGenerator&, const DL_Group&, + const BigInt& = 0); + private: + void PKCS8_load_hook(RandomNumberGenerator&, bool = false); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/nr_core.h b/src/libs/3rdparty/botan/build/botan/nr_core.h new file mode 100644 index 00000000000..48377362211 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/nr_core.h @@ -0,0 +1,37 @@ +/* +* NR Core +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_NR_CORE_H__ +#define BOTAN_NR_CORE_H__ + +#include +#include + +namespace Botan { + +/* +* NR Core +*/ +class BOTAN_DLL NR_Core + { + public: + SecureVector sign(const byte[], u32bit, const BigInt&) const; + SecureVector verify(const byte[], u32bit) const; + + NR_Core& operator=(const NR_Core&); + + NR_Core() { op = 0; } + NR_Core(const NR_Core&); + NR_Core(const DL_Group&, const BigInt&, const BigInt& = 0); + ~NR_Core() { delete op; } + private: + NR_Operation* op; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/nr_op.h b/src/libs/3rdparty/botan/build/botan/nr_op.h new file mode 100644 index 00000000000..cba1465f2f7 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/nr_op.h @@ -0,0 +1,53 @@ +/* +* NR Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_NR_OPS_H__ +#define BOTAN_NR_OPS_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* NR Operation +*/ +class BOTAN_DLL NR_Operation + { + public: + virtual SecureVector verify(const byte[], u32bit) const = 0; + virtual SecureVector sign(const byte[], u32bit, + const BigInt&) const = 0; + virtual NR_Operation* clone() const = 0; + virtual ~NR_Operation() {} + }; + +/* +* Botan's Default NR Operation +*/ +class BOTAN_DLL Default_NR_Op : public NR_Operation + { + public: + SecureVector verify(const byte[], u32bit) const; + SecureVector sign(const byte[], u32bit, const BigInt&) const; + + NR_Operation* clone() const { return new Default_NR_Op(*this); } + + Default_NR_Op(const DL_Group&, const BigInt&, const BigInt&); + private: + const BigInt x, y; + const DL_Group group; + Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; + Modular_Reducer mod_p, mod_q; + }; + + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/numthry.h b/src/libs/3rdparty/botan/build/botan/numthry.h new file mode 100644 index 00000000000..e4c0437997c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/numthry.h @@ -0,0 +1,120 @@ +/* +* Number Theory Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_NUMBER_THEORY_H__ +#define BOTAN_NUMBER_THEORY_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* Fused Arithmetic Operations +*/ +BigInt BOTAN_DLL mul_add(const BigInt&, const BigInt&, const BigInt&); +BigInt BOTAN_DLL sub_mul(const BigInt&, const BigInt&, const BigInt&); + +/* +* Number Theory Functions +*/ +inline BigInt abs(const BigInt& n) { return n.abs(); } + +void BOTAN_DLL divide(const BigInt&, const BigInt&, BigInt&, BigInt&); + +BigInt BOTAN_DLL gcd(const BigInt&, const BigInt&); +BigInt BOTAN_DLL lcm(const BigInt&, const BigInt&); + +BigInt BOTAN_DLL square(const BigInt&); +BigInt BOTAN_DLL inverse_mod(const BigInt&, const BigInt&); +s32bit BOTAN_DLL jacobi(const BigInt&, const BigInt&); + +BigInt BOTAN_DLL power_mod(const BigInt&, const BigInt&, const BigInt&); + +/* +* Compute the square root of x modulo a prime +* using the Shanks-Tonnelli algorithm +*/ +BigInt ressol(const BigInt& x, const BigInt& p); + +/* +* Utility Functions +*/ +u32bit BOTAN_DLL low_zero_bits(const BigInt&); + +/* +* Primality Testing +*/ +bool BOTAN_DLL check_prime(const BigInt&, RandomNumberGenerator&); +bool BOTAN_DLL is_prime(const BigInt&, RandomNumberGenerator&); +bool BOTAN_DLL verify_prime(const BigInt&, RandomNumberGenerator&); + +s32bit BOTAN_DLL simple_primality_tests(const BigInt&); + +bool BOTAN_DLL passes_mr_tests(RandomNumberGenerator&, + const BigInt&, u32bit = 1); + +bool BOTAN_DLL run_primality_tests(RandomNumberGenerator&, + const BigInt&, u32bit = 1); + +/* +* Random Number Generation +*/ +BigInt BOTAN_DLL random_prime(RandomNumberGenerator&, + u32bit bits, const BigInt& coprime = 1, + u32bit equiv = 1, u32bit equiv_mod = 2); + +BigInt BOTAN_DLL random_safe_prime(RandomNumberGenerator&, + u32bit); + +/* +* DSA Parameter Generation +*/ +class Algorithm_Factory; + +SecureVector BOTAN_DLL +generate_dsa_primes(RandomNumberGenerator& rng, + Algorithm_Factory& af, + BigInt& p, BigInt& q, + u32bit pbits, u32bit qbits); + +bool BOTAN_DLL +generate_dsa_primes(RandomNumberGenerator& rng, + Algorithm_Factory& af, + BigInt& p_out, BigInt& q_out, + u32bit p_bits, u32bit q_bits, + const MemoryRegion& seed); + +/* +* Prime Numbers +*/ +const u32bit PRIME_TABLE_SIZE = 6541; +const u32bit PRIME_PRODUCTS_TABLE_SIZE = 256; + +extern const u16bit BOTAN_DLL PRIMES[]; +extern const u64bit PRIME_PRODUCTS[]; + +/* +* Miller-Rabin Primality Tester +*/ +class BOTAN_DLL MillerRabin_Test + { + public: + bool passes_test(const BigInt&); + MillerRabin_Test(const BigInt&); + private: + BigInt n, r, n_minus_1; + u32bit s; + Fixed_Exponent_Power_Mod pow_mod; + Modular_Reducer reducer; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/ofb.h b/src/libs/3rdparty/botan/build/botan/ofb.h new file mode 100644 index 00000000000..a3aadc137b7 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/ofb.h @@ -0,0 +1,33 @@ +/* +* OFB Mode +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_OUTPUT_FEEDBACK_MODE_H__ +#define BOTAN_OUTPUT_FEEDBACK_MODE_H__ + +#include +#include + +namespace Botan { + +/* +* OFB Mode +*/ +class BOTAN_DLL OFB : public BlockCipherMode + { + public: + OFB(BlockCipher* cipher); + + OFB(BlockCipher* cipher, + const SymmetricKey& key, + const InitializationVector& iv); + private: + void write(const byte[], u32bit); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/oids.h b/src/libs/3rdparty/botan/build/botan/oids.h new file mode 100644 index 00000000000..fdfe61f7c6d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/oids.h @@ -0,0 +1,58 @@ +/* +* OID Registry +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_OIDS_H__ +#define BOTAN_OIDS_H__ + +#include + +namespace Botan { + +namespace OIDS { + +/** +* Register an OID to string mapping. +* @param oid the oid to register +* @param name the name to be associated with the oid +*/ +BOTAN_DLL void add_oid(const OID& oid, const std::string& name); + +/** +* See if an OID exists in the internal table. +* @param oid the oid to check for +* @return true if the oid is registered +*/ +BOTAN_DLL bool have_oid(const std::string& oid); + +/** +* Resolve an OID +* @param oid the OID to look up +* @return the name associated with this OID +*/ +BOTAN_DLL std::string lookup(const OID& oid); + +/** +* Find the OID to a name. The lookup will be performed in the +* general OID section of the configuration. +* @param name the name to resolve +* @return the OID associated with the specified name +*/ +BOTAN_DLL OID lookup(const std::string& name); + +/** +* Tests whether the specified OID stands for the specified name. +* @param oid the OID to check +* @param name the name to check +* @return true if the specified OID stands for the specified name +*/ +BOTAN_DLL bool name_of(const OID& oid, const std::string& name); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/openpgp.h b/src/libs/3rdparty/botan/build/botan/openpgp.h new file mode 100644 index 00000000000..890fcf0e31d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/openpgp.h @@ -0,0 +1,34 @@ +/* +* OpenPGP +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_OPENPGP_H__ +#define BOTAN_OPENPGP_H__ + +#include +#include +#include + +namespace Botan { + +namespace OpenPGP { + +/* +* OpenPGP Base64 encoding/decoding +*/ +BOTAN_DLL std::string encode(const byte[], u32bit, const std::string&, + const std::map&); +BOTAN_DLL SecureVector decode(DataSource&, std::string&, + std::map&); + +BOTAN_DLL std::string encode(const byte[], u32bit, const std::string&); +BOTAN_DLL SecureVector decode(DataSource&, std::string&); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/out_buf.h b/src/libs/3rdparty/botan/build/botan/out_buf.h new file mode 100644 index 00000000000..0baacda20c1 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/out_buf.h @@ -0,0 +1,43 @@ +/* +* Output Buffer +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_OUTPUT_BUFFER_H__ +#define BOTAN_OUTPUT_BUFFER_H__ + +#include +#include +#include + +namespace Botan { + +/* +* Container of output buffers for Pipe +*/ +class BOTAN_DLL Output_Buffers + { + public: + u32bit read(byte[], u32bit, Pipe::message_id); + u32bit peek(byte[], u32bit, u32bit, Pipe::message_id) const; + u32bit remaining(Pipe::message_id) const; + + void add(class SecureQueue*); + void retire(); + + Pipe::message_id message_count() const; + + Output_Buffers(); + ~Output_Buffers(); + private: + class SecureQueue* get(Pipe::message_id) const; + + std::deque buffers; + Pipe::message_id offset; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/par_hash.h b/src/libs/3rdparty/botan/build/botan/par_hash.h new file mode 100644 index 00000000000..7e75c27bec2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/par_hash.h @@ -0,0 +1,36 @@ +/* +* Parallel Hash +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PARALLEL_HASH_H__ +#define BOTAN_PARALLEL_HASH_H__ + +#include +#include + +namespace Botan { + +/* +* Parallel +*/ +class BOTAN_DLL Parallel : public HashFunction + { + public: + void clear() throw(); + std::string name() const; + HashFunction* clone() const; + + Parallel(const std::vector&); + ~Parallel(); + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + std::vector hashes; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/parsing.h b/src/libs/3rdparty/botan/build/botan/parsing.h new file mode 100644 index 00000000000..2c29d5b4d20 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/parsing.h @@ -0,0 +1,41 @@ +/* +* Parser Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PARSER_H__ +#define BOTAN_PARSER_H__ + +#include +#include +#include + +namespace Botan { + +/* +* String Parsing Functions +*/ +BOTAN_DLL std::vector parse_algorithm_name(const std::string&); +BOTAN_DLL std::vector split_on(const std::string&, char); +BOTAN_DLL std::vector parse_asn1_oid(const std::string&); +BOTAN_DLL bool x500_name_cmp(const std::string&, const std::string&); + +/* +* String/Integer Conversions +*/ +BOTAN_DLL std::string to_string(u64bit, u32bit = 0); +BOTAN_DLL u32bit to_u32bit(const std::string&); + +BOTAN_DLL u32bit timespec_to_u32bit(const std::string& timespec); + +/* +* String/Network Address Conversions +*/ +BOTAN_DLL u32bit string_to_ipv4(const std::string&); +BOTAN_DLL std::string ipv4_to_string(u32bit); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pbe.h b/src/libs/3rdparty/botan/build/botan/pbe.h new file mode 100644 index 00000000000..f06d593d056 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pbe.h @@ -0,0 +1,56 @@ +/* +* PBE +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PBE_BASE_H__ +#define BOTAN_PBE_BASE_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +* Password Based Encryption (PBE) Filter. +*/ +class BOTAN_DLL PBE : public Filter + { + public: + /** + * Set this filter's key. + * @param pw the password to be used for the encryption + */ + virtual void set_key(const std::string&) = 0; + + /** + * Create a new random salt value and set the default iterations value. + */ + virtual void new_params(RandomNumberGenerator& rng) = 0; + + /** + * DER encode the params (the number of iterations and the salt value) + * @return the encoded params + */ + virtual MemoryVector encode_params() const = 0; + + /** + * Decode params and use them inside this Filter. + * @param src a data source to read the encoded params from + */ + virtual void decode_params(DataSource&) = 0; + + /** + * Get this PBE's OID. + * @return the OID + */ + virtual OID get_oid() const = 0; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pbes1.h b/src/libs/3rdparty/botan/build/botan/pbes1.h new file mode 100644 index 00000000000..2e1855dc27a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pbes1.h @@ -0,0 +1,53 @@ +/* +* PKCS #5 v1.5 PBE +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PBE_PKCS_V15_H__ +#define BOTAN_PBE_PKCS_V15_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* PKCS#5 v1.5 PBE +*/ +class BOTAN_DLL PBE_PKCS5v15 : public PBE + { + public: + void write(const byte[], u32bit); + void start_msg(); + void end_msg(); + + PBE_PKCS5v15(BlockCipher* cipher, + HashFunction* hash, + Cipher_Dir); + + ~PBE_PKCS5v15(); + private: + void set_key(const std::string&); + void new_params(RandomNumberGenerator& rng); + MemoryVector encode_params() const; + void decode_params(DataSource&); + OID get_oid() const; + + void flush_pipe(bool); + + Cipher_Dir direction; + BlockCipher* block_cipher; + HashFunction* hash_function; + + SecureVector salt, key, iv; + u32bit iterations; + Pipe pipe; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pbes2.h b/src/libs/3rdparty/botan/build/botan/pbes2.h new file mode 100644 index 00000000000..fc460a22834 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pbes2.h @@ -0,0 +1,53 @@ +/* +* PKCS #5 v2.0 PBE +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PBE_PKCS_v20_H__ +#define BOTAN_PBE_PKCS_v20_H__ + +#include +#include +#include +#include + +namespace Botan { + +/* +* PKCS#5 v2.0 PBE +*/ +class BOTAN_DLL PBE_PKCS5v20 : public PBE + { + public: + static bool known_cipher(const std::string&); + + void write(const byte[], u32bit); + void start_msg(); + void end_msg(); + + PBE_PKCS5v20(DataSource&); + PBE_PKCS5v20(BlockCipher*, HashFunction*); + + ~PBE_PKCS5v20(); + private: + void set_key(const std::string&); + void new_params(RandomNumberGenerator& rng); + MemoryVector encode_params() const; + void decode_params(DataSource&); + OID get_oid() const; + + void flush_pipe(bool); + + Cipher_Dir direction; + BlockCipher* block_cipher; + HashFunction* hash_function; + SecureVector salt, key, iv; + u32bit iterations, key_length; + Pipe pipe; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pbkdf1.h b/src/libs/3rdparty/botan/build/botan/pbkdf1.h new file mode 100644 index 00000000000..4e5cafdb0af --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pbkdf1.h @@ -0,0 +1,44 @@ +/* +* PBKDF1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PBKDF1_H__ +#define BOTAN_PBKDF1_H__ + +#include +#include + +namespace Botan { + +/** +* This class implements the PKCS #5 PBKDF1 functionality. +*/ +class BOTAN_DLL PKCS5_PBKDF1 : public S2K + { + public: + std::string name() const; + S2K* clone() const; + + /** + * Create a PKCS #5 instance using the specified hash function. + * @param hash a pointer to a hash function object to use + */ + PKCS5_PBKDF1(HashFunction* hash_in) : hash(hash_in) {} + + PKCS5_PBKDF1(const PKCS5_PBKDF1& other) : + S2K(), hash(other.hash->clone()) {} + + ~PKCS5_PBKDF1() { delete hash; } + private: + OctetString derive(u32bit, const std::string&, + const byte[], u32bit, u32bit) const; + + HashFunction* hash; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pbkdf2.h b/src/libs/3rdparty/botan/build/botan/pbkdf2.h new file mode 100644 index 00000000000..7510338bba2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pbkdf2.h @@ -0,0 +1,40 @@ +/* +* PBKDF2 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PBKDF2_H__ +#define BOTAN_PBKDF2_H__ + +#include +#include + +namespace Botan { + +/** +* This class implements the PKCS #5 PBKDF2 functionality. +*/ +class BOTAN_DLL PKCS5_PBKDF2 : public S2K + { + public: + std::string name() const; + S2K* clone() const; + + /** + * Create a PKCS #5 instance using the specified message auth code + * @param mac the MAC to use + */ + PKCS5_PBKDF2(MessageAuthenticationCode* mac); + ~PKCS5_PBKDF2(); + private: + OctetString derive(u32bit, const std::string&, + const byte[], u32bit, u32bit) const; + + MessageAuthenticationCode* mac; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pem.h b/src/libs/3rdparty/botan/build/botan/pem.h new file mode 100644 index 00000000000..9fe8acb8738 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pem.h @@ -0,0 +1,35 @@ +/* +* PEM Encoding/Decoding +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PEM_H__ +#define BOTAN_PEM_H__ + +#include + +namespace Botan { + +namespace PEM_Code { + +/* +* PEM Encoding/Decoding +*/ +BOTAN_DLL std::string encode(const byte[], u32bit, + const std::string&, u32bit = 64); +BOTAN_DLL std::string encode(const MemoryRegion&, + const std::string&, u32bit = 64); + +BOTAN_DLL SecureVector decode(DataSource&, std::string&); +BOTAN_DLL SecureVector decode_check_label(DataSource&, + const std::string&); +BOTAN_DLL bool matches(DataSource&, const std::string& = "", + u32bit search_range = 4096); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pgp_s2k.h b/src/libs/3rdparty/botan/build/botan/pgp_s2k.h new file mode 100644 index 00000000000..00e95f7fa37 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pgp_s2k.h @@ -0,0 +1,36 @@ +/* +* OpenPGP S2K +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_OPENPGP_S2K_H__ +#define BOTAN_OPENPGP_S2K_H__ + +#include +#include + +namespace Botan { + +/* +* OpenPGP S2K +*/ +class BOTAN_DLL OpenPGP_S2K : public S2K + { + public: + std::string name() const; + S2K* clone() const; + + OpenPGP_S2K(HashFunction* hash_in) : hash(hash_in) {} + ~OpenPGP_S2K() { delete hash; } + private: + OctetString derive(u32bit, const std::string&, + const byte[], u32bit, u32bit) const; + + HashFunction* hash; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pipe.h b/src/libs/3rdparty/botan/build/botan/pipe.h new file mode 100644 index 00000000000..120f2fbdd1a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pipe.h @@ -0,0 +1,275 @@ +/* +* Pipe +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PIPE_H__ +#define BOTAN_PIPE_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +* This class represents pipe objects. +* A set of filters can be placed into a pipe, and information flows +* through the pipe until it reaches the end, where the output is +* collected for retrieval. If you're familiar with the Unix shell +* environment, this design will sound quite familiar. +*/ + +class BOTAN_DLL Pipe : public DataSource + { + public: + typedef u32bit message_id; + + class Invalid_Message_Number : public Invalid_Argument + { + public: + Invalid_Message_Number(const std::string&, message_id); + }; + + static const message_id LAST_MESSAGE; + static const message_id DEFAULT_MESSAGE; + + /** + * Write input to the pipe, i.e. to its first filter. + * @param in the byte array to write + * @param length the length of the byte array in + */ + void write(const byte in[], u32bit length); + + /** + * Write input to the pipe, i.e. to its first filter. + * @param in the MemoryRegion containing the data to write + */ + void write(const MemoryRegion& in); + + /** + * Write input to the pipe, i.e. to its first filter. + * @param in the string containing the data to write + */ + void write(const std::string& in); + + /** + * Write input to the pipe, i.e. to its first filter. + * @param in the DataSource to read the data from + */ + void write(DataSource& in); + + /** + * Write input to the pipe, i.e. to its first filter. + * @param in a single byte to be written + */ + void write(byte in); + + /** + * Perform start_msg(), write() and end_msg() sequentially. + * @param in the byte array containing the data to write + * @param length the length of the byte array to write + */ + void process_msg(const byte in[], u32bit length); + + /** + * Perform start_msg(), write() and end_msg() sequentially. + * @param in the MemoryRegion containing the data to write + */ + void process_msg(const MemoryRegion& in); + + /** + * Perform start_msg(), write() and end_msg() sequentially. + * @param in the string containing the data to write + */ + void process_msg(const std::string& in); + + /** + * Perform start_msg(), write() and end_msg() sequentially. + * @param in the DataSource providing the data to write + */ + void process_msg(DataSource& in); + + /** + * Find out how many bytes are ready to read. + * @param msg the number identifying the message + * for which the information is desired + * @return the number of bytes that can still be read + */ + u32bit remaining(message_id msg = DEFAULT_MESSAGE) const; + + /** + * Read the default message from the pipe. Moves the internal + * offset so that every call to read will return a new portion of + * the message. + * @param output the byte array to write the read bytes to + * @param length the length of the byte array output + * @return the number of bytes actually read into output + */ + u32bit read(byte output[], u32bit length); + + /** + * Read a specified message from the pipe. Moves the internal + * offset so that every call to read will return a new portion of + * the message. + * @param output the byte array to write the read bytes to + * @param length the length of the byte array output + * @param msg the number identifying the message to read from + * @return the number of bytes actually read into output + */ + u32bit read(byte output[], u32bit length, message_id msg); + + /** + * Read a single byte from the pipe. Moves the internal offset so that + * every call to read will return a new portion of the message. + * @param output the byte to write the result to + * @return the number of bytes actually read into output + */ + u32bit read(byte& output, message_id msg = DEFAULT_MESSAGE); + + /** + * Read the full contents of the pipe. + * @param msg the number identifying the message to read from + * @return a SecureVector holding the contents of the pipe + */ + SecureVector read_all(message_id msg = DEFAULT_MESSAGE); + + /** + * Read the full contents of the pipe. + * @param msg the number identifying the message to read from + * @return a string holding the contents of the pipe + */ + std::string read_all_as_string(message_id = DEFAULT_MESSAGE); + + /** Read from the default message but do not modify the internal + * offset. Consecutive calls to peek() will return portions of + * the message starting at the same position. + * @param output the byte array to write the peeked message part to + * @param length the length of the byte array output + * @param offset the offset from the current position in message + * @return the number of bytes actually peeked and written into output + */ + u32bit peek(byte output[], u32bit length, u32bit offset) const; + + /** Read from the specified message but do not modify the + * internal offset. Consecutive calls to peek() will return + * portions of the message starting at the same position. + * @param output the byte array to write the peeked message part to + * @param length the length of the byte array output + * @param offset the offset from the current position in message + * @param msg the number identifying the message to peek from + * @return the number of bytes actually peeked and written into output + */ + u32bit peek(byte output[], u32bit length, + u32bit offset, message_id msg) const; + + /** Read a single byte from the specified message but do not + * modify the internal offset. Consecutive calls to peek() will + * return portions of the message starting at the same position. + * @param output the byte to write the peeked message byte to + * @param offset the offset from the current position in message + * @param msg the number identifying the message to peek from + * @return the number of bytes actually peeked and written into output + */ + u32bit peek(byte& output, u32bit offset, + message_id msg = DEFAULT_MESSAGE) const; + + u32bit default_msg() const { return default_read; } + + /** + * Set the default message + * @param msg the number identifying the message which is going to + * be the new default message + */ + void set_default_msg(message_id msg); + + /** + * Get the number of messages the are in this pipe. + * @return the number of messages the are in this pipe + */ + message_id message_count() const; + + /** + * Test whether this pipe has any data that can be read from. + * @return true if there is more data to read, false otherwise + */ + bool end_of_data() const; + + /** + * Start a new message in the pipe. A potential other message in this pipe + * must be closed with end_msg() before this function may be called. + */ + void start_msg(); + + /** + * End the current message. + */ + void end_msg(); + + /** + * Insert a new filter at the front of the pipe + * @param filt the new filter to insert + */ + void prepend(Filter* filt); + + /** + * Insert a new filter at the back of the pipe + * @param filt the new filter to insert + */ + void append(Filter* filt); + + /** + * Remove the first filter at the front of the pipe. + */ + void pop(); + + /** + * Reset this pipe to an empty pipe. + */ + void reset(); + + /** + * Construct a Pipe of up to four filters. The filters are set up + * in the same order as the arguments. + */ + Pipe(Filter* = 0, Filter* = 0, Filter* = 0, Filter* = 0); + + /** + * Construct a Pipe from range of filters passed as an array + * @param filters the set of filters to use + * @param count the number of elements in filters + */ + Pipe(Filter* filters[], u32bit count); + ~Pipe(); + private: + Pipe(const Pipe&) : DataSource() {} + Pipe& operator=(const Pipe&) { return (*this); } + void init(); + void destruct(Filter*); + void find_endpoints(Filter*); + void clear_endpoints(Filter*); + + message_id get_message_no(const std::string&, message_id) const; + + Filter* pipe; + class Output_Buffers* outputs; + message_id default_read; + bool inside_msg; + }; + +/* +* I/O Operators for Pipe +*/ +BOTAN_DLL std::ostream& operator<<(std::ostream&, Pipe&); +BOTAN_DLL std::istream& operator>>(std::istream&, Pipe&); + +} + +#endif + +#if defined(BOTAN_HAS_PIPE_UNIXFD_IO) + #include +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pk_algs.h b/src/libs/3rdparty/botan/build/botan/pk_algs.h new file mode 100644 index 00000000000..c41bf1a630d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pk_algs.h @@ -0,0 +1,31 @@ +/* +* PK Key Factory +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PK_KEY_FACTORY_H__ +#define BOTAN_PK_KEY_FACTORY_H__ + +#include + +namespace Botan { + +/** +* Get an empty public key object. +* @param name the name of the desired public key algorithm +* @return the public key object +*/ +BOTAN_DLL Public_Key* get_public_key(const std::string&); + +/** +* Get an empty private key object. +* @param name the name of the desired public key algorithm +* @return the private key object +*/ +BOTAN_DLL Private_Key* get_private_key(const std::string&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pk_engine.h b/src/libs/3rdparty/botan/build/botan/pk_engine.h new file mode 100644 index 00000000000..256a47c201b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pk_engine.h @@ -0,0 +1,95 @@ +/** +* Engine for PK +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ENGINE_PK_LOOKUP_H__ +#define BOTAN_ENGINE_PK_LOOKUP_H__ + +#include +#include + +#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) + #include +#endif + +#if defined(BOTAN_HAS_DSA) + #include +#endif + +#if defined(BOTAN_HAS_DIFFIE_HELLMAN) + #include +#endif + +#if defined(BOTAN_HAS_NYBERG_RUEPPEL) + #include +#endif + +#if defined(BOTAN_HAS_ELGAMAL) + #include +#endif + +#if defined(BOTAN_HAS_ECDSA) + #include + #include +#endif + +#if defined(BOTAN_HAS_ECKAEG) + #include + #include +#endif + +namespace Botan { + +class Algorithm_Factory; +class Keyed_Filter; +class Modular_Exponentiator; + +namespace Engine_Core { + +/* +* Get an operation from an Engine +*/ +Modular_Exponentiator* mod_exp(const BigInt&, Power_Mod::Usage_Hints); + +#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) +IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&, const BigInt&, + const BigInt&, const BigInt&); +#endif + +#if defined(BOTAN_HAS_DSA) +DSA_Operation* dsa_op(const DL_Group&, const BigInt&, const BigInt&); +#endif + +#if defined(BOTAN_HAS_NYBERG_RUEPPEL) +NR_Operation* nr_op(const DL_Group&, const BigInt&, const BigInt&); +#endif + +#if defined(BOTAN_HAS_ELGAMAL) +ELG_Operation* elg_op(const DL_Group&, const BigInt&, const BigInt&); +#endif + +#if defined(BOTAN_HAS_DIFFIE_HELLMAN) +DH_Operation* dh_op(const DL_Group&, const BigInt&); +#endif + +#if defined(BOTAN_HAS_ECDSA) +ECDSA_Operation* ecdsa_op(const EC_Domain_Params& dom_pars, + const BigInt& priv_key, + const PointGFp& pub_key); +#endif + +#if defined(BOTAN_HAS_ECKAEG) +ECKAEG_Operation* eckaeg_op(const EC_Domain_Params& dom_pars, + const BigInt& priv_key, + const PointGFp& pub_key); +#endif + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pk_filts.h b/src/libs/3rdparty/botan/build/botan/pk_filts.h new file mode 100644 index 00000000000..8bf3fc238f9 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pk_filts.h @@ -0,0 +1,91 @@ +/* +* PK Filters +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PK_FILTERS_H__ +#define BOTAN_PK_FILTERS_H__ + +#include +#include + +namespace Botan { + +/* +* PK_Encryptor Filter +*/ +class BOTAN_DLL PK_Encryptor_Filter : public Filter + { + public: + void write(const byte[], u32bit); + void end_msg(); + PK_Encryptor_Filter(PK_Encryptor* c, + RandomNumberGenerator& rng_ref) : + cipher(c), rng(rng_ref) {} + ~PK_Encryptor_Filter() { delete cipher; } + private: + PK_Encryptor* cipher; + RandomNumberGenerator& rng; + SecureVector buffer; + }; + +/* +* PK_Decryptor Filter +*/ +class BOTAN_DLL PK_Decryptor_Filter : public Filter + { + public: + void write(const byte[], u32bit); + void end_msg(); + PK_Decryptor_Filter(PK_Decryptor* c) : cipher(c) {} + ~PK_Decryptor_Filter() { delete cipher; } + private: + PK_Decryptor* cipher; + SecureVector buffer; + }; + +/* +* PK_Signer Filter +*/ +class BOTAN_DLL PK_Signer_Filter : public Filter + { + public: + void write(const byte[], u32bit); + void end_msg(); + + PK_Signer_Filter(PK_Signer* s, + RandomNumberGenerator& rng_ref) : + signer(s), rng(rng_ref) {} + + ~PK_Signer_Filter() { delete signer; } + private: + PK_Signer* signer; + RandomNumberGenerator& rng; + }; + +/* +* PK_Verifier Filter +*/ +class BOTAN_DLL PK_Verifier_Filter : public Filter + { + public: + void write(const byte[], u32bit); + void end_msg(); + + void set_signature(const byte[], u32bit); + void set_signature(const MemoryRegion&); + + PK_Verifier_Filter(PK_Verifier* v) : verifier(v) {} + PK_Verifier_Filter(PK_Verifier*, const byte[], u32bit); + PK_Verifier_Filter(PK_Verifier*, const MemoryRegion&); + ~PK_Verifier_Filter() { delete verifier; } + private: + PK_Verifier* verifier; + SecureVector signature; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pk_keys.h b/src/libs/3rdparty/botan/build/botan/pk_keys.h new file mode 100644 index 00000000000..5b612577d29 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pk_keys.h @@ -0,0 +1,180 @@ +/* +* PK Key Types +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PK_KEYS_H__ +#define BOTAN_PK_KEYS_H__ + +#include +#include +#include + +namespace Botan { + +/** +* Public Key Base Class. +*/ +class BOTAN_DLL Public_Key + { + public: + /** + * Get the name of the underlying public key scheme. + * @return the name of the public key scheme + */ + virtual std::string algo_name() const = 0; + + /** + * Get the OID of the underlying public key scheme. + * @return the OID of the public key scheme + */ + virtual OID get_oid() const; + + /** + * Test the key values for consistency. + * @param rng rng to use + * @param strong whether to perform strong and lengthy version + * of the test + * @return true if the test is passed + */ + virtual bool check_key(RandomNumberGenerator&, bool) const + { return true; } + + /** + * Find out the number of message parts supported by this scheme. + * @return the number of message parts + */ + virtual u32bit message_parts() const { return 1; } + + /** + * Find out the message part size supported by this scheme/key. + * @return the size of the message parts + */ + virtual u32bit message_part_size() const { return 0; } + + /** + * Get the maximum message size in bits supported by this public key. + * @return the maximum message in bits + */ + virtual u32bit max_input_bits() const = 0; + + /** + * Get an X509 encoder that can be used to encode this key in X509 format. + * @return an X509 encoder for this key + */ + virtual class X509_Encoder* x509_encoder() const = 0; + + /** + * Get an X509 decoder that can be used to set the values of this + * key based on an X509 encoded key object. + * @return an X509 decoder for this key + */ + virtual class X509_Decoder* x509_decoder() = 0; + + virtual ~Public_Key() {} + protected: + virtual void load_check(RandomNumberGenerator&) const; + }; + +/** +* Private Key Base Class +*/ +class BOTAN_DLL Private_Key : public virtual Public_Key + { + public: + /** + * Get a PKCS#8 encoder that can be used to encode this key in + * PKCS#8 format. + * @return an PKCS#8 encoder for this key + */ + virtual class PKCS8_Encoder* pkcs8_encoder() const + { return 0; } + + /** + * Get an PKCS#8 decoder that can be used to set the values of this key + * based on an PKCS#8 encoded key object. + * @return an PKCS#8 decoder for this key + */ + virtual class PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator&) + { return 0; } + protected: + void load_check(RandomNumberGenerator&) const; + void gen_check(RandomNumberGenerator&) const; + }; + +/** +* PK Encrypting Key. +*/ +class BOTAN_DLL PK_Encrypting_Key : public virtual Public_Key + { + public: + virtual SecureVector encrypt(const byte[], u32bit, + RandomNumberGenerator&) const = 0; + virtual ~PK_Encrypting_Key() {} + }; + +/** +* PK Decrypting Key +*/ +class BOTAN_DLL PK_Decrypting_Key : public virtual Private_Key + { + public: + virtual SecureVector decrypt(const byte[], u32bit) const = 0; + virtual ~PK_Decrypting_Key() {} + }; + +/** +* PK Signing Key +*/ +class BOTAN_DLL PK_Signing_Key : public virtual Private_Key + { + public: + virtual SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const = 0; + virtual ~PK_Signing_Key() {} + }; + +/** +* PK Verifying Key, Message Recovery Version +*/ +class BOTAN_DLL PK_Verifying_with_MR_Key : public virtual Public_Key + { + public: + virtual SecureVector verify(const byte[], u32bit) const = 0; + virtual ~PK_Verifying_with_MR_Key() {} + }; + +/** +* PK Verifying Key, No Message Recovery Version +*/ +class BOTAN_DLL PK_Verifying_wo_MR_Key : public virtual Public_Key + { + public: + virtual bool verify(const byte[], u32bit, + const byte[], u32bit) const = 0; + virtual ~PK_Verifying_wo_MR_Key() {} + }; + +/** +* PK Secret Value Derivation Key +*/ +class BOTAN_DLL PK_Key_Agreement_Key : public virtual Private_Key + { + public: + virtual SecureVector derive_key(const byte[], u32bit) const = 0; + virtual MemoryVector public_value() const = 0; + virtual ~PK_Key_Agreement_Key() {} + }; + +/* +* Typedefs +*/ +typedef PK_Key_Agreement_Key PK_KA_Key; +typedef Public_Key X509_PublicKey; +typedef Private_Key PKCS8_PrivateKey; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pkcs10.h b/src/libs/3rdparty/botan/build/botan/pkcs10.h new file mode 100644 index 00000000000..9b435de5257 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pkcs10.h @@ -0,0 +1,101 @@ +/* +* PKCS #10 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PKCS10_H__ +#define BOTAN_PKCS10_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +* PKCS #10 Certificate Request. +*/ +class BOTAN_DLL PKCS10_Request : public X509_Object + { + public: + /** + * Get the subject public key. + * @return the subject public key + */ + Public_Key* subject_public_key() const; + + /** + * Get the raw DER encoded public key. + * @return the raw DER encoded public key + */ + MemoryVector raw_public_key() const; + + /** + * Get the subject DN. + * @return the subject DN + */ + X509_DN subject_dn() const; + + /** + * Get the subject alternative name. + * @return the subject alternative name. + */ + AlternativeName subject_alt_name() const; + + /** + * Get the key constraints for the key associated with this + * PKCS#10 object. + * @return the key constraints + */ + Key_Constraints constraints() const; + + /** + * Get the extendend key constraints (if any). + * @return the extended key constraints + */ + std::vector ex_constraints() const; + + /** + * Find out whether this is a CA request. + * @result true if it is a CA request, false otherwise. + */ + bool is_CA() const; + + /** + * Return the constraint on the path length defined + * in the BasicConstraints extension. + * @return the path limit + */ + u32bit path_limit() const; + + /** + * Get the challenge password for this request + * @return the challenge password for this request + */ + std::string challenge_password() const; + + /** + * Create a PKCS#10 Request from a data source. + * @param source the data source providing the DER encoded request + */ + PKCS10_Request(DataSource& source); + + /** + * Create a PKCS#10 Request from a file. + * @param filename the name of the file containing the DER or PEM + * encoded request file + */ + PKCS10_Request(const std::string& filename); + private: + void force_decode(); + void handle_attribute(const Attribute&); + + Data_Store info; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pkcs8.h b/src/libs/3rdparty/botan/build/botan/pkcs8.h new file mode 100644 index 00000000000..28008bdba66 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pkcs8.h @@ -0,0 +1,177 @@ +/* +* PKCS #8 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PKCS8_H__ +#define BOTAN_PKCS8_H__ + +#include +#include + +namespace Botan { + +/** +* PKCS #8 Private Key Encoder. +*/ +class BOTAN_DLL PKCS8_Encoder + { + public: + /** + * Get the algorithm identifier associated with the scheme + * this encoders key is part of. + * @return the algorithm identifier + */ + virtual AlgorithmIdentifier alg_id() const = 0; + + /** + * Get the DER encoded key. + * @return the DER encoded key + */ + // FIXME: Why not SecureVector? + virtual MemoryVector key_bits() const = 0; + virtual ~PKCS8_Encoder() {} + }; + +/* +* PKCS #8 Private Key Decoder +*/ +class BOTAN_DLL PKCS8_Decoder + { + public: + /** + * Set the algorithm identifier associated with the scheme + * this decoders key is part of. + * @param alg_id the algorithm identifier + */ + virtual void alg_id(const AlgorithmIdentifier&) = 0; + + /** + * Set the DER encoded key. + * @param key the DER encoded key + */ + virtual void key_bits(const MemoryRegion&) = 0; + virtual ~PKCS8_Decoder() {} + }; + +/** +* PKCS #8 General Exception +*/ +struct BOTAN_DLL PKCS8_Exception : public Decoding_Error + { + PKCS8_Exception(const std::string& error) : + Decoding_Error("PKCS #8: " + error) {} + }; + +namespace PKCS8 { + +/** +* Encode a private key into a pipe. +* @param key the private key to encode +* @param pipe the pipe to feed the encoded key into +* @param enc the encoding type to use +*/ +BOTAN_DLL void encode(const Private_Key& key, Pipe& pipe, + X509_Encoding enc = PEM); + +/** +* Encode and encrypt a private key into a pipe. +* @param key the private key to encode +* @param pipe the pipe to feed the encoded key into +* @param pass the password to use for encryption +* @param rng the rng to use +* @param pbe_algo the name of the desired password-based encryption algorithm. +* Provide an empty string to use the default PBE defined in the configuration +* under base/default_pbe. +* @param enc the encoding type to use +*/ +BOTAN_DLL void encrypt_key(const Private_Key& key, + Pipe& pipe, + RandomNumberGenerator& rng, + const std::string& pass, + const std::string& pbe_algo = "", + X509_Encoding enc = PEM); + + +/** +* Get a string containing a PEM encoded private key. +* @param key the key to encode +* @return the encoded key +*/ +BOTAN_DLL std::string PEM_encode(const Private_Key& key); + +/** +* Get a string containing a PEM encoded private key, encrypting it with a +* password. +* @param key the key to encode +* @param rng the rng to use +* @param pass the password to use for encryption +* @param pbe_algo the name of the desired password-based encryption algorithm. +* Provide an empty string to use the default PBE defined in the configuration +* under base/default_pbe. +*/ +BOTAN_DLL std::string PEM_encode(const Private_Key& key, + RandomNumberGenerator& rng, + const std::string& pass, + const std::string& pbe_algo = ""); + +/** +* Load a key from a data source. +* @param source the data source providing the encoded key +* @param rng the rng to use +* @param ui the user interface to be used for passphrase dialog +* @return the loaded private key object +*/ +BOTAN_DLL Private_Key* load_key(DataSource& source, + RandomNumberGenerator& rng, + const User_Interface& ui); + +/** Load a key from a data source. +* @param source the data source providing the encoded key +* @param rng the rng to use +* @param pass the passphrase to decrypt the key. Provide an empty +* string if the key is not encoded. +* @return the loaded private key object +*/ +BOTAN_DLL Private_Key* load_key(DataSource& source, + RandomNumberGenerator& rng, + const std::string& pass = ""); + +/** +* Load a key from a file. +* @param filename the path to the file containing the encoded key +* @param rng the rng to use +* @param ui the user interface to be used for passphrase dialog +* @return the loaded private key object +*/ +BOTAN_DLL Private_Key* load_key(const std::string& filename, + RandomNumberGenerator& rng, + const User_Interface& ui); + +/** Load a key from a file. +* @param filename the path to the file containing the encoded key +* @param rng the rng to use +* @param pass the passphrase to decrypt the key. Provide an empty +* string if the key is not encoded. +* @return the loaded private key object +*/ +BOTAN_DLL Private_Key* load_key(const std::string& filename, + RandomNumberGenerator& rng, + const std::string& pass = ""); + +/** +* Copy an existing encoded key object. +* @param key the key to copy +* @param rng the rng to use +* @return the new copy of the key +*/ +BOTAN_DLL Private_Key* copy_key(const Private_Key& key, + RandomNumberGenerator& rng); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pow_mod.h b/src/libs/3rdparty/botan/build/botan/pow_mod.h new file mode 100644 index 00000000000..6952dcd1bfc --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pow_mod.h @@ -0,0 +1,93 @@ +/* +* Modular Exponentiator +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_POWER_MOD_H__ +#define BOTAN_POWER_MOD_H__ + +#include + +namespace Botan { + +/* +* Modular Exponentiator Interface +*/ +class BOTAN_DLL Modular_Exponentiator + { + public: + virtual void set_base(const BigInt&) = 0; + virtual void set_exponent(const BigInt&) = 0; + virtual BigInt execute() const = 0; + virtual Modular_Exponentiator* copy() const = 0; + virtual ~Modular_Exponentiator() {} + }; + +/* +* Modular Exponentiator Proxy +*/ +class BOTAN_DLL Power_Mod + { + public: + enum Usage_Hints { + NO_HINTS = 0x0000, + + BASE_IS_FIXED = 0x0001, + BASE_IS_SMALL = 0x0002, + BASE_IS_LARGE = 0x0004, + BASE_IS_2 = 0x0008, + + EXP_IS_FIXED = 0x0100, + EXP_IS_SMALL = 0x0200, + EXP_IS_LARGE = 0x0400 + }; + + void set_modulus(const BigInt&, Usage_Hints = NO_HINTS) const; + void set_base(const BigInt&) const; + void set_exponent(const BigInt&) const; + + BigInt execute() const; + + Power_Mod& operator=(const Power_Mod&); + + Power_Mod(const BigInt& = 0, Usage_Hints = NO_HINTS); + Power_Mod(const Power_Mod&); + ~Power_Mod(); + private: + mutable Modular_Exponentiator* core; + Usage_Hints hints; + }; + +/* +* Fixed Exponent Modular Exponentiator Proxy +*/ +class BOTAN_DLL Fixed_Exponent_Power_Mod : public Power_Mod + { + public: + BigInt operator()(const BigInt& b) const + { set_base(b); return execute(); } + + Fixed_Exponent_Power_Mod() {} + Fixed_Exponent_Power_Mod(const BigInt&, const BigInt&, + Usage_Hints = NO_HINTS); + }; + +/* +* Fixed Base Modular Exponentiator Proxy +*/ +class BOTAN_DLL Fixed_Base_Power_Mod : public Power_Mod + { + public: + BigInt operator()(const BigInt& e) const + { set_exponent(e); return execute(); } + + Fixed_Base_Power_Mod() {} + Fixed_Base_Power_Mod(const BigInt&, const BigInt&, + Usage_Hints = NO_HINTS); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/prf_ssl3.h b/src/libs/3rdparty/botan/build/botan/prf_ssl3.h new file mode 100644 index 00000000000..165fc7c3c4e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/prf_ssl3.h @@ -0,0 +1,27 @@ +/* +* SSLv3 PRF +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SSLV3_PRF_H__ +#define BOTAN_SSLV3_PRF_H__ + +#include + +namespace Botan { + +/* +* SSL3 PRF +*/ +class BOTAN_DLL SSL3_PRF : public KDF + { + public: + SecureVector derive(u32bit, const byte[], u32bit, + const byte[], u32bit) const; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/prf_tls.h b/src/libs/3rdparty/botan/build/botan/prf_tls.h new file mode 100644 index 00000000000..d2127958825 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/prf_tls.h @@ -0,0 +1,34 @@ +/* +* TLS v1.0 PRF +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TLS_PRF_H__ +#define BOTAN_TLS_PRF_H__ + +#include +#include + +namespace Botan { + +/* +* TLS PRF +*/ +class BOTAN_DLL TLS_PRF : public KDF + { + public: + SecureVector derive(u32bit, const byte[], u32bit, + const byte[], u32bit) const; + + TLS_PRF(); + ~TLS_PRF(); + private: + MessageAuthenticationCode* hmac_md5; + MessageAuthenticationCode* hmac_sha1; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/prf_x942.h b/src/libs/3rdparty/botan/build/botan/prf_x942.h new file mode 100644 index 00000000000..f957566b096 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/prf_x942.h @@ -0,0 +1,31 @@ +/* +* X9.42 PRF +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ANSI_X942_PRF_H__ +#define BOTAN_ANSI_X942_PRF_H__ + +#include + +namespace Botan { + +/* +* X9.42 PRF +*/ +class BOTAN_DLL X942_PRF : public KDF + { + public: + SecureVector derive(u32bit, const byte[], u32bit, + const byte[], u32bit) const; + + X942_PRF(const std::string&); + private: + std::string key_wrap_oid; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pubkey.h b/src/libs/3rdparty/botan/build/botan/pubkey.h new file mode 100644 index 00000000000..c73a54d35e8 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pubkey.h @@ -0,0 +1,392 @@ +/* +* Public Key Interface +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_PUBKEY_H__ +#define BOTAN_PUBKEY_H__ + +#include +#include +#include +#include +#include +#include + +namespace Botan { + +/** +* The two types of signature format supported by Botan. +*/ +enum Signature_Format { IEEE_1363, DER_SEQUENCE }; + +/** +* Public Key Encryptor +*/ +class BOTAN_DLL PK_Encryptor + { + public: + + /** + * Encrypt a message. + * @param in the message as a byte array + * @param length the length of the above byte array + * @param rng the random number source to use + * @return the encrypted message + */ + SecureVector encrypt(const byte in[], u32bit length, + RandomNumberGenerator& rng) const; + + /** + * Encrypt a message. + * @param in the message + * @param rng the random number source to use + * @return the encrypted message + */ + SecureVector encrypt(const MemoryRegion& in, + RandomNumberGenerator& rng) const; + + /** + * Return the maximum allowed message size in bytes. + * @return the maximum message size in bytes + */ + virtual u32bit maximum_input_size() const = 0; + + virtual ~PK_Encryptor() {} + private: + virtual SecureVector enc(const byte[], u32bit, + RandomNumberGenerator&) const = 0; + }; + +/** +* Public Key Decryptor +*/ +class BOTAN_DLL PK_Decryptor + { + public: + /** + * Decrypt a ciphertext. + * @param in the ciphertext as a byte array + * @param length the length of the above byte array + * @return the decrypted message + */ + SecureVector decrypt(const byte in[], u32bit length) const; + + /** + * Decrypt a ciphertext. + * @param in the ciphertext + * @return the decrypted message + */ + SecureVector decrypt(const MemoryRegion& in) const; + + virtual ~PK_Decryptor() {} + private: + virtual SecureVector dec(const byte[], u32bit) const = 0; + }; + +/** +* Public Key Signer. Use the sign_message() functions for small +* messages. Use multiple calls update() to process large messages and +* generate the signature by finally calling signature(). +*/ +class BOTAN_DLL PK_Signer + { + public: + /** + * Sign a message. + * @param in the message to sign as a byte array + * @param length the length of the above byte array + * @param rng the rng to use + * @return the signature + */ + SecureVector sign_message(const byte in[], u32bit length, + RandomNumberGenerator& rng); + + /** + * Sign a message. + * @param in the message to sign + * @param rng the rng to use + * @return the signature + */ + SecureVector sign_message(const MemoryRegion& in, + RandomNumberGenerator& rng); + + /** + * Add a message part (single byte). + * @param the byte to add + */ + void update(byte in); + + /** + * Add a message part. + * @param in the message part to add as a byte array + * @param length the length of the above byte array + */ + void update(const byte in[], u32bit length); + + /** + * Add a message part. + * @param in the message part to add + */ + void update(const MemoryRegion& in); + + /** + * Get the signature of the so far processed message (provided by the + * calls to update()). + * @param rng the rng to use + * @return the signature of the total message + */ + SecureVector signature(RandomNumberGenerator& rng); + + /** + * Set the output format of the signature. + * @param format the signature format to use + */ + void set_output_format(Signature_Format format); + + /** + * Construct a PK Signer. + * @param key the key to use inside this signer + * @param emsa the EMSA to use + * An example would be "EMSA1(SHA-224)". + */ + PK_Signer(const PK_Signing_Key& key, EMSA* emsa); + + ~PK_Signer() { delete emsa; } + private: + PK_Signer(const PK_Signer&); + PK_Signer& operator=(const PK_Signer&); + + const PK_Signing_Key& key; + Signature_Format sig_format; + EMSA* emsa; + }; + +/** +* Public Key Verifier. Use the verify_message() functions for small +* messages. Use multiple calls update() to process large messages and +* verify the signature by finally calling check_signature(). +*/ +class BOTAN_DLL PK_Verifier + { + public: + /** + * Verify a signature. + * @param msg the message that the signature belongs to, as a byte array + * @param msg_length the length of the above byte array msg + * @param sig the signature as a byte array + * @param sig_length the length of the above byte array sig + * @return true if the signature is valid + */ + bool verify_message(const byte msg[], u32bit msg_length, + const byte sig[], u32bit sig_length); + /** + * Verify a signature. + * @param msg the message that the signature belongs to + * @param sig the signature + * @return true if the signature is valid + */ + bool verify_message(const MemoryRegion& msg, + const MemoryRegion& sig); + + /** + * Add a message part (single byte) of the message corresponding to the + * signature to be verified. + * @param msg_part the byte to add + */ + void update(byte msg_part); + + /** + * Add a message part of the message corresponding to the + * signature to be verified. + * @param msg_part the new message part as a byte array + * @param length the length of the above byte array + */ + void update(const byte msg_part[], u32bit length); + + /** + * Add a message part of the message corresponding to the + * signature to be verified. + * @param msg_part the new message part + */ + void update(const MemoryRegion& msg_part); + + /** + * Check the signature of the buffered message, i.e. the one build + * by successive calls to update. + * @param sig the signature to be verified as a byte array + * @param length the length of the above byte array + * @return true if the signature is valid, false otherwise + */ + bool check_signature(const byte sig[], u32bit length); + + /** + * Check the signature of the buffered message, i.e. the one build + * by successive calls to update. + * @param sig the signature to be verified + * @return true if the signature is valid, false otherwise + */ + bool check_signature(const MemoryRegion& sig); + + /** + * Set the format of the signatures fed to this verifier. + * @param format the signature format to use + */ + void set_input_format(Signature_Format format); + + /** + * Construct a PK Verifier. + * @param emsa the EMSA to use + * An example would be new EMSA1(new SHA_224) + */ + PK_Verifier(EMSA* emsa); + + virtual ~PK_Verifier(); + protected: + virtual bool validate_signature(const MemoryRegion&, + const byte[], u32bit) = 0; + virtual u32bit key_message_parts() const = 0; + virtual u32bit key_message_part_size() const = 0; + + Signature_Format sig_format; + EMSA* emsa; + private: + PK_Verifier(const PK_Verifier&); + PK_Verifier& operator=(const PK_Verifier&); + }; + +/* +* Key Agreement +*/ +class BOTAN_DLL PK_Key_Agreement + { + public: + SymmetricKey derive_key(u32bit, const byte[], u32bit, + const std::string& = "") const; + SymmetricKey derive_key(u32bit, const byte[], u32bit, + const byte[], u32bit) const; + + /** + * Construct a PK Key Agreement. + * @param key the key to use + * @param kdf the KDF to use + */ + PK_Key_Agreement(const PK_Key_Agreement_Key& key, KDF* kdf); + + ~PK_Key_Agreement() { delete kdf; } + private: + PK_Key_Agreement(const PK_Key_Agreement_Key&); + PK_Key_Agreement& operator=(const PK_Key_Agreement&); + + const PK_Key_Agreement_Key& key; + KDF* kdf; + }; + +/** +* Encryption with an MR algorithm and an EME. +*/ +class BOTAN_DLL PK_Encryptor_MR_with_EME : public PK_Encryptor + { + public: + u32bit maximum_input_size() const; + + /** + * Construct an instance. + * @param key the key to use inside the decryptor + * @param eme the EME to use + */ + PK_Encryptor_MR_with_EME(const PK_Encrypting_Key& key, + EME* eme); + + ~PK_Encryptor_MR_with_EME() { delete encoder; } + private: + PK_Encryptor_MR_with_EME(const PK_Encryptor_MR_with_EME&); + PK_Encryptor_MR_with_EME& operator=(const PK_Encryptor_MR_with_EME&); + + SecureVector enc(const byte[], u32bit, + RandomNumberGenerator& rng) const; + + const PK_Encrypting_Key& key; + const EME* encoder; + }; + +/** +* Decryption with an MR algorithm and an EME. +*/ +class BOTAN_DLL PK_Decryptor_MR_with_EME : public PK_Decryptor + { + public: + /** + * Construct an instance. + * @param key the key to use inside the encryptor + * @param eme the EME to use + */ + PK_Decryptor_MR_with_EME(const PK_Decrypting_Key& key, + EME* eme); + + ~PK_Decryptor_MR_with_EME() { delete encoder; } + private: + PK_Decryptor_MR_with_EME(const PK_Decryptor_MR_with_EME&); + PK_Decryptor_MR_with_EME& operator=(const PK_Decryptor_MR_with_EME&); + + SecureVector dec(const byte[], u32bit) const; + + const PK_Decrypting_Key& key; + const EME* encoder; + }; + +/** +* Public Key Verifier with Message Recovery. +*/ +class BOTAN_DLL PK_Verifier_with_MR : public PK_Verifier + { + public: + /** + * Construct an instance. + * @param key the key to use inside the verifier + * @param emsa_name the name of the EMSA to use + */ + PK_Verifier_with_MR(const PK_Verifying_with_MR_Key& k, + EMSA* emsa_obj) : PK_Verifier(emsa_obj), key(k) {} + + private: + PK_Verifier_with_MR(const PK_Verifying_with_MR_Key&); + PK_Verifier_with_MR& operator=(const PK_Verifier_with_MR&); + + bool validate_signature(const MemoryRegion&, const byte[], u32bit); + u32bit key_message_parts() const { return key.message_parts(); } + u32bit key_message_part_size() const { return key.message_part_size(); } + + const PK_Verifying_with_MR_Key& key; + }; + +/** +* Public Key Verifier without Message Recovery +*/ +class BOTAN_DLL PK_Verifier_wo_MR : public PK_Verifier + { + public: + /** + * Construct an instance. + * @param key the key to use inside the verifier + * @param emsa_name the name of the EMSA to use + */ + PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key& k, + EMSA* emsa_obj) : PK_Verifier(emsa_obj), key(k) {} + + private: + PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key&); + PK_Verifier_wo_MR& operator=(const PK_Verifier_wo_MR&); + + bool validate_signature(const MemoryRegion&, const byte[], u32bit); + u32bit key_message_parts() const { return key.message_parts(); } + u32bit key_message_part_size() const { return key.message_part_size(); } + + const PK_Verifying_wo_MR_Key& key; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/pubkey_enums.h b/src/libs/3rdparty/botan/build/botan/pubkey_enums.h new file mode 100644 index 00000000000..53e319f389f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/pubkey_enums.h @@ -0,0 +1,77 @@ +/* +* Enumerations +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ENUMS_H__ +#define BOTAN_ENUMS_H__ + +#include + +namespace Botan { + +/** +* X.509v3 Key Constraints. +*/ +enum Key_Constraints { + NO_CONSTRAINTS = 0, + DIGITAL_SIGNATURE = 32768, + NON_REPUDIATION = 16384, + KEY_ENCIPHERMENT = 8192, + DATA_ENCIPHERMENT = 4096, + KEY_AGREEMENT = 2048, + KEY_CERT_SIGN = 1024, + CRL_SIGN = 512, + ENCIPHER_ONLY = 256, + DECIPHER_ONLY = 128 +}; + +/** +* BER Decoding Function for key constraints +*/ +namespace BER { + +void BOTAN_DLL decode(BER_Decoder&, Key_Constraints&); + +} + +/** +* X.509v2 CRL Reason Code. +*/ +enum CRL_Code { + UNSPECIFIED = 0, + KEY_COMPROMISE = 1, + CA_COMPROMISE = 2, + AFFILIATION_CHANGED = 3, + SUPERSEDED = 4, + CESSATION_OF_OPERATION = 5, + CERTIFICATE_HOLD = 6, + REMOVE_FROM_CRL = 8, + PRIVLEDGE_WITHDRAWN = 9, + AA_COMPROMISE = 10, + + DELETE_CRL_ENTRY = 0xFF00, + OCSP_GOOD = 0xFF01, + OCSP_UNKNOWN = 0xFF02 +}; + +/* +* Various Other Enumerations +*/ + +/** +* The two types of X509 encoding supported by Botan. +*/ +enum X509_Encoding { RAW_BER, PEM }; + +/** +* Value to encode in case of no path limit in the X509 +* BasicConstraints extension. +*/ +static const u32bit NO_CERT_PATH_LIMIT = 0xFFFFFFF0; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/randpool.h b/src/libs/3rdparty/botan/build/botan/randpool.h new file mode 100644 index 00000000000..b6a3adda4a5 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/randpool.h @@ -0,0 +1,53 @@ +/* +* Randpool +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RANDPOOL_H__ +#define BOTAN_RANDPOOL_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +* Randpool +*/ +class BOTAN_DLL Randpool : public RandomNumberGenerator + { + public: + void randomize(byte[], u32bit); + bool is_seeded() const { return seeded; } + void clear() throw(); + std::string name() const; + + void reseed(u32bit bits_to_collect); + void add_entropy_source(EntropySource* es); + void add_entropy(const byte input[], u32bit length); + + Randpool(BlockCipher* cipher, MessageAuthenticationCode* mac, + u32bit pool_blocks = 32, + u32bit iterations_before_reseed = 128); + + ~Randpool(); + private: + void update_buffer(); + void mix_pool(); + + u32bit ITERATIONS_BEFORE_RESEED, POOL_BLOCKS; + BlockCipher* cipher; + MessageAuthenticationCode* mac; + + std::vector entropy_sources; + SecureVector pool, buffer, counter; + bool seeded; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rc2.h b/src/libs/3rdparty/botan/build/botan/rc2.h new file mode 100644 index 00000000000..cb6f58f046a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rc2.h @@ -0,0 +1,37 @@ +/* +* RC2 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RC2_H__ +#define BOTAN_RC2_H__ + +#include + +namespace Botan { + +/* +* RC2 +*/ +class BOTAN_DLL RC2 : public BlockCipher + { + public: + static byte EKB_code(u32bit); + + void clear() throw() { K.clear(); } + std::string name() const { return "RC2"; } + BlockCipher* clone() const { return new RC2; } + RC2() : BlockCipher(8, 1, 32) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer K; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rc5.h b/src/libs/3rdparty/botan/build/botan/rc5.h new file mode 100644 index 00000000000..083224720b9 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rc5.h @@ -0,0 +1,35 @@ +/* +* RC5 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RC5_H__ +#define BOTAN_RC5_H__ + +#include + +namespace Botan { + +/* +* RC5 +*/ +class BOTAN_DLL RC5 : public BlockCipher + { + public: + void clear() throw() { S.clear(); } + std::string name() const; + BlockCipher* clone() const { return new RC5(ROUNDS); } + RC5(u32bit); + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + SecureVector S; + const u32bit ROUNDS; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rc6.h b/src/libs/3rdparty/botan/build/botan/rc6.h new file mode 100644 index 00000000000..cb2800be731 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rc6.h @@ -0,0 +1,35 @@ +/* +* RC6 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RC6_H__ +#define BOTAN_RC6_H__ + +#include + +namespace Botan { + +/* +* RC6 +*/ +class BOTAN_DLL RC6 : public BlockCipher + { + public: + void clear() throw() { S.clear(); } + std::string name() const { return "RC6"; } + BlockCipher* clone() const { return new RC6; } + RC6() : BlockCipher(16, 1, 32) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer S; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/reducer.h b/src/libs/3rdparty/botan/build/botan/reducer.h new file mode 100644 index 00000000000..d234e0735ae --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/reducer.h @@ -0,0 +1,36 @@ +/* +* Modular Reducer +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MODARITH_H__ +#define BOTAN_MODARITH_H__ + +#include + +namespace Botan { + +/* +* Modular Reducer +*/ +class BOTAN_DLL Modular_Reducer + { + public: + BigInt multiply(const BigInt&, const BigInt&) const; + BigInt square(const BigInt&) const; + BigInt reduce(const BigInt&) const; + + bool initialized() const { return (mod_words != 0); } + + Modular_Reducer() { mod_words = 0; } + Modular_Reducer(const BigInt&); + private: + BigInt modulus, modulus_2, mu; + u32bit mod_words, mod2_words, mu_words; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rmd128.h b/src/libs/3rdparty/botan/build/botan/rmd128.h new file mode 100644 index 00000000000..031ae57467e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rmd128.h @@ -0,0 +1,35 @@ +/* +* RIPEMD-128 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RIPEMD_128_H__ +#define BOTAN_RIPEMD_128_H__ + +#include + +namespace Botan { + +/* +* RIPEMD-128 +*/ +class BOTAN_DLL RIPEMD_128 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "RIPEMD-128"; } + HashFunction* clone() const { return new RIPEMD_128; } + RIPEMD_128() : MDx_HashFunction(16, 64, false, true) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer M; + SecureBuffer digest; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rmd160.h b/src/libs/3rdparty/botan/build/botan/rmd160.h new file mode 100644 index 00000000000..f2babc5822e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rmd160.h @@ -0,0 +1,35 @@ +/* +* RIPEMD-160 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RIPEMD_160_H__ +#define BOTAN_RIPEMD_160_H__ + +#include + +namespace Botan { + +/* +* RIPEMD-160 +*/ +class BOTAN_DLL RIPEMD_160 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "RIPEMD-160"; } + HashFunction* clone() const { return new RIPEMD_160; } + RIPEMD_160() : MDx_HashFunction(20, 64, false, true) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer M; + SecureBuffer digest; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rng.h b/src/libs/3rdparty/botan/build/botan/rng.h new file mode 100644 index 00000000000..41904dbef40 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rng.h @@ -0,0 +1,103 @@ +/* +* RandomNumberGenerator +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RANDOM_NUMBER_GENERATOR_H__ +#define BOTAN_RANDOM_NUMBER_GENERATOR_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents a random number (RNG) generator object. +*/ +class BOTAN_DLL RandomNumberGenerator + { + public: + /** + * Create a seeded and active RNG object for general application use + */ + static RandomNumberGenerator* make_rng(); + + /** + * Randomize a byte array. + * @param output the byte array to hold the random output. + * @param length the length of the byte array output. + */ + virtual void randomize(byte output[], u32bit length) = 0; + + /** + * Return a random byte + * @return random byte + */ + byte next_byte(); + + /** + * Check whether this RNG is seeded. + * @return true if this RNG was already seeded, false otherwise. + */ + virtual bool is_seeded() const { return true; } + + /** + * Clear all internally held values of this RNG. + */ + virtual void clear() throw() = 0; + + /** + * Return the name of this object + */ + virtual std::string name() const = 0; + + /** + * Seed this RNG using the entropy sources it contains. + * @param bits_to_collect is the number of bits of entropy to + attempt to gather from the entropy sources + */ + virtual void reseed(u32bit bits_to_collect) = 0; + + /** + * Add this entropy source to the RNG object + * @param source the entropy source which will be retained and used by RNG + */ + virtual void add_entropy_source(EntropySource* source) = 0; + + /** + * Add entropy to this RNG. + * @param in a byte array containg the entropy to be added + * @param length the length of the byte array in + */ + virtual void add_entropy(const byte in[], u32bit length) = 0; + + RandomNumberGenerator() {} + virtual ~RandomNumberGenerator() {} + private: + RandomNumberGenerator(const RandomNumberGenerator&) {} + RandomNumberGenerator& operator=(const RandomNumberGenerator&) + { return (*this); } + }; + +/* +* Null Random Number Generator +*/ +class BOTAN_DLL Null_RNG : public RandomNumberGenerator + { + public: + void randomize(byte[], u32bit) { throw PRNG_Unseeded("Null_RNG"); } + void clear() throw() {} + std::string name() const { return "Null_RNG"; } + + void reseed(u32bit) {} + bool is_seeded() const { return false; } + void add_entropy(const byte[], u32bit) {} + void add_entropy_source(EntropySource* es) { delete es; } + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rotate.h b/src/libs/3rdparty/botan/build/botan/rotate.h new file mode 100644 index 00000000000..c8f8d4a1a01 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rotate.h @@ -0,0 +1,30 @@ +/* +* Word Rotation Operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_WORD_ROTATE_H__ +#define BOTAN_WORD_ROTATE_H__ + +#include + +namespace Botan { + +/* +* Word Rotation Functions +*/ +template inline T rotate_left(T input, u32bit rot) + { + return static_cast((input << rot) | (input >> (8*sizeof(T)-rot)));; + } + +template inline T rotate_right(T input, u32bit rot) + { + return static_cast((input >> rot) | (input << (8*sizeof(T)-rot))); + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rsa.h b/src/libs/3rdparty/botan/build/botan/rsa.h new file mode 100644 index 00000000000..f07533a4f60 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rsa.h @@ -0,0 +1,88 @@ +/* +* RSA +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RSA_H__ +#define BOTAN_RSA_H__ + +#include + +namespace Botan { + +/** +* RSA Public Key +*/ +class BOTAN_DLL RSA_PublicKey : public PK_Encrypting_Key, + public PK_Verifying_with_MR_Key, + public virtual IF_Scheme_PublicKey + { + public: + std::string algo_name() const { return "RSA"; } + + SecureVector encrypt(const byte[], u32bit, + RandomNumberGenerator& rng) const; + + SecureVector verify(const byte[], u32bit) const; + + RSA_PublicKey() {} + RSA_PublicKey(const BigInt&, const BigInt&); + protected: + BigInt public_op(const BigInt&) const; + }; + +/** +* RSA Private Key class. +*/ +class BOTAN_DLL RSA_PrivateKey : public RSA_PublicKey, + public PK_Decrypting_Key, + public PK_Signing_Key, + public IF_Scheme_PrivateKey + { + public: + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator&) const; + + SecureVector decrypt(const byte[], u32bit) const; + + bool check_key(RandomNumberGenerator& rng, bool) const; + + /** + * Default constructor, does not set any internal values. Use this + * constructor if you wish to decode a DER or PEM encoded key. + */ + RSA_PrivateKey() {} + + /** + * Construct a private key from the specified parameters. + * @param rng the random number generator to use + * @param prime1 the first prime + * @param prime2 the second prime + * @param exp the exponent + * @param d_exp if specified, this has to be d with + * exp * d = 1 mod (p - 1, q - 1). Leave it as 0 if you wish to + * the constructor to calculate it. + * @param n if specified, this must be n = p * q. Leave it as 0 + * if you wish to the constructor to calculate it. + */ + RSA_PrivateKey(RandomNumberGenerator& rng, + const BigInt& p, const BigInt& q, const BigInt& e, + const BigInt& d = 0, const BigInt& n = 0); + + /** + * Create a new private key with the specified bit length + * @param rng the random number generator to use + * @param bits the desired bit length of the private key + * @param exp the public exponent to be used + */ + RSA_PrivateKey(RandomNumberGenerator& rng, + u32bit bits, u32bit exp = 65537); + private: + BigInt private_op(const byte[], u32bit) const; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/rw.h b/src/libs/3rdparty/botan/build/botan/rw.h new file mode 100644 index 00000000000..900e5ebda25 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/rw.h @@ -0,0 +1,56 @@ +/* +* Rabin-Williams +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_RW_H__ +#define BOTAN_RW_H__ + +#include + +namespace Botan { + +/* +* Rabin-Williams Public Key +*/ +class BOTAN_DLL RW_PublicKey : public PK_Verifying_with_MR_Key, + public virtual IF_Scheme_PublicKey + { + public: + std::string algo_name() const { return "RW"; } + + SecureVector verify(const byte[], u32bit) const; + + RW_PublicKey() {} + RW_PublicKey(const BigInt&, const BigInt&); + protected: + BigInt public_op(const BigInt&) const; + }; + +/* +* Rabin-Williams Private Key +*/ +class BOTAN_DLL RW_PrivateKey : public RW_PublicKey, + public PK_Signing_Key, + public IF_Scheme_PrivateKey + { + public: + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; + + bool check_key(RandomNumberGenerator& rng, bool) const; + + RW_PrivateKey() {} + + RW_PrivateKey(RandomNumberGenerator&, + const BigInt&, const BigInt&, const BigInt&, + const BigInt& = 0, const BigInt& = 0); + + RW_PrivateKey(RandomNumberGenerator& rng, u32bit bits, u32bit = 2); + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/s2k.h b/src/libs/3rdparty/botan/build/botan/s2k.h new file mode 100644 index 00000000000..7af92519bbc --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/s2k.h @@ -0,0 +1,102 @@ +/* +* S2K +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_S2K_H__ +#define BOTAN_S2K_H__ + +#include +#include + +namespace Botan { + +/* +* S2K Interface +*/ +class BOTAN_DLL S2K + { + public: + /** + * Create a copy of this object. + * @return an auto_ptr to a copy of this object + */ + virtual S2K* clone() const = 0; + + /** + * Get the algorithm name. + * @return the name of this S2K algorithm + */ + virtual std::string name() const = 0; + + /** + * Clear this objects internal values. + */ + virtual void clear() {} + + /** + * Derive a key from a passphrase with this S2K object. It will use + * the salt value and number of iterations configured in this object. + * @param key_len the desired length of the key to produce + * @param passphrase the password to derive the key from + */ + OctetString derive_key(u32bit key_len, + const std::string& passphrase) const; + + /** + * Set the number of iterations for the one-way function during + * key generation. + * @param n the desired number of iterations + */ + void set_iterations(u32bit n); + + /** + * Set a new salt value. + * @param new_salt a byte array defining the new salt value + * @param len the length of the above byte array + */ + void change_salt(const byte new_salt[], u32bit len); + + /** + * Set a new salt value. + * @param new_salt the new salt value + */ + void change_salt(const MemoryRegion& new_salt); + + /** + * Create a new random salt value using the rng + * @param rng the random number generator to use + * @param len the desired length of the new salt value + */ + void new_random_salt(RandomNumberGenerator& rng, u32bit len); + + /** + * Get the number of iterations for the key derivation currently + * configured in this S2K object. + * @return the current number of iterations + */ + u32bit iterations() const { return iter; } + + /** + * Get the currently configured salt value of this S2K object. + * @return the current salt value + */ + SecureVector current_salt() const { return salt; } + + S2K() { iter = 0; } + virtual ~S2K() {} + private: + S2K(const S2K&) {} + S2K& operator=(const S2K&) { return (*this); } + + virtual OctetString derive(u32bit, const std::string&, + const byte[], u32bit, u32bit) const = 0; + SecureVector salt; + u32bit iter; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/safer_sk.h b/src/libs/3rdparty/botan/build/botan/safer_sk.h new file mode 100644 index 00000000000..e52c5837cd6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/safer_sk.h @@ -0,0 +1,40 @@ +/* +* SAFER-SK +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SAFER_SK_H__ +#define BOTAN_SAFER_SK_H__ + +#include + +namespace Botan { + +/* +* SAFER-SK +*/ +class BOTAN_DLL SAFER_SK : public BlockCipher + { + public: + void clear() throw() { EK.clear(); } + std::string name() const; + BlockCipher* clone() const; + SAFER_SK(u32bit); + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + static const byte EXP[256]; + static const byte LOG[512]; + static const byte BIAS[208]; + static const byte KEY_INDEX[208]; + SecureVector EK; + const u32bit ROUNDS; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/salsa20.h b/src/libs/3rdparty/botan/build/botan/salsa20.h new file mode 100644 index 00000000000..3dbfddb50b4 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/salsa20.h @@ -0,0 +1,41 @@ +/* +* Salsa20 +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SALSA20_H__ +#define BOTAN_SALSA20_H__ + +#include + +namespace Botan { + +/* +* Salsa20 +*/ +class BOTAN_DLL Salsa20 : public StreamCipher + { + public: + void clear() throw(); + std::string name() const; + StreamCipher* clone() const { return new Salsa20; } + + void resync(const byte[], u32bit); + + Salsa20(); + ~Salsa20() { clear(); } + private: + void cipher(const byte[], byte[], u32bit); + void key_schedule(const byte[], u32bit); + + SecureBuffer state; + + SecureBuffer buffer; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/scan_name.h b/src/libs/3rdparty/botan/build/botan/scan_name.h new file mode 100644 index 00000000000..9e7af40d602 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/scan_name.h @@ -0,0 +1,77 @@ +/** +SCAN Name Abstraction +(C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SCAN_NAME_H__ +#define BOTAN_SCAN_NAME_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +A class encapsulating a SCAN name (similar to JCE conventions) +http://www.users.zetnet.co.uk/hopwood/crypto/scan/ +*/ +class SCAN_Name + { + public: + /** + @param algo_spec A SCAN name + */ + SCAN_Name(const std::string& algo_spec); + + /** + @return the original input string + */ + std::string as_string() const { return orig_algo_spec; } + + /** + @return the algorithm name + */ + std::string algo_name() const { return name[0]; } + + /** + @return the number of arguments + */ + u32bit arg_count() const { return name.size() - 1; } + + /** + @return if the number of arguments is between lower and upper + */ + bool arg_count_between(u32bit lower, u32bit upper) const + { return ((arg_count() >= lower) && (arg_count() <= upper)); } + + /** + @param i which argument + @return the ith argument + */ + std::string arg(u32bit i) const; + + /** + @param i which argument + @param def_value the default value + @return the ith argument or the default value + */ + std::string arg(u32bit i, const std::string& def_value) const; + + /** + @param i which argument + @param def_value the default value + @return the ith argument as a u32bit, or the default value + */ + u32bit arg_as_u32bit(u32bit i, u32bit def_value) const; + private: + std::string orig_algo_spec; + std::vector name; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/secmem.h b/src/libs/3rdparty/botan/build/botan/secmem.h new file mode 100644 index 00000000000..d64a376ca0c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/secmem.h @@ -0,0 +1,438 @@ +/* +* Secure Memory Buffers +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SECURE_MEMORY_BUFFERS_H__ +#define BOTAN_SECURE_MEMORY_BUFFERS_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents variable length memory buffers. +*/ +template +class MemoryRegion + { + public: + /** + * Find out the size of the buffer, i.e. how many objects of type T it + * contains. + * @return the size of the buffer + */ + u32bit size() const { return used; } + + /** + * Find out whether this buffer is empty. + * @return true if the buffer is empty, false otherwise + */ + bool is_empty() const { return (used == 0); } + + /** + * Find out whether this buffer is non-empty + * @return true if the buffer is non-empty, false otherwise + */ + bool has_items() const { return (used != 0); } + + /** + * Get a pointer to the first element in the buffer. + * @return a pointer to the first element in the buffer + */ + operator T* () { return buf; } + + /** + * Get a constant pointer to the first element in the buffer. + * @return a constant pointer to the first element in the buffer + */ + operator const T* () const { return buf; } + + /** + * Get a pointer to the first element in the buffer. + * @return a pointer to the first element in the buffer + */ + T* begin() { return buf; } + + /** + * Get a constant pointer to the first element in the buffer. + * @return a constant pointer to the first element in the buffer + */ + const T* begin() const { return buf; } + + /** + * Get a pointer to the last element in the buffer. + * @return a pointer to the last element in the buffer + */ + T* end() { return (buf + size()); } + + /** + * Get a constant pointer to the last element in the buffer. + * @return a constant pointer to the last element in the buffer + */ + const T* end() const { return (buf + size()); } + + /** + * Check two buffers for equality. + * @return true iff the content of both buffers is byte-wise equal + */ + bool operator==(const MemoryRegion& other) const + { + return (size() == other.size() && + same_mem(buf, other.buf, size())); + } + + /** + * Compare two buffers lexicographically. + * @return true if this buffer is lexicographically smaller than other. + */ + bool operator<(const MemoryRegion& other) const; + + /** + * Check two buffers for inequality. + * @return false if the content of both buffers is byte-wise equal, true + * otherwise. + */ + bool operator!=(const MemoryRegion& in) const + { return (!(*this == in)); } + + /** + * Copy the contents of another buffer into this buffer. + * The former contents of *this are discarded. + * @param in the buffer to copy the contents from. + * @return a reference to *this + */ + MemoryRegion& operator=(const MemoryRegion& in) + { if(this != &in) set(in); return (*this); } + + /** + * The use of this function is discouraged because of the risk of memory + * errors. Use MemoryRegion::set() + * instead. + * Copy the contents of an array of objects of type T into this buffer. + * The former contents of *this are discarded. + * The length of *this must be at least n, otherwise memory errors occur. + * @param in the array to copy the contents from + * @param n the length of in + */ + void copy(const T in[], u32bit n) + { copy(0, in, n); } + + /** + * The use of this function is discouraged because of the risk of memory + * errors. Use MemoryRegion::set() + * instead. + * Copy the contents of an array of objects of type T into this buffer. + * The former contents of *this are discarded. + * The length of *this must be at least n, otherwise memory errors occur. + * @param off the offset position inside this buffer to start inserting + * the copied bytes + * @param in the array to copy the contents from + * @param n the length of in + */ + void copy(u32bit off, const T in[], u32bit n) + { copy_mem(buf + off, in, (n > size() - off) ? (size() - off) : n); } + + /** + * Set the contents of this according to the argument. The size of + * *this is increased if necessary. + * @param in the array of objects of type T to copy the contents from + * @param n the size of array in + */ + void set(const T in[], u32bit n) { create(n); copy(in, n); } + + /** + * Set the contents of this according to the argument. The size of + * *this is increased if necessary. + * @param in the buffer to copy the contents from + */ + void set(const MemoryRegion& in) { set(in.begin(), in.size()); } + + /** + * Append data to the end of this buffer. + * @param data the array containing the data to append + * @param n the size of the array data + */ + void append(const T data[], u32bit n) + { grow_to(size()+n); copy(size() - n, data, n); } + + /** + * Append a single element. + * @param x the element to append + */ + void append(T x) { append(&x, 1); } + + /** + * Append data to the end of this buffer. + * @param data the buffer containing the data to append + */ + void append(const MemoryRegion& x) { append(x.begin(), x.size()); } + + /** + * Zeroise the bytes of this buffer. The length remains unchanged. + */ + void clear() { clear_mem(buf, allocated); } + + /** + * Reset this buffer to an empty buffer with size zero. + */ + void destroy() { create(0); } + + /** + * Reset this buffer to a buffer of specified length. The content will be + * initialized to zero bytes. + * @param n the new length of the buffer + */ + void create(u32bit n); + + /** + * Preallocate memory, so that this buffer can grow up to size n without + * having to perform any actual memory allocations. (This is + * the same principle as for std::vector::reserve().) + */ + void grow_to(u32bit N); + + /** + * Swap this buffer with another object. + */ + void swap(MemoryRegion& other); + + ~MemoryRegion() { deallocate(buf, allocated); } + protected: + MemoryRegion() { buf = 0; alloc = 0; used = allocated = 0; } + MemoryRegion(const MemoryRegion& other) + { + buf = 0; + used = allocated = 0; + alloc = other.alloc; + set(other.buf, other.used); + } + + void init(bool locking, u32bit length = 0) + { alloc = Allocator::get(locking); create(length); } + private: + T* allocate(u32bit n) + { + return static_cast(alloc->allocate(sizeof(T)*n)); + } + + void deallocate(T* p, u32bit n) + { alloc->deallocate(p, sizeof(T)*n); } + + T* buf; + u32bit used; + u32bit allocated; + Allocator* alloc; + }; + +/* +* Create a new buffer +*/ +template +void MemoryRegion::create(u32bit n) + { + if(n <= allocated) { clear(); used = n; return; } + deallocate(buf, allocated); + buf = allocate(n); + allocated = used = n; + } + +/* +* Increase the size of the buffer +*/ +template +void MemoryRegion::grow_to(u32bit n) + { + if(n > used && n <= allocated) + { + clear_mem(buf + used, n - used); + used = n; + return; + } + else if(n > allocated) + { + T* new_buf = allocate(n); + copy_mem(new_buf, buf, used); + deallocate(buf, allocated); + buf = new_buf; + allocated = used = n; + } + } + +/* +* Compare this buffer with another one +*/ +template +bool MemoryRegion::operator<(const MemoryRegion& in) const + { + if(size() < in.size()) return true; + if(size() > in.size()) return false; + + for(u32bit j = 0; j != size(); j++) + { + if(buf[j] < in[j]) return true; + if(buf[j] > in[j]) return false; + } + + return false; + } + +/* +* Swap this buffer with another one +*/ +template +void MemoryRegion::swap(MemoryRegion& x) + { + std::swap(buf, x.buf); + std::swap(used, x.used); + std::swap(allocated, x.allocated); + std::swap(alloc, x.alloc); + } + +/** +* This class represents variable length buffers that do not +* make use of memory locking. +*/ +template +class MemoryVector : public MemoryRegion + { + public: + /** + * Copy the contents of another buffer into this buffer. + * @param in the buffer to copy the contents from + * @return a reference to *this + */ + MemoryVector& operator=(const MemoryRegion& in) + { if(this != &in) set(in); return (*this); } + + /** + * Create a buffer of the specified length. + * @param n the length of the buffer to create. + + */ + MemoryVector(u32bit n = 0) { MemoryRegion::init(false, n); } + + /** + * Create a buffer with the specified contents. + * @param in the array containing the data to be initially copied + * into the newly created buffer + * @param n the size of the arry in + */ + MemoryVector(const T in[], u32bit n) + { MemoryRegion::init(false); set(in, n); } + + /** + * Copy constructor. + */ + MemoryVector(const MemoryRegion& in) + { MemoryRegion::init(false); set(in); } + + /** + * Create a buffer whose content is the concatenation of two other + * buffers. + * @param in1 the first part of the new contents + * @param in2 the contents to be appended to in1 + */ + MemoryVector(const MemoryRegion& in1, const MemoryRegion& in2) + { MemoryRegion::init(false); set(in1); append(in2); } + }; + +/** +* This class represents variable length buffers using the operating +* systems capability to lock memory, i.e. keeping it from being +* swapped out to disk. In this way, a security hole allowing attackers +* to find swapped out secret keys is closed. Please refer to +* Botan::InitializerOptions::secure_memory() for restrictions and +* further details. +*/ +template +class SecureVector : public MemoryRegion + { + public: + /** + * Copy the contents of another buffer into this buffer. + * @param in the buffer to copy the contents from + * @return a reference to *this + */ + SecureVector& operator=(const MemoryRegion& in) + { if(this != &in) set(in); return (*this); } + + /** + * Create a buffer of the specified length. + * @param n the length of the buffer to create. + + */ + SecureVector(u32bit n = 0) { MemoryRegion::init(true, n); } + + /** + * Create a buffer with the specified contents. + * @param in the array containing the data to be initially copied + * into the newly created buffer + * @param n the size of the array in + */ + SecureVector(const T in[], u32bit n) + { MemoryRegion::init(true); set(in, n); } + + /** + * Create a buffer with contents specified contents. + * @param in the buffer holding the contents that will be + * copied into the newly created buffer. + */ + SecureVector(const MemoryRegion& in) + { MemoryRegion::init(true); set(in); } + + /** + * Create a buffer whose content is the concatenation of two other + * buffers. + * @param in1 the first part of the new contents + * @param in2 the contents to be appended to in1 + */ + SecureVector(const MemoryRegion& in1, const MemoryRegion& in2) + { MemoryRegion::init(true); set(in1); append(in2); } + }; + +/** +* This class represents fixed length buffers using the operating +* systems capability to lock memory, i.e. keeping it from being +* swapped out to disk. In this way, a security hole allowing attackers +* to find swapped out secret keys is closed. Please refer to +* Botan::InitializerOptions::secure_memory() for restrictions and +* further details. +*/ +template +class SecureBuffer : public MemoryRegion + { + public: + /** + * Copy the contents of another buffer into this buffer. + * @param in the buffer to copy the contents from + * @return a reference to *this + */ + SecureBuffer& operator=(const SecureBuffer& in) + { if(this != &in) set(in); return (*this); } + + /** + * Create a buffer of the length L. + */ + SecureBuffer() { MemoryRegion::init(true, L); } + + /** + * Create a buffer of size L with the specified contents. + * @param in the array containing the data to be initially copied + * into the newly created buffer + * @param n the size of the array in + */ + SecureBuffer(const T in[], u32bit n) + { MemoryRegion::init(true, L); copy(in, n); } + private: + SecureBuffer& operator=(const MemoryRegion& in) + { if(this != &in) set(in); return (*this); } + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/secqueue.h b/src/libs/3rdparty/botan/build/botan/secqueue.h new file mode 100644 index 00000000000..fc1fc213aa5 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/secqueue.h @@ -0,0 +1,43 @@ +/* +* SecureQueue +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SECURE_QUEUE_H__ +#define BOTAN_SECURE_QUEUE_H__ + +#include +#include + +namespace Botan { + +/* +* SecureQueue +*/ +class BOTAN_DLL SecureQueue : public Fanout_Filter, public DataSource + { + public: + void write(const byte[], u32bit); + + u32bit read(byte[], u32bit); + u32bit peek(byte[], u32bit, u32bit = 0) const; + + bool end_of_data() const; + u32bit size() const; + bool attachable() { return false; } + + SecureQueue& operator=(const SecureQueue&); + SecureQueue(); + SecureQueue(const SecureQueue&); + ~SecureQueue() { destroy(); } + private: + void destroy(); + class SecureQueueNode* head; + class SecureQueueNode* tail; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/seed.h b/src/libs/3rdparty/botan/build/botan/seed.h new file mode 100644 index 00000000000..54c25d5807d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/seed.h @@ -0,0 +1,43 @@ +/* +* SEED +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SEED_H__ +#define BOTAN_SEED_H__ + +#include + +namespace Botan { + +/* +* SEED +*/ +class BOTAN_DLL SEED : public BlockCipher + { + public: + void clear() throw() { K.clear(); } + std::string name() const { return "SEED"; } + BlockCipher* clone() const { return new SEED; } + SEED() : BlockCipher(16, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + class G_FUNC + { + public: + u32bit operator()(u32bit) const; + private: + static const u32bit S0[256], S1[256], S2[256], S3[256]; + }; + + SecureBuffer K; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/selftest.h b/src/libs/3rdparty/botan/build/botan/selftest.h new file mode 100644 index 00000000000..9e36d2298a1 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/selftest.h @@ -0,0 +1,22 @@ +/* +* Startup Self Test +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SELF_TESTS_H__ +#define BOTAN_SELF_TESTS_H__ + +#include + +namespace Botan { + +/* +* Self Tests +*/ +BOTAN_DLL bool passes_self_tests(Algorithm_Factory& af); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/serpent.h b/src/libs/3rdparty/botan/build/botan/serpent.h new file mode 100644 index 00000000000..5b9be257f3e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/serpent.h @@ -0,0 +1,35 @@ +/* +* Serpent +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SERPENT_H__ +#define BOTAN_SERPENT_H__ + +#include + +namespace Botan { + +/* +* Serpent +*/ +class BOTAN_DLL Serpent : public BlockCipher + { + public: + void clear() throw() { round_key.clear(); } + std::string name() const { return "Serpent"; } + BlockCipher* clone() const { return new Serpent; } + Serpent() : BlockCipher(16, 16, 32, 8) {} + protected: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + SecureBuffer round_key; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/sha160.h b/src/libs/3rdparty/botan/build/botan/sha160.h new file mode 100644 index 00000000000..232cf03229c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/sha160.h @@ -0,0 +1,38 @@ +/* +* SHA-160 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SHA_160_H__ +#define BOTAN_SHA_160_H__ + +#include + +namespace Botan { + +/* +* SHA-160 +*/ +class BOTAN_DLL SHA_160 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "SHA-160"; } + HashFunction* clone() const { return new SHA_160; } + SHA_160(); + + protected: + SHA_160(u32bit W_size); + + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer digest; + SecureVector W; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/sha2_32.h b/src/libs/3rdparty/botan/build/botan/sha2_32.h new file mode 100644 index 00000000000..05083d19d21 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/sha2_32.h @@ -0,0 +1,59 @@ +/* +* SHA-{224,256} +* (C) 1999-2008 Jack Lloyd +* 2007 FlexSecure GmbH +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SHA_256_H__ +#define BOTAN_SHA_256_H__ + +#include + +namespace Botan { + +/* +* SHA-{224,256} Base +*/ +class BOTAN_DLL SHA_224_256_BASE : public MDx_HashFunction + { + protected: + void clear() throw(); + SHA_224_256_BASE(u32bit out) : + MDx_HashFunction(out, 64, true, true) { clear(); } + + SecureBuffer W; + SecureBuffer digest; + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + }; + +/* +* SHA-224 +*/ +class BOTAN_DLL SHA_224 : public SHA_224_256_BASE + { + public: + void clear() throw(); + std::string name() const { return "SHA-224"; } + HashFunction* clone() const { return new SHA_224; } + SHA_224() : SHA_224_256_BASE(28) { clear(); } + }; + +/* +* SHA-256 +*/ +class BOTAN_DLL SHA_256 : public SHA_224_256_BASE + { + public: + void clear() throw(); + std::string name() const { return "SHA-256"; } + HashFunction* clone() const { return new SHA_256; } + SHA_256() : SHA_224_256_BASE(32) { clear (); } + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/sha2_64.h b/src/libs/3rdparty/botan/build/botan/sha2_64.h new file mode 100644 index 00000000000..dcc6dc83b6d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/sha2_64.h @@ -0,0 +1,60 @@ +/* +* SHA-{384,512} +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SHA_64BIT_H__ +#define BOTAN_SHA_64BIT_H__ + +#include + +namespace Botan { + +/* +* SHA-{384,512} Base +*/ +class BOTAN_DLL SHA_384_512_BASE : public MDx_HashFunction + { + protected: + void clear() throw(); + + SHA_384_512_BASE(u32bit out) : + MDx_HashFunction(out, 128, true, true, 16) {} + + SecureBuffer digest; + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureBuffer W; + }; + +/* +* SHA-384 +*/ +class BOTAN_DLL SHA_384 : public SHA_384_512_BASE + { + public: + void clear() throw(); + std::string name() const { return "SHA-384"; } + HashFunction* clone() const { return new SHA_384; } + SHA_384() : SHA_384_512_BASE(48) { clear(); } + }; + +/* +* SHA-512 +*/ +class BOTAN_DLL SHA_512 : public SHA_384_512_BASE + { + public: + void clear() throw(); + std::string name() const { return "SHA-512"; } + HashFunction* clone() const { return new SHA_512; } + SHA_512() : SHA_384_512_BASE(64) { clear(); } + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/skein_512.h b/src/libs/3rdparty/botan/build/botan/skein_512.h new file mode 100644 index 00000000000..fa558fc0d56 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/skein_512.h @@ -0,0 +1,41 @@ +/** +* The Skein-512 hash function +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SKEIN_512_H__ +#define BOTAN_SKEIN_512_H__ + +#include +#include +#include + +namespace Botan { + +class BOTAN_DLL Skein_512 : public HashFunction + { + public: + Skein_512(u32bit output_bits = 512, + const std::string& personalization = ""); + + HashFunction* clone() const; + std::string name() const; + void clear() throw(); + private: + void add_data(const byte input[], u32bit length); + void final_result(byte out[]); + + std::string personalization; + u32bit output_bits; + SecureBuffer H; + SecureBuffer T; + + SecureBuffer buffer; + u32bit buf_pos; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/skipjack.h b/src/libs/3rdparty/botan/build/botan/skipjack.h new file mode 100644 index 00000000000..231cd9c872f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/skipjack.h @@ -0,0 +1,38 @@ +/* +* Skipjack +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SKIPJACK_H__ +#define BOTAN_SKIPJACK_H__ + +#include + +namespace Botan { + +/* +* Skipjack +*/ +class BOTAN_DLL Skipjack : public BlockCipher + { + public: + void clear() throw(); + std::string name() const { return "Skipjack"; } + BlockCipher* clone() const { return new Skipjack; } + Skipjack() : BlockCipher(8, 10) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + void step_A(u16bit&, u16bit&, u32bit) const; + void step_B(u16bit&, u16bit&, u32bit) const; + void step_Ai(u16bit&, u16bit&, u32bit) const; + void step_Bi(u16bit&, u16bit&, u32bit) const; + SecureBuffer FTABLE[10]; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/square.h b/src/libs/3rdparty/botan/build/botan/square.h new file mode 100644 index 00000000000..94a1fc3701d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/square.h @@ -0,0 +1,52 @@ +/* +* Square +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SQUARE_H__ +#define BOTAN_SQUARE_H__ + +#include + +namespace Botan { + +/* +* Square +*/ +class BOTAN_DLL Square : public BlockCipher + { + public: + void clear() throw(); + std::string name() const { return "Square"; } + BlockCipher* clone() const { return new Square; } + Square() : BlockCipher(16, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + static void transform(u32bit[4]); + + static const byte SE[256]; + static const byte SD[256]; + static const byte Log[256]; + static const byte ALog[255]; + + static const u32bit TE0[256]; + static const u32bit TE1[256]; + static const u32bit TE2[256]; + static const u32bit TE3[256]; + static const u32bit TD0[256]; + static const u32bit TD1[256]; + static const u32bit TD2[256]; + static const u32bit TD3[256]; + + SecureBuffer EK, DK; + SecureBuffer ME, MD; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/ssl3_mac.h b/src/libs/3rdparty/botan/build/botan/ssl3_mac.h new file mode 100644 index 00000000000..dcaf7f40414 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/ssl3_mac.h @@ -0,0 +1,39 @@ +/* +* SSL3-MAC +* (C) 1999-2004 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SSL3_MAC_H__ +#define BOTAN_SSL3_MAC_H__ + +#include +#include + +namespace Botan { + +/* +* SSL3-MAC +*/ +class BOTAN_DLL SSL3_MAC : public MessageAuthenticationCode + { + public: + void clear() throw(); + std::string name() const; + MessageAuthenticationCode* clone() const; + + SSL3_MAC(HashFunction*); + ~SSL3_MAC() { delete hash; } + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + void key_schedule(const byte[], u32bit); + + HashFunction* hash; + SecureVector i_key, o_key; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/stl_util.h b/src/libs/3rdparty/botan/build/botan/stl_util.h new file mode 100644 index 00000000000..18c8b149b1d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/stl_util.h @@ -0,0 +1,86 @@ +/* +* STL Utility Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_STL_UTIL_H__ +#define BOTAN_STL_UTIL_H__ + +#include + +namespace Botan { + +/* +* Copy-on-Predicate Algorithm +*/ +template +OutputIterator copy_if(InputIterator current, InputIterator end, + OutputIterator dest, Predicate copy_p) + { + while(current != end) + { + if(copy_p(*current)) + *dest++ = *current; + ++current; + } + return dest; + } + +/* +* Searching through a std::map +*/ +template +inline V search_map(const std::map& mapping, + const K& key, + const V& null_result = V()) + { + typename std::map::const_iterator i = mapping.find(key); + if(i == mapping.end()) + return null_result; + return i->second; + } + +template +inline R search_map(const std::map& mapping, const K& key, + const R& null_result, const R& found_result) + { + typename std::map::const_iterator i = mapping.find(key); + if(i == mapping.end()) + return null_result; + return found_result; + } + +/* +* Function adaptor for delete operation +*/ +template +class del_fun : public std::unary_function + { + public: + void operator()(T* ptr) { delete ptr; } + }; + +/* +* Delete the second half of a pair of objects +*/ +template +void delete2nd(Pair& pair) + { + delete pair.second; + } + +/* +* Insert a key/value pair into a multimap +*/ +template +void multimap_insert(std::multimap& multimap, + const K& key, const V& value) + { + multimap.insert(std::make_pair(key, value)); + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/stream_cipher.h b/src/libs/3rdparty/botan/build/botan/stream_cipher.h new file mode 100644 index 00000000000..8ea35913108 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/stream_cipher.h @@ -0,0 +1,92 @@ +/** +* Stream Cipher +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_STREAM_CIPHER_H__ +#define BOTAN_STREAM_CIPHER_H__ + +#include + +namespace Botan { + +/* +* Stream Cipher +*/ +class BOTAN_DLL StreamCipher : public SymmetricAlgorithm + { + public: + const u32bit IV_LENGTH; + + /** + * Encrypt a message. + * @param i the plaintext + * @param o the byte array to hold the output, i.e. the ciphertext + * @param len the length of both i and o + */ + void encrypt(const byte i[], byte o[], u32bit len) { cipher(i, o, len); } + + /** + * Decrypt a message. + * @param i the ciphertext to decrypt + * @param o the byte array to hold the output, i.e. the plaintext + * @param len the length of both i and o + */ + void decrypt(const byte i[], byte o[], u32bit len) { cipher(i, o, len); } + + /** + * Encrypt a message. + * @param in the plaintext as input, after the function has + * returned it will hold the ciphertext + + * @param len the length of in + */ + void encrypt(byte in[], u32bit len) { cipher(in, in, len); } + + /** + * Decrypt a message. + * @param in the ciphertext as input, after the function has + * returned it will hold the plaintext + * @param len the length of in + */ + void decrypt(byte in[], u32bit len) { cipher(in, in, len); } + + /** + * Resync the cipher using the IV + * @param iv the initialization vector + * @param iv_len the length of the IV in bytes + */ + virtual void resync(const byte iv[], u32bit iv_len); + + /** + * Seek ahead in the stream. + * @param len the length to seek ahead. + */ + virtual void seek(u32bit len); + + /** + * Get a new object representing the same algorithm as *this + */ + virtual StreamCipher* clone() const = 0; + + /** + * Zeroize internal state + */ + virtual void clear() throw() = 0; + + StreamCipher(u32bit key_min, u32bit key_max = 0, + u32bit key_mod = 1, + u32bit iv_len = 0) : + SymmetricAlgorithm(key_min, key_max, key_mod), + IV_LENGTH(iv_len) {} + + virtual ~StreamCipher() {} + private: + virtual void cipher(const byte[], byte[], u32bit) = 0; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/sym_algo.h b/src/libs/3rdparty/botan/build/botan/sym_algo.h new file mode 100644 index 00000000000..1c8b816fdf4 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/sym_algo.h @@ -0,0 +1,101 @@ +/** +* Symmetric Algorithm Base Class +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SYMMETRIC_ALGORITHM_H__ +#define BOTAN_SYMMETRIC_ALGORITHM_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents a symmetric algorithm object. +*/ +class BOTAN_DLL SymmetricAlgorithm + { + public: + + /** + * The maximum allowed key length. + */ + const u32bit MAXIMUM_KEYLENGTH; + + /** + * The minimal allowed key length. + */ + const u32bit MINIMUM_KEYLENGTH; + + /** + * A valid keylength is a multiple of this value. + */ + const u32bit KEYLENGTH_MULTIPLE; + + /** + * The name of the algorithm. + * @return the name of the algorithm + */ + virtual std::string name() const = 0; + + /** + * Set the symmetric key of this object. + * @param key the SymmetricKey to be set. + */ + void set_key(const SymmetricKey& key) throw(Invalid_Key_Length) + { set_key(key.begin(), key.length()); } + + /** + * Set the symmetric key of this object. + * @param key the to be set as a byte array. + * @param the length of the byte array. + */ + void set_key(const byte key[], u32bit length) throw(Invalid_Key_Length) + { + if(!valid_keylength(length)) + throw Invalid_Key_Length(name(), length); + key_schedule(key, length); + } + + /** + * Check whether a given key length is valid for this algorithm. + * @param length the key length to be checked. + * @return true if the key length is valid. + */ + bool valid_keylength(u32bit length) const + { + return ((length >= MINIMUM_KEYLENGTH) && + (length <= MAXIMUM_KEYLENGTH) && + (length % KEYLENGTH_MULTIPLE == 0)); + } + + /** + * Construct a SymmetricAlgorithm. + * @param key_min the minimum allowed key length + * @param key_max the maximum allowed key length + * @param key_mod any valid key length must be a multiple of this value + */ + SymmetricAlgorithm(u32bit key_min, u32bit key_max, u32bit key_mod) : + MAXIMUM_KEYLENGTH(key_max ? key_max : key_min), + MINIMUM_KEYLENGTH(key_min), + KEYLENGTH_MULTIPLE(key_mod) + {} + + virtual ~SymmetricAlgorithm() {} + private: + virtual void key_schedule(const byte[], u32bit) = 0; + }; + +/** +* The two possible directions for cipher filters, determining whether they +* actually perform encryption or decryption. +*/ +enum Cipher_Dir { ENCRYPTION, DECRYPTION }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/symkey.h b/src/libs/3rdparty/botan/build/botan/symkey.h new file mode 100644 index 00000000000..5504297a408 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/symkey.h @@ -0,0 +1,62 @@ +/* +* OctetString +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SYMKEY_H__ +#define BOTAN_SYMKEY_H__ + +#include +#include + +namespace Botan { + +/* +* Octet String +*/ +class BOTAN_DLL OctetString + { + public: + u32bit length() const { return bits.size(); } + SecureVector bits_of() const { return bits; } + + const byte* begin() const { return bits.begin(); } + const byte* end() const { return bits.end(); } + + std::string as_string() const; + + OctetString& operator^=(const OctetString&); + + void set_odd_parity(); + + void change(const std::string&); + void change(const byte[], u32bit); + void change(const MemoryRegion& in) { bits = in; } + + OctetString(class RandomNumberGenerator&, u32bit len); + OctetString(const std::string& str = "") { change(str); } + OctetString(const byte in[], u32bit len) { change(in, len); } + OctetString(const MemoryRegion& in) { change(in); } + private: + SecureVector bits; + }; + +/* +* Operations on Octet Strings +*/ +BOTAN_DLL bool operator==(const OctetString&, const OctetString&); +BOTAN_DLL bool operator!=(const OctetString&, const OctetString&); +BOTAN_DLL OctetString operator+(const OctetString&, const OctetString&); +BOTAN_DLL OctetString operator^(const OctetString&, const OctetString&); + +/* +* Alternate Names +*/ +typedef OctetString SymmetricKey; +typedef OctetString InitializationVector; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/tea.h b/src/libs/3rdparty/botan/build/botan/tea.h new file mode 100644 index 00000000000..8ddf3e33002 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/tea.h @@ -0,0 +1,34 @@ +/* +* TEA +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TEA_H__ +#define BOTAN_TEA_H__ + +#include + +namespace Botan { + +/* +* TEA +*/ +class BOTAN_DLL TEA : public BlockCipher + { + public: + void clear() throw() { K.clear(); } + std::string name() const { return "TEA"; } + BlockCipher* clone() const { return new TEA; } + TEA() : BlockCipher(8, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + SecureBuffer K; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/tiger.h b/src/libs/3rdparty/botan/build/botan/tiger.h new file mode 100644 index 00000000000..63184a9387d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/tiger.h @@ -0,0 +1,44 @@ +/* +* Tiger +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TIGER_H__ +#define BOTAN_TIGER_H__ + +#include + +namespace Botan { + +/* +* Tiger +*/ +class BOTAN_DLL Tiger : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const; + HashFunction* clone() const { return new Tiger(OUTPUT_LENGTH); } + Tiger(u32bit = 24, u32bit = 3); + private: + void compress_n(const byte[], u32bit block); + void copy_out(byte[]); + + static void pass(u64bit&, u64bit&, u64bit&, u64bit[8], byte); + static void mix(u64bit[8]); + + static const u64bit SBOX1[256]; + static const u64bit SBOX2[256]; + static const u64bit SBOX3[256]; + static const u64bit SBOX4[256]; + + SecureBuffer X; + SecureBuffer digest; + const u32bit PASS; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/timer.h b/src/libs/3rdparty/botan/build/botan/timer.h new file mode 100644 index 00000000000..b6e8ef448b6 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/timer.h @@ -0,0 +1,45 @@ +/** +* Timestamp Functions +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TIMERS_H__ +#define BOTAN_TIMERS_H__ + +#include + +namespace Botan { + +/** +* Timer Interface +*/ +class BOTAN_DLL Timer : public EntropySource + { + public: + /** + @return nanoseconds resolution timestamp, unknown epoch + */ + virtual u64bit clock() const = 0; + + void poll(Entropy_Accumulator& accum); + + virtual ~Timer() {} + protected: + static u64bit combine_timers(u32bit, u32bit, u32bit); + }; + +/** +* ANSI Clock Timer +*/ +class BOTAN_DLL ANSI_Clock_Timer : public Timer + { + public: + std::string name() const { return "ANSI clock"; } + u64bit clock() const; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/tm_win32.h b/src/libs/3rdparty/botan/build/botan/tm_win32.h new file mode 100644 index 00000000000..5bcb720ab14 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/tm_win32.h @@ -0,0 +1,27 @@ +/* +* Win32 Timer +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TIMER_WIN32_H__ +#define BOTAN_TIMER_WIN32_H__ + +#include + +namespace Botan { + +/* +* Win32 Timer +*/ +class BOTAN_DLL Win32_Timer : public Timer + { + public: + std::string name() const { return "Win32 QueryPerformanceCounter"; } + u64bit clock() const; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/turing.h b/src/libs/3rdparty/botan/build/botan/turing.h new file mode 100644 index 00000000000..d48c1d8a878 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/turing.h @@ -0,0 +1,47 @@ +/* +* Turing +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TURING_H__ +#define BOTAN_TURING_H__ + +#include + +namespace Botan { + +/* +* Turing +*/ +class BOTAN_DLL Turing : public StreamCipher + { + public: + void clear() throw(); + std::string name() const { return "Turing"; } + StreamCipher* clone() const { return new Turing; } + Turing() : StreamCipher(4, 32, 4) { position = 0; } + private: + void cipher(const byte[], byte[], u32bit); + void key_schedule(const byte[], u32bit); + void resync(const byte[], u32bit); + void generate(); + + static u32bit fixedS(u32bit); + static void gen_sbox(MemoryRegion&, u32bit, + const MemoryRegion&); + + static const u32bit Q_BOX[256]; + static const byte SBOX[256]; + + SecureBuffer S0, S1, S2, S3; + SecureBuffer R; + SecureVector K; + SecureBuffer buffer; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/twofish.h b/src/libs/3rdparty/botan/build/botan/twofish.h new file mode 100644 index 00000000000..0640e32f8ef --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/twofish.h @@ -0,0 +1,48 @@ +/* +* Twofish +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TWOFISH_H__ +#define BOTAN_TWOFISH_H__ + +#include + +namespace Botan { + +/* +* Twofish +*/ +class BOTAN_DLL Twofish : public BlockCipher + { + public: + void clear() throw(); + std::string name() const { return "Twofish"; } + BlockCipher* clone() const { return new Twofish; } + Twofish() : BlockCipher(16, 16, 32, 8) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + + static void rs_mul(byte[4], byte, u32bit); + + static const u32bit MDS0[256]; + static const u32bit MDS1[256]; + static const u32bit MDS2[256]; + static const u32bit MDS3[256]; + static const byte Q0[256]; + static const byte Q1[256]; + static const byte RS[32]; + static const byte EXP_TO_POLY[255]; + static const byte POLY_TO_EXP[255]; + + SecureBuffer SBox0, SBox1, SBox2, SBox3; + SecureBuffer round_key; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/types.h b/src/libs/3rdparty/botan/build/botan/types.h new file mode 100644 index 00000000000..304628d027b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/types.h @@ -0,0 +1,42 @@ +/* +* Low Level Types +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TYPES_H__ +#define BOTAN_TYPES_H__ + +#include + +namespace Botan { + +typedef unsigned char byte; +typedef unsigned short u16bit; +typedef unsigned int u32bit; + +typedef signed int s32bit; + +#if defined(_MSC_VER) || defined(__BORLANDC__) + typedef unsigned __int64 u64bit; +#elif defined(__KCC) + typedef unsigned __long_long u64bit; +#elif defined(__GNUG__) + __extension__ typedef unsigned long long u64bit; +#else + typedef unsigned long long u64bit; +#endif + +static const u32bit DEFAULT_BUFFERSIZE = BOTAN_DEFAULT_BUFFER_SIZE; + +} + +namespace Botan_types { + +using Botan::byte; +using Botan::u32bit; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/ui.h b/src/libs/3rdparty/botan/build/botan/ui.h new file mode 100644 index 00000000000..fe62c60fc76 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/ui.h @@ -0,0 +1,36 @@ +/* +* User Interface +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_UI_H__ +#define BOTAN_UI_H__ + +#include +#include + +namespace Botan { + +/* +* User Interface +*/ +class BOTAN_DLL User_Interface + { + public: + enum UI_Result { OK, CANCEL_ACTION }; + + virtual std::string get_passphrase(const std::string&, + const std::string&, + UI_Result&) const; + User_Interface(const std::string& = ""); + virtual ~User_Interface() {} + protected: + std::string preset_passphrase; + mutable bool first_try; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/util.h b/src/libs/3rdparty/botan/build/botan/util.h new file mode 100644 index 00000000000..ac786739004 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/util.h @@ -0,0 +1,39 @@ +/* +* Utility Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_UTIL_H__ +#define BOTAN_UTIL_H__ + +#include + +namespace Botan { + +/* +* Time Access Functions +*/ +BOTAN_DLL u64bit system_time(); + +/* +* Memory Locking Functions +*/ +BOTAN_DLL bool lock_mem(void*, u32bit); +BOTAN_DLL void unlock_mem(void*, u32bit); + +/* +* Misc Utility Functions +*/ +BOTAN_DLL u32bit round_up(u32bit, u32bit); +BOTAN_DLL u32bit round_down(u32bit, u32bit); + +/* +* Work Factor Estimates +*/ +BOTAN_DLL u32bit dl_work_factor(u32bit); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/version.h b/src/libs/3rdparty/botan/build/botan/version.h new file mode 100644 index 00000000000..3cc44e8068a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/version.h @@ -0,0 +1,61 @@ +/* +* Version Information +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_VERSION_H__ +#define BOTAN_VERSION_H__ + +#include +#include + +namespace Botan { + +/* +* Get information describing the version +*/ + +/** +* Get the version string identifying the version of Botan. +* @return the version string +*/ +BOTAN_DLL std::string version_string(); + +/** +* Get the major version number. +* @return the major version number +*/ +BOTAN_DLL u32bit version_major(); + +/** +* Get the minor version number. +* @return the minor version number +*/ +BOTAN_DLL u32bit version_minor(); + +/** +* Get the patch number. +* @return the patch number +*/ +BOTAN_DLL u32bit version_patch(); + +/* +* Macros for compile-time version checks +*/ +#define BOTAN_VERSION_CODE_FOR(a,b,c) ((a << 16) | (b << 8) | (c)) + +/** +* Compare using BOTAN_VERSION_CODE_FOR, as in +* # if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,8,0) +* # error "Botan version too old" +* # endif +*/ +#define BOTAN_VERSION_CODE BOTAN_VERSION_CODE_FOR(BOTAN_VERSION_MAJOR, \ + BOTAN_VERSION_MINOR, \ + BOTAN_VERSION_PATCH) + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/whrlpool.h b/src/libs/3rdparty/botan/build/botan/whrlpool.h new file mode 100644 index 00000000000..b72ff609f6b --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/whrlpool.h @@ -0,0 +1,42 @@ +/* +* Whirlpool +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_WHIRLPOOL_H__ +#define BOTAN_WHIRLPOOL_H__ + +#include + +namespace Botan { + +/* +* Whirlpool +*/ +class BOTAN_DLL Whirlpool : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "Whirlpool"; } + HashFunction* clone() const { return new Whirlpool; } + Whirlpool() : MDx_HashFunction(64, 64, true, true, 32) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + static const u64bit C0[256]; + static const u64bit C1[256]; + static const u64bit C2[256]; + static const u64bit C3[256]; + static const u64bit C4[256]; + static const u64bit C5[256]; + static const u64bit C6[256]; + static const u64bit C7[256]; + SecureBuffer M, digest; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/wid_wake.h b/src/libs/3rdparty/botan/build/botan/wid_wake.h new file mode 100644 index 00000000000..4720afdb2b9 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/wid_wake.h @@ -0,0 +1,41 @@ +/* +* WiderWake +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_WIDER_WAKE_H__ +#define BOTAN_WIDER_WAKE_H__ + +#include + +namespace Botan { + +/* +* WiderWake4+1-BE +*/ +class BOTAN_DLL WiderWake_41_BE : public StreamCipher + { + public: + void clear() throw(); + std::string name() const { return "WiderWake4+1-BE"; } + StreamCipher* clone() const { return new WiderWake_41_BE; } + WiderWake_41_BE() : StreamCipher(16, 16, 1, 8) {} + private: + void cipher(const byte[], byte[], u32bit); + void key_schedule(const byte[], u32bit); + void resync(const byte[], u32bit); + + void generate(u32bit); + + SecureBuffer buffer; + SecureBuffer T; + SecureBuffer state; + SecureBuffer t_key; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509_ca.h b/src/libs/3rdparty/botan/build/botan/x509_ca.h new file mode 100644 index 00000000000..ef2a8d134f2 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509_ca.h @@ -0,0 +1,108 @@ +/* +* X.509 Certificate Authority +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_CA_H__ +#define BOTAN_X509_CA_H__ + +#include +#include +#include +#include +#include +#include + +namespace Botan { + +/** +* This class represents X.509 Certificate Authorities (CAs). +*/ +class BOTAN_DLL X509_CA + { + public: + + /** + * Sign a PKCS#10 Request. + * @param req the request to sign + * @param rng the rng to use + * @param not_before the starting time for the certificate + * @param not_after the expiration time for the certificate + * @return the resulting certificate + */ + X509_Certificate sign_request(const PKCS10_Request& req, + RandomNumberGenerator& rng, + const X509_Time& not_before, + const X509_Time& not_after); + + /** + * Get the certificate of this CA. + * @return the CA certificate + */ + X509_Certificate ca_certificate() const; + + /** + * Create a new and empty CRL for this CA. + * @param rng the random number generator to use + * @param next_update the time to set in next update in seconds + * as the offset from the current time + * @return the new CRL + */ + X509_CRL new_crl(RandomNumberGenerator& rng, u32bit = 0) const; + + /** + * Create a new CRL by with additional entries. + * @param last_crl the last CRL of this CA to add the new entries to + * @param new_entries contains the new CRL entries to be added to the CRL + * @param rng the random number generator to use + * @param next_update the time to set in next update in seconds + * as the offset from the current time + */ + X509_CRL update_crl(const X509_CRL& last_crl, + const std::vector& new_entries, + RandomNumberGenerator& rng, + u32bit next_update = 0) const; + + static X509_Certificate make_cert(PK_Signer*, + RandomNumberGenerator&, + const AlgorithmIdentifier&, + const MemoryRegion&, + const X509_Time&, const X509_Time&, + const X509_DN&, const X509_DN&, + const Extensions&); + + /** + * Create a new CA object. + * @param ca_certificate the certificate of the CA + * @param key the private key of the CA + */ + X509_CA(const X509_Certificate& ca_certificate, const Private_Key& key); + ~X509_CA(); + private: + X509_CA(const X509_CA&) {} + X509_CA& operator=(const X509_CA&) { return (*this); } + + X509_CRL make_crl(const std::vector&, + u32bit, u32bit, RandomNumberGenerator&) const; + + AlgorithmIdentifier ca_sig_algo; + X509_Certificate cert; + PK_Signer* signer; + }; + +/** +* Choose the default signature format for a certain public key signature +* scheme. +* @param key will be the key to choose a padding scheme for +* @param alg_id will be set to the chosen scheme +* @return A PK_Signer object for generating signatures +*/ +BOTAN_DLL PK_Signer* choose_sig_format(const Private_Key& key, + AlgorithmIdentifier& alg_id); + + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509_crl.h b/src/libs/3rdparty/botan/build/botan/x509_crl.h new file mode 100644 index 00000000000..6caef42cc87 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509_crl.h @@ -0,0 +1,90 @@ +/* +* X.509 CRL +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_CRL_H__ +#define BOTAN_X509_CRL_H__ + +#include +#include +#include + +namespace Botan { + +/** +* This class represents X.509 Certificate Revocation Lists (CRLs). +*/ +class BOTAN_DLL X509_CRL : public X509_Object + { + public: + /** + * This class represents CRL related errors. + */ + struct X509_CRL_Error : public Exception + { + X509_CRL_Error(const std::string& error) : + Exception("X509_CRL: " + error) {} + }; + + /** + * Get the entries of this CRL in the form of a vector. + * @return a vector containing the entries of this CRL. + */ + std::vector get_revoked() const; + + /** + * Get the issuer DN of this CRL. + * @return the CRLs issuer DN + */ + X509_DN issuer_dn() const; + + /** + * Get the AuthorityKeyIdentifier of this CRL. + * @return this CRLs AuthorityKeyIdentifier + */ + MemoryVector authority_key_id() const; + + /** + * Get the serial number of this CRL. + * @return the CRLs serial number + */ + u32bit crl_number() const; + + /** + * Get the CRL's thisUpdate value. + * @return the CRLs thisUpdate + */ + X509_Time this_update() const; + + /** + * Get the CRL's nextUpdate value. + * @return the CRLs nextdUpdate + */ + X509_Time next_update() const; + + /** + * Construct a CRL from a data source. + * @param source the data source providing the DER or PEM encoded CRL. + */ + X509_CRL(DataSource&, bool throw_on_unknown_critical = false); + + /** + * Construct a CRL from a file containing the DER or PEM encoded CRL. + * @param filename the name of the CRL file + */ + X509_CRL(const std::string& filename, + bool throw_on_unknown_critical = false); + private: + void force_decode(); + + bool throw_on_unknown_critical; + std::vector revoked; + Data_Store info; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509_ext.h b/src/libs/3rdparty/botan/build/botan/x509_ext.h new file mode 100644 index 00000000000..108215ee75a --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509_ext.h @@ -0,0 +1,317 @@ +/* +* X.509 Certificate Extensions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_EXTENSIONS_H__ +#define BOTAN_X509_EXTENSIONS_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/* +* X.509 Certificate Extension +*/ +class BOTAN_DLL Certificate_Extension + { + public: + OID oid_of() const; + + virtual Certificate_Extension* copy() const = 0; + + virtual void contents_to(Data_Store&, Data_Store&) const = 0; + virtual std::string config_id() const = 0; + virtual std::string oid_name() const = 0; + + virtual ~Certificate_Extension() {} + protected: + friend class Extensions; + virtual bool should_encode() const { return true; } + virtual MemoryVector encode_inner() const = 0; + virtual void decode_inner(const MemoryRegion&) = 0; + }; + +/* +* X.509 Certificate Extension List +*/ +class BOTAN_DLL Extensions : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + void contents_to(Data_Store&, Data_Store&) const; + + void add(Certificate_Extension* extn) + { extensions.push_back(extn); } + + Extensions& operator=(const Extensions&); + + Extensions(const Extensions&); + Extensions(bool st = true) : should_throw(st) {} + ~Extensions(); + private: + static Certificate_Extension* get_extension(const OID&); + + std::vector extensions; + bool should_throw; + }; + +namespace Cert_Extension { + +/* +* Basic Constraints Extension +*/ +class BOTAN_DLL Basic_Constraints : public Certificate_Extension + { + public: + Basic_Constraints* copy() const + { return new Basic_Constraints(is_ca, path_limit); } + + Basic_Constraints(bool ca = false, u32bit limit = 0) : + is_ca(ca), path_limit(limit) {} + + bool get_is_ca() const { return is_ca; } + u32bit get_path_limit() const; + private: + std::string config_id() const { return "basic_constraints"; } + std::string oid_name() const { return "X509v3.BasicConstraints"; } + + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + bool is_ca; + u32bit path_limit; + }; + +/* +* Key Usage Constraints Extension +*/ +class BOTAN_DLL Key_Usage : public Certificate_Extension + { + public: + Key_Usage* copy() const { return new Key_Usage(constraints); } + + Key_Usage(Key_Constraints c = NO_CONSTRAINTS) : constraints(c) {} + + Key_Constraints get_constraints() const { return constraints; } + private: + std::string config_id() const { return "key_usage"; } + std::string oid_name() const { return "X509v3.KeyUsage"; } + + bool should_encode() const { return (constraints != NO_CONSTRAINTS); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + Key_Constraints constraints; + }; + +/* +* Subject Key Identifier Extension +*/ +class BOTAN_DLL Subject_Key_ID : public Certificate_Extension + { + public: + Subject_Key_ID* copy() const { return new Subject_Key_ID(key_id); } + + Subject_Key_ID() {} + Subject_Key_ID(const MemoryRegion&); + + MemoryVector get_key_id() const { return key_id; } + private: + std::string config_id() const { return "subject_key_id"; } + std::string oid_name() const { return "X509v3.SubjectKeyIdentifier"; } + + bool should_encode() const { return (key_id.size() > 0); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + MemoryVector key_id; + }; + +/* +* Authority Key Identifier Extension +*/ +class BOTAN_DLL Authority_Key_ID : public Certificate_Extension + { + public: + Authority_Key_ID* copy() const { return new Authority_Key_ID(key_id); } + + Authority_Key_ID() {} + Authority_Key_ID(const MemoryRegion& k) : key_id(k) {} + + MemoryVector get_key_id() const { return key_id; } + private: + std::string config_id() const { return "authority_key_id"; } + std::string oid_name() const { return "X509v3.AuthorityKeyIdentifier"; } + + bool should_encode() const { return (key_id.size() > 0); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + MemoryVector key_id; + }; + +/* +* Alternative Name Extension Base Class +*/ +class BOTAN_DLL Alternative_Name : public Certificate_Extension + { + public: + AlternativeName get_alt_name() const { return alt_name; } + + protected: + Alternative_Name(const AlternativeName&, + const std::string&, const std::string&); + + Alternative_Name(const std::string&, const std::string&); + private: + std::string config_id() const { return config_name_str; } + std::string oid_name() const { return oid_name_str; } + + bool should_encode() const { return alt_name.has_items(); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + std::string config_name_str, oid_name_str; + AlternativeName alt_name; + }; + +/* +* Subject Alternative Name Extension +*/ +class BOTAN_DLL Subject_Alternative_Name : public Alternative_Name + { + public: + Subject_Alternative_Name* copy() const + { return new Subject_Alternative_Name(get_alt_name()); } + + Subject_Alternative_Name(const AlternativeName& = AlternativeName()); + }; + +/* +* Issuer Alternative Name Extension +*/ +class BOTAN_DLL Issuer_Alternative_Name : public Alternative_Name + { + public: + Issuer_Alternative_Name* copy() const + { return new Issuer_Alternative_Name(get_alt_name()); } + + Issuer_Alternative_Name(const AlternativeName& = AlternativeName()); + }; + +/* +* Extended Key Usage Extension +*/ +class BOTAN_DLL Extended_Key_Usage : public Certificate_Extension + { + public: + Extended_Key_Usage* copy() const { return new Extended_Key_Usage(oids); } + + Extended_Key_Usage() {} + Extended_Key_Usage(const std::vector& o) : oids(o) {} + + std::vector get_oids() const { return oids; } + private: + std::string config_id() const { return "extended_key_usage"; } + std::string oid_name() const { return "X509v3.ExtendedKeyUsage"; } + + bool should_encode() const { return (oids.size() > 0); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + std::vector oids; + }; + +/* +* Certificate Policies Extension +*/ +class BOTAN_DLL Certificate_Policies : public Certificate_Extension + { + public: + Certificate_Policies* copy() const + { return new Certificate_Policies(oids); } + + Certificate_Policies() {} + Certificate_Policies(const std::vector& o) : oids(o) {} + + std::vector get_oids() const { return oids; } + private: + std::string config_id() const { return "policy_info"; } + std::string oid_name() const { return "X509v3.CertificatePolicies"; } + + bool should_encode() const { return (oids.size() > 0); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + std::vector oids; + }; + +/* +* CRL Number Extension +*/ +class BOTAN_DLL CRL_Number : public Certificate_Extension + { + public: + CRL_Number* copy() const; + + CRL_Number() : has_value(false), crl_number(0) {} + CRL_Number(u32bit n) : has_value(true), crl_number(n) {} + + u32bit get_crl_number() const; + private: + std::string config_id() const { return "crl_number"; } + std::string oid_name() const { return "X509v3.CRLNumber"; } + + bool should_encode() const { return has_value; } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + bool has_value; + u32bit crl_number; + }; + +/* +* CRL Entry Reason Code Extension +*/ +class BOTAN_DLL CRL_ReasonCode : public Certificate_Extension + { + public: + CRL_ReasonCode* copy() const { return new CRL_ReasonCode(reason); } + + CRL_ReasonCode(CRL_Code r = UNSPECIFIED) : reason(r) {} + + CRL_Code get_reason() const { return reason; } + private: + std::string config_id() const { return "crl_reason"; } + std::string oid_name() const { return "X509v3.ReasonCode"; } + + bool should_encode() const { return (reason != UNSPECIFIED); } + MemoryVector encode_inner() const; + void decode_inner(const MemoryRegion&); + void contents_to(Data_Store&, Data_Store&) const; + + CRL_Code reason; + }; + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509_key.h b/src/libs/3rdparty/botan/build/botan/x509_key.h new file mode 100644 index 00000000000..9404b7ecc42 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509_key.h @@ -0,0 +1,110 @@ +/* +* X.509 Public Key +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_PUBLIC_KEY_H__ +#define BOTAN_X509_PUBLIC_KEY_H__ + +#include +#include +#include +#include + +namespace Botan { + +/** +* This class represents abstract X.509 public key encoders. +*/ +class BOTAN_DLL X509_Encoder + { + public: + virtual AlgorithmIdentifier alg_id() const = 0; + virtual MemoryVector key_bits() const = 0; + virtual ~X509_Encoder() {} + }; + +/** +* This class represents abstract X.509 public key decoders. +*/ +class BOTAN_DLL X509_Decoder + { + public: + virtual void alg_id(const AlgorithmIdentifier&) = 0; + virtual void key_bits(const MemoryRegion&) = 0; + virtual ~X509_Decoder() {} + }; + +/** +* This namespace contains functions for handling X509 objects. +*/ +namespace X509 { + +/* +* X.509 Public Key Encoding/Decoding +*/ + +/** +* Encode a key into a pipe. +* @param key the public key to encode +* @param pipe the pipe to feed the encoded key into +* @param enc the encoding type to use +*/ +BOTAN_DLL void encode(const Public_Key& key, Pipe& pipe, + X509_Encoding enc = PEM); + +/** +* PEM encode a public key into a string. +* @param key the key to encode +* @return the PEM encoded key +*/ +BOTAN_DLL std::string PEM_encode(const Public_Key& key); + +/** +* Create a public key from a data source. +* @param source the source providing the DER or PEM encoded key +* @return the new public key object +*/ +BOTAN_DLL Public_Key* load_key(DataSource& source); + +/** +* Create a public key from a string. +* @param enc the string containing the PEM encoded key +* @return the new public key object +*/ +BOTAN_DLL Public_Key* load_key(const std::string& enc); + +/** +* Create a public key from a memory region. +* @param enc the memory region containing the DER or PEM encoded key +* @return the new public key object +*/ +BOTAN_DLL Public_Key* load_key(const MemoryRegion& enc); + +/** +* Copy a key. +* @param key the public key to copy +* @return the new public key object +*/ +BOTAN_DLL Public_Key* copy_key(const Public_Key& key); + +/** +* Create the key constraints for a specific public key. +* @param pub_key the public key from which the basic set of +* constraints to be placed in the return value is derived +* @param limits additional limits that will be incorporated into the +* return value +* @return the combination of key type specific constraints and +* additional limits +*/ + +BOTAN_DLL Key_Constraints find_constraints(const Public_Key& pub_key, + Key_Constraints limits); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509_obj.h b/src/libs/3rdparty/botan/build/botan/x509_obj.h new file mode 100644 index 00000000000..c7f92fa9daa --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509_obj.h @@ -0,0 +1,67 @@ +/* +* X.509 SIGNED Object +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_OBJECT_H__ +#define BOTAN_X509_OBJECT_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/** +* This class represents abstract X.509 signed objects as +* in the X.500 SIGNED macro +*/ +class BOTAN_DLL X509_Object + { + public: + SecureVector tbs_data() const; + SecureVector signature() const; + AlgorithmIdentifier signature_algorithm() const; + + /** + * Create a signed X509 object. + * @param signer the signer used to sign the object + * @param rng the random number generator to use + * @param alg_id the algorithm identifier of the signature scheme + * @param tbs the tbs bits to be signed + * @return the signed X509 object + */ + static MemoryVector make_signed(class PK_Signer* signer, + RandomNumberGenerator& rng, + const AlgorithmIdentifier& alg_id, + const MemoryRegion& tbs); + + bool check_signature(class Public_Key&) const; + + void encode(Pipe&, X509_Encoding = PEM) const; + SecureVector BER_encode() const; + std::string PEM_encode() const; + + X509_Object(DataSource&, const std::string&); + X509_Object(const std::string&, const std::string&); + virtual ~X509_Object() {} + protected: + void do_decode(); + X509_Object() {} + AlgorithmIdentifier sig_algo; + SecureVector tbs_bits, sig; + private: + virtual void force_decode() = 0; + void init(DataSource&, const std::string&); + void decode_info(DataSource&); + std::vector PEM_labels_allowed; + std::string PEM_label_pref; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509cert.h b/src/libs/3rdparty/botan/build/botan/x509cert.h new file mode 100644 index 00000000000..4a9d11f7fa7 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509cert.h @@ -0,0 +1,185 @@ +/* +* X.509 Certificates +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_CERTS_H__ +#define BOTAN_X509_CERTS_H__ + +#include +#include +#include +#include +#include + +namespace Botan { + +/** +* This class represents X.509 Certificate +*/ +class BOTAN_DLL X509_Certificate : public X509_Object + { + public: + /** + * Get the public key associated with this certificate. + * @return the subject public key of this certificate + */ + Public_Key* subject_public_key() const; + + /** + * Get the issuer certificate DN. + * @return the issuer DN of this certificate + */ + X509_DN issuer_dn() const; + + /** + * Get the subject certificate DN. + * @return the subject DN of this certificate + */ + X509_DN subject_dn() const; + + /** + * Get a value for a specific subject_info parameter name. + * @param name the name of the paramter to look up. Possible names are + * "X509.Certificate.version", "X509.Certificate.serial", + * "X509.Certificate.start", "X509.Certificate.end", + * "X509.Certificate.v2.key_id", "X509.Certificate.public_key", + * "X509v3.BasicConstraints.path_constraint", + * "X509v3.BasicConstraints.is_ca", "X509v3.ExtendedKeyUsage", + * "X509v3.CertificatePolicies", "X509v3.SubjectKeyIdentifier" or + * "X509.Certificate.serial". + * @return the value(s) of the specified parameter + */ + std::vector subject_info(const std::string& name) const; + + /** + * Get a value for a specific subject_info parameter name. + * @param name the name of the paramter to look up. Possible names are + * "X509.Certificate.v2.key_id" or "X509v3.AuthorityKeyIdentifier". + * @return the value(s) of the specified parameter + */ + std::vector issuer_info(const std::string& name) const; + + /** + * Get the notBefore of the certificate. + * @return the notBefore of the certificate + */ + std::string start_time() const; + + /** + * Get the notAfter of the certificate. + * @return the notAfter of the certificate + */ + std::string end_time() const; + + /** + * Get the X509 version of this certificate object. + * @return the X509 version + */ + u32bit x509_version() const; + + /** + * Get the serial number of this certificate. + * @return the certificates serial number + */ + MemoryVector serial_number() const; + + /** + * Get the DER encoded AuthorityKeyIdentifier of this certificate. + * @return the DER encoded AuthorityKeyIdentifier + */ + MemoryVector authority_key_id() const; + + /** + * Get the DER encoded SubjectKeyIdentifier of this certificate. + * @return the DER encoded SubjectKeyIdentifier + */ + MemoryVector subject_key_id() const; + + /** + * Check whether this certificate is self signed. + * @return true if this certificate is self signed + */ + bool is_self_signed() const { return self_signed; } + + /** + * Check whether this certificate is a CA certificate. + * @return true if this certificate is a CA certificate + */ + bool is_CA_cert() const; + + /** + * Get the path limit as defined in the BasicConstraints extension of + * this certificate. + * @return the path limit + */ + u32bit path_limit() const; + + /** + * Get the key constraints as defined in the KeyUsage extension of this + * certificate. + * @return the key constraints + */ + Key_Constraints constraints() const; + + /** + * Get the key constraints as defined in the ExtendedKeyUsage + * extension of this + * certificate. + * @return the key constraints + */ + std::vector ex_constraints() const; + + /** + * Get the policies as defined in the CertificatePolicies extension + * of this certificate. + * @return the certificate policies + */ + std::vector policies() const; + + /** + * Check to certificates for equality. + * @return true both certificates are (binary) equal + */ + bool operator==(const X509_Certificate& other) const; + + /** + * Create a certificate from a data source providing the DER or + * PEM encoded certificate. + * @param source the data source + */ + X509_Certificate(DataSource& source); + + /** + * Create a certificate from a file containing the DER or PEM + * encoded certificate. + * @param filename the name of the certificate file + */ + X509_Certificate(const std::string& filename); + private: + void force_decode(); + friend class X509_CA; + X509_Certificate() {} + + Data_Store subject, issuer; + bool self_signed; + }; + +/** +* Check two certificates for inequality +* @return true if the arguments represent different certificates, +* false if they are binary identical +*/ +BOTAN_DLL bool operator!=(const X509_Certificate&, const X509_Certificate&); + +/* +* Data Store Extraction Operations +*/ +BOTAN_DLL X509_DN create_dn(const Data_Store&); +BOTAN_DLL AlternativeName create_alt_name(const Data_Store&); + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509find.h b/src/libs/3rdparty/botan/build/botan/x509find.h new file mode 100644 index 00000000000..a7a84c7a55f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509find.h @@ -0,0 +1,60 @@ +/* +* X.509 Certificate Store Searching +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_CERT_STORE_SEARCH_H__ +#define BOTAN_X509_CERT_STORE_SEARCH_H__ + +#include + +namespace Botan { + +/* +* Search based on the contents of a DN entry +*/ +class BOTAN_DLL DN_Check : public X509_Store::Search_Func + { + public: + typedef bool (*compare_fn)(const std::string&, const std::string&); + enum Search_Type { SUBSTRING_MATCHING, IGNORE_CASE }; + + bool match(const X509_Certificate& cert) const; + + DN_Check(const std::string&, const std::string&, compare_fn); + DN_Check(const std::string&, const std::string&, Search_Type); + private: + std::string dn_entry, looking_for; + compare_fn compare; + }; + +/* +* Search for a certificate by issuer/serial +*/ +class BOTAN_DLL IandS_Match : public X509_Store::Search_Func + { + public: + bool match(const X509_Certificate& cert) const; + IandS_Match(const X509_DN&, const MemoryRegion&); + private: + X509_DN issuer; + MemoryVector serial; + }; + +/* +* Search for a certificate by subject keyid +*/ +class BOTAN_DLL SKID_Match : public X509_Store::Search_Func + { + public: + bool match(const X509_Certificate& cert) const; + SKID_Match(const MemoryRegion& s) : skid(s) {} + private: + MemoryVector skid; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509self.h b/src/libs/3rdparty/botan/build/botan/x509self.h new file mode 100644 index 00000000000..bd3e291799c --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509self.h @@ -0,0 +1,198 @@ +/* +* X.509 Self-Signed Certificate +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_SELF_H__ +#define BOTAN_X509_SELF_H__ + +#include +#include +#include + +namespace Botan { + +/** +* Options for X.509 certificates. +*/ +class BOTAN_DLL X509_Cert_Options + { + public: + /** + * the subject common name + */ + std::string common_name; + + /** + * the subject counry + */ + std::string country; + + /** + * the subject organization + */ + std::string organization; + + /** + * the subject organizational unit + */ + std::string org_unit; + + /** + * the subject locality + */ + std::string locality; + + /** + * the subject state + */ + std::string state; + + /** + * the subject serial number + */ + std::string serial_number; + + /** + * the subject email adress + */ + std::string email; + + /** + * the subject URI + */ + std::string uri; + + /** + * the subject IPv4 address + */ + std::string ip; + + /** + * the subject DNS + */ + std::string dns; + + /** + * the subject XMPP + */ + std::string xmpp; + + /** + * the subject challenge password + */ + std::string challenge; + + /** + * the subject notBefore + */ + X509_Time start; + /** + * the subject notAfter + */ + X509_Time end; + + /** + * Indicates whether the certificate request + */ + bool is_CA; + + /** + * Indicates the BasicConstraints path limit + */ + u32bit path_limit; + + /** + * The key constraints for the subject public key + */ + Key_Constraints constraints; + + /** + * The key extended constraints for the subject public key + */ + std::vector ex_constraints; + + /** + * Check the options set in this object for validity. + */ + void sanity_check() const; + + /** + * Mark the certificate as a CA certificate and set the path limit. + * @param limit the path limit to be set in the BasicConstraints extension. + */ + void CA_key(u32bit limit = 1); + + /** + * Set the notBefore of the certificate. + * @param time the notBefore value of the certificate + */ + void not_before(const std::string& time); + + /** + * Set the notAfter of the certificate. + * @param time the notAfter value of the certificate + */ + void not_after(const std::string& time); + + /** + * Add the key constraints of the KeyUsage extension. + * @param constr the constraints to set + */ + void add_constraints(Key_Constraints constr); + + /** + * Add constraints to the ExtendedKeyUsage extension. + * @param oid the oid to add + */ + void add_ex_constraint(const OID& oid); + + /** + * Add constraints to the ExtendedKeyUsage extension. + * @param name the name to look up the oid to add + */ + void add_ex_constraint(const std::string& name); + + /** + * Construct a new options object + * @param opts define the common name of this object. An example for this + * parameter would be "common_name/country/organization/organizational_unit". + * @param expire_time the expiration time (from the current clock in seconds) + */ + X509_Cert_Options(const std::string& opts = "", + u32bit expire_time = 365 * 24 * 60 * 60); + }; + +namespace X509 { + +/** +* Create a self-signed X.509 certificate. +* @param opts the options defining the certificate to create +* @param key the private key used for signing, i.e. the key +* associated with this self-signed certificate +* @param rng the rng to use +* @return the newly created self-signed certificate +*/ +BOTAN_DLL X509_Certificate +create_self_signed_cert(const X509_Cert_Options& opts, + const Private_Key& key, + RandomNumberGenerator& rng); + +/** +* Create a PKCS#10 certificate request. +* @param opts the options defining the request to create +* @param key the key used to sign this request +* @param rng the rng to use +* @return the newly created PKCS#10 request +*/ +BOTAN_DLL PKCS10_Request create_cert_req(const X509_Cert_Options& opts, + const Private_Key& key, + RandomNumberGenerator& rng); + +} + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x509stor.h b/src/libs/3rdparty/botan/build/botan/x509stor.h new file mode 100644 index 00000000000..4e60378836d --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x509stor.h @@ -0,0 +1,143 @@ +/* +* X.509 Certificate Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_X509_CERT_STORE_H__ +#define BOTAN_X509_CERT_STORE_H__ + +#include +#include +#include + +namespace Botan { + +/* +* X.509 Certificate Validation Result +*/ +enum X509_Code { + VERIFIED, + UNKNOWN_X509_ERROR, + CANNOT_ESTABLISH_TRUST, + CERT_CHAIN_TOO_LONG, + SIGNATURE_ERROR, + POLICY_ERROR, + INVALID_USAGE, + + CERT_FORMAT_ERROR, + CERT_ISSUER_NOT_FOUND, + CERT_NOT_YET_VALID, + CERT_HAS_EXPIRED, + CERT_IS_REVOKED, + + CRL_FORMAT_ERROR, + CRL_ISSUER_NOT_FOUND, + CRL_NOT_YET_VALID, + CRL_HAS_EXPIRED, + + CA_CERT_CANNOT_SIGN, + CA_CERT_NOT_FOR_CERT_ISSUER, + CA_CERT_NOT_FOR_CRL_ISSUER +}; + +/* +* X.509 Certificate Store +*/ +class BOTAN_DLL X509_Store + { + public: + class BOTAN_DLL Search_Func + { + public: + virtual bool match(const X509_Certificate&) const = 0; + virtual ~Search_Func() {} + }; + + enum Cert_Usage { + ANY = 0x00, + TLS_SERVER = 0x01, + TLS_CLIENT = 0x02, + CODE_SIGNING = 0x04, + EMAIL_PROTECTION = 0x08, + TIME_STAMPING = 0x10, + CRL_SIGNING = 0x20 + }; + + X509_Code validate_cert(const X509_Certificate&, Cert_Usage = ANY); + + std::vector get_certs(const Search_Func&) const; + std::vector get_cert_chain(const X509_Certificate&); + std::string PEM_encode() const; + + /* + * Made CRL_Data public for XLC for Cell 0.9, otherwise cannot + * instantiate member variable std::vector revoked + */ + class BOTAN_DLL CRL_Data + { + public: + X509_DN issuer; + MemoryVector serial, auth_key_id; + bool operator==(const CRL_Data&) const; + bool operator!=(const CRL_Data&) const; + bool operator<(const CRL_Data&) const; + }; + + X509_Code add_crl(const X509_CRL&); + void add_cert(const X509_Certificate&, bool = false); + void add_certs(DataSource&); + void add_trusted_certs(DataSource&); + + void add_new_certstore(Certificate_Store*); + + static X509_Code check_sig(const X509_Object&, Public_Key*); + + X509_Store(u32bit time_slack = 24*60*60, + u32bit cache_results = 30*60); + + X509_Store(const X509_Store&); + ~X509_Store(); + private: + X509_Store& operator=(const X509_Store&) { return (*this); } + + class BOTAN_DLL Cert_Info + { + public: + bool is_verified(u32bit timeout) const; + bool is_trusted() const; + X509_Code verify_result() const; + void set_result(X509_Code) const; + Cert_Info(const X509_Certificate&, bool = false); + + X509_Certificate cert; + bool trusted; + private: + mutable bool checked; + mutable X509_Code result; + mutable u64bit last_checked; + }; + + u32bit find_cert(const X509_DN&, const MemoryRegion&) const; + X509_Code check_sig(const Cert_Info&, const Cert_Info&) const; + void recompute_revoked_info() const; + + void do_add_certs(DataSource&, bool); + X509_Code construct_cert_chain(const X509_Certificate&, + std::vector&, bool = false); + + u32bit find_parent_of(const X509_Certificate&); + bool is_revoked(const X509_Certificate&) const; + + static const u32bit NO_CERT_FOUND = 0xFFFFFFFF; + std::vector certs; + std::vector revoked; + std::vector stores; + u32bit time_slack, validation_cache_timeout; + mutable bool revoked_info_valid; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x919_mac.h b/src/libs/3rdparty/botan/build/botan/x919_mac.h new file mode 100644 index 00000000000..1c2a06bee3e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x919_mac.h @@ -0,0 +1,41 @@ +/* +* ANSI X9.19 MAC +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ANSI_X919_MAC_H__ +#define BOTAN_ANSI_X919_MAC_H__ + +#include +#include + +namespace Botan { + +/** +* DES/3DES-based MAC from ANSI X9.19 +*/ +class BOTAN_DLL ANSI_X919_MAC : public MessageAuthenticationCode + { + public: + void clear() throw(); + std::string name() const; + MessageAuthenticationCode* clone() const; + + ANSI_X919_MAC(BlockCipher*); + ~ANSI_X919_MAC(); + private: + void add_data(const byte[], u32bit); + void final_result(byte[]); + void key_schedule(const byte[], u32bit); + + BlockCipher* e; + BlockCipher* d; + SecureBuffer state; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/x931_rng.h b/src/libs/3rdparty/botan/build/botan/x931_rng.h new file mode 100644 index 00000000000..44e9b442811 --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/x931_rng.h @@ -0,0 +1,45 @@ +/* +* ANSI X9.31 RNG +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ANSI_X931_RNG_H__ +#define BOTAN_ANSI_X931_RNG_H__ + +#include +#include + +namespace Botan { + +/** +* ANSI X9.31 RNG +*/ +class BOTAN_DLL ANSI_X931_RNG : public RandomNumberGenerator + { + public: + void randomize(byte[], u32bit); + bool is_seeded() const; + void clear() throw(); + std::string name() const; + + void reseed(u32bit poll_bits); + void add_entropy_source(EntropySource*); + void add_entropy(const byte[], u32bit); + + ANSI_X931_RNG(BlockCipher*, RandomNumberGenerator*); + ~ANSI_X931_RNG(); + private: + void rekey(); + void update_buffer(); + + BlockCipher* cipher; + RandomNumberGenerator* prng; + SecureVector V, R; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/xor_buf.h b/src/libs/3rdparty/botan/build/botan/xor_buf.h new file mode 100644 index 00000000000..39781f0174e --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/xor_buf.h @@ -0,0 +1,74 @@ +/** +* XOR operations +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_XOR_BUF_H__ +#define BOTAN_XOR_BUF_H__ + +#include + +namespace Botan { + +/** +* XOR arrays. Postcondition out[i] = in[i] ^ out[i] forall i = 0...length +* @param out the input/output buffer +* @param in the read-only input buffer +* @param length the length of the buffers +*/ +inline void xor_buf(byte out[], const byte in[], u32bit length) + { + while(length >= 8) + { +#if BOTAN_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) ^= *reinterpret_cast(in); +#else + out[0] ^= in[0]; out[1] ^= in[1]; + out[2] ^= in[2]; out[3] ^= in[3]; + out[4] ^= in[4]; out[5] ^= in[5]; + out[6] ^= in[6]; out[7] ^= in[7]; +#endif + + out += 8; in += 8; length -= 8; + } + for(u32bit j = 0; j != length; ++j) + out[j] ^= in[j]; + } + +/** +* XOR arrays. Postcondition out[i] = in[i] ^ in2[i] forall i = 0...length +* @param out the output buffer +* @param in the first input buffer +* @param in2 the second output buffer +* @param length the length of the three buffers +*/ +inline void xor_buf(byte out[], + const byte in[], + const byte in2[], + u32bit length) + { + while(length >= 8) + { +#if BOTAN_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = + *reinterpret_cast(in) ^ + *reinterpret_cast(in2); +#else + out[0] = in[0] ^ in2[0]; out[1] = in[1] ^ in2[1]; + out[2] = in[2] ^ in2[2]; out[3] = in[3] ^ in2[3]; + out[4] = in[4] ^ in2[4]; out[5] = in[5] ^ in2[5]; + out[6] = in[6] ^ in2[6]; out[7] = in[7] ^ in2[7]; +#endif + + in += 8; in2 += 8; out += 8; length -= 8; + } + + for(u32bit j = 0; j != length; ++j) + out[j] = in[j] ^ in2[j]; + } + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/xtea.h b/src/libs/3rdparty/botan/build/botan/xtea.h new file mode 100644 index 00000000000..d9c6066cb3f --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/xtea.h @@ -0,0 +1,34 @@ +/* +* XTEA +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_XTEA_H__ +#define BOTAN_XTEA_H__ + +#include + +namespace Botan { + +/* +* XTEA +*/ +class BOTAN_DLL XTEA : public BlockCipher + { + public: + void clear() throw() { EK.clear(); } + std::string name() const { return "XTEA"; } + BlockCipher* clone() const { return new XTEA; } + XTEA() : BlockCipher(8, 16) {} + private: + void enc(const byte[], byte[]) const; + void dec(const byte[], byte[]) const; + void key_schedule(const byte[], u32bit); + SecureBuffer EK; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/build/botan/xts.h b/src/libs/3rdparty/botan/build/botan/xts.h new file mode 100644 index 00000000000..01558175bea --- /dev/null +++ b/src/libs/3rdparty/botan/build/botan/xts.h @@ -0,0 +1,76 @@ +/* +* XTS mode, from IEEE P1619 +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_XTS_H__ +#define BOTAN_XTS_H__ + +#include +#include + +namespace Botan { + +/* +* XTS Encryption +*/ +class BOTAN_DLL XTS_Encryption : public Keyed_Filter + { + public: + void set_key(const SymmetricKey& key); + void set_iv(const InitializationVector& iv); + + std::string name() const; + + XTS_Encryption(BlockCipher* ciph); + + XTS_Encryption(BlockCipher* ciph, + const SymmetricKey& key, + const InitializationVector& iv); + + ~XTS_Encryption() { delete cipher; delete cipher2; } + private: + void write(const byte[], u32bit); + void end_msg(); + void encrypt(const byte block[]); + + BlockCipher* cipher; + BlockCipher* cipher2; + SecureVector tweak; + SecureVector buffer; + u32bit position; + }; + +/* +* XTS Decryption +*/ +class BOTAN_DLL XTS_Decryption : public Keyed_Filter + { + public: + void set_key(const SymmetricKey& key); + void set_iv(const InitializationVector& iv); + + std::string name() const; + + XTS_Decryption(BlockCipher* ciph); + + XTS_Decryption(BlockCipher* ciph, + const SymmetricKey& key, + const InitializationVector& iv); + private: + void write(const byte[], u32bit); + void end_msg(); + void decrypt(const byte[]); + + BlockCipher* cipher; + BlockCipher* cipher2; + SecureVector tweak; + SecureVector buffer; + u32bit position; + }; + +} + +#endif diff --git a/src/libs/3rdparty/botan/src/src.pro b/src/libs/3rdparty/botan/src/src.pro new file mode 100644 index 00000000000..c6ad8961671 --- /dev/null +++ b/src/libs/3rdparty/botan/src/src.pro @@ -0,0 +1,478 @@ +TEMPLATE = lib +TARGET = Botan + +CONFIG += dll + +include(../../../../qtcreatorlibrary.pri) + +DEPENDPATH += . +INCLUDEPATH += $$PWD $$PWD/../build $$PWD/../build/botan + +win32 { + LIBS += advapi32.lib user32.lib + win32-msvc*: QMAKE_CXXFLAGS += -wd4251 -wd4290 + + DEFINES += _CRT_SECURE_NO_WARNINGS + DEFINES += BOTAN_USE_WINDOWS_BUILD_H + DEFINES += BOTAN_DLL=__declspec(dllexport) +} + +# Input +HEADERS += algo_factory/algo_cache.h \ + algo_factory/algo_factory.h \ + alloc/allocate.h \ + alloc/mem_pool/mem_pool.h \ + alloc/secmem.h \ + alloc/system_alloc/defalloc.h \ + asn1/alg_id.h \ + asn1/asn1_int.h \ + asn1/asn1_obj.h \ + asn1/asn1_oid.h \ + asn1/ber_dec.h \ + asn1/der_enc.h \ + benchmark/benchmark.h \ + block/aes/aes.h \ + block/block_cipher.h \ + block/blowfish/blowfish.h \ + block/cast/cast128.h \ + block/cast/cast256.h \ + block/des/des.h \ + block/des/desx.h \ + block/gost_28147/gost_28147.h \ + block/idea/idea.h \ + block/kasumi/kasumi.h \ + block/lion/lion.h \ + block/lubyrack/lubyrack.h \ + block/mars/mars.h \ + block/misty1/misty1.h \ + block/noekeon/noekeon.h \ + block/rc2/rc2.h \ + block/rc5/rc5.h \ + block/rc6/rc6.h \ + block/safer/safer_sk.h \ + block/seed/seed.h \ + block/serpent/serpent.h \ + block/skipjack/skipjack.h \ + block/square/square.h \ + block/tea/tea.h \ + block/twofish/twofish.h \ + block/xtea/xtea.h \ + cert/x509/certstor.h \ + cert/x509/crl_ent.h \ + cert/x509/pkcs10.h \ + cert/x509/x509_ca.h \ + cert/x509/x509_crl.h \ + cert/x509/x509_ext.h \ + cert/x509/x509_obj.h \ + cert/x509/x509cert.h \ + cert/x509/x509find.h \ + cert/x509/x509self.h \ + cert/x509/x509stor.h \ + checksum/adler32/adler32.h \ + checksum/crc24/crc24.h \ + checksum/crc32/crc32.h \ + cms/cms_dec.h \ + cms/cms_enc.h \ + codec/base64/base64.h \ + codec/hex/hex.h \ + codec/openpgp/openpgp.h \ + codec/pem/pem.h \ + cryptobox/cryptobox.h \ + engine/def_engine/def_eng.h \ + engine/engine.h \ + entropy/cryptoapi_rng/es_capi.h \ + entropy/entropy_src.h \ + entropy/win32_stats/es_win32.h \ + filters/basefilt.h \ + filters/buf_filt.h \ + filters/data_snk.h \ + filters/data_src.h \ + filters/filter.h \ + filters/filters.h \ + filters/out_buf.h \ + filters/pbe.h \ + filters/pipe.h \ + filters/secqueue.h \ + hash/fork256/fork256.h \ + hash/gost_3411/gost_3411.h \ + hash/has160/has160.h \ + hash/hash.h \ + hash/md2/md2.h \ + hash/md4/md4.h \ + hash/md5/md5.h \ + hash/mdx_hash/mdx_hash.h \ + hash/par_hash/par_hash.h \ + hash/rmd128/rmd128.h \ + hash/rmd160/rmd160.h \ + hash/sha1/sha160.h \ + hash/sha2/sha2_32.h \ + hash/sha2/sha2_64.h \ + hash/skein/skein_512.h \ + hash/tiger/tiger.h \ + hash/whirlpool/whrlpool.h \ + kdf/kdf.h \ + kdf/kdf1/kdf1.h \ + kdf/kdf2/kdf2.h \ + kdf/mgf1/mgf1.h \ + kdf/ssl_prf/prf_ssl3.h \ + kdf/tls_prf/prf_tls.h \ + kdf/x942_prf/prf_x942.h \ + libstate/botan.h \ + libstate/init.h \ + libstate/libstate.h \ + libstate/look_pk.h \ + libstate/lookup.h \ + libstate/oid_lookup/oids.h \ + libstate/pk_engine.h \ + libstate/scan_name.h \ + mac/cbc_mac/cbc_mac.h \ + mac/cmac/cmac.h \ + mac/hmac/hmac.h \ + mac/mac.h \ + mac/ssl3mac/ssl3_mac.h \ + mac/x919_mac/x919_mac.h \ + math/bigint/bigint.h \ + math/bigint/divide.h \ + math/bigint/mp_core.h \ + math/bigint/mp_generic/mp_asm.h \ + math/bigint/mp_generic/mp_asmi.h \ + math/bigint/mp_types.h \ + math/numbertheory/blinding.h \ + math/numbertheory/def_powm.h \ + math/numbertheory/numthry.h \ + math/numbertheory/pow_mod.h \ + math/numbertheory/reducer.h \ + modes/cbc/cbc.h \ + modes/cfb/cfb.h \ + modes/ctr/ctr.h \ + modes/cts/cts.h \ + modes/eax/eax.h \ + modes/ecb/ecb.h \ + modes/mode_pad/mode_pad.h \ + modes/modebase.h \ + modes/ofb/ofb.h \ + modes/xts/xts.h \ + mutex/mutex.h \ + mutex/noop_mutex/mux_noop.h \ + mutex/win32_crit_section/mux_win32.h \ + pbe/get_pbe.h \ + pbe/pbes1/pbes1.h \ + pbe/pbes2/pbes2.h \ + pk_pad/eme.h \ + pk_pad/eme1/eme1.h \ + pk_pad/eme_pkcs/eme_pkcs.h \ + pk_pad/emsa.h \ + pk_pad/emsa1/emsa1.h \ + pk_pad/emsa1_bsi/emsa1_bsi.h \ + pk_pad/emsa2/emsa2.h \ + pk_pad/emsa3/emsa3.h \ + pk_pad/emsa4/emsa4.h \ + pk_pad/emsa_raw/emsa_raw.h \ + pk_pad/hash_id/hash_id.h \ + pubkey/dh/dh.h \ + pubkey/dh/dh_core.h \ + pubkey/dh/dh_op.h \ + pubkey/dl_algo/dl_algo.h \ + pubkey/dl_group/dl_group.h \ + pubkey/dlies/dlies.h \ + pubkey/dsa/dsa.h \ + pubkey/dsa/dsa_core.h \ + pubkey/dsa/dsa_op.h \ + pubkey/elgamal/elg_core.h \ + pubkey/elgamal/elg_op.h \ + pubkey/elgamal/elgamal.h \ + pubkey/if_algo/if_algo.h \ + pubkey/if_algo/if_core.h \ + pubkey/if_algo/if_op.h \ + pubkey/keypair/keypair.h \ + pubkey/nr/nr.h \ + pubkey/nr/nr_core.h \ + pubkey/nr/nr_op.h \ + pubkey/pk_algs.h \ + pubkey/pk_codecs/pkcs8.h \ + pubkey/pk_codecs/x509_key.h \ + pubkey/pk_filts.h \ + pubkey/pk_keys.h \ + pubkey/pubkey.h \ + pubkey/pubkey_enums.h \ + pubkey/rsa/rsa.h \ + pubkey/rw/rw.h \ + rng/auto_rng/auto_rng.h \ + rng/hmac_rng/hmac_rng.h \ + rng/randpool/randpool.h \ + rng/rng.h \ + rng/x931_rng/x931_rng.h \ + s2k/pbkdf1/pbkdf1.h \ + s2k/pbkdf2/pbkdf2.h \ + s2k/pgps2k/pgp_s2k.h \ + s2k/s2k.h \ + selftest/selftest.h \ + stream/arc4/arc4.h \ + stream/salsa20/salsa20.h \ + stream/stream_cipher.h \ + stream/turing/turing.h \ + stream/wid_wake/wid_wake.h \ + sym_algo/sym_algo.h \ + sym_algo/symkey.h \ + timer/timer.h \ + timer/win32_query_perf_ctr/tm_win32.h \ + utils/bit_ops.h \ + utils/bswap.h \ + utils/buf_comp/buf_comp.h \ + utils/charset.h \ + utils/datastor/datastor.h \ + utils/exceptn.h \ + utils/loadstor.h \ + utils/mem_ops.h \ + utils/parsing.h \ + utils/rotate.h \ + utils/stl_util.h \ + utils/types.h \ + utils/ui.h \ + utils/util.h \ + utils/version.h \ + utils/xor_buf.h + +SOURCES += algo_factory/algo_factory.cpp \ + algo_factory/prov_weight.cpp \ + alloc/mem_pool/mem_pool.cpp \ + alloc/system_alloc/defalloc.cpp \ + asn1/alg_id.cpp \ + asn1/asn1_alt.cpp \ + asn1/asn1_att.cpp \ + asn1/asn1_dn.cpp \ + asn1/asn1_int.cpp \ + asn1/asn1_oid.cpp \ + asn1/asn1_str.cpp \ + asn1/asn1_tm.cpp \ + asn1/ber_dec.cpp \ + asn1/der_enc.cpp \ + benchmark/benchmark.cpp \ + block/aes/aes.cpp \ + block/aes/aes_tab.cpp \ + block/blowfish/blfs_tab.cpp \ + block/blowfish/blowfish.cpp \ + block/cast/cast128.cpp \ + block/cast/cast256.cpp \ + block/cast/cast_tab.cpp \ + block/des/des.cpp \ + block/des/des_tab.cpp \ + block/des/desx.cpp \ + block/gost_28147/gost_28147.cpp \ + block/idea/idea.cpp \ + block/kasumi/kasumi.cpp \ + block/lion/lion.cpp \ + block/lubyrack/lubyrack.cpp \ + block/mars/mars.cpp \ + block/mars/mars_tab.cpp \ + block/misty1/misty1.cpp \ + block/noekeon/noekeon.cpp \ + block/rc2/rc2.cpp \ + block/rc5/rc5.cpp \ + block/rc6/rc6.cpp \ + block/safer/safe_tab.cpp \ + block/safer/safer_sk.cpp \ + block/seed/seed.cpp \ + block/seed/seed_tab.cpp \ + block/serpent/serpent.cpp \ + block/skipjack/skipjack.cpp \ + block/square/sqr_tab.cpp \ + block/square/square.cpp \ + block/tea/tea.cpp \ + block/twofish/two_tab.cpp \ + block/twofish/twofish.cpp \ + block/xtea/xtea.cpp \ + cert/x509/certstor.cpp \ + cert/x509/crl_ent.cpp \ + cert/x509/pkcs10.cpp \ + cert/x509/x509_ca.cpp \ + cert/x509/x509_crl.cpp \ + cert/x509/x509_ext.cpp \ + cert/x509/x509_obj.cpp \ + cert/x509/x509cert.cpp \ + cert/x509/x509find.cpp \ + cert/x509/x509opt.cpp \ + cert/x509/x509self.cpp \ + cert/x509/x509stor.cpp \ + checksum/adler32/adler32.cpp \ + checksum/crc24/crc24.cpp \ + checksum/crc32/crc32.cpp \ + cms/cms_algo.cpp \ + cms/cms_comp.cpp \ + cms/cms_dalg.cpp \ + cms/cms_dec.cpp \ + cms/cms_ealg.cpp \ + cms/cms_enc.cpp \ + codec/base64/b64_char.cpp \ + codec/base64/base64.cpp \ + codec/hex/hex.cpp \ + codec/hex/hex_char.cpp \ + codec/openpgp/openpgp.cpp \ + codec/pem/pem.cpp \ + cryptobox/cryptobox.cpp \ + engine/def_engine/def_mode.cpp \ + engine/def_engine/def_pk_ops.cpp \ + engine/def_engine/def_powm.cpp \ + engine/def_engine/lookup_block.cpp \ + engine/def_engine/lookup_hash.cpp \ + engine/def_engine/lookup_mac.cpp \ + engine/def_engine/lookup_stream.cpp \ + entropy/cryptoapi_rng/es_capi.cpp \ + entropy/win32_stats/es_win32.cpp \ + filters/algo_filt.cpp \ + filters/basefilt.cpp \ + filters/buf_filt.cpp \ + filters/data_snk.cpp \ + filters/data_src.cpp \ + filters/filter.cpp \ + filters/out_buf.cpp \ + filters/pipe.cpp \ + filters/pipe_io.cpp \ + filters/pipe_rw.cpp \ + filters/secqueue.cpp \ + hash/fork256/fork256.cpp \ + hash/gost_3411/gost_3411.cpp \ + hash/has160/has160.cpp \ + hash/md2/md2.cpp \ + hash/md4/md4.cpp \ + hash/md5/md5.cpp \ + hash/mdx_hash/mdx_hash.cpp \ + hash/par_hash/par_hash.cpp \ + hash/rmd128/rmd128.cpp \ + hash/rmd160/rmd160.cpp \ + hash/sha1/sha160.cpp \ + hash/sha2/sha2_32.cpp \ + hash/sha2/sha2_64.cpp \ + hash/skein/skein_512.cpp \ + hash/tiger/tig_tab.cpp \ + hash/tiger/tiger.cpp \ + hash/whirlpool/whrl_tab.cpp \ + hash/whirlpool/whrlpool.cpp \ + kdf/kdf.cpp \ + kdf/kdf1/kdf1.cpp \ + kdf/kdf2/kdf2.cpp \ + kdf/mgf1/mgf1.cpp \ + kdf/ssl_prf/prf_ssl3.cpp \ + kdf/tls_prf/prf_tls.cpp \ + kdf/x942_prf/prf_x942.cpp \ + libstate/get_enc.cpp \ + libstate/init.cpp \ + libstate/libstate.cpp \ + libstate/look_pk.cpp \ + libstate/lookup.cpp \ + libstate/oid_lookup/oids.cpp \ + libstate/pk_engine.cpp \ + libstate/policy.cpp \ + libstate/scan_name.cpp \ + mac/cbc_mac/cbc_mac.cpp \ + mac/cmac/cmac.cpp \ + mac/hmac/hmac.cpp \ + mac/mac.cpp \ + mac/ssl3mac/ssl3_mac.cpp \ + mac/x919_mac/x919_mac.cpp \ + math/bigint/big_code.cpp \ + math/bigint/big_io.cpp \ + math/bigint/big_ops2.cpp \ + math/bigint/big_ops3.cpp \ + math/bigint/big_rand.cpp \ + math/bigint/bigint.cpp \ + math/bigint/divide.cpp \ + math/bigint/monty_generic/mp_monty.cpp \ + math/bigint/mp_asm.cpp \ + math/bigint/mp_comba.cpp \ + math/bigint/mp_karat.cpp \ + math/bigint/mp_misc.cpp \ + math/bigint/mp_shift.cpp \ + math/bigint/mulop_generic/mp_mulop.cpp \ + math/numbertheory/blinding.cpp \ + math/numbertheory/dsa_gen.cpp \ + math/numbertheory/jacobi.cpp \ + math/numbertheory/make_prm.cpp \ + math/numbertheory/mp_numth.cpp \ + math/numbertheory/numthry.cpp \ + math/numbertheory/pow_mod.cpp \ + math/numbertheory/powm_fw.cpp \ + math/numbertheory/powm_mnt.cpp \ + math/numbertheory/primes.cpp \ + math/numbertheory/reducer.cpp \ + math/numbertheory/ressol.cpp \ + modes/cbc/cbc.cpp \ + modes/cfb/cfb.cpp \ + modes/ctr/ctr.cpp \ + modes/cts/cts.cpp \ + modes/eax/eax.cpp \ + modes/eax/eax_dec.cpp \ + modes/ecb/ecb.cpp \ + modes/mode_pad/mode_pad.cpp \ + modes/modebase.cpp \ + modes/ofb/ofb.cpp \ + modes/xts/xts.cpp \ + mutex/noop_mutex/mux_noop.cpp \ + mutex/win32_crit_section/mux_win32.cpp \ + pbe/get_pbe.cpp \ + pbe/pbes1/pbes1.cpp \ + pbe/pbes2/pbes2.cpp \ + pk_pad/eme.cpp \ + pk_pad/eme1/eme1.cpp \ + pk_pad/eme_pkcs/eme_pkcs.cpp \ + pk_pad/emsa1/emsa1.cpp \ + pk_pad/emsa1_bsi/emsa1_bsi.cpp \ + pk_pad/emsa2/emsa2.cpp \ + pk_pad/emsa3/emsa3.cpp \ + pk_pad/emsa4/emsa4.cpp \ + pk_pad/emsa_raw/emsa_raw.cpp \ + pk_pad/hash_id/hash_id.cpp \ + pubkey/dh/dh.cpp \ + pubkey/dh/dh_core.cpp \ + pubkey/dl_algo/dl_algo.cpp \ + pubkey/dl_group/dl_group.cpp \ + pubkey/dlies/dlies.cpp \ + pubkey/dsa/dsa.cpp \ + pubkey/dsa/dsa_core.cpp \ + pubkey/dsa/dsa_op.cpp \ + pubkey/elgamal/elg_core.cpp \ + pubkey/elgamal/elg_op.cpp \ + pubkey/elgamal/elgamal.cpp \ + pubkey/if_algo/if_algo.cpp \ + pubkey/if_algo/if_core.cpp \ + pubkey/if_algo/if_op.cpp \ + pubkey/keypair/keypair.cpp \ + pubkey/nr/nr.cpp \ + pubkey/nr/nr_core.cpp \ + pubkey/nr/nr_op.cpp \ + pubkey/pk_algs.cpp \ + pubkey/pk_codecs/pkcs8.cpp \ + pubkey/pk_codecs/x509_key.cpp \ + pubkey/pk_filts.cpp \ + pubkey/pk_keys.cpp \ + pubkey/pubkey.cpp \ + pubkey/pubkey_enums.cpp \ + pubkey/rsa/rsa.cpp \ + pubkey/rw/rw.cpp \ + rng/auto_rng/auto_rng.cpp \ + rng/hmac_rng/hmac_rng.cpp \ + rng/randpool/randpool.cpp \ + rng/rng.cpp \ + rng/x931_rng/x931_rng.cpp \ + s2k/pbkdf1/pbkdf1.cpp \ + s2k/pbkdf2/pbkdf2.cpp \ + s2k/pgps2k/pgp_s2k.cpp \ + s2k/s2k.cpp \ + selftest/selftest.cpp \ + stream/arc4/arc4.cpp \ + stream/salsa20/salsa20.cpp \ + stream/stream_cipher.cpp \ + stream/turing/tur_tab.cpp \ + stream/turing/turing.cpp \ + stream/wid_wake/wid_wake.cpp \ + sym_algo/symkey.cpp \ + timer/timer.cpp \ + timer/win32_query_perf_ctr/tm_win32.cpp \ + utils/charset.cpp \ + utils/datastor/datastor.cpp \ + utils/exceptn.cpp \ + utils/mlock.cpp \ + utils/parsing.cpp \ + utils/ui.cpp \ + utils/util.cpp \ + utils/version.cpp