Namespaces | |
| namespace | AllOrNothingTransform |
| namespace | ASN1 |
| namespace | BER |
| namespace | Cert_Extension |
| namespace | Charset |
| namespace | CryptoBox |
| namespace | CVC_EAC |
| namespace | DE_EAC |
| namespace | Debug |
| namespace | Engine_Core |
| namespace | HAS_160_F |
| namespace | KeyPair |
| namespace | OIDS |
| namespace | OpenPGP |
| namespace | PEM_Code |
| namespace | PKCS8 |
| namespace | PKCS_IDS |
| namespace | PREFETCH |
| namespace | RIPEMD_128_F |
| namespace | X509 |
Classes | |
| class | Adler32 |
| class | AES |
| class | AES_128 |
| class | AES_128_Intel |
| class | AES_192 |
| class | AES_192_Intel |
| class | AES_256 |
| class | AES_256_Intel |
| class | AES_ISA_Engine |
| class | Algorithm_Cache |
| class | Algorithm_Factory |
| struct | Algorithm_Not_Found |
| class | AlgorithmIdentifier |
| class | Allocator |
| class | AlternativeName |
| class | AMD64_Assembler_Engine |
| class | ANSI_X919_MAC |
| class | ANSI_X923_Padding |
| class | ANSI_X931_RNG |
| class | ARC4 |
| class | ASN1_Car |
| class | ASN1_Ced |
| class | ASN1_Cex |
| class | ASN1_Chr |
| class | ASN1_EAC_String |
| class | ASN1_Object |
| class | ASN1_String |
| class | Attribute |
| class | AutoSeeded_RNG |
| class | Base64_Decoder |
| class | Base64_Encoder |
| class | BeOS_EntropySource |
| struct | BER_Bad_Tag |
| class | BER_Decoder |
| struct | BER_Decoding_Error |
| class | BER_Object |
| class | BigInt |
| struct | BitBucket |
| class | Blinder |
| class | BlockCipher |
| class | BlockCipherModePaddingMethod |
| class | Blowfish |
| class | BMW_512 |
| class | Buffered_Filter |
| class | BufferedComputation |
| class | Bzip_Compression |
| class | Bzip_Decompression |
| class | Bzip_Stream |
| struct | calendar_point |
| class | Cascade_Cipher |
| class | CAST_128 |
| class | CAST_256 |
| class | CBC_Decryption |
| class | CBC_Encryption |
| class | CBC_MAC |
| class | Certificate_Extension |
| class | Certificate_Store |
| class | CFB_Decryption |
| class | CFB_Encryption |
| class | Chain |
| class | CMAC |
| class | CMS_Decoder |
| class | CMS_Encoder |
| class | CPUID |
| class | CRC24 |
| class | CRC32 |
| class | CRL_Entry |
| class | CTR_BE |
| class | CTS_Decryption |
| class | CTS_Encryption |
| class | CubeHash |
| class | CurveGFp |
| class | Data_Store |
| class | DataSink |
| class | DataSink_Stream |
| class | DataSource |
| class | DataSource_Command |
| class | DataSource_Memory |
| class | DataSource_Stream |
| struct | Decoding_Error |
| class | Default_DH_Op |
| class | Default_DSA_Op |
| class | Default_ECDSA_Op |
| class | Default_ECKAEG_Op |
| class | Default_ELG_Op |
| class | Default_Engine |
| class | Default_IF_Op |
| class | Default_NR_Op |
| class | del_fun |
| class | DER_Encoder |
| class | DES |
| class | DESX |
| class | Device_EntropySource |
| class | DH_Core |
| class | DH_Operation |
| class | DH_PrivateKey |
| class | DH_PublicKey |
| class | DL_Group |
| class | DL_Scheme_PrivateKey |
| class | DL_Scheme_PublicKey |
| class | DLIES_Decryptor |
| class | DLIES_Encryptor |
| class | DN_Check |
| class | DSA_Core |
| class | DSA_Operation |
| class | DSA_PrivateKey |
| class | DSA_PublicKey |
| class | EAC1_1_ADO |
| class | EAC1_1_CVC |
| class | EAC1_1_CVC_CA |
| class | EAC1_1_CVC_Decoder |
| class | EAC1_1_CVC_Encoder |
| class | EAC1_1_CVC_Options |
| class | EAC1_1_gen_CVC |
| class | EAC1_1_obj |
| class | EAC1_1_Req |
| class | EAC_Signed_Object |
| class | EAC_Time |
| class | EAX_Base |
| class | EAX_Decryption |
| class | EAX_Encryption |
| class | EC_Domain_Params |
| class | EC_PrivateKey |
| class | EC_PublicKey |
| class | ECB_Decryption |
| class | ECB_Encryption |
| class | ECDSA_Core |
| class | ECDSA_Operation |
| class | ECDSA_PrivateKey |
| class | ECDSA_PublicKey |
| class | ECDSA_Signature |
| class | ECDSA_Signature_Decoder |
| class | ECDSA_Signature_Encoder |
| class | ECKAEG_Core |
| class | ECKAEG_Operation |
| class | ECKAEG_PrivateKey |
| class | ECKAEG_PublicKey |
| class | EGD_EntropySource |
| class | ELG_Core |
| class | ELG_Operation |
| class | ElGamal_PrivateKey |
| class | ElGamal_PublicKey |
| class | EME |
| class | EME1 |
| class | EME_PKCS1v15 |
| class | EMSA |
| class | EMSA1 |
| class | EMSA1_BSI |
| class | EMSA2 |
| class | EMSA3 |
| class | EMSA3_Raw |
| class | EMSA4 |
| class | EMSA_Raw |
| struct | Encoding_Error |
| class | Engine |
| class | Entropy_Accumulator |
| class | Entropy_Accumulator_BufferedComputation |
| class | EntropySource |
| class | Extensions |
| class | Fanout_Filter |
| class | Filter |
| class | Fixed_Base_Power_Mod |
| class | Fixed_Exponent_Power_Mod |
| class | Fixed_Window_Exponentiator |
| class | Fork |
| class | FORK_256 |
| class | FTW_EntropySource |
| class | GFpElement |
| class | GFpModulus |
| class | GMP_Engine |
| class | GMP_MPZ |
| class | GOST_28147_89 |
| class | GOST_28147_89_Params |
| class | GOST_34_11 |
| class | HAS_160 |
| class | Hash_Filter |
| class | HashFunction |
| class | Hex_Decoder |
| class | Hex_Encoder |
| class | High_Resolution_Timestamp |
| class | HMAC |
| class | HMAC_RNG |
| class | IA32_Assembler_Engine |
| class | IandS_Match |
| class | IDEA |
| class | IDEA_SSE2 |
| class | IF_Core |
| class | IF_Operation |
| class | IF_Scheme_PrivateKey |
| class | IF_Scheme_PublicKey |
| struct | Illegal_Point |
| struct | Illegal_Transformation |
| struct | Internal_Error |
| struct | Invalid_Algorithm_Name |
| struct | Invalid_Block_Size |
| struct | Invalid_IV_Length |
| struct | Invalid_Key_Length |
| struct | Invalid_OID |
| struct | Invalid_State |
| class | KASUMI |
| class | KDF |
| class | KDF1 |
| class | KDF2 |
| class | Keyed_Filter |
| class | Library_State |
| class | LibraryInitializer |
| class | Lion |
| class | Locking_Allocator |
| struct | Lookup_Error |
| class | LubyRackoff |
| class | MAC_Filter |
| class | Malloc_Allocator |
| class | MARS |
| class | MD2 |
| class | MD4 |
| class | MD4_IA32 |
| class | MD5 |
| class | MD5_IA32 |
| class | MDx_HashFunction |
| struct | Memory_Exhaustion |
| class | MemoryMapping_Allocator |
| class | MemoryRegion |
| class | MemoryVector |
| class | MessageAuthenticationCode |
| class | MGF |
| class | MGF1 |
| class | MillerRabin_Test |
| class | MISTY1 |
| class | Modular_Exponentiator |
| class | Modular_Reducer |
| class | Montgomery_Exponentiator |
| class | Mutex |
| class | Mutex_Factory |
| class | Mutex_Holder |
| class | Noekeon |
| class | Noekeon_SIMD |
| class | Noop_Mutex_Factory |
| class | NR_Core |
| class | NR_Operation |
| class | NR_PrivateKey |
| class | NR_PublicKey |
| class | Null_Padding |
| class | Null_RNG |
| class | OctetString |
| class | OFB |
| class | OID |
| class | OneAndZeros_Padding |
| class | OpenPGP_S2K |
| class | OpenSSL_Engine |
| class | OSSL_BN |
| class | OSSL_BN_CTX |
| class | Output_Buffers |
| class | Parallel |
| class | PBE |
| class | PBE_PKCS5v15 |
| class | PBE_PKCS5v20 |
| class | Pipe |
| struct | pipe_wrapper |
| class | PK_Decrypting_Key |
| class | PK_Decryptor |
| class | PK_Decryptor_Filter |
| class | PK_Decryptor_MR_with_EME |
| class | PK_Encrypting_Key |
| class | PK_Encryptor |
| class | PK_Encryptor_Filter |
| class | PK_Encryptor_MR_with_EME |
| class | PK_Key_Agreement |
| class | PK_Key_Agreement_Key |
| class | PK_Signer |
| class | PK_Signer_Filter |
| class | PK_Signing_Key |
| class | PK_Verifier |
| class | PK_Verifier_Filter |
| class | PK_Verifier_with_MR |
| class | PK_Verifier_wo_MR |
| class | PK_Verifying_with_MR_Key |
| class | PK_Verifying_wo_MR_Key |
| class | PKCS10_Request |
| class | PKCS5_PBKDF1 |
| class | PKCS5_PBKDF2 |
| class | PKCS7_Padding |
| class | PKCS8_Decoder |
| class | PKCS8_Encoder |
| struct | PKCS8_Exception |
| class | PointGFp |
| struct | Policy_Violation |
| class | Pooling_Allocator |
| class | Power_Mod |
| class | Private_Key |
| struct | PRNG_Unseeded |
| class | Pthread_Mutex_Factory |
| class | Public_Key |
| class | Qt_Mutex_Factory |
| class | RandomNumberGenerator |
| class | Randpool |
| class | RC2 |
| class | RC5 |
| class | RC6 |
| class | RIPEMD_128 |
| class | RIPEMD_160 |
| class | RSA_PrivateKey |
| class | RSA_PublicKey |
| class | RTSS_Share |
| class | RW_PrivateKey |
| class | RW_PublicKey |
| class | S2K |
| class | SAFER_SK |
| class | Salsa20 |
| class | SCAN_Name |
| class | SecureBuffer |
| class | SecureQueue |
| class | SecureQueueNode |
| class | SecureVector |
| class | SEED |
| struct | Self_Test_Failure |
| class | Serpent |
| class | Serpent_IA32 |
| class | Serpent_SIMD |
| class | SHA_160 |
| class | SHA_160_AMD64 |
| class | SHA_160_IA32 |
| class | SHA_160_SSE2 |
| class | SHA_224 |
| class | SHA_224_256_BASE |
| class | SHA_256 |
| class | SHA_384 |
| class | SHA_384_512_BASE |
| class | SHA_512 |
| class | SharedPtrConverter |
| class | SIMD_Engine |
| class | SIMD_Scalar |
| class | Skein_512 |
| class | SKID_Match |
| class | Skipjack |
| class | Square |
| class | SSL3_MAC |
| class | SSL3_PRF |
| struct | Stream_IO_Error |
| class | StreamCipher |
| class | StreamCipher_Filter |
| class | SymmetricAlgorithm |
| class | TEA |
| class | Tiger |
| class | TLS_PRF |
| class | TripleDES |
| class | Turing |
| class | Twofish |
| class | Unix_EntropySource |
| struct | Unix_Program |
| class | User_Interface |
| class | Whirlpool |
| class | WiderWake_41_BE |
| class | Win32_CAPI_EntropySource |
| class | Win32_EntropySource |
| class | Win32_Mutex_Factory |
| class | X509_CA |
| class | X509_Cert_Options |
| class | X509_Certificate |
| class | X509_CRL |
| class | X509_Decoder |
| class | X509_DN |
| class | X509_Encoder |
| class | X509_Object |
| class | X509_Store |
| class | X509_Time |
| class | X942_PRF |
| class | XTEA |
| class | XTEA_SIMD |
| class | XTS_Decryption |
| class | XTS_Encryption |
| class | Zlib_Compression |
| class | Zlib_Decompression |
| class | Zlib_Stream |
Typedefs | |
| typedef unsigned char | byte |
| typedef std::runtime_error | Exception |
| typedef OctetString | InitializationVector |
| typedef std::invalid_argument | Invalid_Argument |
| typedef PK_Key_Agreement_Key | PK_KA_Key |
| typedef Private_Key | PKCS8_PrivateKey |
| typedef signed int | s32bit |
| typedef SIMD_Scalar | SIMD_32 |
| typedef OctetString | SymmetricKey |
| typedef unsigned short | u16bit |
| typedef unsigned int | u32bit |
| typedef unsigned long long | u64bit |
| typedef Public_Key | X509_PublicKey |
Enumerations | |
| 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 } |
| enum | Character_Set { LOCAL_CHARSET, UCS2_CHARSET, UTF8_CHARSET, LATIN1_CHARSET } |
| enum | Cipher_Dir { ENCRYPTION, DECRYPTION } |
| 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 } |
| enum | Decoder_Checking { NONE, IGNORE_WS, FULL_CHECK } |
| enum | EC_dompar_enc { ENC_EXPLICIT = 0, ENC_IMPLICITCA = 1, ENC_OID = 2 } |
| 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 } |
| enum | Signature_Format { IEEE_1363, DER_SEQUENCE } |
| 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 } |
| enum | X509_Encoding { RAW_BER, PEM } |
Functions | |
| BigInt | abs (const BigInt &n) |
| std::map< std::string, double > | algorithm_benchmark (const std::string &name, u32bit milliseconds, RandomNumberGenerator &rng, Algorithm_Factory &af) |
| std::map< std::string, bool > | algorithm_kat (const SCAN_Name &algo_name, const std::map< std::string, std::string > &vars, Algorithm_Factory &af) |
| void | bigint_2word_mul (word a, word b, word *z1, word *z0) |
| void | bigint_add2 (word x[], u32bit x_size, const word y[], u32bit y_size) |
| word | bigint_add2_nc (word x[], u32bit x_size, const word y[], u32bit y_size) |
| void | bigint_add3 (word z[], const word x[], u32bit x_size, const word y[], u32bit y_size) |
| word | bigint_add3_nc (word z[], const word x[], u32bit x_size, const word y[], u32bit y_size) |
| s32bit | bigint_cmp (const word[], u32bit, const word[], u32bit) |
| void | bigint_comba_mul16 (word z[32], const word x[16], const word y[16]) |
| void | bigint_comba_mul4 (word z[8], const word x[4], const word y[4]) |
| void | bigint_comba_mul6 (word z[12], const word x[6], const word y[6]) |
| void | bigint_comba_mul8 (word z[16], const word x[8], const word y[8]) |
| void | bigint_comba_sqr16 (word[64], const word[32]) |
| void | bigint_comba_sqr16 (word z[32], const word x[16]) |
| void | bigint_comba_sqr4 (word z[8], const word x[4]) |
| void | bigint_comba_sqr6 (word z[12], const word x[6]) |
| void | bigint_comba_sqr8 (word[32], const word[16]) |
| void | bigint_comba_sqr8 (word z[16], const word x[8]) |
| u32bit | bigint_divcore (word, word, word, word, word, word) |
| word | bigint_divop (word, word, word) |
| void | bigint_linmul2 (word x[], u32bit x_size, word y) |
| void | bigint_linmul3 (word z[], const word x[], u32bit x_size, word y) |
| void | bigint_linmul_add (word[], u32bit, const word[], u32bit, word) |
| word | bigint_modop (word, word, word) |
| void | bigint_monty_redc (word z[], u32bit z_size, const word x[], u32bit x_size, word u) |
| void | bigint_mul (word[], u32bit, word[], const word[], u32bit, u32bit, const word[], u32bit, u32bit) |
| 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) |
| 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) |
| void | bigint_sqr (word[], u32bit, word[], const word[], u32bit, u32bit) |
| void | bigint_sub2 (word x[], u32bit x_size, const word y[], u32bit y_size) |
| void | bigint_sub3 (word z[], const word x[], u32bit x_size, const word y[], u32bit y_size) |
| void | bigint_wordmul (word, word, word *, word *) |
| u32bit | block_size_of (const std::string &name) |
| void | botan_md4_ia32_compress (u32bit[4], const byte[64], u32bit[16]) |
| void | botan_serpent_ia32_decrypt (const byte[16], byte[16], const u32bit[132]) |
| void | botan_serpent_ia32_encrypt (const byte[16], byte[16], const u32bit[132]) |
| void | botan_serpent_ia32_key_schedule (u32bit[140]) |
| template<typename T > | |
| void | bswap_4 (T x[4]) |
| calendar_point | calendar_value (u64bit a_time_t) |
| bool | check_prime (const BigInt &n, RandomNumberGenerator &rng) |
| PK_Signer * | choose_sig_format (const Private_Key &key, const std::string &hash_fn, AlgorithmIdentifier &sig_algo) |
| template<typename T > | |
| void | clear_mem (T *ptr, u32bit n) |
| void | confirm_startup_self_tests (Algorithm_Factory &af) |
| template<typename InputIterator , typename OutputIterator , typename Predicate > | |
| OutputIterator | copy_if (InputIterator current, InputIterator end, OutputIterator dest, Predicate copy_p) |
| template<typename T > | |
| void | copy_mem (T *out, const T *in, u32bit n) |
| AlternativeName | create_alt_name (const Data_Store &info) |
| X509_DN | create_dn (const Data_Store &info) |
| PointGFp | create_random_point (RandomNumberGenerator &rng, const CurveGFp &curve) |
| template<typename T > | |
| u32bit | ctz (T n) |
| EC_Domain_Params | decode_ber_ec_dompar (SecureVector< byte > const &encoded) |
| ECDSA_Signature const | decode_concatenation (MemoryRegion< byte > const &concat) |
| ECDSA_Signature const | decode_seq (MemoryRegion< byte > const &seq) |
| template<typename Pair > | |
| void | delete2nd (Pair &pair) |
| void | divide (const BigInt &x, const BigInt &y_arg, BigInt &q, BigInt &r) |
| u32bit | dl_work_factor (u32bit bits) |
| SecureVector< byte > | EC2OSP (const PointGFp &point, byte format) |
| SecureVector< byte > | encode_compressed (const PointGFp &point) |
| SecureVector< byte > | encode_der_ec_dompar (EC_Domain_Params const &dom_pars, EC_dompar_enc enc_type) |
| SecureVector< byte > | encode_hybrid (const PointGFp &point) |
| SecureVector< byte > | encode_uncompressed (const PointGFp &point) |
| SecureVector< byte > | FE2OSP (const GFpElement &elem) |
| BigInt | fpe_decrypt (const BigInt &n, const BigInt &X0, const SymmetricKey &key, const MemoryRegion< byte > &tweak) |
| BigInt | fpe_encrypt (const BigInt &n, const BigInt &X0, const SymmetricKey &key, const MemoryRegion< byte > &tweak) |
| BigInt | gcd (const BigInt &a, const BigInt &b) |
| SecureVector< byte > | generate_dsa_primes (RandomNumberGenerator &rng, Algorithm_Factory &af, BigInt &p, BigInt &q, u32bit pbits, u32bit qbits) |
| bool | generate_dsa_primes (RandomNumberGenerator &rng, Algorithm_Factory &af, BigInt &p, BigInt &q, u32bit pbits, u32bit qbits, const MemoryRegion< byte > &seed_c) |
| BlockCipher * | get_block_cipher (const std::string &algo_spec) |
| template<typename T > | |
| byte | get_byte (u32bit byte_num, T input) |
| Keyed_Filter * | get_cipher (const std::string &algo_spec, const SymmetricKey &key, Cipher_Dir direction) |
| Keyed_Filter * | get_cipher (const std::string &algo_spec, const SymmetricKey &key, const InitializationVector &iv, Cipher_Dir direction) |
| Keyed_Filter * | get_cipher (const std::string &algo_spec, Cipher_Dir direction) |
| Keyed_Filter * | get_cipher_mode (const BlockCipher *block_cipher, Cipher_Dir direction, const std::string &mode, const std::string &padding) |
| EC_Domain_Params | get_EC_Dom_Pars_by_oid (std::string oid) |
| EME * | get_eme (const std::string &algo_spec) |
| EMSA * | get_emsa (const std::string &algo_spec) |
| HashFunction * | get_hash (const std::string &algo_spec) |
| KDF * | get_kdf (const std::string &algo_spec) |
| MessageAuthenticationCode * | get_mac (const std::string &algo_spec) |
| u64bit | get_nanoseconds_clock () |
| PBE * | get_pbe (const OID &pbe_oid, DataSource ¶ms) |
| PBE * | get_pbe (const std::string &algo_spec) |
| PK_Decryptor * | get_pk_decryptor (const PK_Decrypting_Key &key, const std::string &eme) |
| PK_Encryptor * | get_pk_encryptor (const PK_Encrypting_Key &key, const std::string &eme) |
| PK_Key_Agreement * | get_pk_kas (const PK_Key_Agreement_Key &key, const std::string &kdf) |
| PK_Signer * | get_pk_signer (const PK_Signing_Key &key, const std::string &emsa, Signature_Format sig_format) |
| PK_Verifier * | get_pk_verifier (const PK_Verifying_wo_MR_Key &key, const std::string &emsa, Signature_Format sig_format) |
| PK_Verifier * | get_pk_verifier (const PK_Verifying_with_MR_Key &key, const std::string &emsa, Signature_Format sig_format) |
| Private_Key * | get_private_key (const std::string &alg_name) |
| Public_Key * | get_public_key (const std::string &alg_name) |
| S2K * | get_s2k (const std::string &algo_spec) |
| StreamCipher * | get_stream_cipher (const std::string &algo_spec) |
| Library_State & | global_state () |
| template<typename T > | |
| u32bit | hamming_weight (T n) |
| bool | have_algorithm (const std::string &name) |
| bool | have_block_cipher (const std::string &algo_spec) |
| bool | have_hash (const std::string &algo_spec) |
| bool | have_mac (const std::string &algo_spec) |
| bool | have_stream_cipher (const std::string &algo_spec) |
| template<typename T > | |
| u32bit | high_bit (T n) |
| byte | ieee1363_hash_id (const std::string &name) |
| GFpElement | inverse (const GFpElement &elem) |
| BigInt | inverse_mod (const BigInt &n, const BigInt &mod) |
| std::string | ipv4_to_string (u32bit ip) |
| bool | is_prime (const BigInt &n, RandomNumberGenerator &rng) |
| bool BOTAN_DLL | is_string_type (ASN1_Tag) |
| s32bit | jacobi (const BigInt &a, const BigInt &n) |
| u32bit | keylength_multiple_of (const std::string &name) |
| BigInt | lcm (const BigInt &a, const BigInt &b) |
| template<typename T > | |
| void | load_be (T out[], const byte in[], u32bit count) |
| template<typename T > | |
| void | load_be (const byte in[], T &x0, T &x1, T &x2, T &x3, T &x4, T &x5, T &x6, T &x7) |
| template<typename T > | |
| void | load_be (const byte in[], T &x0, T &x1, T &x2, T &x3) |
| template<typename T > | |
| void | load_be (const byte in[], T &x0, T &x1) |
| template<typename T > | |
| T | load_be (const byte in[], u32bit off) |
| template<> | |
| u16bit | load_be< u16bit > (const byte in[], u32bit off) |
| template<> | |
| u32bit | load_be< u32bit > (const byte in[], u32bit off) |
| template<> | |
| u64bit | load_be< u64bit > (const byte in[], u32bit off) |
| template<typename T > | |
| void | load_le (T out[], const byte in[], u32bit count) |
| template<typename T > | |
| void | load_le (const byte in[], T &x0, T &x1, T &x2, T &x3, T &x4, T &x5, T &x6, T &x7) |
| template<typename T > | |
| void | load_le (const byte in[], T &x0, T &x1, T &x2, T &x3) |
| template<typename T > | |
| void | load_le (const byte in[], T &x0, T &x1) |
| template<typename T > | |
| T | load_le (const byte in[], u32bit off) |
| template<> | |
| u16bit | load_le< u16bit > (const byte in[], u32bit off) |
| template<> | |
| u32bit | load_le< u32bit > (const byte in[], u32bit off) |
| template<> | |
| u64bit | load_le< u64bit > (const byte in[], u32bit off) |
| bool | lock_mem (void *ptr, u32bit bytes) |
| template<typename T > | |
| u32bit | low_bit (T n) |
| u32bit | low_zero_bits (const BigInt &n) |
| u16bit | make_u16bit (byte i0, byte i1) |
| u32bit | make_u32bit (byte i0, byte i1, byte i2, byte i3) |
| u64bit | make_u64bit (byte i0, byte i1, byte i2, byte i3, byte i4, byte i5, byte i6, byte i7) |
| u32bit | max_keylength_of (const std::string &name) |
| u32bit | min_keylength_of (const std::string &name) |
| BigInt | mul_add (const BigInt &a, const BigInt &b, const BigInt &c) |
| PointGFp | mult2 (const PointGFp &point) |
| PointGFp | mult_point_secure (const PointGFp &point, const BigInt &scalar, const BigInt &point_order, const BigInt &max_secret) |
| template<typename K , typename V > | |
| void | multimap_insert (std::multimap< K, V > &multimap, const K &key, const V &value) |
| bool | operator!= (const OctetString &s1, const OctetString &s2) |
| bool | operator!= (const EC_Domain_Params &lhs, const EC_Domain_Params &rhs) |
| bool | operator!= (const PointGFp &lhs, const PointGFp &rhs) |
| bool | operator!= (const GFpElement &lhs, const GFpElement &rhs) |
| bool | operator!= (const CurveGFp &lhs, const CurveGFp &rhs) |
| bool | operator!= (const BigInt &a, const BigInt &b) |
| bool | operator!= (const X509_Certificate &cert1, const X509_Certificate &cert2) |
| bool | operator!= (const CRL_Entry &a1, const CRL_Entry &a2) |
| bool | operator!= (const ECDSA_Signature &lhs, const ECDSA_Signature &rhs) |
| bool | operator!= (const ASN1_EAC_String &lhs, const ASN1_EAC_String &rhs) |
| bool | operator!= (EAC1_1_Req const &lhs, EAC1_1_Req const &rhs) |
| bool | operator!= (EAC1_1_CVC const &lhs, EAC1_1_CVC const &rhs) |
| bool | operator!= (EAC1_1_ADO const &lhs, EAC1_1_ADO const &rhs) |
| bool | operator!= (const EAC_Time &t1, const EAC_Time &t2) |
| bool | operator!= (const OID &a, const OID &b) |
| bool BOTAN_DLL | operator!= (const X509_Time &, const X509_Time &) |
| bool | operator!= (const X509_DN &dn1, const X509_DN &dn2) |
| bool | operator!= (const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2) |
| word | operator% (const BigInt &n, word mod) |
| BigInt | operator% (const BigInt &n, const BigInt &mod) |
| PointGFp | operator* (const PointGFp &point, const BigInt &scalar) |
| PointGFp | operator* (const BigInt &scalar, const PointGFp &point) |
| GFpElement | operator* (u32bit lhs, const GFpElement &rhs) |
| GFpElement | operator* (const GFpElement &lhs, u32bit rhs) |
| GFpElement | operator* (const GFpElement &lhs, const GFpElement &rhs) |
| BigInt | operator* (const BigInt &x, const BigInt &y) |
| OctetString | operator+ (const OctetString &k1, const OctetString &k2) |
| PointGFp | operator+ (const PointGFp &lhs, PointGFp const &rhs) |
| GFpElement | operator+ (const GFpElement &lhs, const GFpElement &rhs) |
| BigInt | operator+ (const BigInt &x, const BigInt &y) |
| OID | operator+ (const OID &oid, u32bit component) |
| PointGFp | operator- (const PointGFp &lhs) |
| PointGFp | operator- (const PointGFp &lhs, PointGFp const &rhs) |
| GFpElement | operator- (const GFpElement &lhs) |
| GFpElement | operator- (const GFpElement &lhs, const GFpElement &rhs) |
| BigInt | operator- (const BigInt &x, const BigInt &y) |
| GFpElement | operator/ (const GFpElement &lhs, const GFpElement &rhs) |
| BigInt | operator/ (const BigInt &x, const BigInt &y) |
| bool | operator< (const BigInt &a, const BigInt &b) |
| bool | operator< (const CRL_Entry &a1, const CRL_Entry &a2) |
| bool | operator< (const EAC_Time &t1, const EAC_Time &t2) |
| bool | operator< (const OID &a, const OID &b) |
| bool | operator< (const X509_DN &dn1, const X509_DN &dn2) |
| std::ostream & | operator<< (std::ostream &output, const GFpElement &elem) |
| std::ostream & | operator<< (std::ostream &output, const CurveGFp &elem) |
| BigInt | operator<< (const BigInt &x, u32bit shift) |
| std::ostream & | operator<< (std::ostream &stream, const BigInt &n) |
| BOTAN_DLL std::ostream & | operator<< (std::ostream &, Pipe &) |
| int | operator<< (int fd, Pipe &pipe) |
| bool | operator<= (const BigInt &a, const BigInt &b) |
| bool | operator<= (const EAC_Time &t1, const EAC_Time &t2) |
| bool BOTAN_DLL | operator<= (const X509_Time &, const X509_Time &) |
| bool | operator== (const OctetString &s1, const OctetString &s2) |
| bool | operator== (EC_Domain_Params const &lhs, EC_Domain_Params const &rhs) |
| bool | operator== (const PointGFp &lhs, PointGFp const &rhs) |
| bool | operator== (const GFpElement &lhs, const GFpElement &rhs) |
| bool | operator== (const CurveGFp &lhs, const CurveGFp &rhs) |
| bool | operator== (const BigInt &a, const BigInt &b) |
| bool | operator== (const CRL_Entry &a1, const CRL_Entry &a2) |
| bool | operator== (const ECDSA_Signature &lhs, const ECDSA_Signature &rhs) |
| bool | operator== (const EAC_Time &t1, const EAC_Time &t2) |
| bool | operator== (const ASN1_EAC_String &lhs, const ASN1_EAC_String &rhs) |
| bool BOTAN_DLL | operator== (const X509_Time &, const X509_Time &) |
| bool | operator== (const X509_DN &dn1, const X509_DN &dn2) |
| bool | operator== (const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2) |
| bool | operator> (const BigInt &a, const BigInt &b) |
| bool | operator> (const EAC_Time &t1, const EAC_Time &t2) |
| bool | operator>= (const BigInt &a, const BigInt &b) |
| bool | operator>= (const EAC_Time &t1, const EAC_Time &t2) |
| bool BOTAN_DLL | operator>= (const X509_Time &, const X509_Time &) |
| BigInt | operator>> (const BigInt &x, u32bit shift) |
| std::istream & | operator>> (std::istream &stream, BigInt &n) |
| BOTAN_DLL std::istream & | operator>> (std::istream &, Pipe &) |
| int | operator>> (int fd, Pipe &pipe) |
| OctetString | operator^ (const OctetString &k1, const OctetString &k2) |
| PointGFp | OS2ECP (MemoryRegion< byte > const &os, const CurveGFp &curve) |
| GFpElement | OS2FEP (MemoryRegion< byte > const &os, BigInt p) |
| u32bit | output_length_of (const std::string &name) |
| std::vector< std::string > | parse_algorithm_name (const std::string &namex) |
| std::vector< u32bit > | parse_asn1_oid (const std::string &oid) |
| bool | passes_mr_tests (RandomNumberGenerator &rng, const BigInt &n, u32bit level) |
| bool | passes_self_tests (Algorithm_Factory &af) |
| MemoryVector< byte > | pkcs_hash_id (const std::string &name) |
| BigInt | power_mod (const BigInt &base, const BigInt &exp, const BigInt &mod) |
| template<typename T > | |
| bool | power_of_2 (T arg) |
| BigInt | random_prime (RandomNumberGenerator &rng, u32bit bits, const BigInt &coprime, u32bit equiv, u32bit modulo) |
| BigInt | random_safe_prime (RandomNumberGenerator &rng, u32bit bits) |
| BigInt BOTAN_DLL | ressol (const BigInt &x, const BigInt &p) |
| const BlockCipher * | retrieve_block_cipher (const std::string &algo_spec) |
| const HashFunction * | retrieve_hash (const std::string &algo_spec) |
| const MessageAuthenticationCode * | retrieve_mac (const std::string &algo_spec) |
| const StreamCipher * | retrieve_stream_cipher (const std::string &algo_spec) |
| u64bit | reverse_bytes (u64bit input) |
| u32bit | reverse_bytes (u32bit input) |
| u16bit | reverse_bytes (u16bit input) |
| SIMD_32 | rotate_left (SIMD_32 x, u32bit rot) |
| template<typename T > | |
| T | rotate_left (T input, u32bit rot) |
| SIMD_32 | rotate_right (SIMD_32 x, u32bit rot) |
| template<typename T > | |
| T | rotate_right (T input, u32bit rot) |
| u32bit | round_down (u32bit n, u32bit align_to) |
| u32bit | round_up (u32bit n, u32bit align_to) |
| bool | run_primality_tests (RandomNumberGenerator &rng, const BigInt &n, u32bit level) |
| template<typename T > | |
| bool | same_mem (const T *p1, const T *p2, u32bit n) |
| template<typename K , typename V , typename R > | |
| R | search_map (const std::map< K, V > &mapping, const K &key, const R &null_result, const R &found_result) |
| template<typename K , typename V > | |
| V | search_map (const std::map< K, V > &mapping, const K &key, const V &null_result=V()) |
| void | set_global_state (Library_State *new_state) |
| template<typename T > | |
| void | set_mem (T *ptr, u32bit n, byte val) |
| template<typename T > | |
| u32bit | significant_bytes (T n) |
| s32bit | simple_primality_tests (const BigInt &n) |
| std::vector< std::string > | split_on (const std::string &str, char delim) |
| BigInt | square (const BigInt &x) |
| u32bit | static_provider_weight (const std::string &prov_name) |
| template<typename T > | |
| void | store_be (byte out[], T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7) |
| template<typename T > | |
| void | store_be (byte out[], T x0, T x1, T x2, T x3) |
| template<typename T > | |
| void | store_be (byte out[], T x0, T x1) |
| void | store_be (u64bit in, byte out[8]) |
| void | store_be (u32bit in, byte out[4]) |
| void | store_be (u16bit in, byte out[2]) |
| template<typename T > | |
| void | store_le (byte out[], T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7) |
| template<typename T > | |
| void | store_le (byte out[], T x0, T x1, T x2, T x3) |
| template<typename T > | |
| void | store_le (byte out[], T x0, T x1) |
| void | store_le (u64bit in, byte out[8]) |
| void | store_le (u32bit in, byte out[4]) |
| void | store_le (u16bit in, byte out[2]) |
| u32bit | string_to_ipv4 (const std::string &str) |
| BigInt | sub_mul (const BigInt &a, const BigInt &b, const BigInt &c) |
| void | swap (PointGFp &point1, PointGFp &point2) |
| void | swap (GFpElement &x, GFpElement &y) |
| void | swap (CurveGFp &curve1, CurveGFp &curve2) |
| Library_State * | swap_global_state (Library_State *new_state) |
| u64bit | system_time () |
| u32bit | timespec_to_u32bit (const std::string ×pec) |
| std::string | to_string (u64bit n, u32bit min_len) |
| u32bit | to_u32bit (const std::string &number) |
| void | unlock_mem (void *ptr, u32bit bytes) |
| bool | valid_keylength_for (u32bit key_len, const std::string &name) |
| bool | verify_prime (const BigInt &n, RandomNumberGenerator &rng) |
| u32bit | version_major () |
| u32bit | version_minor () |
| u32bit | version_patch () |
| std::string | version_string () |
| void | word3_muladd (word *w2, word *w1, word *w0, word x, word y) |
| void | word3_muladd_2 (word *w2, word *w1, word *w0, word x, word y) |
| word | word8_add2 (word x[8], const word y[8], word carry) |
| word | word8_add3 (word z[8], const word x[8], const word y[8], word carry) |
| word | word8_linmul2 (word x[4], word y, word carry) |
| word | word8_linmul2 (word x[8], word y, word carry) |
| word | word8_linmul3 (word z[4], const word x[4], word y, word carry) |
| word | word8_linmul3 (word z[8], const word x[8], word y, word carry) |
| word | word8_madd3 (word z[8], const word x[8], word y, word carry) |
| word | word8_muladd (word z[8], const word x[8], word y, word carry) |
| word | word8_sub2 (word x[4], const word y[4], word carry) |
| word | word8_sub2 (word x[8], const word y[8], word carry) |
| word | word8_sub3 (word z[8], const word x[8], const word y[8], word carry) |
| word | word_add (word x, word y, word *carry) |
| word | word_madd2 (word a, word b, word *c) |
| word | word_madd3 (word a, word b, word c, word *d) |
| word | word_sub (word x, word y, word *carry) |
| bool | x500_name_cmp (const std::string &name1, const std::string &name2) |
| void | xor_buf (byte out[], const byte in[], const byte in2[], u32bit length) |
| void | xor_buf (byte out[], const byte in[], u32bit length) |
Variables | |
| const u32bit | CAST_SBOX1 [256] |
| const u32bit | CAST_SBOX2 [256] |
| const u32bit | CAST_SBOX3 [256] |
| const u32bit | CAST_SBOX4 [256] |
| const u64bit | DES_FPTAB1 [256] |
| const u64bit | DES_FPTAB2 [256] |
| const u64bit | DES_IPTAB1 [256] |
| const u64bit | DES_IPTAB2 [256] |
| const u32bit | DES_SPBOX1 [256] |
| const u32bit | DES_SPBOX2 [256] |
| const u32bit | DES_SPBOX3 [256] |
| const u32bit | DES_SPBOX4 [256] |
| const u32bit | DES_SPBOX5 [256] |
| const u32bit | DES_SPBOX6 [256] |
| const u32bit | DES_SPBOX7 [256] |
| const u32bit | DES_SPBOX8 [256] |
| const u32bit | HEX_CODEC_BUFFER_SIZE = 256 |
| const u32bit | MP_WORD_BITS = BOTAN_MP_WORD_BITS |
| const word | MP_WORD_MASK = ~static_cast<word>(0) |
| const word | MP_WORD_MAX = MP_WORD_MASK |
| const word | MP_WORD_TOP_BIT = static_cast<word>(1) << (8*sizeof(word) - 1) |
| const u64bit | PRIME_PRODUCTS [] |
| const u32bit | PRIME_PRODUCTS_TABLE_SIZE = 256 |
| const u32bit | PRIME_TABLE_SIZE = 6541 |
| const u16bit BOTAN_DLL | PRIMES [] |
Distributed under the terms of the Botan license
Default provider weights for Algorithm_Cache (C) 2008 Jack Lloyd
Distributed under the terms of the Botan license
Runtime benchmarking (C) 2008 Jack Lloyd
Distributed under the terms of the Botan license
AES (C) 1999-2009 Jack Lloyd
Distributed under the terms of the Botan license
AES using Intel's AES-NI instructions (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Block Cipher Base Class (C) 1999-2009 Jack Lloyd
Distributed under the terms of the Botan license
MISTY1 (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
Engine for AES instructions (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
AMD64 Assembly Implementation Engine (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
x86-64 Assembly Implementation Engines (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
IA-32 Assembly Implementation Engines (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
SIMD Engine (C) 1999-2009 Jack Lloyd
Distributed under the terms of the Botan license
SIMD Assembly Engine (C) 1999-2009 Jack Lloyd
Distributed under the terms of the Botan license
BeOS EntropySource (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
EGD EntropySource (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
EntropySource (C) 2008-2009 Jack Lloyd
Distributed under the terms of the Botan license
Unix Command Execution (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
Win32 EntropySource (C) 1999-2009 Jack Lloyd
Distributed under the terms of the Botan license
CBC Padding Methods (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
CubeHash (C) 2010 Jack Lloyd
Distributed under the terms of the Botan license
GOST 34.11 (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Hash Function Base Class (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
MD5 (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
Merkle-Damgard Hash Function (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
MDx Hash Function (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
The Skein-512 hash function (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Default Initialization Function (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
Library Initialization (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
Engine for PK (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
SCAN Name Abstraction (C) 2008-2009 Jack Lloyd
Distributed under the terms of the Botan license
SCAN Name Abstraction (C) 2008 Jack Lloyd
Distributed under the terms of the Botan license
Message Authentication Code base class (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
Base class for message authentiction codes (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
PKCS #5 PBES2 (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
Stream Cipher (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
Symmetric Algorithm Base Class (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
BufferedComputation (C) 1999-2007 Jack Lloyd
Distributed under the terms of the Botan license
Runtime CPU detection (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Internal-use debugging functions for Botan (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Lightweight wrappers for SIMD operations (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Scalar emulation of SIMD 32-bit operations (C) 2009 Jack Lloyd
Distributed under the terms of the Botan license
Time Functions (C) 1999-2009 Jack Lloyd
Distributed under the terms of the Botan license
XOR operations (C) 1999-2008 Jack Lloyd
Distributed under the terms of the Botan license
| typedef unsigned char Botan::byte |
| typedef std::runtime_error Botan::Exception |
| typedef std::invalid_argument Botan::Invalid_Argument |
| typedef PK_Key_Agreement_Key Botan::PK_KA_Key |
| typedef Private_Key Botan::PKCS8_PrivateKey |
| typedef signed int Botan::s32bit |
| typedef SIMD_Scalar Botan::SIMD_32 |
| typedef OctetString Botan::SymmetricKey |
| typedef unsigned short Botan::u16bit |
| typedef unsigned int Botan::u32bit |
| typedef unsigned long long Botan::u64bit |
| typedef Public_Key Botan::X509_PublicKey |
| enum Botan::ASN1_Tag |
Definition at line 19 of file asn1_int.h.
00019 { 00020 UNIVERSAL = 0x00, 00021 APPLICATION = 0x40, 00022 CONTEXT_SPECIFIC = 0x80, 00023 PRIVATE = 0xC0, 00024 00025 CONSTRUCTED = 0x20, 00026 00027 EOC = 0x00, 00028 BOOLEAN = 0x01, 00029 INTEGER = 0x02, 00030 BIT_STRING = 0x03, 00031 OCTET_STRING = 0x04, 00032 NULL_TAG = 0x05, 00033 OBJECT_ID = 0x06, 00034 ENUMERATED = 0x0A, 00035 SEQUENCE = 0x10, 00036 SET = 0x11, 00037 00038 UTF8_STRING = 0x0C, 00039 NUMERIC_STRING = 0x12, 00040 PRINTABLE_STRING = 0x13, 00041 T61_STRING = 0x14, 00042 IA5_STRING = 0x16, 00043 VISIBLE_STRING = 0x1A, 00044 BMP_STRING = 0x1E, 00045 00046 UTC_TIME = 0x17, 00047 GENERALIZED_TIME = 0x18, 00048 00049 NO_OBJECT = 0xFF00, 00050 DIRECTORY_STRING = 0xFF01 00051 };
| enum Botan::Character_Set |
The different charsets (nominally) supported by Botan.
Definition at line 19 of file charset.h.
00019 { 00020 LOCAL_CHARSET, 00021 UCS2_CHARSET, 00022 UTF8_CHARSET, 00023 LATIN1_CHARSET 00024 };
| enum Botan::Cipher_Dir |
The two possible directions for cipher filters, determining whether they actually perform encryption or decryption.
Definition at line 97 of file sym_algo.h.
00097 { ENCRYPTION, DECRYPTION };
| enum Botan::CRL_Code |
X.509v2 CRL Reason Code.
Definition at line 43 of file pubkey_enums.h.
00043 { 00044 UNSPECIFIED = 0, 00045 KEY_COMPROMISE = 1, 00046 CA_COMPROMISE = 2, 00047 AFFILIATION_CHANGED = 3, 00048 SUPERSEDED = 4, 00049 CESSATION_OF_OPERATION = 5, 00050 CERTIFICATE_HOLD = 6, 00051 REMOVE_FROM_CRL = 8, 00052 PRIVLEDGE_WITHDRAWN = 9, 00053 AA_COMPROMISE = 10, 00054 00055 DELETE_CRL_ENTRY = 0xFF00, 00056 OCSP_GOOD = 0xFF01, 00057 OCSP_UNKNOWN = 0xFF02 00058 };
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.
Definition at line 109 of file filter.h.
00109 { NONE, IGNORE_WS, FULL_CHECK };
| enum Botan::EC_dompar_enc |
Definition at line 104 of file ec_dompar.h.
00104 { ENC_EXPLICIT = 0, ENC_IMPLICITCA = 1, ENC_OID = 2 };
X.509v3 Key Constraints.
| NO_CONSTRAINTS | |
| DIGITAL_SIGNATURE | |
| NON_REPUDIATION | |
| KEY_ENCIPHERMENT | |
| DATA_ENCIPHERMENT | |
| KEY_AGREEMENT | |
| KEY_CERT_SIGN | |
| CRL_SIGN | |
| ENCIPHER_ONLY | |
| DECIPHER_ONLY |
Definition at line 18 of file pubkey_enums.h.
00018 { 00019 NO_CONSTRAINTS = 0, 00020 DIGITAL_SIGNATURE = 32768, 00021 NON_REPUDIATION = 16384, 00022 KEY_ENCIPHERMENT = 8192, 00023 DATA_ENCIPHERMENT = 4096, 00024 KEY_AGREEMENT = 2048, 00025 KEY_CERT_SIGN = 1024, 00026 CRL_SIGN = 512, 00027 ENCIPHER_ONLY = 256, 00028 DECIPHER_ONLY = 128 00029 };
The two types of signature format supported by Botan.
Definition at line 23 of file pubkey.h.
00023 { IEEE_1363, DER_SEQUENCE };
| enum Botan::X509_Code |
Definition at line 20 of file x509stor.h.
00020 { 00021 VERIFIED, 00022 UNKNOWN_X509_ERROR, 00023 CANNOT_ESTABLISH_TRUST, 00024 CERT_CHAIN_TOO_LONG, 00025 SIGNATURE_ERROR, 00026 POLICY_ERROR, 00027 INVALID_USAGE, 00028 00029 CERT_FORMAT_ERROR, 00030 CERT_ISSUER_NOT_FOUND, 00031 CERT_NOT_YET_VALID, 00032 CERT_HAS_EXPIRED, 00033 CERT_IS_REVOKED, 00034 00035 CRL_FORMAT_ERROR, 00036 CRL_ISSUER_NOT_FOUND, 00037 CRL_NOT_YET_VALID, 00038 CRL_HAS_EXPIRED, 00039 00040 CA_CERT_CANNOT_SIGN, 00041 CA_CERT_NOT_FOR_CERT_ISSUER, 00042 CA_CERT_NOT_FOR_CRL_ISSUER 00043 };
| enum Botan::X509_Encoding |
| BigInt Botan::abs | ( | const BigInt & | n | ) | [inline] |
| std::map< std::string, double > BOTAN_DLL Botan::algorithm_benchmark | ( | const std::string & | name, | |
| u32bit | milliseconds, | |||
| RandomNumberGenerator & | rng, | |||
| Algorithm_Factory & | af | |||
| ) |
Algorithm benchmark
| name | the name of the algorithm to test (cipher, hash, or MAC) | |
| milliseconds | total time for the benchmark to run | |
| rng | the rng to use to generate random inputs | |
| af | the algorithm factory used to create objects |
Definition at line 122 of file benchmark.cpp.
References mac, Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_hash_function(), Botan::Algorithm_Factory::prototype_mac(), Botan::Algorithm_Factory::prototype_stream_cipher(), Botan::Algorithm_Factory::providers_of(), and Botan::RandomNumberGenerator::randomize().
00126 { 00127 std::vector<std::string> providers = af.providers_of(name); 00128 std::map<std::string, double> all_results; 00129 00130 if(providers.empty()) // no providers, nothing to do 00131 return all_results; 00132 00133 const u64bit ns_per_provider = 00134 ((u64bit)milliseconds * 1000 * 1000) / providers.size(); 00135 00136 std::vector<byte> buf(16 * 1024); 00137 rng.randomize(&buf[0], buf.size()); 00138 00139 for(u32bit i = 0; i != providers.size(); ++i) 00140 { 00141 const std::string provider = providers[i]; 00142 00143 std::pair<u64bit, u64bit> results(0, 0); 00144 00145 if(const BlockCipher* proto = 00146 af.prototype_block_cipher(name, provider)) 00147 { 00148 std::auto_ptr<BlockCipher> block_cipher(proto->clone()); 00149 results = bench_block_cipher(block_cipher.get(), 00150 ns_per_provider, 00151 &buf[0], buf.size()); 00152 } 00153 else if(const StreamCipher* proto = 00154 af.prototype_stream_cipher(name, provider)) 00155 { 00156 std::auto_ptr<StreamCipher> stream_cipher(proto->clone()); 00157 results = bench_stream_cipher(stream_cipher.get(), 00158 ns_per_provider, 00159 &buf[0], buf.size()); 00160 } 00161 else if(const HashFunction* proto = 00162 af.prototype_hash_function(name, provider)) 00163 { 00164 std::auto_ptr<HashFunction> hash(proto->clone()); 00165 results = bench_hash(hash.get(), ns_per_provider, 00166 &buf[0], buf.size()); 00167 } 00168 else if(const MessageAuthenticationCode* proto = 00169 af.prototype_mac(name, provider)) 00170 { 00171 std::auto_ptr<MessageAuthenticationCode> mac(proto->clone()); 00172 results = bench_mac(mac.get(), ns_per_provider, 00173 &buf[0], buf.size()); 00174 } 00175 00176 if(results.first && results.second) 00177 { 00178 /* 953.67 == 1000 * 1000 * 1000 / 1024 / 1024 - the conversion 00179 factor from bytes per nanosecond to mebibytes per second. 00180 */ 00181 double speed = (953.67 * results.first) / results.second; 00182 all_results[provider] = speed; 00183 } 00184 } 00185 00186 return all_results; 00187 }
| BOTAN_DLL std::map< std::string, bool > Botan::algorithm_kat | ( | const SCAN_Name & | algo_name, | |
| const std::map< std::string, std::string > & | vars, | |||
| Algorithm_Factory & | af | |||
| ) |
Definition at line 38 of file selftest.cpp.
References Botan::SCAN_Name::algo_name_and_args(), Botan::SCAN_Name::cipher_mode(), Botan::SCAN_Name::cipher_mode_pad(), DECRYPTION, ENCRYPTION, get_cipher_mode(), Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_hash_function(), Botan::Algorithm_Factory::prototype_mac(), Botan::Algorithm_Factory::prototype_stream_cipher(), Botan::Algorithm_Factory::providers_of(), search_map(), Botan::Keyed_Filter::set_iv(), and Botan::Keyed_Filter::set_key().
00041 { 00042 const std::string& algo = algo_name.algo_name_and_args(); 00043 00044 std::vector<std::string> providers = af.providers_of(algo); 00045 std::map<std::string, bool> all_results; 00046 00047 if(providers.empty()) // no providers, nothing to do 00048 return all_results; 00049 00050 const std::string input = search_map(vars, std::string("input")); 00051 const std::string output = search_map(vars, std::string("output")); 00052 const std::string key = search_map(vars, std::string("key")); 00053 const std::string iv = search_map(vars, std::string("iv")); 00054 00055 for(u32bit i = 0; i != providers.size(); ++i) 00056 { 00057 const std::string provider = providers[i]; 00058 00059 if(const HashFunction* proto = 00060 af.prototype_hash_function(algo, provider)) 00061 { 00062 Filter* filt = new Hash_Filter(proto->clone()); 00063 all_results[provider] = test_filter_kat(filt, input, output); 00064 } 00065 else if(const MessageAuthenticationCode* proto = 00066 af.prototype_mac(algo, provider)) 00067 { 00068 Keyed_Filter* filt = new MAC_Filter(proto->clone(), key); 00069 all_results[provider] = test_filter_kat(filt, input, output); 00070 } 00071 else if(const StreamCipher* proto = 00072 af.prototype_stream_cipher(algo, provider)) 00073 { 00074 Keyed_Filter* filt = new StreamCipher_Filter(proto->clone()); 00075 filt->set_key(key); 00076 filt->set_iv(iv); 00077 00078 all_results[provider] = test_filter_kat(filt, input, output); 00079 } 00080 else if(const BlockCipher* proto = 00081 af.prototype_block_cipher(algo, provider)) 00082 { 00083 Keyed_Filter* enc = get_cipher_mode(proto, ENCRYPTION, 00084 algo_name.cipher_mode(), 00085 algo_name.cipher_mode_pad()); 00086 00087 Keyed_Filter* dec = get_cipher_mode(proto, DECRYPTION, 00088 algo_name.cipher_mode(), 00089 algo_name.cipher_mode_pad()); 00090 00091 if(!enc || !dec) 00092 { 00093 delete enc; 00094 delete dec; 00095 continue; 00096 } 00097 00098 enc->set_key(key); 00099 enc->set_iv(iv); 00100 00101 dec->set_key(key); 00102 dec->set_iv(iv); 00103 00104 bool enc_ok = test_filter_kat(enc, input, output); 00105 bool dec_ok = test_filter_kat(dec, output, input); 00106 00107 all_results[provider] = enc_ok && dec_ok; 00108 } 00109 } 00110 00111 return all_results; 00112 }
| void Botan::bigint_2word_mul | ( | word | a, | |
| word | b, | |||
| word * | z1, | |||
| word * | z0 | |||
| ) | [inline] |
Definition at line 58 of file mp_asm.h.
00059 { 00060 const u32bit MP_HWORD_BITS = BOTAN_MP_WORD_BITS / 2; 00061 const word MP_HWORD_MASK = ((word)1 << MP_HWORD_BITS) - 1; 00062 00063 const word a_hi = (a >> MP_HWORD_BITS); 00064 const word a_lo = (a & MP_HWORD_MASK); 00065 const word b_hi = (b >> MP_HWORD_BITS); 00066 const word b_lo = (b & MP_HWORD_MASK); 00067 00068 word x0 = a_hi * b_hi; 00069 word x1 = a_lo * b_hi; 00070 word x2 = a_hi * b_lo; 00071 word x3 = a_lo * b_lo; 00072 00073 x2 += x3 >> (MP_HWORD_BITS); 00074 x2 += x1; 00075 if(x2 < x1) 00076 x0 += ((word)1 << MP_HWORD_BITS); 00077 00078 *z0 = x0 + (x2 >> MP_HWORD_BITS); 00079 *z1 = ((x2 & MP_HWORD_MASK) << MP_HWORD_BITS) + (x3 & MP_HWORD_MASK); 00080 }
| void Botan::bigint_add2 | ( | word | x[], | |
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 76 of file mp_asm.cpp.
References bigint_add2_nc().
Referenced by mul_add(), Botan::BigInt::operator+=(), and Botan::BigInt::operator-=().
00077 { 00078 if(bigint_add2_nc(x, x_size, y, y_size)) 00079 ++x[x_size]; 00080 }
| word Botan::bigint_add2_nc | ( | word | x[], | |
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 21 of file mp_asm.cpp.
References word8_add2(), and word_add().
Referenced by bigint_add2().
00022 { 00023 word carry = 0; 00024 00025 const u32bit blocks = y_size - (y_size % 8); 00026 00027 for(u32bit j = 0; j != blocks; j += 8) 00028 carry = word8_add2(x + j, y + j, carry); 00029 00030 for(u32bit j = blocks; j != y_size; ++j) 00031 x[j] = word_add(x[j], y[j], &carry); 00032 00033 if(!carry) 00034 return 0; 00035 00036 for(u32bit j = y_size; j != x_size; ++j) 00037 if(++x[j]) 00038 return 0; 00039 00040 return 1; 00041 }
| void Botan::bigint_add3 | ( | word | z[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 85 of file mp_asm.cpp.
References bigint_add3_nc().
Referenced by operator+(), and operator-().
00087 { 00088 if(bigint_add3_nc(z, x, x_size, y, y_size)) 00089 ++z[(x_size > y_size ? x_size : y_size)]; 00090 }
| word Botan::bigint_add3_nc | ( | word | z[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 46 of file mp_asm.cpp.
References word8_add3(), and word_add().
Referenced by bigint_add3().
00048 { 00049 if(x_size < y_size) 00050 { return bigint_add3_nc(z, y, y_size, x, x_size); } 00051 00052 word carry = 0; 00053 00054 const u32bit blocks = y_size - (y_size % 8); 00055 00056 for(u32bit j = 0; j != blocks; j += 8) 00057 carry = word8_add3(z + j, x + j, y + j, carry); 00058 00059 for(u32bit j = blocks; j != y_size; ++j) 00060 z[j] = word_add(x[j], y[j], &carry); 00061 00062 for(u32bit j = y_size; j != x_size; ++j) 00063 { 00064 word x_j = x[j] + carry; 00065 if(carry && x_j) 00066 carry = 0; 00067 z[j] = x_j; 00068 } 00069 00070 return carry; 00071 }
| s32bit Botan::bigint_cmp | ( | const word | x[], | |
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 37 of file mp_misc.cpp.
Referenced by Botan::BigInt::cmp(), operator+(), Botan::BigInt::operator+=(), operator-(), and Botan::BigInt::operator-=().
00039 { 00040 if(x_size < y_size) { return (-bigint_cmp(y, y_size, x, x_size)); } 00041 00042 while(x_size > y_size) 00043 { 00044 if(x[x_size-1]) 00045 return 1; 00046 x_size--; 00047 } 00048 for(u32bit j = x_size; j > 0; --j) 00049 { 00050 if(x[j-1] > y[j-1]) return 1; 00051 if(x[j-1] < y[j-1]) return -1; 00052 } 00053 return 0; 00054 }
| void Botan::bigint_comba_mul16 | ( | word | z[32], | |
| const word | x[16], | |||
| const word | y[16] | |||
| ) |
Definition at line 594 of file mp_comba.cpp.
References word3_muladd().
Referenced by bigint_mul().
00595 { 00596 word w2 = 0, w1 = 0, w0 = 0; 00597 00598 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 0]); 00599 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00600 00601 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 1]); 00602 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 0]); 00603 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00604 00605 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 2]); 00606 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 1]); 00607 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 0]); 00608 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00609 00610 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 3]); 00611 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 2]); 00612 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 1]); 00613 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 0]); 00614 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00615 00616 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 4]); 00617 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 3]); 00618 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 2]); 00619 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 1]); 00620 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 0]); 00621 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00622 00623 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 5]); 00624 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 4]); 00625 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 3]); 00626 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 2]); 00627 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 1]); 00628 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 0]); 00629 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00630 00631 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 6]); 00632 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 5]); 00633 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 4]); 00634 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 3]); 00635 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 2]); 00636 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 1]); 00637 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 0]); 00638 z[6] = w0; w0 = w1; w1 = w2; w2 = 0; 00639 00640 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 7]); 00641 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 6]); 00642 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 5]); 00643 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 4]); 00644 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 3]); 00645 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 2]); 00646 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 1]); 00647 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 0]); 00648 z[7] = w0; w0 = w1; w1 = w2; w2 = 0; 00649 00650 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 8]); 00651 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 7]); 00652 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 6]); 00653 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 5]); 00654 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 4]); 00655 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 3]); 00656 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 2]); 00657 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 1]); 00658 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 0]); 00659 z[8] = w0; w0 = w1; w1 = w2; w2 = 0; 00660 00661 word3_muladd(&w2, &w1, &w0, x[ 0], y[ 9]); 00662 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 8]); 00663 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 7]); 00664 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 6]); 00665 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 5]); 00666 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 4]); 00667 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 3]); 00668 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 2]); 00669 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 1]); 00670 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 0]); 00671 z[9] = w0; w0 = w1; w1 = w2; w2 = 0; 00672 00673 word3_muladd(&w2, &w1, &w0, x[ 0], y[10]); 00674 word3_muladd(&w2, &w1, &w0, x[ 1], y[ 9]); 00675 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 8]); 00676 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 7]); 00677 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 6]); 00678 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 5]); 00679 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 4]); 00680 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 3]); 00681 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 2]); 00682 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 1]); 00683 word3_muladd(&w2, &w1, &w0, x[10], y[ 0]); 00684 z[10] = w0; w0 = w1; w1 = w2; w2 = 0; 00685 00686 word3_muladd(&w2, &w1, &w0, x[ 0], y[11]); 00687 word3_muladd(&w2, &w1, &w0, x[ 1], y[10]); 00688 word3_muladd(&w2, &w1, &w0, x[ 2], y[ 9]); 00689 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 8]); 00690 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 7]); 00691 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 6]); 00692 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 5]); 00693 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 4]); 00694 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 3]); 00695 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 2]); 00696 word3_muladd(&w2, &w1, &w0, x[10], y[ 1]); 00697 word3_muladd(&w2, &w1, &w0, x[11], y[ 0]); 00698 z[11] = w0; w0 = w1; w1 = w2; w2 = 0; 00699 00700 word3_muladd(&w2, &w1, &w0, x[ 0], y[12]); 00701 word3_muladd(&w2, &w1, &w0, x[ 1], y[11]); 00702 word3_muladd(&w2, &w1, &w0, x[ 2], y[10]); 00703 word3_muladd(&w2, &w1, &w0, x[ 3], y[ 9]); 00704 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 8]); 00705 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 7]); 00706 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 6]); 00707 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 5]); 00708 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 4]); 00709 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 3]); 00710 word3_muladd(&w2, &w1, &w0, x[10], y[ 2]); 00711 word3_muladd(&w2, &w1, &w0, x[11], y[ 1]); 00712 word3_muladd(&w2, &w1, &w0, x[12], y[ 0]); 00713 z[12] = w0; w0 = w1; w1 = w2; w2 = 0; 00714 00715 word3_muladd(&w2, &w1, &w0, x[ 0], y[13]); 00716 word3_muladd(&w2, &w1, &w0, x[ 1], y[12]); 00717 word3_muladd(&w2, &w1, &w0, x[ 2], y[11]); 00718 word3_muladd(&w2, &w1, &w0, x[ 3], y[10]); 00719 word3_muladd(&w2, &w1, &w0, x[ 4], y[ 9]); 00720 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 8]); 00721 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 7]); 00722 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 6]); 00723 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 5]); 00724 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 4]); 00725 word3_muladd(&w2, &w1, &w0, x[10], y[ 3]); 00726 word3_muladd(&w2, &w1, &w0, x[11], y[ 2]); 00727 word3_muladd(&w2, &w1, &w0, x[12], y[ 1]); 00728 word3_muladd(&w2, &w1, &w0, x[13], y[ 0]); 00729 z[13] = w0; w0 = w1; w1 = w2; w2 = 0; 00730 00731 word3_muladd(&w2, &w1, &w0, x[ 0], y[14]); 00732 word3_muladd(&w2, &w1, &w0, x[ 1], y[13]); 00733 word3_muladd(&w2, &w1, &w0, x[ 2], y[12]); 00734 word3_muladd(&w2, &w1, &w0, x[ 3], y[11]); 00735 word3_muladd(&w2, &w1, &w0, x[ 4], y[10]); 00736 word3_muladd(&w2, &w1, &w0, x[ 5], y[ 9]); 00737 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 8]); 00738 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 7]); 00739 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 6]); 00740 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 5]); 00741 word3_muladd(&w2, &w1, &w0, x[10], y[ 4]); 00742 word3_muladd(&w2, &w1, &w0, x[11], y[ 3]); 00743 word3_muladd(&w2, &w1, &w0, x[12], y[ 2]); 00744 word3_muladd(&w2, &w1, &w0, x[13], y[ 1]); 00745 word3_muladd(&w2, &w1, &w0, x[14], y[ 0]); 00746 z[14] = w0; w0 = w1; w1 = w2; w2 = 0; 00747 00748 word3_muladd(&w2, &w1, &w0, x[ 0], y[15]); 00749 word3_muladd(&w2, &w1, &w0, x[ 1], y[14]); 00750 word3_muladd(&w2, &w1, &w0, x[ 2], y[13]); 00751 word3_muladd(&w2, &w1, &w0, x[ 3], y[12]); 00752 word3_muladd(&w2, &w1, &w0, x[ 4], y[11]); 00753 word3_muladd(&w2, &w1, &w0, x[ 5], y[10]); 00754 word3_muladd(&w2, &w1, &w0, x[ 6], y[ 9]); 00755 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 8]); 00756 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 7]); 00757 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 6]); 00758 word3_muladd(&w2, &w1, &w0, x[10], y[ 5]); 00759 word3_muladd(&w2, &w1, &w0, x[11], y[ 4]); 00760 word3_muladd(&w2, &w1, &w0, x[12], y[ 3]); 00761 word3_muladd(&w2, &w1, &w0, x[13], y[ 2]); 00762 word3_muladd(&w2, &w1, &w0, x[14], y[ 1]); 00763 word3_muladd(&w2, &w1, &w0, x[15], y[ 0]); 00764 z[15] = w0; w0 = w1; w1 = w2; w2 = 0; 00765 00766 word3_muladd(&w2, &w1, &w0, x[ 1], y[15]); 00767 word3_muladd(&w2, &w1, &w0, x[ 2], y[14]); 00768 word3_muladd(&w2, &w1, &w0, x[ 3], y[13]); 00769 word3_muladd(&w2, &w1, &w0, x[ 4], y[12]); 00770 word3_muladd(&w2, &w1, &w0, x[ 5], y[11]); 00771 word3_muladd(&w2, &w1, &w0, x[ 6], y[10]); 00772 word3_muladd(&w2, &w1, &w0, x[ 7], y[ 9]); 00773 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 8]); 00774 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 7]); 00775 word3_muladd(&w2, &w1, &w0, x[10], y[ 6]); 00776 word3_muladd(&w2, &w1, &w0, x[11], y[ 5]); 00777 word3_muladd(&w2, &w1, &w0, x[12], y[ 4]); 00778 word3_muladd(&w2, &w1, &w0, x[13], y[ 3]); 00779 word3_muladd(&w2, &w1, &w0, x[14], y[ 2]); 00780 word3_muladd(&w2, &w1, &w0, x[15], y[ 1]); 00781 z[16] = w0; w0 = w1; w1 = w2; w2 = 0; 00782 00783 word3_muladd(&w2, &w1, &w0, x[ 2], y[15]); 00784 word3_muladd(&w2, &w1, &w0, x[ 3], y[14]); 00785 word3_muladd(&w2, &w1, &w0, x[ 4], y[13]); 00786 word3_muladd(&w2, &w1, &w0, x[ 5], y[12]); 00787 word3_muladd(&w2, &w1, &w0, x[ 6], y[11]); 00788 word3_muladd(&w2, &w1, &w0, x[ 7], y[10]); 00789 word3_muladd(&w2, &w1, &w0, x[ 8], y[ 9]); 00790 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 8]); 00791 word3_muladd(&w2, &w1, &w0, x[10], y[ 7]); 00792 word3_muladd(&w2, &w1, &w0, x[11], y[ 6]); 00793 word3_muladd(&w2, &w1, &w0, x[12], y[ 5]); 00794 word3_muladd(&w2, &w1, &w0, x[13], y[ 4]); 00795 word3_muladd(&w2, &w1, &w0, x[14], y[ 3]); 00796 word3_muladd(&w2, &w1, &w0, x[15], y[ 2]); 00797 z[17] = w0; w0 = w1; w1 = w2; w2 = 0; 00798 00799 word3_muladd(&w2, &w1, &w0, x[ 3], y[15]); 00800 word3_muladd(&w2, &w1, &w0, x[ 4], y[14]); 00801 word3_muladd(&w2, &w1, &w0, x[ 5], y[13]); 00802 word3_muladd(&w2, &w1, &w0, x[ 6], y[12]); 00803 word3_muladd(&w2, &w1, &w0, x[ 7], y[11]); 00804 word3_muladd(&w2, &w1, &w0, x[ 8], y[10]); 00805 word3_muladd(&w2, &w1, &w0, x[ 9], y[ 9]); 00806 word3_muladd(&w2, &w1, &w0, x[10], y[ 8]); 00807 word3_muladd(&w2, &w1, &w0, x[11], y[ 7]); 00808 word3_muladd(&w2, &w1, &w0, x[12], y[ 6]); 00809 word3_muladd(&w2, &w1, &w0, x[13], y[ 5]); 00810 word3_muladd(&w2, &w1, &w0, x[14], y[ 4]); 00811 word3_muladd(&w2, &w1, &w0, x[15], y[ 3]); 00812 z[18] = w0; w0 = w1; w1 = w2; w2 = 0; 00813 00814 word3_muladd(&w2, &w1, &w0, x[ 4], y[15]); 00815 word3_muladd(&w2, &w1, &w0, x[ 5], y[14]); 00816 word3_muladd(&w2, &w1, &w0, x[ 6], y[13]); 00817 word3_muladd(&w2, &w1, &w0, x[ 7], y[12]); 00818 word3_muladd(&w2, &w1, &w0, x[ 8], y[11]); 00819 word3_muladd(&w2, &w1, &w0, x[ 9], y[10]); 00820 word3_muladd(&w2, &w1, &w0, x[10], y[ 9]); 00821 word3_muladd(&w2, &w1, &w0, x[11], y[ 8]); 00822 word3_muladd(&w2, &w1, &w0, x[12], y[ 7]); 00823 word3_muladd(&w2, &w1, &w0, x[13], y[ 6]); 00824 word3_muladd(&w2, &w1, &w0, x[14], y[ 5]); 00825 word3_muladd(&w2, &w1, &w0, x[15], y[ 4]); 00826 z[19] = w0; w0 = w1; w1 = w2; w2 = 0; 00827 00828 word3_muladd(&w2, &w1, &w0, x[ 5], y[15]); 00829 word3_muladd(&w2, &w1, &w0, x[ 6], y[14]); 00830 word3_muladd(&w2, &w1, &w0, x[ 7], y[13]); 00831 word3_muladd(&w2, &w1, &w0, x[ 8], y[12]); 00832 word3_muladd(&w2, &w1, &w0, x[ 9], y[11]); 00833 word3_muladd(&w2, &w1, &w0, x[10], y[10]); 00834 word3_muladd(&w2, &w1, &w0, x[11], y[ 9]); 00835 word3_muladd(&w2, &w1, &w0, x[12], y[ 8]); 00836 word3_muladd(&w2, &w1, &w0, x[13], y[ 7]); 00837 word3_muladd(&w2, &w1, &w0, x[14], y[ 6]); 00838 word3_muladd(&w2, &w1, &w0, x[15], y[ 5]); 00839 z[20] = w0; w0 = w1; w1 = w2; w2 = 0; 00840 00841 word3_muladd(&w2, &w1, &w0, x[ 6], y[15]); 00842 word3_muladd(&w2, &w1, &w0, x[ 7], y[14]); 00843 word3_muladd(&w2, &w1, &w0, x[ 8], y[13]); 00844 word3_muladd(&w2, &w1, &w0, x[ 9], y[12]); 00845 word3_muladd(&w2, &w1, &w0, x[10], y[11]); 00846 word3_muladd(&w2, &w1, &w0, x[11], y[10]); 00847 word3_muladd(&w2, &w1, &w0, x[12], y[ 9]); 00848 word3_muladd(&w2, &w1, &w0, x[13], y[ 8]); 00849 word3_muladd(&w2, &w1, &w0, x[14], y[ 7]); 00850 word3_muladd(&w2, &w1, &w0, x[15], y[ 6]); 00851 z[21] = w0; w0 = w1; w1 = w2; w2 = 0; 00852 00853 word3_muladd(&w2, &w1, &w0, x[ 7], y[15]); 00854 word3_muladd(&w2, &w1, &w0, x[ 8], y[14]); 00855 word3_muladd(&w2, &w1, &w0, x[ 9], y[13]); 00856 word3_muladd(&w2, &w1, &w0, x[10], y[12]); 00857 word3_muladd(&w2, &w1, &w0, x[11], y[11]); 00858 word3_muladd(&w2, &w1, &w0, x[12], y[10]); 00859 word3_muladd(&w2, &w1, &w0, x[13], y[ 9]); 00860 word3_muladd(&w2, &w1, &w0, x[14], y[ 8]); 00861 word3_muladd(&w2, &w1, &w0, x[15], y[ 7]); 00862 z[22] = w0; w0 = w1; w1 = w2; w2 = 0; 00863 00864 word3_muladd(&w2, &w1, &w0, x[ 8], y[15]); 00865 word3_muladd(&w2, &w1, &w0, x[ 9], y[14]); 00866 word3_muladd(&w2, &w1, &w0, x[10], y[13]); 00867 word3_muladd(&w2, &w1, &w0, x[11], y[12]); 00868 word3_muladd(&w2, &w1, &w0, x[12], y[11]); 00869 word3_muladd(&w2, &w1, &w0, x[13], y[10]); 00870 word3_muladd(&w2, &w1, &w0, x[14], y[ 9]); 00871 word3_muladd(&w2, &w1, &w0, x[15], y[ 8]); 00872 z[23] = w0; w0 = w1; w1 = w2; w2 = 0; 00873 00874 word3_muladd(&w2, &w1, &w0, x[ 9], y[15]); 00875 word3_muladd(&w2, &w1, &w0, x[10], y[14]); 00876 word3_muladd(&w2, &w1, &w0, x[11], y[13]); 00877 word3_muladd(&w2, &w1, &w0, x[12], y[12]); 00878 word3_muladd(&w2, &w1, &w0, x[13], y[11]); 00879 word3_muladd(&w2, &w1, &w0, x[14], y[10]); 00880 word3_muladd(&w2, &w1, &w0, x[15], y[ 9]); 00881 z[24] = w0; w0 = w1; w1 = w2; w2 = 0; 00882 00883 word3_muladd(&w2, &w1, &w0, x[10], y[15]); 00884 word3_muladd(&w2, &w1, &w0, x[11], y[14]); 00885 word3_muladd(&w2, &w1, &w0, x[12], y[13]); 00886 word3_muladd(&w2, &w1, &w0, x[13], y[12]); 00887 word3_muladd(&w2, &w1, &w0, x[14], y[11]); 00888 word3_muladd(&w2, &w1, &w0, x[15], y[10]); 00889 z[25] = w0; w0 = w1; w1 = w2; w2 = 0; 00890 00891 word3_muladd(&w2, &w1, &w0, x[11], y[15]); 00892 word3_muladd(&w2, &w1, &w0, x[12], y[14]); 00893 word3_muladd(&w2, &w1, &w0, x[13], y[13]); 00894 word3_muladd(&w2, &w1, &w0, x[14], y[12]); 00895 word3_muladd(&w2, &w1, &w0, x[15], y[11]); 00896 z[26] = w0; w0 = w1; w1 = w2; w2 = 0; 00897 00898 word3_muladd(&w2, &w1, &w0, x[12], y[15]); 00899 word3_muladd(&w2, &w1, &w0, x[13], y[14]); 00900 word3_muladd(&w2, &w1, &w0, x[14], y[13]); 00901 word3_muladd(&w2, &w1, &w0, x[15], y[12]); 00902 z[27] = w0; w0 = w1; w1 = w2; w2 = 0; 00903 00904 word3_muladd(&w2, &w1, &w0, x[13], y[15]); 00905 word3_muladd(&w2, &w1, &w0, x[14], y[14]); 00906 word3_muladd(&w2, &w1, &w0, x[15], y[13]); 00907 z[28] = w0; w0 = w1; w1 = w2; w2 = 0; 00908 00909 word3_muladd(&w2, &w1, &w0, x[14], y[15]); 00910 word3_muladd(&w2, &w1, &w0, x[15], y[14]); 00911 z[29] = w0; w0 = w1; w1 = w2; w2 = 0; 00912 00913 word3_muladd(&w2, &w1, &w0, x[15], y[15]); 00914 z[30] = w0; 00915 z[31] = w1; 00916 }
| void Botan::bigint_comba_mul4 | ( | word | z[8], | |
| const word | x[4], | |||
| const word | y[4] | |||
| ) |
Definition at line 51 of file mp_comba.cpp.
References word3_muladd().
Referenced by bigint_mul().
00052 { 00053 word w2 = 0, w1 = 0, w0 = 0; 00054 00055 word3_muladd(&w2, &w1, &w0, x[0], y[0]); 00056 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00057 00058 word3_muladd(&w2, &w1, &w0, x[0], y[1]); 00059 word3_muladd(&w2, &w1, &w0, x[1], y[0]); 00060 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00061 00062 word3_muladd(&w2, &w1, &w0, x[0], y[2]); 00063 word3_muladd(&w2, &w1, &w0, x[1], y[1]); 00064 word3_muladd(&w2, &w1, &w0, x[2], y[0]); 00065 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00066 00067 word3_muladd(&w2, &w1, &w0, x[0], y[3]); 00068 word3_muladd(&w2, &w1, &w0, x[1], y[2]); 00069 word3_muladd(&w2, &w1, &w0, x[2], y[1]); 00070 word3_muladd(&w2, &w1, &w0, x[3], y[0]); 00071 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00072 00073 word3_muladd(&w2, &w1, &w0, x[1], y[3]); 00074 word3_muladd(&w2, &w1, &w0, x[2], y[2]); 00075 word3_muladd(&w2, &w1, &w0, x[3], y[1]); 00076 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00077 00078 word3_muladd(&w2, &w1, &w0, x[2], y[3]); 00079 word3_muladd(&w2, &w1, &w0, x[3], y[2]); 00080 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00081 00082 word3_muladd(&w2, &w1, &w0, x[3], y[3]); 00083 z[6] = w0; 00084 z[7] = w1; 00085 }
| void Botan::bigint_comba_mul6 | ( | word | z[12], | |
| const word | x[6], | |||
| const word | y[6] | |||
| ) |
Definition at line 142 of file mp_comba.cpp.
References word3_muladd().
Referenced by bigint_mul().
00143 { 00144 word w2 = 0, w1 = 0, w0 = 0; 00145 00146 word3_muladd(&w2, &w1, &w0, x[0], y[0]); 00147 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00148 00149 word3_muladd(&w2, &w1, &w0, x[0], y[1]); 00150 word3_muladd(&w2, &w1, &w0, x[1], y[0]); 00151 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00152 00153 word3_muladd(&w2, &w1, &w0, x[0], y[2]); 00154 word3_muladd(&w2, &w1, &w0, x[1], y[1]); 00155 word3_muladd(&w2, &w1, &w0, x[2], y[0]); 00156 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00157 00158 word3_muladd(&w2, &w1, &w0, x[0], y[3]); 00159 word3_muladd(&w2, &w1, &w0, x[1], y[2]); 00160 word3_muladd(&w2, &w1, &w0, x[2], y[1]); 00161 word3_muladd(&w2, &w1, &w0, x[3], y[0]); 00162 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00163 00164 word3_muladd(&w2, &w1, &w0, x[0], y[4]); 00165 word3_muladd(&w2, &w1, &w0, x[1], y[3]); 00166 word3_muladd(&w2, &w1, &w0, x[2], y[2]); 00167 word3_muladd(&w2, &w1, &w0, x[3], y[1]); 00168 word3_muladd(&w2, &w1, &w0, x[4], y[0]); 00169 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00170 00171 word3_muladd(&w2, &w1, &w0, x[0], y[5]); 00172 word3_muladd(&w2, &w1, &w0, x[1], y[4]); 00173 word3_muladd(&w2, &w1, &w0, x[2], y[3]); 00174 word3_muladd(&w2, &w1, &w0, x[3], y[2]); 00175 word3_muladd(&w2, &w1, &w0, x[4], y[1]); 00176 word3_muladd(&w2, &w1, &w0, x[5], y[0]); 00177 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00178 00179 word3_muladd(&w2, &w1, &w0, x[1], y[5]); 00180 word3_muladd(&w2, &w1, &w0, x[2], y[4]); 00181 word3_muladd(&w2, &w1, &w0, x[3], y[3]); 00182 word3_muladd(&w2, &w1, &w0, x[4], y[2]); 00183 word3_muladd(&w2, &w1, &w0, x[5], y[1]); 00184 z[6] = w0; w0 = w1; w1 = w2; w2 = 0; 00185 00186 word3_muladd(&w2, &w1, &w0, x[2], y[5]); 00187 word3_muladd(&w2, &w1, &w0, x[3], y[4]); 00188 word3_muladd(&w2, &w1, &w0, x[4], y[3]); 00189 word3_muladd(&w2, &w1, &w0, x[5], y[2]); 00190 z[7] = w0; w0 = w1; w1 = w2; w2 = 0; 00191 00192 word3_muladd(&w2, &w1, &w0, x[3], y[5]); 00193 word3_muladd(&w2, &w1, &w0, x[4], y[4]); 00194 word3_muladd(&w2, &w1, &w0, x[5], y[3]); 00195 z[8] = w0; w0 = w1; w1 = w2; w2 = 0; 00196 00197 word3_muladd(&w2, &w1, &w0, x[4], y[5]); 00198 word3_muladd(&w2, &w1, &w0, x[5], y[4]); 00199 z[9] = w0; w0 = w1; w1 = w2; w2 = 0; 00200 00201 word3_muladd(&w2, &w1, &w0, x[5], y[5]); 00202 z[10] = w0; 00203 z[11] = w1; 00204 }
| void Botan::bigint_comba_mul8 | ( | word | z[16], | |
| const word | x[8], | |||
| const word | y[8] | |||
| ) |
Definition at line 284 of file mp_comba.cpp.
References word3_muladd().
Referenced by bigint_mul().
00285 { 00286 word w2 = 0, w1 = 0, w0 = 0; 00287 00288 word3_muladd(&w2, &w1, &w0, x[0], y[0]); 00289 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00290 00291 word3_muladd(&w2, &w1, &w0, x[0], y[1]); 00292 word3_muladd(&w2, &w1, &w0, x[1], y[0]); 00293 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00294 00295 word3_muladd(&w2, &w1, &w0, x[0], y[2]); 00296 word3_muladd(&w2, &w1, &w0, x[1], y[1]); 00297 word3_muladd(&w2, &w1, &w0, x[2], y[0]); 00298 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00299 00300 word3_muladd(&w2, &w1, &w0, x[0], y[3]); 00301 word3_muladd(&w2, &w1, &w0, x[1], y[2]); 00302 word3_muladd(&w2, &w1, &w0, x[2], y[1]); 00303 word3_muladd(&w2, &w1, &w0, x[3], y[0]); 00304 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00305 00306 word3_muladd(&w2, &w1, &w0, x[0], y[4]); 00307 word3_muladd(&w2, &w1, &w0, x[1], y[3]); 00308 word3_muladd(&w2, &w1, &w0, x[2], y[2]); 00309 word3_muladd(&w2, &w1, &w0, x[3], y[1]); 00310 word3_muladd(&w2, &w1, &w0, x[4], y[0]); 00311 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00312 00313 word3_muladd(&w2, &w1, &w0, x[0], y[5]); 00314 word3_muladd(&w2, &w1, &w0, x[1], y[4]); 00315 word3_muladd(&w2, &w1, &w0, x[2], y[3]); 00316 word3_muladd(&w2, &w1, &w0, x[3], y[2]); 00317 word3_muladd(&w2, &w1, &w0, x[4], y[1]); 00318 word3_muladd(&w2, &w1, &w0, x[5], y[0]); 00319 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00320 00321 word3_muladd(&w2, &w1, &w0, x[0], y[6]); 00322 word3_muladd(&w2, &w1, &w0, x[1], y[5]); 00323 word3_muladd(&w2, &w1, &w0, x[2], y[4]); 00324 word3_muladd(&w2, &w1, &w0, x[3], y[3]); 00325 word3_muladd(&w2, &w1, &w0, x[4], y[2]); 00326 word3_muladd(&w2, &w1, &w0, x[5], y[1]); 00327 word3_muladd(&w2, &w1, &w0, x[6], y[0]); 00328 z[6] = w0; w0 = w1; w1 = w2; w2 = 0; 00329 00330 word3_muladd(&w2, &w1, &w0, x[0], y[7]); 00331 word3_muladd(&w2, &w1, &w0, x[1], y[6]); 00332 word3_muladd(&w2, &w1, &w0, x[2], y[5]); 00333 word3_muladd(&w2, &w1, &w0, x[3], y[4]); 00334 word3_muladd(&w2, &w1, &w0, x[4], y[3]); 00335 word3_muladd(&w2, &w1, &w0, x[5], y[2]); 00336 word3_muladd(&w2, &w1, &w0, x[6], y[1]); 00337 word3_muladd(&w2, &w1, &w0, x[7], y[0]); 00338 z[7] = w0; w0 = w1; w1 = w2; w2 = 0; 00339 00340 word3_muladd(&w2, &w1, &w0, x[1], y[7]); 00341 word3_muladd(&w2, &w1, &w0, x[2], y[6]); 00342 word3_muladd(&w2, &w1, &w0, x[3], y[5]); 00343 word3_muladd(&w2, &w1, &w0, x[4], y[4]); 00344 word3_muladd(&w2, &w1, &w0, x[5], y[3]); 00345 word3_muladd(&w2, &w1, &w0, x[6], y[2]); 00346 word3_muladd(&w2, &w1, &w0, x[7], y[1]); 00347 z[8] = w0; w0 = w1; w1 = w2; w2 = 0; 00348 00349 word3_muladd(&w2, &w1, &w0, x[2], y[7]); 00350 word3_muladd(&w2, &w1, &w0, x[3], y[6]); 00351 word3_muladd(&w2, &w1, &w0, x[4], y[5]); 00352 word3_muladd(&w2, &w1, &w0, x[5], y[4]); 00353 word3_muladd(&w2, &w1, &w0, x[6], y[3]); 00354 word3_muladd(&w2, &w1, &w0, x[7], y[2]); 00355 z[9] = w0; w0 = w1; w1 = w2; w2 = 0; 00356 00357 word3_muladd(&w2, &w1, &w0, x[3], y[7]); 00358 word3_muladd(&w2, &w1, &w0, x[4], y[6]); 00359 word3_muladd(&w2, &w1, &w0, x[5], y[5]); 00360 word3_muladd(&w2, &w1, &w0, x[6], y[4]); 00361 word3_muladd(&w2, &w1, &w0, x[7], y[3]); 00362 z[10] = w0; w0 = w1; w1 = w2; w2 = 0; 00363 00364 word3_muladd(&w2, &w1, &w0, x[4], y[7]); 00365 word3_muladd(&w2, &w1, &w0, x[5], y[6]); 00366 word3_muladd(&w2, &w1, &w0, x[6], y[5]); 00367 word3_muladd(&w2, &w1, &w0, x[7], y[4]); 00368 z[11] = w0; w0 = w1; w1 = w2; w2 = 0; 00369 00370 word3_muladd(&w2, &w1, &w0, x[5], y[7]); 00371 word3_muladd(&w2, &w1, &w0, x[6], y[6]); 00372 word3_muladd(&w2, &w1, &w0, x[7], y[5]); 00373 z[12] = w0; w0 = w1; w1 = w2; w2 = 0; 00374 00375 word3_muladd(&w2, &w1, &w0, x[6], y[7]); 00376 word3_muladd(&w2, &w1, &w0, x[7], y[6]); 00377 z[13] = w0; w0 = w1; w1 = w2; w2 = 0; 00378 00379 word3_muladd(&w2, &w1, &w0, x[7], y[7]); 00380 z[14] = w0; 00381 z[15] = w1; 00382 }
| void Botan::bigint_comba_sqr16 | ( | word | [64], | |
| const | word[32] | |||
| ) |
| void Botan::bigint_comba_sqr16 | ( | word | z[32], | |
| const word | x[16] | |||
| ) |
Definition at line 387 of file mp_comba.cpp.
References word3_muladd(), and word3_muladd_2().
Referenced by bigint_sqr().
00388 { 00389 word w2 = 0, w1 = 0, w0 = 0; 00390 00391 word3_muladd(&w2, &w1, &w0, x[ 0], x[ 0]); 00392 z[ 0] = w0; w0 = w1; w1 = w2; w2 = 0; 00393 00394 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 1]); 00395 z[ 1] = w0; w0 = w1; w1 = w2; w2 = 0; 00396 00397 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 2]); 00398 word3_muladd(&w2, &w1, &w0, x[ 1], x[ 1]); 00399 z[ 2] = w0; w0 = w1; w1 = w2; w2 = 0; 00400 00401 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 3]); 00402 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 2]); 00403 z[ 3] = w0; w0 = w1; w1 = w2; w2 = 0; 00404 00405 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 4]); 00406 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 3]); 00407 word3_muladd(&w2, &w1, &w0, x[ 2], x[ 2]); 00408 z[ 4] = w0; w0 = w1; w1 = w2; w2 = 0; 00409 00410 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 5]); 00411 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 4]); 00412 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 3]); 00413 z[ 5] = w0; w0 = w1; w1 = w2; w2 = 0; 00414 00415 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 6]); 00416 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 5]); 00417 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 4]); 00418 word3_muladd(&w2, &w1, &w0, x[ 3], x[ 3]); 00419 z[ 6] = w0; w0 = w1; w1 = w2; w2 = 0; 00420 00421 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 7]); 00422 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 6]); 00423 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 5]); 00424 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[ 4]); 00425 z[ 7] = w0; w0 = w1; w1 = w2; w2 = 0; 00426 00427 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 8]); 00428 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 7]); 00429 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 6]); 00430 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[ 5]); 00431 word3_muladd(&w2, &w1, &w0, x[ 4], x[ 4]); 00432 z[ 8] = w0; w0 = w1; w1 = w2; w2 = 0; 00433 00434 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[ 9]); 00435 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 8]); 00436 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 7]); 00437 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[ 6]); 00438 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[ 5]); 00439 z[ 9] = w0; w0 = w1; w1 = w2; w2 = 0; 00440 00441 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[10]); 00442 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[ 9]); 00443 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 8]); 00444 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[ 7]); 00445 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[ 6]); 00446 word3_muladd(&w2, &w1, &w0, x[ 5], x[ 5]); 00447 z[10] = w0; w0 = w1; w1 = w2; w2 = 0; 00448 00449 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[11]); 00450 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[10]); 00451 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[ 9]); 00452 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[ 8]); 00453 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[ 7]); 00454 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[ 6]); 00455 z[11] = w0; w0 = w1; w1 = w2; w2 = 0; 00456 00457 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[12]); 00458 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[11]); 00459 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[10]); 00460 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[ 9]); 00461 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[ 8]); 00462 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[ 7]); 00463 word3_muladd(&w2, &w1, &w0, x[ 6], x[ 6]); 00464 z[12] = w0; w0 = w1; w1 = w2; w2 = 0; 00465 00466 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[13]); 00467 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[12]); 00468 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[11]); 00469 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[10]); 00470 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[ 9]); 00471 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[ 8]); 00472 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[ 7]); 00473 z[13] = w0; w0 = w1; w1 = w2; w2 = 0; 00474 00475 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[14]); 00476 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[13]); 00477 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[12]); 00478 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[11]); 00479 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[10]); 00480 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[ 9]); 00481 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[ 8]); 00482 word3_muladd(&w2, &w1, &w0, x[ 7], x[ 7]); 00483 z[14] = w0; w0 = w1; w1 = w2; w2 = 0; 00484 00485 word3_muladd_2(&w2, &w1, &w0, x[ 0], x[15]); 00486 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[14]); 00487 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[13]); 00488 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[12]); 00489 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[11]); 00490 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[10]); 00491 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[ 9]); 00492 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[ 8]); 00493 z[15] = w0; w0 = w1; w1 = w2; w2 = 0; 00494 00495 word3_muladd_2(&w2, &w1, &w0, x[ 1], x[15]); 00496 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[14]); 00497 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[13]); 00498 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[12]); 00499 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[11]); 00500 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[10]); 00501 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[ 9]); 00502 word3_muladd(&w2, &w1, &w0, x[ 8], x[ 8]); 00503 z[16] = w0; w0 = w1; w1 = w2; w2 = 0; 00504 00505 word3_muladd_2(&w2, &w1, &w0, x[ 2], x[15]); 00506 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[14]); 00507 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[13]); 00508 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[12]); 00509 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[11]); 00510 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[10]); 00511 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[ 9]); 00512 z[17] = w0; w0 = w1; w1 = w2; w2 = 0; 00513 00514 word3_muladd_2(&w2, &w1, &w0, x[ 3], x[15]); 00515 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[14]); 00516 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[13]); 00517 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[12]); 00518 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[11]); 00519 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[10]); 00520 word3_muladd(&w2, &w1, &w0, x[ 9], x[ 9]); 00521 z[18] = w0; w0 = w1; w1 = w2; w2 = 0; 00522 00523 word3_muladd_2(&w2, &w1, &w0, x[ 4], x[15]); 00524 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[14]); 00525 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[13]); 00526 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[12]); 00527 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[11]); 00528 word3_muladd_2(&w2, &w1, &w0, x[ 9], x[10]); 00529 z[19] = w0; w0 = w1; w1 = w2; w2 = 0; 00530 00531 word3_muladd_2(&w2, &w1, &w0, x[ 5], x[15]); 00532 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[14]); 00533 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[13]); 00534 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[12]); 00535 word3_muladd_2(&w2, &w1, &w0, x[ 9], x[11]); 00536 word3_muladd(&w2, &w1, &w0, x[10], x[10]); 00537 z[20] = w0; w0 = w1; w1 = w2; w2 = 0; 00538 00539 word3_muladd_2(&w2, &w1, &w0, x[ 6], x[15]); 00540 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[14]); 00541 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[13]); 00542 word3_muladd_2(&w2, &w1, &w0, x[ 9], x[12]); 00543 word3_muladd_2(&w2, &w1, &w0, x[10], x[11]); 00544 z[21] = w0; w0 = w1; w1 = w2; w2 = 0; 00545 00546 word3_muladd_2(&w2, &w1, &w0, x[ 7], x[15]); 00547 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[14]); 00548 word3_muladd_2(&w2, &w1, &w0, x[ 9], x[13]); 00549 word3_muladd_2(&w2, &w1, &w0, x[10], x[12]); 00550 word3_muladd(&w2, &w1, &w0, x[11], x[11]); 00551 z[22] = w0; w0 = w1; w1 = w2; w2 = 0; 00552 00553 word3_muladd_2(&w2, &w1, &w0, x[ 8], x[15]); 00554 word3_muladd_2(&w2, &w1, &w0, x[ 9], x[14]); 00555 word3_muladd_2(&w2, &w1, &w0, x[10], x[13]); 00556 word3_muladd_2(&w2, &w1, &w0, x[11], x[12]); 00557 z[23] = w0; w0 = w1; w1 = w2; w2 = 0; 00558 00559 word3_muladd_2(&w2, &w1, &w0, x[ 9], x[15]); 00560 word3_muladd_2(&w2, &w1, &w0, x[10], x[14]); 00561 word3_muladd_2(&w2, &w1, &w0, x[11], x[13]); 00562 word3_muladd(&w2, &w1, &w0, x[12], x[12]); 00563 z[24] = w0; w0 = w1; w1 = w2; w2 = 0; 00564 00565 word3_muladd_2(&w2, &w1, &w0, x[10], x[15]); 00566 word3_muladd_2(&w2, &w1, &w0, x[11], x[14]); 00567 word3_muladd_2(&w2, &w1, &w0, x[12], x[13]); 00568 z[25] = w0; w0 = w1; w1 = w2; w2 = 0; 00569 00570 word3_muladd_2(&w2, &w1, &w0, x[11], x[15]); 00571 word3_muladd_2(&w2, &w1, &w0, x[12], x[14]); 00572 word3_muladd(&w2, &w1, &w0, x[13], x[13]); 00573 z[26] = w0; w0 = w1; w1 = w2; w2 = 0; 00574 00575 word3_muladd_2(&w2, &w1, &w0, x[12], x[15]); 00576 word3_muladd_2(&w2, &w1, &w0, x[13], x[14]); 00577 z[27] = w0; w0 = w1; w1 = w2; w2 = 0; 00578 00579 word3_muladd_2(&w2, &w1, &w0, x[13], x[15]); 00580 word3_muladd(&w2, &w1, &w0, x[14], x[14]); 00581 z[28] = w0; w0 = w1; w1 = w2; w2 = 0; 00582 00583 word3_muladd_2(&w2, &w1, &w0, x[14], x[15]); 00584 z[29] = w0; w0 = w1; w1 = w2; w2 = 0; 00585 00586 word3_muladd(&w2, &w1, &w0, x[15], x[15]); 00587 z[30] = w0; 00588 z[31] = w1; 00589 }
| void Botan::bigint_comba_sqr4 | ( | word | z[8], | |
| const word | x[4] | |||
| ) |
Definition at line 18 of file mp_comba.cpp.
References word3_muladd(), and word3_muladd_2().
Referenced by bigint_sqr().
00019 { 00020 word w2 = 0, w1 = 0, w0 = 0; 00021 00022 word3_muladd(&w2, &w1, &w0, x[0], x[0]); 00023 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00024 00025 word3_muladd_2(&w2, &w1, &w0, x[0], x[1]); 00026 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00027 00028 word3_muladd_2(&w2, &w1, &w0, x[0], x[2]); 00029 word3_muladd(&w2, &w1, &w0, x[1], x[1]); 00030 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00031 00032 word3_muladd_2(&w2, &w1, &w0, x[0], x[3]); 00033 word3_muladd_2(&w2, &w1, &w0, x[1], x[2]); 00034 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00035 00036 word3_muladd_2(&w2, &w1, &w0, x[1], x[3]); 00037 word3_muladd(&w2, &w1, &w0, x[2], x[2]); 00038 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00039 00040 word3_muladd_2(&w2, &w1, &w0, x[2], x[3]); 00041 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00042 00043 word3_muladd(&w2, &w1, &w0, x[3], x[3]); 00044 z[6] = w0; 00045 z[7] = w1; 00046 }
| void Botan::bigint_comba_sqr6 | ( | word | z[12], | |
| const word | x[6] | |||
| ) |
Definition at line 90 of file mp_comba.cpp.
References word3_muladd(), and word3_muladd_2().
Referenced by bigint_sqr().
00091 { 00092 word w2 = 0, w1 = 0, w0 = 0; 00093 00094 word3_muladd(&w2, &w1, &w0, x[0], x[0]); 00095 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00096 00097 word3_muladd_2(&w2, &w1, &w0, x[0], x[1]); 00098 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00099 00100 word3_muladd_2(&w2, &w1, &w0, x[0], x[2]); 00101 word3_muladd(&w2, &w1, &w0, x[1], x[1]); 00102 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00103 00104 word3_muladd_2(&w2, &w1, &w0, x[0], x[3]); 00105 word3_muladd_2(&w2, &w1, &w0, x[1], x[2]); 00106 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00107 00108 word3_muladd_2(&w2, &w1, &w0, x[0], x[4]); 00109 word3_muladd_2(&w2, &w1, &w0, x[1], x[3]); 00110 word3_muladd(&w2, &w1, &w0, x[2], x[2]); 00111 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00112 00113 word3_muladd_2(&w2, &w1, &w0, x[0], x[5]); 00114 word3_muladd_2(&w2, &w1, &w0, x[1], x[4]); 00115 word3_muladd_2(&w2, &w1, &w0, x[2], x[3]); 00116 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00117 00118 word3_muladd_2(&w2, &w1, &w0, x[1], x[5]); 00119 word3_muladd_2(&w2, &w1, &w0, x[2], x[4]); 00120 word3_muladd(&w2, &w1, &w0, x[3], x[3]); 00121 z[6] = w0; w0 = w1; w1 = w2; w2 = 0; 00122 00123 word3_muladd_2(&w2, &w1, &w0, x[2], x[5]); 00124 word3_muladd_2(&w2, &w1, &w0, x[3], x[4]); 00125 z[7] = w0; w0 = w1; w1 = w2; w2 = 0; 00126 00127 word3_muladd_2(&w2, &w1, &w0, x[3], x[5]); 00128 word3_muladd(&w2, &w1, &w0, x[4], x[4]); 00129 z[8] = w0; w0 = w1; w1 = w2; w2 = 0; 00130 00131 word3_muladd_2(&w2, &w1, &w0, x[4], x[5]); 00132 z[9] = w0; w0 = w1; w1 = w2; w2 = 0; 00133 00134 word3_muladd(&w2, &w1, &w0, x[5], x[5]); 00135 z[10] = w0; 00136 z[11] = w1; 00137 }
| void Botan::bigint_comba_sqr8 | ( | word | [32], | |
| const | word[16] | |||
| ) |
| void Botan::bigint_comba_sqr8 | ( | word | z[16], | |
| const word | x[8] | |||
| ) |
Definition at line 209 of file mp_comba.cpp.
References word3_muladd(), and word3_muladd_2().
Referenced by bigint_sqr().
00210 { 00211 word w2 = 0, w1 = 0, w0 = 0; 00212 00213 word3_muladd(&w2, &w1, &w0, x[0], x[0]); 00214 z[0] = w0; w0 = w1; w1 = w2; w2 = 0; 00215 00216 word3_muladd_2(&w2, &w1, &w0, x[0], x[1]); 00217 z[1] = w0; w0 = w1; w1 = w2; w2 = 0; 00218 00219 word3_muladd_2(&w2, &w1, &w0, x[0], x[2]); 00220 word3_muladd(&w2, &w1, &w0, x[1], x[1]); 00221 z[2] = w0; w0 = w1; w1 = w2; w2 = 0; 00222 00223 word3_muladd_2(&w2, &w1, &w0, x[0], x[3]); 00224 word3_muladd_2(&w2, &w1, &w0, x[1], x[2]); 00225 z[3] = w0; w0 = w1; w1 = w2; w2 = 0; 00226 00227 word3_muladd_2(&w2, &w1, &w0, x[0], x[4]); 00228 word3_muladd_2(&w2, &w1, &w0, x[1], x[3]); 00229 word3_muladd(&w2, &w1, &w0, x[2], x[2]); 00230 z[4] = w0; w0 = w1; w1 = w2; w2 = 0; 00231 00232 word3_muladd_2(&w2, &w1, &w0, x[0], x[5]); 00233 word3_muladd_2(&w2, &w1, &w0, x[1], x[4]); 00234 word3_muladd_2(&w2, &w1, &w0, x[2], x[3]); 00235 z[5] = w0; w0 = w1; w1 = w2; w2 = 0; 00236 00237 word3_muladd_2(&w2, &w1, &w0, x[0], x[6]); 00238 word3_muladd_2(&w2, &w1, &w0, x[1], x[5]); 00239 word3_muladd_2(&w2, &w1, &w0, x[2], x[4]); 00240 word3_muladd(&w2, &w1, &w0, x[3], x[3]); 00241 z[6] = w0; w0 = w1; w1 = w2; w2 = 0; 00242 00243 word3_muladd_2(&w2, &w1, &w0, x[0], x[7]); 00244 word3_muladd_2(&w2, &w1, &w0, x[1], x[6]); 00245 word3_muladd_2(&w2, &w1, &w0, x[2], x[5]); 00246 word3_muladd_2(&w2, &w1, &w0, x[3], x[4]); 00247 z[7] = w0; w0 = w1; w1 = w2; w2 = 0; 00248 00249 word3_muladd_2(&w2, &w1, &w0, x[1], x[7]); 00250 word3_muladd_2(&w2, &w1, &w0, x[2], x[6]); 00251 word3_muladd_2(&w2, &w1, &w0, x[3], x[5]); 00252 word3_muladd(&w2, &w1, &w0, x[4], x[4]); 00253 z[8] = w0; w0 = w1; w1 = w2; w2 = 0; 00254 00255 word3_muladd_2(&w2, &w1, &w0, x[2], x[7]); 00256 word3_muladd_2(&w2, &w1, &w0, x[3], x[6]); 00257 word3_muladd_2(&w2, &w1, &w0, x[4], x[5]); 00258 z[9] = w0; w0 = w1; w1 = w2; w2 = 0; 00259 00260 word3_muladd_2(&w2, &w1, &w0, x[3], x[7]); 00261 word3_muladd_2(&w2, &w1, &w0, x[4], x[6]); 00262 word3_muladd(&w2, &w1, &w0, x[5], x[5]); 00263 z[10] = w0; w0 = w1; w1 = w2; w2 = 0; 00264 00265 word3_muladd_2(&w2, &w1, &w0, x[4], x[7]); 00266 word3_muladd_2(&w2, &w1, &w0, x[5], x[6]); 00267 z[11] = w0; w0 = w1; w1 = w2; w2 = 0; 00268 00269 word3_muladd_2(&w2, &w1, &w0, x[5], x[7]); 00270 word3_muladd(&w2, &w1, &w0, x[6], x[6]); 00271 z[12] = w0; w0 = w1; w1 = w2; w2 = 0; 00272 00273 word3_muladd_2(&w2, &w1, &w0, x[6], x[7]); 00274 z[13] = w0; w0 = w1; w1 = w2; w2 = 0; 00275 00276 word3_muladd(&w2, &w1, &w0, x[7], x[7]); 00277 z[14] = w0; 00278 z[15] = w1; 00279 }
| u32bit Botan::bigint_divcore | ( | word | q, | |
| word | y1, | |||
| word | y2, | |||
| word | x1, | |||
| word | x2, | |||
| word | x3 | |||
| ) |
Definition at line 18 of file mp_misc.cpp.
References word_madd2().
Referenced by divide().
00020 { 00021 word y0 = 0; 00022 y2 = word_madd2(q, y2, &y0); 00023 y1 = word_madd2(q, y1, &y0); 00024 00025 if(y0 > x1) return 1; 00026 if(y0 < x1) return 0; 00027 if(y1 > x2) return 1; 00028 if(y1 < x2) return 0; 00029 if(y2 > x3) return 1; 00030 if(y2 < x3) return 0; 00031 return 0; 00032 }
| word Botan::bigint_divop | ( | word | n1, | |
| word | n0, | |||
| word | d | |||
| ) |
Definition at line 59 of file mp_misc.cpp.
References MP_WORD_BITS, and MP_WORD_TOP_BIT.
Referenced by bigint_modop(), and divide().
00060 { 00061 word high = n1 % d, quotient = 0; 00062 00063 for(u32bit j = 0; j != MP_WORD_BITS; ++j) 00064 { 00065 word high_top_bit = (high & MP_WORD_TOP_BIT); 00066 00067 high <<= 1; 00068 high |= (n0 >> (MP_WORD_BITS-1-j)) & 1; 00069 quotient <<= 1; 00070 00071 if(high_top_bit || high >= d) 00072 { 00073 high -= d; 00074 quotient |= 1; 00075 } 00076 } 00077 00078 return quotient; 00079 }
| void Botan::bigint_linmul2 | ( | word | x[], | |
| u32bit | x_size, | |||
| word | y | |||
| ) |
Definition at line 144 of file mp_asm.cpp.
References word8_linmul2(), and word_madd2().
Referenced by Botan::BigInt::operator*=().
00145 { 00146 const u32bit blocks = x_size - (x_size % 8); 00147 00148 word carry = 0; 00149 00150 for(u32bit j = 0; j != blocks; j += 8) 00151 carry = word8_linmul2(x + j, y, carry); 00152 00153 for(u32bit j = blocks; j != x_size; ++j) 00154 x[j] = word_madd2(x[j], y, &carry); 00155 00156 x[x_size] = carry; 00157 }
| void Botan::bigint_linmul3 | ( | word | z[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| word | y | |||
| ) |
Definition at line 162 of file mp_asm.cpp.
References word8_linmul3(), and word_madd2().
Referenced by bigint_mul(), bigint_sqr(), operator*(), and Botan::BigInt::operator*=().
00163 { 00164 const u32bit blocks = x_size - (x_size % 8); 00165 00166 word carry = 0; 00167 00168 for(u32bit j = 0; j != blocks; j += 8) 00169 carry = word8_linmul3(z + j, x + j, y, carry); 00170 00171 for(u32bit j = blocks; j != x_size; ++j) 00172 z[j] = word_madd2(x[j], y, &carry); 00173 00174 z[x_size] = carry; 00175 }
| void Botan::bigint_linmul_add | ( | word | [], | |
| u32bit | , | |||
| const | word[], | |||
| u32bit | , | |||
| word | ||||
| ) |
| word Botan::bigint_modop | ( | word | n1, | |
| word | n0, | |||
| word | d | |||
| ) |
Definition at line 84 of file mp_misc.cpp.
References bigint_divop(), and word_madd2().
Referenced by operator%(), and Botan::BigInt::operator%=().
00085 { 00086 word z = bigint_divop(n1, n0, d); 00087 word dummy = 0; 00088 z = word_madd2(z, d, &dummy); 00089 return (n0-z); 00090 }
| void Botan::bigint_monty_redc | ( | word | z[], | |
| u32bit | z_size, | |||
| const word | x[], | |||
| u32bit | x_size, | |||
| word | u | |||
| ) |
Definition at line 20 of file mp_monty.cpp.
References word8_madd3(), word8_sub2(), word_madd3(), and word_sub().
00022 { 00023 const u32bit blocks_of_8 = x_size - (x_size % 8); 00024 00025 for(u32bit i = 0; i != x_size; ++i) 00026 { 00027 word* z_i = z + i; 00028 00029 const word y = z_i[0] * u; 00030 00031 word carry = 0; 00032 00033 for(u32bit j = 0; j != blocks_of_8; j += 8) 00034 carry = word8_madd3(z_i + j, x + j, y, carry); 00035 00036 for(u32bit j = blocks_of_8; j != x_size; ++j) 00037 z_i[j] = word_madd3(x[j], y, z_i[j], &carry); 00038 00039 word z_sum = z_i[x_size] + carry; 00040 carry = (z_sum < z_i[x_size]); 00041 z_i[x_size] = z_sum; 00042 00043 for(u32bit j = x_size + 1; carry && j != z_size - i; ++j) 00044 { 00045 ++z_i[j]; 00046 carry = !z_i[j]; 00047 } 00048 } 00049 00050 // Check if z[x_size...x_size+1] >= x[0...x_size] using bigint_cmp (inlined) 00051 if(!z[x_size + x_size]) 00052 { 00053 for(u32bit i = x_size; i > 0; --i) 00054 { 00055 if(z[x_size + i - 1] > x[i-1]) 00056 break; 00057 00058 if(z[x_size + i - 1] < x[i-1]) 00059 return; 00060 } 00061 } 00062 00063 // If the compare above is true, subtract using bigint_sub2 (inlined) 00064 word carry = 0; 00065 00066 for(u32bit i = 0; i != blocks_of_8; i += 8) 00067 carry = word8_sub2(z + x_size + i, x + i, carry); 00068 00069 for(u32bit i = blocks_of_8; i != x_size; ++i) 00070 z[x_size + i] = word_sub(z[x_size + i], x[i], &carry); 00071 00072 if(carry) 00073 --z[x_size+x_size]; 00074 }
| void Botan::bigint_mul | ( | word | z[], | |
| u32bit | z_size, | |||
| word | workspace[], | |||
| const word | x[], | |||
| u32bit | x_size, | |||
| u32bit | x_sw, | |||
| const word | y[], | |||
| u32bit | y_size, | |||
| u32bit | y_sw | |||
| ) |
Definition at line 244 of file mp_karat.cpp.
References bigint_comba_mul16(), bigint_comba_mul4(), bigint_comba_mul6(), bigint_comba_mul8(), bigint_linmul3(), bigint_simple_mul(), and clear_mem().
Referenced by Botan::Montgomery_Exponentiator::execute(), mul_add(), operator*(), Botan::BigInt::operator*=(), and Botan::Montgomery_Exponentiator::set_base().
00247 { 00248 if(x_sw == 1) 00249 { 00250 bigint_linmul3(z, y, y_sw, x[0]); 00251 } 00252 else if(y_sw == 1) 00253 { 00254 bigint_linmul3(z, x, x_sw, y[0]); 00255 } 00256 else if(x_sw <= 4 && x_size >= 4 && 00257 y_sw <= 4 && y_size >= 4 && z_size >= 8) 00258 { 00259 bigint_comba_mul4(z, x, y); 00260 } 00261 else if(x_sw <= 6 && x_size >= 6 && 00262 y_sw <= 6 && y_size >= 6 && z_size >= 12) 00263 { 00264 bigint_comba_mul6(z, x, y); 00265 } 00266 else if(x_sw <= 8 && x_size >= 8 && 00267 y_sw <= 8 && y_size >= 8 && z_size >= 16) 00268 { 00269 bigint_comba_mul8(z, x, y); 00270 } 00271 else if(x_sw <= 16 && x_size >= 16 && 00272 y_sw <= 16 && y_size >= 16 && z_size >= 32) 00273 { 00274 bigint_comba_mul16(z, x, y); 00275 } 00276 else if(x_sw < BOTAN_KARAT_MUL_THRESHOLD || y_sw < BOTAN_KARAT_MUL_THRESHOLD) 00277 bigint_simple_mul(z, x, x_sw, y, y_sw); 00278 else 00279 { 00280 const u32bit N = karatsuba_size(z_size, x_size, x_sw, y_size, y_sw); 00281 00282 if(N) 00283 { 00284 clear_mem(workspace, 2*N); 00285 karatsuba_mul(z, x, y, N, workspace); 00286 } 00287 else 00288 bigint_simple_mul(z, x, x_sw, y, y_sw); 00289 } 00290 }
| void Botan::bigint_shl1 | ( | word | x[], | |
| u32bit | x_size, | |||
| u32bit | word_shift, | |||
| u32bit | bit_shift | |||
| ) |
Definition at line 18 of file mp_shift.cpp.
References clear_mem(), and MP_WORD_BITS.
Referenced by Botan::BigInt::operator-=(), and Botan::BigInt::operator<<=().
00019 { 00020 if(word_shift) 00021 { 00022 for(u32bit j = 1; j != x_size + 1; ++j) 00023 x[(x_size - j) + word_shift] = x[x_size - j]; 00024 clear_mem(x, word_shift); 00025 } 00026 00027 if(bit_shift) 00028 { 00029 word carry = 0; 00030 for(u32bit j = word_shift; j != x_size + word_shift + 1; ++j) 00031 { 00032 word temp = x[j]; 00033 x[j] = (temp << bit_shift) | carry; 00034 carry = (temp >> (MP_WORD_BITS - bit_shift)); 00035 } 00036 } 00037 }
| void Botan::bigint_shl2 | ( | word | y[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| u32bit | word_shift, | |||
| u32bit | bit_shift | |||
| ) |
Definition at line 97 of file mp_shift.cpp.
References MP_WORD_BITS.
Referenced by operator-(), and operator<<().
00099 { 00100 for(u32bit j = 0; j != x_size; ++j) 00101 y[j + word_shift] = x[j]; 00102 if(bit_shift) 00103 { 00104 word carry = 0; 00105 for(u32bit j = word_shift; j != x_size + word_shift + 1; ++j) 00106 { 00107 word w = y[j]; 00108 y[j] = (w << bit_shift) | carry; 00109 carry = (w >> (MP_WORD_BITS - bit_shift)); 00110 } 00111 } 00112 }
| void Botan::bigint_shr1 | ( | word | x[], | |
| u32bit | x_size, | |||
| u32bit | word_shift, | |||
| u32bit | bit_shift | |||
| ) |
Definition at line 42 of file mp_shift.cpp.
References clear_mem(), copy_mem(), and MP_WORD_BITS.
Referenced by Botan::BigInt::operator>>=().
00043 { 00044 if(x_size < word_shift) 00045 { 00046 clear_mem(x, x_size); 00047 return; 00048 } 00049 00050 if(word_shift) 00051 { 00052 copy_mem(x, x + word_shift, x_size - word_shift); 00053 clear_mem(x + x_size - word_shift, word_shift); 00054 } 00055 00056 if(bit_shift) 00057 { 00058 word carry = 0; 00059 00060 u32bit top = x_size - word_shift; 00061 00062 while(top >= 4) 00063 { 00064 word w = x[top-1]; 00065 x[top-1] = (w >> bit_shift) | carry; 00066 carry = (w << (MP_WORD_BITS - bit_shift)); 00067 00068 w = x[top-2]; 00069 x[top-2] = (w >> bit_shift) | carry; 00070 carry = (w << (MP_WORD_BITS - bit_shift)); 00071 00072 w = x[top-3]; 00073 x[top-3] = (w >> bit_shift) | carry; 00074 carry = (w << (MP_WORD_BITS - bit_shift)); 00075 00076 w = x[top-4]; 00077 x[top-4] = (w >> bit_shift) | carry; 00078 carry = (w << (MP_WORD_BITS - bit_shift)); 00079 00080 top -= 4; 00081 } 00082 00083 while(top) 00084 { 00085 word w = x[top-1]; 00086 x[top-1] = (w >> bit_shift) | carry; 00087 carry = (w << (MP_WORD_BITS - bit_shift)); 00088 00089 top--; 00090 } 00091 } 00092 }
| void Botan::bigint_shr2 | ( | word | y[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| u32bit | word_shift, | |||
| u32bit | bit_shift | |||
| ) |
Definition at line 117 of file mp_shift.cpp.
References MP_WORD_BITS.
Referenced by operator>>().
00119 { 00120 if(x_size < word_shift) return; 00121 00122 for(u32bit j = 0; j != x_size - word_shift; ++j) 00123 y[j] = x[j + word_shift]; 00124 if(bit_shift) 00125 { 00126 word carry = 0; 00127 for(u32bit j = x_size - word_shift; j > 0; --j) 00128 { 00129 word w = y[j-1]; 00130 y[j-1] = (w >> bit_shift) | carry; 00131 carry = (w << (MP_WORD_BITS - bit_shift)); 00132 } 00133 } 00134 }
| void Botan::bigint_simple_mul | ( | word | z[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 20 of file mp_mulop.cpp.
References clear_mem(), word8_madd3(), and word_madd3().
Referenced by bigint_mul().
00022 { 00023 const u32bit blocks = x_size - (x_size % 8); 00024 00025 clear_mem(z, x_size + y_size); 00026 00027 for(u32bit i = 0; i != y_size; ++i) 00028 { 00029 word carry = 0; 00030 00031 for(u32bit j = 0; j != blocks; j += 8) 00032 carry = word8_madd3(z + i + j, x + j, y[i], carry); 00033 00034 for(u32bit j = blocks; j != x_size; ++j) 00035 z[i+j] = word_madd3(x[j], y[i], z[i+j], &carry); 00036 00037 z[x_size+i] = carry; 00038 } 00039 }
| void Botan::bigint_simple_sqr | ( | word | z[], | |
| const word | x[], | |||
| u32bit | x_size | |||
| ) |
Definition at line 54 of file mp_mulop.cpp.
References clear_mem(), word8_madd3(), and word_madd3().
Referenced by bigint_sqr().
00055 { 00056 const u32bit x_size_8 = x_size - (x_size % 8); 00057 00058 clear_mem(z, 2*x_size); 00059 00060 for(u32bit i = 0; i != x_size; ++i) 00061 { 00062 const word x_i = x[i]; 00063 word carry = 0; 00064 00065 for(u32bit j = 0; j != x_size_8; j += 8) 00066 carry = word8_madd3(z + i + j, x + j, x_i, carry); 00067 00068 for(u32bit j = x_size_8; j != x_size; ++j) 00069 z[i+j] = word_madd3(x[j], x_i, z[i+j], &carry); 00070 00071 z[x_size+i] = carry; 00072 } 00073 }
| void Botan::bigint_sqr | ( | word | z[], | |
| u32bit | z_size, | |||
| word | workspace[], | |||
| const word | x[], | |||
| u32bit | x_size, | |||
| u32bit | x_sw | |||
| ) |
Definition at line 295 of file mp_karat.cpp.
References bigint_comba_sqr16(), bigint_comba_sqr4(), bigint_comba_sqr6(), bigint_comba_sqr8(), bigint_linmul3(), bigint_simple_sqr(), and clear_mem().
Referenced by Botan::Montgomery_Exponentiator::execute(), and square().
00297 { 00298 if(x_sw == 1) 00299 { 00300 bigint_linmul3(z, x, x_sw, x[0]); 00301 } 00302 else if(x_sw <= 4 && x_size >= 4 && z_size >= 8) 00303 { 00304 bigint_comba_sqr4(z, x); 00305 } 00306 else if(x_sw <= 6 && x_size >= 6 && z_size >= 12) 00307 { 00308 bigint_comba_sqr6(z, x); 00309 } 00310 else if(x_sw <= 8 && x_size >= 8 && z_size >= 16) 00311 { 00312 bigint_comba_sqr8(z, x); 00313 } 00314 else if(x_sw <= 16 && x_size >= 16 && z_size >= 32) 00315 { 00316 bigint_comba_sqr16(z, x); 00317 } 00318 else if(x_size < BOTAN_KARAT_SQR_THRESHOLD) 00319 { 00320 bigint_simple_sqr(z, x, x_sw); 00321 } 00322 else 00323 { 00324 const u32bit N = karatsuba_size(z_size, x_size, x_sw); 00325 00326 if(N) 00327 { 00328 clear_mem(workspace, 2*N); 00329 karatsuba_sqr(z, x, N, workspace); 00330 } 00331 else 00332 bigint_simple_sqr(z, x, x_sw); 00333 } 00334 }
| void Botan::bigint_sub2 | ( | word | x[], | |
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 95 of file mp_asm.cpp.
References MP_WORD_MAX, word8_sub2(), and word_sub().
Referenced by Botan::BigInt::operator+=(), and Botan::BigInt::operator-=().
00096 { 00097 word carry = 0; 00098 00099 const u32bit blocks = y_size - (y_size % 8); 00100 00101 for(u32bit j = 0; j != blocks; j += 8) 00102 carry = word8_sub2(x + j, y + j, carry); 00103 00104 for(u32bit j = blocks; j != y_size; ++j) 00105 x[j] = word_sub(x[j], y[j], &carry); 00106 00107 if(!carry) return; 00108 00109 for(u32bit j = y_size; j != x_size; ++j) 00110 { 00111 --x[j]; 00112 if(x[j] != MP_WORD_MAX) return; 00113 } 00114 }
| void Botan::bigint_sub3 | ( | word | z[], | |
| const word | x[], | |||
| u32bit | x_size, | |||
| const word | y[], | |||
| u32bit | y_size | |||
| ) |
Definition at line 119 of file mp_asm.cpp.
References MP_WORD_MAX, word8_sub3(), and word_sub().
Referenced by operator+(), Botan::BigInt::operator+=(), operator-(), and Botan::BigInt::operator-=().
00121 { 00122 word carry = 0; 00123 00124 const u32bit blocks = y_size - (y_size % 8); 00125 00126 for(u32bit j = 0; j != blocks; j += 8) 00127 carry = word8_sub3(z + j, x + j, y + j, carry); 00128 00129 for(u32bit j = blocks; j != y_size; ++j) 00130 z[j] = word_sub(x[j], y[j], &carry); 00131 00132 for(u32bit j = y_size; j != x_size; ++j) 00133 { 00134 word x_j = x[j] - carry; 00135 if(carry && x_j != MP_WORD_MAX) 00136 carry = 0; 00137 z[j] = x_j; 00138 } 00139 }
| void Botan::bigint_wordmul | ( | word | , | |
| word | , | |||
| word * | , | |||
| word * | ||||
| ) |
| BOTAN_DLL u32bit Botan::block_size_of | ( | const std::string & | name | ) |
Query the block size of a cipher or hash
Find out the block size of a certain symmetric algorithm.
| name | the name of the algorithm |
Definition at line 35 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), Botan::Algorithm_Factory::prototype_block_cipher(), and Botan::Algorithm_Factory::prototype_hash_function().
00036 { 00037 Algorithm_Factory& af = global_state().algorithm_factory(); 00038 00039 if(const BlockCipher* cipher = af.prototype_block_cipher(name)) 00040 return cipher->BLOCK_SIZE; 00041 00042 if(const HashFunction* hash = af.prototype_hash_function(name)) 00043 return hash->HASH_BLOCK_SIZE; 00044 00045 throw Algorithm_Not_Found(name); 00046 }
| void Botan::botan_md4_ia32_compress | ( | u32bit | [4], | |
| const | byte[64], | |||
| u32bit | [16] | |||
| ) |
| void Botan::botan_serpent_ia32_decrypt | ( | const | byte[16], | |
| byte | [16], | |||
| const | u32bit[132] | |||
| ) |
Referenced by Botan::Serpent_IA32::decrypt_n().
| void Botan::botan_serpent_ia32_encrypt | ( | const | byte[16], | |
| byte | [16], | |||
| const | u32bit[132] | |||
| ) |
Referenced by Botan::Serpent_IA32::encrypt_n().
| void Botan::botan_serpent_ia32_key_schedule | ( | u32bit | [140] | ) |
| void Botan::bswap_4 | ( | T | x[4] | ) | [inline] |
Definition at line 73 of file bswap.h.
References reverse_bytes().
Referenced by load_be(), and load_le().
00074 { 00075 x[0] = reverse_bytes(x[0]); 00076 x[1] = reverse_bytes(x[1]); 00077 x[2] = reverse_bytes(x[2]); 00078 x[3] = reverse_bytes(x[3]); 00079 }
| BOTAN_DLL calendar_point Botan::calendar_value | ( | u64bit | time_point | ) |
| time_point | a time point from the system clock |
Definition at line 81 of file time.cpp.
Referenced by Botan::EAC_Time::EAC_Time(), and Botan::X509_Time::X509_Time().
00082 { 00083 std::tm tm = do_gmtime(static_cast<std::time_t>(a_time_t)); 00084 00085 return calendar_point(tm.tm_year + 1900, 00086 tm.tm_mon + 1, 00087 tm.tm_mday, 00088 tm.tm_hour, 00089 tm.tm_min, 00090 tm.tm_sec); 00091 }
| bool BOTAN_DLL Botan::check_prime | ( | const BigInt & | n, | |
| RandomNumberGenerator & | rng | |||
| ) |
Definition at line 229 of file numthry.cpp.
References run_primality_tests().
Referenced by Botan::IF_Scheme_PrivateKey::check_key(), and Botan::DL_Group::verify_group().
00230 { 00231 return run_primality_tests(rng, n, 0); 00232 }
| BOTAN_DLL PK_Signer * Botan::choose_sig_format | ( | const Private_Key & | key, | |
| const std::string & | hash_fn, | |||
| AlgorithmIdentifier & | alg_id | |||
| ) |
Choose the default signature format for a certain public key signature scheme.
| key | will be the key to choose a padding scheme for | |
| hash_fn | is the desired hash function | |
| alg_id | will be set to the chosen scheme |
Definition at line 247 of file x509_ca.cpp.
References Botan::Public_Key::algo_name(), algo_name, DER_SEQUENCE, get_pk_signer(), IEEE_1363, Botan::OIDS::lookup(), Botan::Public_Key::max_input_bits(), Botan::Public_Key::message_parts(), Botan::HashFunction::name(), Botan::AlgorithmIdentifier::oid, Botan::BufferedComputation::OUTPUT_LENGTH, Botan::AlgorithmIdentifier::parameters, retrieve_hash(), and Botan::Public_Key::x509_encoder().
Referenced by Botan::X509::create_cert_req(), Botan::X509::create_self_signed_cert(), and Botan::X509_CA::X509_CA().
00250 { 00251 std::string padding; 00252 00253 const std::string algo_name = key.algo_name(); 00254 00255 const HashFunction* proto_hash = retrieve_hash(hash_fn); 00256 if(!proto_hash) 00257 throw Algorithm_Not_Found(hash_fn); 00258 00259 if(key.max_input_bits() < proto_hash->OUTPUT_LENGTH*8) 00260 throw Invalid_Argument("Key is too small for chosen hash function"); 00261 00262 if(algo_name == "RSA") 00263 padding = "EMSA3"; 00264 else if(algo_name == "DSA") 00265 padding = "EMSA1"; 00266 else if(algo_name == "ECDSA") 00267 padding = "EMSA1_BSI"; 00268 else 00269 throw Invalid_Argument("Unknown X.509 signing key type: " + algo_name); 00270 00271 Signature_Format format = 00272 (key.message_parts() > 1) ? DER_SEQUENCE : IEEE_1363; 00273 00274 padding = padding + '(' + proto_hash->name() + ')'; 00275 00276 sig_algo.oid = OIDS::lookup(algo_name + "/" + padding); 00277 00278 std::auto_ptr<X509_Encoder> encoding(key.x509_encoder()); 00279 if(!encoding.get()) 00280 throw Encoding_Error("Key " + algo_name + " does not support " 00281 "X.509 encoding"); 00282 00283 sig_algo.parameters = encoding->alg_id().parameters; 00284 00285 const PK_Signing_Key& sig_key = dynamic_cast<const PK_Signing_Key&>(key); 00286 00287 return get_pk_signer(sig_key, padding, format); 00288 }
| void Botan::clear_mem | ( | T * | ptr, | |
| u32bit | n | |||
| ) | [inline] |
Definition at line 22 of file mem_ops.h.
Referenced by bigint_mul(), bigint_shl1(), bigint_shr1(), bigint_simple_mul(), bigint_simple_sqr(), bigint_sqr(), Botan::MemoryRegion< byte >::clear(), Botan::GOST_34_11::final_result(), Botan::MemoryRegion< T >::grow_to(), Botan::AllOrNothingTransform::package(), and Botan::Unix_EntropySource::poll().
| BOTAN_DLL void Botan::confirm_startup_self_tests | ( | Algorithm_Factory & | af | ) |
Definition at line 217 of file selftest.cpp.
Referenced by Botan::Library_State::initialize(), and passes_self_tests().
00218 { 00219 cipher_kat(af, "DES", 00220 "0123456789ABCDEF", "1234567890ABCDEF", 00221 "4E6F77206973207468652074696D6520666F7220616C6C20", 00222 "3FA40E8A984D48156A271787AB8883F9893D51EC4B563B53", 00223 "E5C7CDDE872BF27C43E934008C389C0F683788499A7C05F6", 00224 "F3096249C7F46E51A69E839B1A92F78403467133898EA622", 00225 "F3096249C7F46E5135F24A242EEB3D3F3D6D5BE3255AF8C3", 00226 "F3096249C7F46E51163A8CA0FFC94C27FA2F80F480B86F75"); 00227 00228 cipher_kat(af, "TripleDES", 00229 "385D7189A5C3D485E1370AA5D408082B5CCCCB5E19F2D90E", 00230 "C141B5FCCD28DC8A", 00231 "6E1BD7C6120947A464A6AAB293A0F89A563D8D40D3461B68", 00232 "64EAAD4ACBB9CEAD6C7615E7C7E4792FE587D91F20C7D2F4", 00233 "6235A461AFD312973E3B4F7AA7D23E34E03371F8E8C376C9", 00234 "E26BA806A59B0330DE40CA38E77A3E494BE2B212F6DD624B", 00235 "E26BA806A59B03307DE2BCC25A08BA40A8BA335F5D604C62", 00236 "E26BA806A59B03303C62C2EFF32D3ACDD5D5F35EBCC53371"); 00237 00238 cipher_kat(af, "AES-128", 00239 "2B7E151628AED2A6ABF7158809CF4F3C", 00240 "000102030405060708090A0B0C0D0E0F", 00241 "6BC1BEE22E409F96E93D7E117393172A" 00242 "AE2D8A571E03AC9C9EB76FAC45AF8E51", 00243 "3AD77BB40D7A3660A89ECAF32466EF97" 00244 "F5D3D58503B9699DE785895A96FDBAAF", 00245 "7649ABAC8119B246CEE98E9B12E9197D" 00246 "5086CB9B507219EE95DB113A917678B2", 00247 "3B3FD92EB72DAD20333449F8E83CFB4A" 00248 "C8A64537A0B3A93FCDE3CDAD9F1CE58B", 00249 "3B3FD92EB72DAD20333449F8E83CFB4A" 00250 "7789508D16918F03F53C52DAC54ED825", 00251 "3B3FD92EB72DAD20333449F8E83CFB4A" 00252 "010C041999E03F36448624483E582D0E"); 00253 00254 hash_test(af, "SHA-1", 00255 "", "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"); 00256 00257 hash_test(af, "SHA-1", 00258 "616263", "A9993E364706816ABA3E25717850C26C9CD0D89D"); 00259 00260 hash_test(af, "SHA-1", 00261 "6162636462636465636465666465666765666768666768696768696A" 00262 "68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071", 00263 "84983E441C3BD26EBAAE4AA1F95129E5E54670F1"); 00264 00265 mac_test(af, "HMAC(SHA-1)", 00266 "4869205468657265", 00267 "B617318655057264E28BC0B6FB378C8EF146BE00", 00268 "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); 00269 00270 hash_test(af, "SHA-256", 00271 "", 00272 "E3B0C44298FC1C149AFBF4C8996FB924" 00273 "27AE41E4649B934CA495991B7852B855"); 00274 00275 hash_test(af, "SHA-256", 00276 "616263", 00277 "BA7816BF8F01CFEA414140DE5DAE2223" 00278 "B00361A396177A9CB410FF61F20015AD"); 00279 00280 hash_test(af, "SHA-256", 00281 "6162636462636465636465666465666765666768666768696768696A" 00282 "68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071", 00283 "248D6A61D20638B8E5C026930C3E6039" 00284 "A33CE45964FF2167F6ECEDD419DB06C1"); 00285 00286 mac_test(af, "HMAC(SHA-256)", 00287 "4869205468657265", 00288 "198A607EB44BFBC69903A0F1CF2BBDC5" 00289 "BA0AA3F3D9AE3C1C7A3B1696A0B68CF7", 00290 "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B" 00291 "0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"); 00292 }
| OutputIterator Botan::copy_if | ( | InputIterator | current, | |
| InputIterator | end, | |||
| OutputIterator | dest, | |||
| Predicate | copy_p | |||
| ) | [inline] |
Definition at line 19 of file stl_util.h.
00021 { 00022 while(current != end) 00023 { 00024 if(copy_p(*current)) 00025 *dest++ = *current; 00026 ++current; 00027 } 00028 return dest; 00029 }
| void Botan::copy_mem | ( | T * | out, | |
| const T * | in, | |||
| u32bit | n | |||
| ) | [inline] |
Definition at line 19 of file mem_ops.h.
Referenced by bigint_shr1(), Botan::GOST_34_11::compress_n(), Botan::MemoryRegion< byte >::copy(), Botan::GOST_34_11::final_result(), Botan::MemoryRegion< T >::grow_to(), Botan::BigInt::operator+=(), Botan::BigInt::operator-=(), Botan::AllOrNothingTransform::package(), Botan::SecureQueueNode::peek(), Botan::DataSource_Memory::peek(), Botan::ANSI_X931_RNG::randomize(), Botan::Randpool::randomize(), Botan::HMAC_RNG::randomize(), Botan::SecureQueueNode::read(), Botan::DataSource_Memory::read(), Botan::AllOrNothingTransform::unpackage(), Botan::SecureQueueNode::write(), and Botan::Buffered_Filter::write().
| BOTAN_DLL AlternativeName Botan::create_alt_name | ( | const Data_Store & | info | ) |
Definition at line 333 of file x509cert.cpp.
References Botan::AlternativeName::add_attribute(), Botan::PEM_Code::matches(), Botan::Data_Store::search_with(), and split_on().
Referenced by Botan::PKCS10_Request::subject_alt_name().
00334 { 00335 class AltName_Matcher : public Data_Store::Matcher 00336 { 00337 public: 00338 bool operator()(const std::string& key, const std::string&) const 00339 { 00340 for(u32bit j = 0; j != matches.size(); ++j) 00341 if(key.compare(matches[j]) == 0) 00342 return true; 00343 return false; 00344 } 00345 00346 AltName_Matcher(const std::string& match_any_of) 00347 { 00348 matches = split_on(match_any_of, '/'); 00349 } 00350 private: 00351 std::vector<std::string> matches; 00352 }; 00353 00354 std::multimap<std::string, std::string> names = 00355 info.search_with(AltName_Matcher("RFC822/DNS/URI/IP")); 00356 00357 AlternativeName alt_name; 00358 00359 std::multimap<std::string, std::string>::iterator j; 00360 for(j = names.begin(); j != names.end(); ++j) 00361 alt_name.add_attribute(j->first, j->second); 00362 00363 return alt_name; 00364 }
| BOTAN_DLL X509_DN Botan::create_dn | ( | const Data_Store & | info | ) |
Definition at line 305 of file x509cert.cpp.
References Botan::X509_DN::add_attribute(), and Botan::Data_Store::search_with().
Referenced by Botan::X509_Certificate::issuer_dn(), Botan::X509_CRL::issuer_dn(), Botan::X509_Certificate::subject_dn(), and Botan::PKCS10_Request::subject_dn().
00306 { 00307 class DN_Matcher : public Data_Store::Matcher 00308 { 00309 public: 00310 bool operator()(const std::string& key, const std::string&) const 00311 { 00312 if(key.find("X520.") != std::string::npos) 00313 return true; 00314 return false; 00315 } 00316 }; 00317 00318 std::multimap<std::string, std::string> names = 00319 info.search_with(DN_Matcher()); 00320 00321 X509_DN dn; 00322 00323 std::multimap<std::string, std::string>::iterator j; 00324 for(j = names.begin(); j != names.end(); ++j) 00325 dn.add_attribute(j->first, j->second); 00326 00327 return dn; 00328 }
| PointGFp BOTAN_DLL Botan::create_random_point | ( | RandomNumberGenerator & | rng, | |
| const CurveGFp & | curve | |||
| ) |
Definition at line 1117 of file point_gfp.cpp.
References Botan::BigInt::bits(), Botan::CurveGFp::get_a(), Botan::CurveGFp::get_b(), Botan::CurveGFp::get_p(), Botan::GFpElement::get_value(), Botan::BigInt::Negative, and ressol().
01119 { 01120 01121 // create a random point 01122 GFpElement mX(1,1); 01123 GFpElement mY(1,1); 01124 GFpElement mZ(1,1); 01125 GFpElement minusOne(curve.get_p(), BigInt(BigInt::Negative,1)); 01126 mY = minusOne; 01127 GFpElement y2(1,1); 01128 GFpElement x(1,1); 01129 01130 while (mY == minusOne) 01131 { 01132 BigInt value(rng, curve.get_p().bits()); 01133 mX = GFpElement(curve.get_p(),value); 01134 y2 = curve.get_a() * mX; 01135 x = mX * mX; 01136 x *= mX; 01137 y2 += (x + curve.get_b()); 01138 01139 value = ressol(y2.get_value(), curve.get_p()); 01140 01141 if(value < 0) 01142 mY = minusOne; 01143 else 01144 mY = GFpElement(curve.get_p(), value); 01145 } 01146 mZ = GFpElement(curve.get_p(), BigInt(1)); 01147 01148 return PointGFp(curve, mX, mY, mZ); 01149 }
| u32bit Botan::ctz | ( | T | n | ) | [inline] |
Definition at line 81 of file bit_ops.h.
Referenced by low_zero_bits().
00082 { 00083 for(u32bit i = 0; i != 8*sizeof(T); ++i) 00084 if((n >> i) & 0x01) 00085 return i; 00086 return 8*sizeof(T); 00087 }
| EC_Domain_Params BOTAN_DLL Botan::decode_ber_ec_dompar | ( | SecureVector< byte > const & | encoded | ) |
Definition at line 551 of file ec_dompar.cpp.
References Botan::OID::as_string(), Botan::BER_Decoder::get_next_object(), NULL_TAG, OBJECT_ID, SEQUENCE, and Botan::BER_Object::type_tag.
Referenced by Botan::EC_PrivateKey::pkcs8_decoder(), and Botan::EC_PublicKey::x509_decoder().
00552 { 00553 BER_Decoder dec(encoded); 00554 BER_Object obj = dec.get_next_object(); 00555 ASN1_Tag tag = obj.type_tag; 00556 std::auto_ptr<EC_Domain_Params> p_result; 00557 00558 if(tag == OBJECT_ID) 00559 { 00560 OID dom_par_oid; 00561 BER_Decoder(encoded).decode(dom_par_oid); 00562 return EC_Domain_Params(get_ec_dompar(dom_par_oid.as_string())); 00563 } 00564 else if(tag == SEQUENCE) 00565 return EC_Domain_Params(decode_ber_ec_dompar_explicit(encoded)); 00566 else if(tag == NULL_TAG) 00567 throw Decoding_Error("cannot decode ECDSA parameters that are ImplicitCA"); 00568 00569 throw Decoding_Error("encountered unexpected when trying to decode domain parameters"); 00570 }
| ECDSA_Signature const Botan::decode_concatenation | ( | MemoryRegion< byte > const & | concat | ) |
Definition at line 49 of file ecdsa_sig.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::BigInt::decode(), Botan::MemoryRegion< T >::set(), and Botan::MemoryRegion< T >::size().
Referenced by Botan::EAC1_1_gen_CVC< Derived >::decode_info().
00050 { 00051 if(concat.size() % 2 != 0) 00052 throw Invalid_Argument("Erroneous length of signature"); 00053 00054 u32bit rs_len = concat.size()/2; 00055 SecureVector<byte> sv_r; 00056 SecureVector<byte> sv_s; 00057 sv_r.set(concat.begin(), rs_len); 00058 sv_s.set(&concat[rs_len], rs_len); 00059 BigInt r = BigInt::decode(sv_r, sv_r.size()); 00060 BigInt s = BigInt::decode(sv_s, sv_s.size()); 00061 return ECDSA_Signature(r, s); 00062 }
| ECDSA_Signature const Botan::decode_seq | ( | MemoryRegion< byte > const & | seq | ) |
Definition at line 40 of file ecdsa_sig.cpp.
Referenced by Botan::EAC1_1_obj< Derived >::make_signature().
00041 { 00042 ECDSA_Signature sig; 00043 00044 std::auto_ptr<ECDSA_Signature_Decoder> dec(new ECDSA_Signature_Decoder(&sig)); 00045 dec->signature_bits(seq); 00046 return sig; 00047 }
| void Botan::delete2nd | ( | Pair & | pair | ) | [inline] |
| void BOTAN_DLL Botan::divide | ( | const BigInt & | x, | |
| const BigInt & | y_arg, | |||
| BigInt & | q, | |||
| BigInt & | r | |||
| ) |
Definition at line 34 of file divide.cpp.
References bigint_divcore(), bigint_divop(), Botan::BigInt::cmp(), Botan::BigInt::get_reg(), Botan::BigInt::is_negative(), Botan::BigInt::is_zero(), MP_WORD_BITS, MP_WORD_MAX, MP_WORD_TOP_BIT, Botan::BigInt::Positive, Botan::MemoryRegion< T >::resize(), Botan::BigInt::set_sign(), Botan::BigInt::sig_words(), and Botan::BigInt::word_at().
Referenced by Botan::BigInt::encode(), operator%(), and operator/().
00035 { 00036 if(y_arg.is_zero()) 00037 throw BigInt::DivideByZero(); 00038 00039 BigInt y = y_arg; 00040 const u32bit y_words = y.sig_words(); 00041 r = x; 00042 00043 r.set_sign(BigInt::Positive); 00044 y.set_sign(BigInt::Positive); 00045 00046 s32bit compare = r.cmp(y); 00047 00048 if(compare < 0) 00049 q = 0; 00050 else if(compare == 0) 00051 { 00052 q = 1; 00053 r = 0; 00054 } 00055 else 00056 { 00057 u32bit shifts = 0; 00058 word y_top = y[y.sig_words()-1]; 00059 while(y_top < MP_WORD_TOP_BIT) { y_top <<= 1; ++shifts; } 00060 y <<= shifts; 00061 r <<= shifts; 00062 00063 const u32bit n = r.sig_words() - 1, t = y_words - 1; 00064 00065 q.get_reg().resize(n - t + 1); 00066 if(n <= t) 00067 { 00068 while(r > y) { r -= y; ++q; } 00069 r >>= shifts; 00070 sign_fixup(x, y_arg, q, r); 00071 return; 00072 } 00073 00074 BigInt temp = y << (MP_WORD_BITS * (n-t)); 00075 00076 while(r >= temp) { r -= temp; ++q[n-t]; } 00077 00078 for(u32bit j = n; j != t; --j) 00079 { 00080 const word x_j0 = r.word_at(j); 00081 const word x_j1 = r.word_at(j-1); 00082 const word y_t = y.word_at(t); 00083 00084 if(x_j0 == y_t) 00085 q[j-t-1] = MP_WORD_MAX; 00086 else 00087 q[j-t-1] = bigint_divop(x_j0, x_j1, y_t); 00088 00089 while(bigint_divcore(q[j-t-1], y_t, y.word_at(t-1), 00090 x_j0, x_j1, r.word_at(j-2))) 00091 --q[j-t-1]; 00092 00093 r -= (q[j-t-1] * y) << (MP_WORD_BITS * (j-t-1)); 00094 if(r.is_negative()) 00095 { 00096 r += y << (MP_WORD_BITS * (j-t-1)); 00097 --q[j-t-1]; 00098 } 00099 } 00100 r >>= shifts; 00101 } 00102 00103 sign_fixup(x, y_arg, q, r); 00104 }
| BOTAN_DLL u32bit Botan::dl_work_factor | ( | u32bit | bits | ) |
Definition at line 17 of file workfactor.cpp.
Referenced by Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DL_Group::DL_Group(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), and Botan::ElGamal_PublicKey::encrypt().
00018 { 00019 #if 0 00020 /* 00021 These values were taken from RFC 3526 00022 */ 00023 if(bits <= 1536) 00024 return 90; 00025 else if(bits <= 2048) 00026 return 110; 00027 else if(bits <= 3072) 00028 return 130; 00029 else if(bits <= 4096) 00030 return 150; 00031 else if(bits <= 6144) 00032 return 170; 00033 else if(bits <= 8192) 00034 return 190; 00035 return 256; 00036 #else 00037 const u32bit MIN_ESTIMATE = 64; 00038 00039 const double log_x = bits / 1.44; 00040 00041 const double strength = 00042 2.76 * std::pow(log_x, 1.0/3.0) * std::pow(std::log(log_x), 2.0/3.0); 00043 00044 if(strength > MIN_ESTIMATE) 00045 return static_cast<u32bit>(strength); 00046 return MIN_ESTIMATE; 00047 #endif 00048 }
| SecureVector< byte > BOTAN_DLL Botan::EC2OSP | ( | const PointGFp & | point, | |
| byte | format | |||
| ) |
Definition at line 906 of file point_gfp.cpp.
References Botan::PointGFp::COMPRESSED, encode_compressed(), encode_hybrid(), encode_uncompressed(), Botan::PointGFp::HYBRID, and Botan::PointGFp::UNCOMPRESSED.
Referenced by Botan::ECKAEG_PrivateKey::public_value(), and Botan::EC_PublicKey::x509_encoder().
00907 { 00908 SecureVector<byte> result; 00909 if (format == PointGFp::UNCOMPRESSED) 00910 { 00911 result = encode_uncompressed(point); 00912 } 00913 else if (format == PointGFp::COMPRESSED) 00914 { 00915 result = encode_compressed(point); 00916 00917 } 00918 else if (format == PointGFp::HYBRID) 00919 { 00920 result = encode_hybrid(point); 00921 } 00922 else 00923 { 00924 throw Invalid_Argument("illegal point encoding format specification"); 00925 } 00926 return result; 00927 }
| SecureVector< byte > BOTAN_DLL Botan::encode_compressed | ( | const PointGFp & | point | ) |
Definition at line 928 of file point_gfp.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::BigInt::bits(), Botan::MemoryRegion< T >::copy(), Botan::BigInt::encode_1363(), Botan::PointGFp::get_affine_x(), Botan::PointGFp::get_affine_y(), Botan::BigInt::get_bit(), Botan::PointGFp::get_curve(), Botan::CurveGFp::get_p(), Botan::GFpElement::get_value(), Botan::PointGFp::is_zero(), and Botan::MemoryRegion< T >::size().
Referenced by EC2OSP().
00929 { 00930 00931 00932 if (point.is_zero()) 00933 { 00934 SecureVector<byte> result (1); 00935 result[0] = 0; 00936 return result; 00937 00938 } 00939 u32bit l = point.get_curve().get_p().bits(); 00940 int dummy = l & 7; 00941 if (dummy != 0) 00942 { 00943 l += 8 - dummy; 00944 } 00945 l /= 8; 00946 SecureVector<byte> result (l+1); 00947 result[0] = 2; 00948 BigInt x = point.get_affine_x().get_value(); 00949 SecureVector<byte> bX = BigInt::encode_1363(x, l); 00950 result.copy(1, bX.begin(), bX.size()); 00951 BigInt y = point.get_affine_y().get_value(); 00952 if (y.get_bit(0)) 00953 { 00954 result[0] |= 1; 00955 } 00956 return result; 00957 }
| SecureVector< byte > BOTAN_DLL Botan::encode_der_ec_dompar | ( | EC_Domain_Params const & | dom_pars, | |
| EC_dompar_enc | enc_type | |||
| ) |
Definition at line 527 of file ec_dompar.cpp.
References ENC_EXPLICIT, ENC_IMPLICITCA, ENC_OID, and Botan::EC_Domain_Params::get_oid().
Referenced by Botan::EC_PrivateKey::pkcs8_encoder(), and Botan::EC_PublicKey::x509_encoder().
00528 { 00529 SecureVector<byte> result; 00530 00531 if(enc_type == ENC_EXPLICIT) 00532 { 00533 result = encode_der_ec_dompar_explicit(dom_pars); 00534 } 00535 else if(enc_type == ENC_OID) 00536 { 00537 OID dom_par_oid(dom_pars.get_oid()); 00538 result = DER_Encoder().encode(dom_par_oid).get_contents(); 00539 } 00540 else if(enc_type == ENC_IMPLICITCA) 00541 { 00542 result = DER_Encoder().encode_null().get_contents(); 00543 } 00544 else 00545 { 00546 throw Internal_Error("encountered illegal value for ec parameter encoding type"); 00547 } 00548 return result; 00549 }
| SecureVector< byte > BOTAN_DLL Botan::encode_hybrid | ( | const PointGFp & | point | ) |
Definition at line 987 of file point_gfp.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::BigInt::bits(), Botan::MemoryRegion< T >::copy(), Botan::BigInt::encode_1363(), Botan::PointGFp::get_affine_x(), Botan::PointGFp::get_affine_y(), Botan::BigInt::get_bit(), Botan::PointGFp::get_curve(), Botan::CurveGFp::get_p(), Botan::GFpElement::get_value(), Botan::PointGFp::is_zero(), and Botan::MemoryRegion< T >::size().
Referenced by EC2OSP().
00988 { 00989 if (point.is_zero()) 00990 { 00991 SecureVector<byte> result (1); 00992 result[0] = 0; 00993 return result; 00994 } 00995 u32bit l = point.get_curve().get_p().bits(); 00996 int dummy = l & 7; 00997 if (dummy != 0) 00998 { 00999 l += 8 - dummy; 01000 } 01001 l /= 8; 01002 SecureVector<byte> result (2*l+1); 01003 result[0] = 6; 01004 BigInt x = point.get_affine_x().get_value(); 01005 BigInt y = point.get_affine_y().get_value(); 01006 SecureVector<byte> bX = BigInt::encode_1363(x, l); 01007 SecureVector<byte> bY = BigInt::encode_1363(y, l); 01008 result.copy(1, bX.begin(), bX.size()); 01009 result.copy(l+1, bY.begin(), bY.size()); 01010 if (y.get_bit(0)) 01011 { 01012 result[0] |= 1; 01013 } 01014 return result; 01015 }
| SecureVector< byte > BOTAN_DLL Botan::encode_uncompressed | ( | const PointGFp & | point | ) |
Definition at line 960 of file point_gfp.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::BigInt::bits(), Botan::MemoryRegion< T >::copy(), Botan::BigInt::encode_1363(), Botan::PointGFp::get_affine_x(), Botan::PointGFp::get_affine_y(), Botan::PointGFp::get_curve(), Botan::CurveGFp::get_p(), Botan::GFpElement::get_value(), and Botan::PointGFp::is_zero().
Referenced by EC2OSP().
00961 { 00962 if (point.is_zero()) 00963 { 00964 SecureVector<byte> result (1); 00965 result[0] = 0; 00966 return result; 00967 } 00968 u32bit l = point.get_curve().get_p().bits(); 00969 int dummy = l & 7; 00970 if (dummy != 0) 00971 { 00972 l += 8 - dummy; 00973 } 00974 l /= 8; 00975 SecureVector<byte> result (2*l+1); 00976 result[0] = 4; 00977 BigInt x = point.get_affine_x().get_value(); 00978 BigInt y = point.get_affine_y().get_value(); 00979 SecureVector<byte> bX = BigInt::encode_1363(x, l); 00980 SecureVector<byte> bY = BigInt::encode_1363(y, l); 00981 result.copy(1, bX.begin(), l); 00982 result.copy(l+1, bY.begin(), l); 00983 return result; 00984 00985 }
| SecureVector< byte > BOTAN_DLL Botan::FE2OSP | ( | const GFpElement & | elem | ) |
Definition at line 681 of file gfp_element.cpp.
References Botan::BigInt::bytes(), Botan::BigInt::encode_1363(), Botan::GFpElement::get_p(), and Botan::GFpElement::get_value().
Referenced by Botan::Default_ECKAEG_Op::agree().
| BigInt BOTAN_DLL Botan::fpe_decrypt | ( | const BigInt & | n, | |
| const BigInt & | X0, | |||
| const SymmetricKey & | key, | |||
| const MemoryRegion< byte > & | tweak | |||
| ) |
Generic Z_n FPE decryption, FD1 scheme
Definition at line 170 of file fpe.cpp.
00173 { 00174 FPE_Encryptor F(key, n, tweak); 00175 00176 BigInt a, b; 00177 factor(n, a, b); 00178 00179 const u32bit r = rounds(a, b); 00180 00181 BigInt X = X0; 00182 00183 for(u32bit i = 0; i != r; ++i) 00184 { 00185 BigInt W = X % a; 00186 BigInt R = X / a; 00187 00188 BigInt L = (W - F(r-i-1, R)) % a; 00189 X = b * L + R; 00190 } 00191 00192 return X; 00193 }
| BigInt BOTAN_DLL Botan::fpe_encrypt | ( | const BigInt & | n, | |
| const BigInt & | X0, | |||
| const SymmetricKey & | key, | |||
| const MemoryRegion< byte > & | tweak | |||
| ) |
Generic Z_n FPE encryption, FE1 scheme
Definition at line 142 of file fpe.cpp.
00145 { 00146 FPE_Encryptor F(key, n, tweak); 00147 00148 BigInt a, b; 00149 factor(n, a, b); 00150 00151 const u32bit r = rounds(a, b); 00152 00153 BigInt X = X0; 00154 00155 for(u32bit i = 0; i != r; ++i) 00156 { 00157 BigInt L = X / b; 00158 BigInt R = X % b; 00159 00160 BigInt W = (L + F(i, R)) % a; 00161 X = a * R + W; 00162 } 00163 00164 return X; 00165 }
| BigInt BOTAN_DLL Botan::gcd | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) |
Definition at line 103 of file numthry.cpp.
References Botan::BigInt::is_nonzero(), Botan::BigInt::is_zero(), low_zero_bits(), Botan::BigInt::Positive, and Botan::BigInt::set_sign().
Referenced by lcm(), random_prime(), and simple_primality_tests().
00104 { 00105 if(a.is_zero() || b.is_zero()) return 0; 00106 if(a == 1 || b == 1) return 1; 00107 00108 BigInt x = a, y = b; 00109 x.set_sign(BigInt::Positive); 00110 y.set_sign(BigInt::Positive); 00111 u32bit shift = std::min(low_zero_bits(x), low_zero_bits(y)); 00112 00113 x >>= shift; 00114 y >>= shift; 00115 00116 while(x.is_nonzero()) 00117 { 00118 x >>= low_zero_bits(x); 00119 y >>= low_zero_bits(y); 00120 if(x >= y) { x -= y; x >>= 1; } 00121 else { y -= x; y >>= 1; } 00122 } 00123 00124 return (y << shift); 00125 }
| SecureVector< byte > BOTAN_DLL Botan::generate_dsa_primes | ( | RandomNumberGenerator & | rng, | |
| Algorithm_Factory & | af, | |||
| BigInt & | p, | |||
| BigInt & | q, | |||
| u32bit | pbits, | |||
| u32bit | qbits | |||
| ) |
Definition at line 119 of file dsa_gen.cpp.
References generate_dsa_primes(), Botan::RandomNumberGenerator::randomize(), and Botan::MemoryRegion< T >::size().
00123 { 00124 SecureVector<byte> seed(qbits/8); 00125 00126 while(true) 00127 { 00128 rng.randomize(seed, seed.size()); 00129 00130 if(generate_dsa_primes(rng, af, p, q, pbits, qbits, seed)) 00131 return seed; 00132 } 00133 }
| bool BOTAN_DLL Botan::generate_dsa_primes | ( | RandomNumberGenerator & | rng, | |
| Algorithm_Factory & | af, | |||
| BigInt & | p, | |||
| BigInt & | q, | |||
| u32bit | pbits, | |||
| u32bit | qbits, | |||
| const MemoryRegion< byte > & | seed_c | |||
| ) |
Definition at line 41 of file dsa_gen.cpp.
References Botan::BigInt::binary_decode(), Botan::BigInt::bits(), is_prime(), Botan::Algorithm_Factory::make_hash_function(), Botan::BigInt::set_bit(), Botan::MemoryRegion< T >::size(), and to_string().
Referenced by Botan::DL_Group::DL_Group(), and generate_dsa_primes().
00046 { 00047 if(!fips186_3_valid_size(pbits, qbits)) 00048 throw Invalid_Argument( 00049 "FIPS 186-3 does not allow DSA domain parameters of " + 00050 to_string(pbits) + "/" + to_string(qbits) + " bits long"); 00051 00052 if(seed_c.size() * 8 < qbits) 00053 throw Invalid_Argument( 00054 "Generating a DSA parameter set with a " + to_string(qbits) + 00055 "long q requires a seed at least as many bits long"); 00056 00057 std::auto_ptr<HashFunction> hash( 00058 af.make_hash_function("SHA-" + to_string(qbits))); 00059 00060 const u32bit HASH_SIZE = hash->OUTPUT_LENGTH; 00061 00062 class Seed 00063 { 00064 public: 00065 Seed(const MemoryRegion<byte>& s) : seed(s) {} 00066 00067 operator MemoryRegion<byte>& () { return seed; } 00068 00069 Seed& operator++() 00070 { 00071 for(u32bit j = seed.size(); j > 0; --j) 00072 if(++seed[j-1]) 00073 break; 00074 return (*this); 00075 } 00076 private: 00077 SecureVector<byte> seed; 00078 }; 00079 00080 Seed seed(seed_c); 00081 00082 q.binary_decode(hash->process(seed)); 00083 q.set_bit(qbits-1); 00084 q.set_bit(0); 00085 00086 if(!is_prime(q, rng)) 00087 return false; 00088 00089 const u32bit n = (pbits-1) / (HASH_SIZE * 8), 00090 b = (pbits-1) % (HASH_SIZE * 8); 00091 00092 BigInt X; 00093 SecureVector<byte> V(HASH_SIZE * (n+1)); 00094 00095 for(u32bit j = 0; j != 4096; ++j) 00096 { 00097 for(u32bit k = 0; k <= n; ++k) 00098 { 00099 ++seed; 00100 hash->update(seed); 00101 hash->final(V + HASH_SIZE * (n-k)); 00102 } 00103 00104 X.binary_decode(V + (HASH_SIZE - 1 - b/8), 00105 V.size() - (HASH_SIZE - 1 - b/8)); 00106 X.set_bit(pbits-1); 00107 00108 p = X - (X % (2*q) - 1); 00109 00110 if(p.bits() == pbits && is_prime(p, rng)) 00111 return true; 00112 } 00113 return false; 00114 }
| BlockCipher* Botan::get_block_cipher | ( | const std::string & | algo_spec | ) | [inline] |
Block cipher factory method.
| algo_spec | the name of the desired block cipher |
Definition at line 67 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::make_block_cipher().
00068 { 00069 Algorithm_Factory& af = global_state().algorithm_factory(); 00070 return af.make_block_cipher(algo_spec); 00071 }
| byte Botan::get_byte | ( | u32bit | byte_num, | |
| T | input | |||
| ) | [inline] |
Definition at line 43 of file loadstor.h.
Referenced by Botan::BigInt::byte_at(), Botan::GOST_34_11::compress_n(), Botan::CryptoBox::decrypt(), Botan::Twofish::decrypt_n(), Botan::Square::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::DES::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::AES::decrypt_n(), Botan::KDF2::derive(), Botan::CryptoBox::encrypt(), Botan::Twofish::encrypt_n(), Botan::Square::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::DES::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::AES::encrypt_n(), ipv4_to_string(), Botan::MGF1::mask(), Botan::AllOrNothingTransform::package(), Botan::Turing::set_iv(), significant_bytes(), Botan::RTSS_Share::split(), store_be(), store_le(), and Botan::AllOrNothingTransform::unpackage().
00044 { 00045 return static_cast<byte>( 00046 input >> ((sizeof(T)-1-(byte_num&(sizeof(T)-1))) << 3) 00047 ); 00048 }
| BOTAN_DLL Keyed_Filter * Botan::get_cipher | ( | const std::string & | algo_spec, | |
| const SymmetricKey & | key, | |||
| Cipher_Dir | direction | |||
| ) |
Get a cipher object
Factory method for general symmetric cipher filters.
| algo_spec | the name of the desired cipher | |
| key | the key to be used for encryption/decryption performed by the filter | |
| direction | determines whether the filter will be an encrypting or decrypting filter |
Definition at line 179 of file lookup.cpp.
References get_cipher().
Referenced by make_filter3(), make_filter4(), and Py_Cipher::Py_Cipher().
00182 { 00183 return get_cipher(algo_spec, 00184 key, InitializationVector(), direction); 00185 }
| BOTAN_DLL Keyed_Filter * Botan::get_cipher | ( | const std::string & | algo_spec, | |
| const SymmetricKey & | key, | |||
| const InitializationVector & | iv, | |||
| Cipher_Dir | direction | |||
| ) |
Get a cipher object
Factory method for general symmetric cipher filters.
| algo_spec | the name of the desired cipher | |
| key | the key to be used for encryption/decryption performed by the filter | |
| iv | the initialization vector to be used | |
| direction | determines whether the filter will be an encrypting or decrypting filter |
Definition at line 162 of file lookup.cpp.
References get_cipher(), Botan::OctetString::length(), Botan::Keyed_Filter::set_iv(), and Botan::Keyed_Filter::set_key().
00166 { 00167 Keyed_Filter* cipher = get_cipher(algo_spec, direction); 00168 cipher->set_key(key); 00169 00170 if(iv.length()) 00171 cipher->set_iv(iv); 00172 00173 return cipher; 00174 }
| BOTAN_DLL Keyed_Filter * Botan::get_cipher | ( | const std::string & | algo_spec, | |
| Cipher_Dir | direction | |||
| ) |
Get a cipher object
Factory method for general symmetric cipher filters. No key will be set in the filter.
| algo_spec | the name of the desired cipher | |
| direction | determines whether the filter will be an encrypting or decrypting filter |
Definition at line 143 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::Algorithm_Factory::Engine_Iterator::next().
Referenced by Botan::CryptoBox::decrypt(), Botan::CryptoBox::encrypt(), and get_cipher().
00145 { 00146 Algorithm_Factory& af = global_state().algorithm_factory(); 00147 00148 Algorithm_Factory::Engine_Iterator i(af); 00149 00150 while(Engine* engine = i.next()) 00151 { 00152 if(Keyed_Filter* algo = engine->get_cipher(algo_spec, direction, af)) 00153 return algo; 00154 } 00155 00156 throw Algorithm_Not_Found(algo_spec); 00157 }
| Keyed_Filter * Botan::get_cipher_mode | ( | const BlockCipher * | block_cipher, | |
| Cipher_Dir | direction, | |||
| const std::string & | mode, | |||
| const std::string & | padding | |||
| ) |
Definition at line 77 of file def_mode.cpp.
References Botan::BlockCipher::BLOCK_SIZE, Botan::BlockCipher::clone(), ENCRYPTION, parse_algorithm_name(), and to_u32bit().
Referenced by algorithm_kat(), and Botan::Default_Engine::get_cipher().
00081 { 00082 #if defined(BOTAN_HAS_OFB) 00083 if(mode == "OFB") 00084 return new StreamCipher_Filter(new OFB(block_cipher->clone())); 00085 #endif 00086 00087 #if defined(BOTAN_HAS_CTR_BE) 00088 if(mode == "CTR-BE") 00089 return new StreamCipher_Filter(new CTR_BE(block_cipher->clone())); 00090 #endif 00091 00092 #if defined(BOTAN_HAS_ECB) 00093 if(mode == "ECB" || mode == "") 00094 { 00095 if(direction == ENCRYPTION) 00096 return new ECB_Encryption(block_cipher->clone(), 00097 get_bc_pad(padding, "NoPadding")); 00098 else 00099 return new ECB_Decryption(block_cipher->clone(), 00100 get_bc_pad(padding, "NoPadding")); 00101 } 00102 #endif 00103 00104 if(mode == "CBC") 00105 { 00106 if(padding == "CTS") 00107 { 00108 #if defined(BOTAN_HAS_CTS) 00109 if(direction == ENCRYPTION) 00110 return new CTS_Encryption(block_cipher->clone()); 00111 else 00112 return new CTS_Decryption(block_cipher->clone()); 00113 #else 00114 return 0; 00115 #endif 00116 } 00117 00118 #if defined(BOTAN_HAS_CBC) 00119 if(direction == ENCRYPTION) 00120 return new CBC_Encryption(block_cipher->clone(), 00121 get_bc_pad(padding, "PKCS7")); 00122 else 00123 return new CBC_Decryption(block_cipher->clone(), 00124 get_bc_pad(padding, "PKCS7")); 00125 #else 00126 return 0; 00127 #endif 00128 } 00129 00130 #if defined(BOTAN_HAS_XTS) 00131 if(mode == "XTS") 00132 { 00133 if(direction == ENCRYPTION) 00134 return new XTS_Encryption(block_cipher->clone()); 00135 else 00136 return new XTS_Decryption(block_cipher->clone()); 00137 } 00138 #endif 00139 00140 if(mode.find("CFB") != std::string::npos || 00141 mode.find("EAX") != std::string::npos) 00142 { 00143 u32bit bits = 0; 00144 00145 std::vector<std::string> algo_info = parse_algorithm_name(mode); 00146 std::string mode_name = algo_info[0]; 00147 if(algo_info.size() == 1) 00148 bits = 8*block_cipher->BLOCK_SIZE; 00149 else if(algo_info.size() == 2) 00150 bits = to_u32bit(algo_info[1]); 00151 else 00152 return 0; 00153 00154 #if defined(BOTAN_HAS_CFB) 00155 if(mode_name == "CFB") 00156 { 00157 if(direction == ENCRYPTION) 00158 return new CFB_Encryption(block_cipher->clone(), bits); 00159 else 00160 return new CFB_Decryption(block_cipher->clone(), bits); 00161 } 00162 #endif 00163 00164 #if defined(BOTAN_HAS_EAX) 00165 if(mode_name == "EAX") 00166 { 00167 if(direction == ENCRYPTION) 00168 return new EAX_Encryption(block_cipher->clone(), bits); 00169 else 00170 return new EAX_Decryption(block_cipher->clone(), bits); 00171 } 00172 #endif 00173 } 00174 00175 return 0; 00176 }
| EC_Domain_Params BOTAN_DLL Botan::get_EC_Dom_Pars_by_oid | ( | std::string | oid | ) |
Factory function, the only way to obtain EC domain parameters with an OID. The demanded OID has to be registered in the InSiTo configuration. Consult the file ec_dompar.cpp for the default configuration.
| oid | the oid of the demanded EC domain parameters |
Definition at line 438 of file ec_dompar.cpp.
References Botan::EC_Domain_Params::m_oid.
00439 { 00440 EC_Domain_Params result = get_ec_dompar(oid); 00441 result.m_oid = oid; 00442 return result; 00443 }
| BOTAN_DLL EME * Botan::get_eme | ( | const std::string & | algo_spec | ) |
Factory method for EME (message-encoding methods for encryption) objects
| name | the name of the EME to create |
Definition at line 170 of file get_enc.cpp.
References Botan::SCAN_Name::algo_name(), Botan::Library_State::algorithm_factory(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::SCAN_Name::arg_count_between(), global_state(), and Botan::Algorithm_Factory::make_hash_function().
Referenced by get_pk_decryptor(), and get_pk_encryptor().
00171 { 00172 SCAN_Name request(algo_spec); 00173 00174 Algorithm_Factory& af = global_state().algorithm_factory(); 00175 00176 if(request.algo_name() == "Raw") 00177 return 0; // No padding 00178 00179 #if defined(BOTAN_HAS_EME_PKCS1v15) 00180 if(request.algo_name() == "PKCS1v15" && request.arg_count() == 0) 00181 return new EME_PKCS1v15; 00182 #endif 00183 00184 #if defined(BOTAN_HAS_EME1) 00185 if(request.algo_name() == "EME1" && request.arg_count_between(1, 2)) 00186 { 00187 if(request.arg_count() == 1 || 00188 (request.arg_count() == 2 && request.arg(1) == "MGF1")) 00189 { 00190 return new EME1(af.make_hash_function(request.arg(0))); 00191 } 00192 } 00193 #endif 00194 00195 throw Algorithm_Not_Found(algo_spec); 00196 }
| BOTAN_DLL EMSA * Botan::get_emsa | ( | const std::string & | algo_spec | ) |
Factory method for EMSA (message-encoding methods for signatures with appendix) objects
| name | the name of the EME to create |
Definition at line 113 of file get_enc.cpp.
References Botan::SCAN_Name::algo_name(), Botan::Library_State::algorithm_factory(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_u32bit(), Botan::SCAN_Name::arg_count(), Botan::SCAN_Name::arg_count_between(), global_state(), and Botan::Algorithm_Factory::make_hash_function().
Referenced by get_pk_signer(), and get_pk_verifier().
00114 { 00115 SCAN_Name request(algo_spec); 00116 00117 Algorithm_Factory& af = global_state().algorithm_factory(); 00118 00119 #if defined(BOTAN_HAS_EMSA_RAW) 00120 if(request.algo_name() == "Raw" && request.arg_count() == 0) 00121 return new EMSA_Raw; 00122 #endif 00123 00124 #if defined(BOTAN_HAS_EMSA1) 00125 if(request.algo_name() == "EMSA1" && request.arg_count() == 1) 00126 return new EMSA1(af.make_hash_function(request.arg(0))); 00127 #endif 00128 00129 #if defined(BOTAN_HAS_EMSA1_BSI) 00130 if(request.algo_name() == "EMSA1_BSI" && request.arg_count() == 1) 00131 return new EMSA1_BSI(af.make_hash_function(request.arg(0))); 00132 #endif 00133 00134 #if defined(BOTAN_HAS_EMSA2) 00135 if(request.algo_name() == "EMSA2" && request.arg_count() == 1) 00136 return new EMSA2(af.make_hash_function(request.arg(0))); 00137 #endif 00138 00139 #if defined(BOTAN_HAS_EMSA3) 00140 if(request.algo_name() == "EMSA3" && request.arg_count() == 1) 00141 { 00142 if(request.arg(0) == "Raw") 00143 return new EMSA3_Raw; 00144 return new EMSA3(af.make_hash_function(request.arg(0))); 00145 } 00146 #endif 00147 00148 #if defined(BOTAN_HAS_EMSA4) 00149 if(request.algo_name() == "EMSA4" && request.arg_count_between(1, 3)) 00150 { 00151 // 3 args: Hash, MGF, salt size (MGF is hardcoded MGF1 in Botan) 00152 if(request.arg_count() == 1) 00153 return new EMSA4(af.make_hash_function(request.arg(0))); 00154 00155 if(request.arg_count() == 2 && request.arg(1) != "MGF1") 00156 return new EMSA4(af.make_hash_function(request.arg(0))); 00157 00158 if(request.arg_count() == 3) 00159 return new EMSA4(af.make_hash_function(request.arg(0)), 00160 request.arg_as_u32bit(2, 0)); 00161 } 00162 #endif 00163 00164 throw Algorithm_Not_Found(algo_spec); 00165 }
| HashFunction* Botan::get_hash | ( | const std::string & | algo_spec | ) | [inline] |
Hash function factory method.
| algo_spec | the name of the desired hash function |
Definition at line 89 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::make_hash_function().
Referenced by Py_HashFunction::Py_HashFunction(), and python_pbkdf2().
00090 { 00091 Algorithm_Factory& af = global_state().algorithm_factory(); 00092 return af.make_hash_function(algo_spec); 00093 }
| BOTAN_DLL KDF * Botan::get_kdf | ( | const std::string & | algo_spec | ) |
Factory method for KDF (key derivation function)
| name | the name of the KDF to create |
Definition at line 201 of file get_enc.cpp.
References Botan::SCAN_Name::algo_name(), Botan::Library_State::algorithm_factory(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), global_state(), and Botan::Algorithm_Factory::make_hash_function().
Referenced by get_pk_kas().
00202 { 00203 SCAN_Name request(algo_spec); 00204 00205 Algorithm_Factory& af = global_state().algorithm_factory(); 00206 00207 if(request.algo_name() == "Raw") 00208 return 0; // No KDF 00209 00210 #if defined(BOTAN_HAS_KDF1) 00211 if(request.algo_name() == "KDF1" && request.arg_count() == 1) 00212 return new KDF1(af.make_hash_function(request.arg(0))); 00213 #endif 00214 00215 #if defined(BOTAN_HAS_KDF2) 00216 if(request.algo_name() == "KDF2" && request.arg_count() == 1) 00217 return new KDF2(af.make_hash_function(request.arg(0))); 00218 #endif 00219 00220 #if defined(BOTAN_HAS_X942_PRF) 00221 if(request.algo_name() == "X9.42-PRF" && request.arg_count() == 1) 00222 return new X942_PRF(request.arg(0)); // OID 00223 #endif 00224 00225 #if defined(BOTAN_HAS_TLS_V10_PRF) 00226 if(request.algo_name() == "TLS-PRF" && request.arg_count() == 0) 00227 return new TLS_PRF; 00228 #endif 00229 00230 #if defined(BOTAN_HAS_SSL_V3_PRF) 00231 if(request.algo_name() == "SSL3-PRF" && request.arg_count() == 0) 00232 return new SSL3_PRF; 00233 #endif 00234 00235 throw Algorithm_Not_Found(algo_spec); 00236 }
| MessageAuthenticationCode* Botan::get_mac | ( | const std::string & | algo_spec | ) | [inline] |
MAC factory method.
| algo_spec | the name of the desired MAC |
Definition at line 100 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::make_mac().
Referenced by Py_MAC::Py_MAC().
00101 { 00102 Algorithm_Factory& af = global_state().algorithm_factory(); 00103 return af.make_mac(algo_spec); 00104 }
| BOTAN_DLL u64bit Botan::get_nanoseconds_clock | ( | ) |
Definition at line 93 of file time.cpp.
00094 { 00095 #if defined(BOTAN_TARGET_OS_HAS_CLOCK_GETTIME) 00096 struct ::timespec tv; 00097 ::clock_gettime(CLOCK_REALTIME, &tv); 00098 return combine_timers(tv.tv_sec, tv.tv_nsec, 1000000000); 00099 00100 #elif defined(BOTAN_TARGET_OS_HAS_GETTIMEOFDAY) 00101 struct ::timeval tv; 00102 ::gettimeofday(&tv, 0); 00103 return combine_timers(tv.tv_sec, tv.tv_usec, 1000000); 00104 00105 #elif defined(BOTAN_TARGET_OS_HAS_WIN32_GET_SYSTEMTIME) 00106 00107 // Returns time since January 1, 1601 in 100-ns increments 00108 ::FILETIME tv; 00109 ::GetSystemTimeAsFileTime(&tv); 00110 u64bit tstamp = (static_cast<u64bit>(tv.dwHighDateTime) << 32) | 00111 tv.dwLowDateTime; 00112 00113 return (tstamp * 100); // Scale to 1 nanosecond units 00114 00115 #else 00116 return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC); 00117 00118 #endif 00119 }
| BOTAN_DLL PBE * Botan::get_pbe | ( | const OID & | , | |
| DataSource & | ||||
| ) |
Factory function for PBEs.
| pbe_oid | the oid of the desired PBE | |
| params | a DataSource providing the DER encoded parameters to use |
Definition at line 77 of file get_pbe.cpp.
References Botan::SCAN_Name::algo_name(), Botan::Library_State::algorithm_factory(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::OID::as_string(), Botan::SCAN_Name::as_string(), Botan::HashFunction::clone(), Botan::BlockCipher::clone(), Botan::PBE::decode_params(), DECRYPTION, Botan::Library_State::deref_alias(), global_state(), Botan::OIDS::lookup(), Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_hash_function(), and split_on().
00078 { 00079 SCAN_Name request(OIDS::lookup(pbe_oid)); 00080 00081 const std::string pbe = request.algo_name(); 00082 00083 #if defined(BOTAN_HAS_PBE_PKCS_V15) 00084 if(pbe == "PBE-PKCS5v15") 00085 { 00086 if(request.arg_count() != 2) 00087 throw Invalid_Algorithm_Name(request.as_string()); 00088 00089 std::string digest_name = request.arg(0); 00090 const std::string cipher = request.arg(1); 00091 00092 std::vector<std::string> cipher_spec = split_on(cipher, '/'); 00093 if(cipher_spec.size() != 2) 00094 throw Invalid_Argument("PBE: Invalid cipher spec " + cipher); 00095 00096 const std::string cipher_algo = global_state().deref_alias(cipher_spec[0]); 00097 const std::string cipher_mode = cipher_spec[1]; 00098 00099 if(cipher_mode != "CBC") 00100 throw Invalid_Argument("PBE: Invalid cipher mode " + cipher); 00101 00102 Algorithm_Factory& af = global_state().algorithm_factory(); 00103 00104 const BlockCipher* block_cipher = af.prototype_block_cipher(cipher_algo); 00105 if(!block_cipher) 00106 throw Algorithm_Not_Found(cipher_algo); 00107 00108 const HashFunction* hash_function = 00109 af.prototype_hash_function(digest_name); 00110 00111 if(!hash_function) 00112 throw Algorithm_Not_Found(digest_name); 00113 00114 PBE* pbe = new PBE_PKCS5v15(block_cipher->clone(), 00115 hash_function->clone(), 00116 DECRYPTION); 00117 pbe->decode_params(params); 00118 return pbe; 00119 } 00120 #endif 00121 00122 #if defined(BOTAN_HAS_PBE_PKCS_V20) 00123 if(pbe == "PBE-PKCS5v20") 00124 return new PBE_PKCS5v20(params); 00125 #endif 00126 00127 throw Algorithm_Not_Found(pbe_oid.as_string()); 00128 }
| BOTAN_DLL PBE * Botan::get_pbe | ( | const std::string & | ) |
Factory function for PBEs.
| algo_spec | the name of the PBE algorithm to retrieve |
Definition at line 27 of file get_pbe.cpp.
References Botan::SCAN_Name::algo_name(), Botan::Library_State::algorithm_factory(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::HashFunction::clone(), Botan::BlockCipher::clone(), Botan::Library_State::deref_alias(), ENCRYPTION, global_state(), Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_hash_function(), and split_on().
Referenced by Botan::PKCS8::encrypt_key().
00028 { 00029 SCAN_Name request(algo_spec); 00030 00031 const std::string pbe = request.algo_name(); 00032 std::string digest_name = request.arg(0); 00033 const std::string cipher = request.arg(1); 00034 00035 std::vector<std::string> cipher_spec = split_on(cipher, '/'); 00036 if(cipher_spec.size() != 2) 00037 throw Invalid_Argument("PBE: Invalid cipher spec " + cipher); 00038 00039 const std::string cipher_algo = global_state().deref_alias(cipher_spec[0]); 00040 const std::string cipher_mode = cipher_spec[1]; 00041 00042 if(cipher_mode != "CBC") 00043 throw Invalid_Argument("PBE: Invalid cipher mode " + cipher); 00044 00045 Algorithm_Factory& af = global_state().algorithm_factory(); 00046 00047 const BlockCipher* block_cipher = af.prototype_block_cipher(cipher_algo); 00048 if(!block_cipher) 00049 throw Algorithm_Not_Found(cipher_algo); 00050 00051 const HashFunction* hash_function = af.prototype_hash_function(digest_name); 00052 if(!hash_function) 00053 throw Algorithm_Not_Found(digest_name); 00054 00055 if(request.arg_count() != 2) 00056 throw Invalid_Algorithm_Name(algo_spec); 00057 00058 #if defined(BOTAN_HAS_PBE_PKCS_V15) 00059 if(pbe == "PBE-PKCS5v15") 00060 return new PBE_PKCS5v15(block_cipher->clone(), 00061 hash_function->clone(), 00062 ENCRYPTION); 00063 #endif 00064 00065 #if defined(BOTAN_HAS_PBE_PKCS_V20) 00066 if(pbe == "PBE-PKCS5v20") 00067 return new PBE_PKCS5v20(block_cipher->clone(), 00068 hash_function->clone()); 00069 #endif 00070 00071 throw Algorithm_Not_Found(algo_spec); 00072 }
| BOTAN_DLL PK_Decryptor * Botan::get_pk_decryptor | ( | const PK_Decrypting_Key & | key, | |
| const std::string & | pad | |||
| ) |
Public key decryptor factory method.
| key | the key that will work inside the decryptor | |
| pad | determines the algorithm and encoding |
Definition at line 25 of file look_pk.cpp.
References get_eme().
Referenced by Botan::RSA_PrivateKey::check_key(), Botan::ElGamal_PrivateKey::check_key(), and Py_RSA_PrivateKey::decrypt().
00027 { 00028 return new PK_Decryptor_MR_with_EME(key, get_eme(eme)); 00029 }
| BOTAN_DLL PK_Encryptor * Botan::get_pk_encryptor | ( | const PK_Encrypting_Key & | key, | |
| const std::string & | pad | |||
| ) |
Public key encryptor factory method.
| key | the key that will work inside the encryptor | |
| pad | determines the algorithm and encoding |
Definition at line 16 of file look_pk.cpp.
References get_eme().
Referenced by Botan::RSA_PrivateKey::check_key(), Botan::ElGamal_PrivateKey::check_key(), and Py_RSA_PublicKey::encrypt().
00018 { 00019 return new PK_Encryptor_MR_with_EME(key, get_eme(eme)); 00020 }
| BOTAN_DLL PK_Key_Agreement * Botan::get_pk_kas | ( | const PK_Key_Agreement_Key & | key, | |
| const std::string & | pad | |||
| ) |
Public key key agreement factory method.
| key | the key that will work inside the key agreement | |
| pad | determines the algorithm, encoding and hash algorithm |
Definition at line 70 of file look_pk.cpp.
References get_kdf().
00072 { 00073 return new PK_Key_Agreement(key, get_kdf(kdf)); 00074 }
| BOTAN_DLL PK_Signer * Botan::get_pk_signer | ( | const PK_Signing_Key & | key, | |
| const std::string & | pad, | |||
| Signature_Format | = IEEE_1363 | |||
| ) |
Public key signer factory method.
| key | the key that will work inside the signer | |
| pad | determines the algorithm, encoding and hash algorithm | |
| sig_format | the signature format to be used |
Definition at line 34 of file look_pk.cpp.
References get_emsa(), and Botan::PK_Signer::set_output_format().
Referenced by Botan::RW_PrivateKey::check_key(), Botan::RSA_PrivateKey::check_key(), Botan::NR_PrivateKey::check_key(), Botan::DSA_PrivateKey::check_key(), choose_sig_format(), Botan::CVC_EAC::create_ado_req(), Botan::CVC_EAC::create_cvc_req(), Botan::CVC_EAC::create_self_signed_cert(), Botan::DE_EAC::link_cvca(), Py_RSA_PrivateKey::sign(), Botan::CMS_Encoder::sign(), and Botan::DE_EAC::sign_request().
00037 { 00038 PK_Signer* signer = new PK_Signer(key, get_emsa(emsa)); 00039 signer->set_output_format(sig_format); 00040 return signer; 00041 }
| BOTAN_DLL PK_Verifier * Botan::get_pk_verifier | ( | const PK_Verifying_wo_MR_Key & | key, | |
| const std::string & | pad, | |||
| Signature_Format | sig_form = IEEE_1363 | |||
| ) |
Public key verifier factory method.
| key | the key that will work inside the verifier | |
| pad | determines the algorithm, encoding and hash algorithm | |
| sig_form | the signature format to be used |
Definition at line 58 of file look_pk.cpp.
References get_emsa(), and Botan::PK_Verifier::set_input_format().
Referenced by Py_RSA_PublicKey::verify().
00061 { 00062 PK_Verifier* verifier = new PK_Verifier_wo_MR(key, get_emsa(emsa)); 00063 verifier->set_input_format(sig_format); 00064 return verifier; 00065 }
| BOTAN_DLL PK_Verifier * Botan::get_pk_verifier | ( | const PK_Verifying_with_MR_Key & | key, | |
| const std::string & | pad, | |||
| Signature_Format | = IEEE_1363 | |||
| ) |
Public key verifier factory method.
| key | the key that will work inside the verifier | |
| pad | determines the algorithm, encoding and hash algorithm | |
| sig_format | the signature format to be used |
Definition at line 46 of file look_pk.cpp.
References get_emsa(), and Botan::PK_Verifier::set_input_format().
Referenced by Botan::RW_PrivateKey::check_key(), Botan::RSA_PrivateKey::check_key(), Botan::NR_PrivateKey::check_key(), Botan::DSA_PrivateKey::check_key(), Botan::X509_Store::check_sig(), Botan::X509_Object::check_signature(), and Botan::EAC1_1_obj< Derived >::check_signature().
00049 { 00050 PK_Verifier* verifier = new PK_Verifier_with_MR(key, get_emsa(emsa)); 00051 verifier->set_input_format(sig_format); 00052 return verifier; 00053 }
| BOTAN_DLL Private_Key * Botan::get_private_key | ( | const std::string & | ) |
Get an empty private key object.
| name | the name of the desired public key algorithm |
Definition at line 79 of file pk_algs.cpp.
Referenced by Botan::PKCS8::load_key().
00080 { 00081 #if defined(BOTAN_HAS_RSA) 00082 if(alg_name == "RSA") return new RSA_PrivateKey; 00083 #endif 00084 00085 #if defined(BOTAN_HAS_DSA) 00086 if(alg_name == "DSA") return new DSA_PrivateKey; 00087 #endif 00088 00089 #if defined(BOTAN_HAS_DIFFIE_HELLMAN) 00090 if(alg_name == "DH") return new DH_PrivateKey; 00091 #endif 00092 00093 #if defined(BOTAN_HAS_NYBERG_RUEPPEL) 00094 if(alg_name == "NR") return new NR_PrivateKey; 00095 #endif 00096 00097 #if defined(BOTAN_HAS_RW) 00098 if(alg_name == "RW") return new RW_PrivateKey; 00099 #endif 00100 00101 #if defined(BOTAN_HAS_ELG) 00102 if(alg_name == "ELG") return new ElGamal_PrivateKey; 00103 #endif 00104 00105 #if defined(BOTAN_HAS_ECDSA) 00106 if(alg_name == "ECDSA") return new ECDSA_PrivateKey; 00107 #endif 00108 00109 return 0; 00110 }
| BOTAN_DLL Public_Key * Botan::get_public_key | ( | const std::string & | ) |
Get an empty public key object.
| name | the name of the desired public key algorithm |
Definition at line 43 of file pk_algs.cpp.
Referenced by Botan::X509::load_key().
00044 { 00045 #if defined(BOTAN_HAS_RSA) 00046 if(alg_name == "RSA") return new RSA_PublicKey; 00047 #endif 00048 00049 #if defined(BOTAN_HAS_DSA) 00050 if(alg_name == "DSA") return new DSA_PublicKey; 00051 #endif 00052 00053 #if defined(BOTAN_HAS_DIFFIE_HELLMAN) 00054 if(alg_name == "DH") return new DH_PublicKey; 00055 #endif 00056 00057 #if defined(BOTAN_HAS_NYBERG_RUEPPEL) 00058 if(alg_name == "NR") return new NR_PublicKey; 00059 #endif 00060 00061 #if defined(BOTAN_HAS_RW) 00062 if(alg_name == "RW") return new RW_PublicKey; 00063 #endif 00064 00065 #if defined(BOTAN_HAS_ELG) 00066 if(alg_name == "ELG") return new ElGamal_PublicKey; 00067 #endif 00068 00069 #if defined(BOTAN_HAS_ECDSA) 00070 if(alg_name == "ECDSA") return new ECDSA_PublicKey; 00071 #endif 00072 00073 return 0; 00074 }
| BOTAN_DLL S2K * Botan::get_s2k | ( | const std::string & | algo_spec | ) |
String to key algorithm factory method.
| name | the name of the desired string to key (S2K) algorithm |
Definition at line 86 of file get_enc.cpp.
References Botan::SCAN_Name::algo_name(), Botan::Library_State::algorithm_factory(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), global_state(), and Botan::Algorithm_Factory::make_hash_function().
Referenced by Codec::GenerateWriteKey().
00087 { 00088 SCAN_Name request(algo_spec); 00089 00090 Algorithm_Factory& af = global_state().algorithm_factory(); 00091 00092 #if defined(BOTAN_HAS_PBKDF1) 00093 if(request.algo_name() == "PBKDF1" && request.arg_count() == 1) 00094 return new PKCS5_PBKDF1(af.make_hash_function(request.arg(0))); 00095 #endif 00096 00097 #if defined(BOTAN_HAS_PBKDF2) 00098 if(request.algo_name() == "PBKDF2" && request.arg_count() == 1) 00099 return new PKCS5_PBKDF2(new HMAC(af.make_hash_function(request.arg(0)))); 00100 #endif 00101 00102 #if defined(BOTAN_HAS_PGPS2K) 00103 if(request.algo_name() == "OpenPGP-S2K" && request.arg_count() == 1) 00104 return new OpenPGP_S2K(af.make_hash_function(request.arg(0))); 00105 #endif 00106 00107 throw Algorithm_Not_Found(algo_spec); 00108 }
| StreamCipher* Botan::get_stream_cipher | ( | const std::string & | algo_spec | ) | [inline] |
Stream cipher factory method.
| algo_spec | the name of the desired stream cipher |
Definition at line 78 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::make_stream_cipher().
00079 { 00080 Algorithm_Factory& af = global_state().algorithm_factory(); 00081 return af.make_stream_cipher(algo_spec); 00082 }
| BOTAN_DLL Library_State & Botan::global_state | ( | ) |
Definition at line 73 of file libstate.cpp.
References Botan::LibraryInitializer::initialize().
Referenced by Botan::OIDS::add_oid(), Botan::AutoSeeded_RNG::AutoSeeded_RNG(), block_size_of(), Botan::DL_Group::DL_Group(), Botan::Extensions::encode_into(), Botan::Allocator::get(), get_block_cipher(), get_cipher(), get_eme(), get_emsa(), get_hash(), get_kdf(), get_mac(), get_pbe(), get_s2k(), get_stream_cipher(), Botan::Hash_Filter::Hash_Filter(), have_algorithm(), have_block_cipher(), have_hash(), have_mac(), Botan::OIDS::have_oid(), have_stream_cipher(), Botan::LibraryInitializer::initialize(), keylength_multiple_of(), Botan::OIDS::lookup(), Botan::MAC_Filter::MAC_Filter(), max_keylength_of(), min_keylength_of(), Botan::Engine_Core::mod_exp(), output_length_of(), retrieve_block_cipher(), retrieve_hash(), retrieve_mac(), retrieve_stream_cipher(), Botan::StreamCipher_Filter::StreamCipher_Filter(), and valid_keylength_for().
00074 { 00075 /* Lazy initialization. Botan still needs to be deinitialized later 00076 on or memory might leak. 00077 */ 00078 if(!global_lib_state) 00079 LibraryInitializer::initialize("thread_safe=true"); 00080 00081 return (*global_lib_state); 00082 }
| u32bit Botan::hamming_weight | ( | T | n | ) | [inline] |
Definition at line 66 of file bit_ops.h.
00067 { 00068 const byte NIBBLE_WEIGHTS[] = { 00069 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; 00070 00071 u32bit weight = 0; 00072 for(u32bit i = 0; i != 2*sizeof(T); ++i) 00073 weight += NIBBLE_WEIGHTS[(n >> (4*i)) & 0x0F]; 00074 return weight; 00075 }
| BOTAN_DLL bool Botan::have_algorithm | ( | const std::string & | name | ) |
Query if an algorithm exists
Check if an algorithm exists.
| name | the name of the algorithm to check for |
Definition at line 17 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_hash_function(), Botan::Algorithm_Factory::prototype_mac(), and Botan::Algorithm_Factory::prototype_stream_cipher().
00018 { 00019 Algorithm_Factory& af = global_state().algorithm_factory(); 00020 00021 if(af.prototype_block_cipher(name)) 00022 return true; 00023 if(af.prototype_stream_cipher(name)) 00024 return true; 00025 if(af.prototype_hash_function(name)) 00026 return true; 00027 if(af.prototype_mac(name)) 00028 return true; 00029 return false; 00030 }
| bool Botan::have_block_cipher | ( | const std::string & | algo_spec | ) | [inline] |
Check if a block cipher algorithm exists.
| name | the name of the algorithm to check for |
Definition at line 194 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_block_cipher().
00195 { 00196 Algorithm_Factory& af = global_state().algorithm_factory(); 00197 return (af.prototype_block_cipher(algo_spec) != 0); 00198 }
| bool Botan::have_hash | ( | const std::string & | algo_spec | ) | [inline] |
Check if a hash algorithm exists.
| algo_spec | the name of the algorithm to check for |
Definition at line 216 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_hash_function().
Referenced by make_filter1().
00217 { 00218 Algorithm_Factory& af = global_state().algorithm_factory(); 00219 return (af.prototype_hash_function(algo_spec) != 0); 00220 }
| bool Botan::have_mac | ( | const std::string & | algo_spec | ) | [inline] |
Check if a MAC algorithm exists.
| algo_spec | the name of the algorithm to check for |
Definition at line 227 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_mac().
Referenced by make_filter2().
00228 { 00229 Algorithm_Factory& af = global_state().algorithm_factory(); 00230 return (af.prototype_mac(algo_spec) != 0); 00231 }
| bool Botan::have_stream_cipher | ( | const std::string & | algo_spec | ) | [inline] |
Check if a stream cipher algorithm exists.
| name | the name of the algorithm to check for |
Definition at line 205 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_stream_cipher().
Referenced by make_filter2().
00206 { 00207 Algorithm_Factory& af = global_state().algorithm_factory(); 00208 return (af.prototype_stream_cipher(algo_spec) != 0); 00209 }
| u32bit Botan::high_bit | ( | T | n | ) | [inline] |
Definition at line 30 of file bit_ops.h.
Referenced by Botan::OID::encode_into().
00031 { 00032 for(u32bit i = 8*sizeof(T); i > 0; --i) 00033 if((n >> (i - 1)) & 0x01) 00034 return i; 00035 return 0; 00036 }
| BOTAN_DLL byte Botan::ieee1363_hash_id | ( | const std::string & | name | ) |
Definition at line 99 of file hash_id.cpp.
Referenced by Botan::EMSA2::EMSA2().
00100 { 00101 if(name == "SHA-160") return 0x33; 00102 00103 if(name == "SHA-224") return 0x38; 00104 if(name == "SHA-256") return 0x34; 00105 if(name == "SHA-384") return 0x36; 00106 if(name == "SHA-512") return 0x35; 00107 00108 if(name == "RIPEMD-160") return 0x31; 00109 if(name == "RIPEMD-128") return 0x32; 00110 00111 if(name == "Whirlpool") return 0x37; 00112 00113 return 0; 00114 }
| GFpElement BOTAN_DLL Botan::inverse | ( | const GFpElement & | elem | ) |
Definition at line 691 of file gfp_element.cpp.
References Botan::GFpElement::inverse_in_place().
Referenced by Botan::PointGFp::set_z_to_one().
| BigInt BOTAN_DLL Botan::inverse_mod | ( | const BigInt & | n, | |
| const BigInt & | mod | |||
| ) |
Definition at line 138 of file numthry.cpp.
References Botan::BigInt::is_even(), Botan::BigInt::is_negative(), Botan::BigInt::is_odd(), Botan::BigInt::is_zero(), and low_zero_bits().
Referenced by Botan::Default_ECKAEG_Op::agree(), Botan::IF_Scheme_PrivateKey::check_key(), Botan::Default_ELG_Op::decrypt(), Botan::DH_Core::DH_Core(), Botan::IF_Core::IF_Core(), Botan::GFpElement::inverse_in_place(), Botan::Montgomery_Exponentiator::Montgomery_Exponentiator(), Botan::IF_Scheme_PrivateKey::PKCS8_load_hook(), Botan::RSA_PrivateKey::RSA_PrivateKey(), Botan::RW_PrivateKey::RW_PrivateKey(), Botan::Default_ECDSA_Op::sign(), Botan::Default_DSA_Op::sign(), Botan::Default_ECDSA_Op::verify(), and Botan::Default_DSA_Op::verify().
00139 { 00140 if(mod.is_zero()) 00141 throw BigInt::DivideByZero(); 00142 if(mod.is_negative() || n.is_negative()) 00143 throw Invalid_Argument("inverse_mod: arguments must be non-negative"); 00144 00145 if(n.is_zero() || (n.is_even() && mod.is_even())) 00146 return 0; 00147 00148 BigInt x = mod, y = n, u = mod, v = n; 00149 BigInt A = 1, B = 0, C = 0, D = 1; 00150 00151 while(u.is_nonzero()) 00152 { 00153 u32bit zero_bits = low_zero_bits(u); 00154 u >>= zero_bits; 00155 for(u32bit i = 0; i != zero_bits; ++i) 00156 { 00157 if(A.is_odd() || B.is_odd()) 00158 { A += y; B -= x; } 00159 A >>= 1; B >>= 1; 00160 } 00161 00162 zero_bits = low_zero_bits(v); 00163 v >>= zero_bits; 00164 for(u32bit i = 0; i != zero_bits; ++i) 00165 { 00166 if(C.is_odd() || D.is_odd()) 00167 { C += y; D -= x; } 00168 C >>= 1; D >>= 1; 00169 } 00170 00171 if(u >= v) { u -= v; A -= C; B -= D; } 00172 else { v -= u; C -= A; D -= B; } 00173 } 00174 00175 if(v != 1) 00176 return 0; 00177 00178 while(D.is_negative()) D += mod; 00179 while(D >= mod) D -= mod; 00180 00181 return D; 00182 }
| BOTAN_DLL std::string Botan::ipv4_to_string | ( | u32bit | ip | ) |
Definition at line 277 of file parsing.cpp.
References get_byte(), and to_string().
Referenced by Botan::AlternativeName::decode_from().
00278 { 00279 std::string str; 00280 00281 for(size_t j = 0; j != sizeof(ip); j++) 00282 { 00283 if(j) 00284 str += "."; 00285 str += to_string(get_byte(j, ip)); 00286 } 00287 00288 return str; 00289 }
| bool BOTAN_DLL Botan::is_prime | ( | const BigInt & | n, | |
| RandomNumberGenerator & | rng | |||
| ) |
Definition at line 237 of file numthry.cpp.
References run_primality_tests().
Referenced by Botan::DL_Group::DL_Group(), generate_dsa_primes(), and random_safe_prime().
00238 { 00239 return run_primality_tests(rng, n, 1); 00240 }
| bool Botan::is_string_type | ( | ASN1_Tag | tag | ) |
Definition at line 65 of file asn1_str.cpp.
References BMP_STRING, IA5_STRING, NUMERIC_STRING, PRINTABLE_STRING, T61_STRING, UTF8_STRING, and VISIBLE_STRING.
Referenced by Botan::AlternativeName::decode_from().
00066 { 00067 if(tag == NUMERIC_STRING || tag == PRINTABLE_STRING || 00068 tag == VISIBLE_STRING || tag == T61_STRING || tag == IA5_STRING || 00069 tag == UTF8_STRING || tag == BMP_STRING) 00070 return true; 00071 return false; 00072 }
| s32bit BOTAN_DLL Botan::jacobi | ( | const BigInt & | a, | |
| const BigInt & | n | |||
| ) |
Definition at line 15 of file jacobi.cpp.
References Botan::BigInt::is_even(), Botan::BigInt::is_negative(), Botan::BigInt::is_zero(), low_zero_bits(), and swap().
Referenced by ressol(), and Botan::RW_PrivateKey::sign().
00016 { 00017 if(a.is_negative()) 00018 throw Invalid_Argument("jacobi: first argument must be non-negative"); 00019 if(n.is_even() || n < 2) 00020 throw Invalid_Argument("jacobi: second argument must be odd and > 1"); 00021 00022 BigInt x = a, y = n; 00023 s32bit J = 1; 00024 00025 while(y > 1) 00026 { 00027 x %= y; 00028 if(x > y / 2) 00029 { 00030 x = y - x; 00031 if(y % 4 == 3) 00032 J = -J; 00033 } 00034 if(x.is_zero()) 00035 return 0; 00036 00037 u32bit shifts = low_zero_bits(x); 00038 x >>= shifts; 00039 if(shifts % 2) 00040 { 00041 word y_mod_8 = y % 8; 00042 if(y_mod_8 == 3 || y_mod_8 == 5) 00043 J = -J; 00044 } 00045 00046 if(x % 4 == 3 && y % 4 == 3) 00047 J = -J; 00048 std::swap(x, y); 00049 } 00050 return J; 00051 }
| BOTAN_DLL u32bit Botan::keylength_multiple_of | ( | const std::string & | name | ) |
Query the KEYLENGTH_MULTIPLE of an algorithm
Find out the size any valid key is a multiple of for a certain algorithm.
| name | the name of the algorithm |
Definition at line 124 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), Botan::SymmetricAlgorithm::KEYLENGTH_MULTIPLE, mac, Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_mac(), and Botan::Algorithm_Factory::prototype_stream_cipher().
00125 { 00126 Algorithm_Factory& af = global_state().algorithm_factory(); 00127 00128 if(const BlockCipher* bc = af.prototype_block_cipher(name)) 00129 return bc->KEYLENGTH_MULTIPLE; 00130 00131 if(const StreamCipher* sc = af.prototype_stream_cipher(name)) 00132 return sc->KEYLENGTH_MULTIPLE; 00133 00134 if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) 00135 return mac->KEYLENGTH_MULTIPLE; 00136 00137 throw Algorithm_Not_Found(name); 00138 }
| BigInt BOTAN_DLL Botan::lcm | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) |
Definition at line 130 of file numthry.cpp.
References gcd().
Referenced by Botan::RW_PrivateKey::check_key(), Botan::RSA_PrivateKey::check_key(), Botan::RSA_PrivateKey::RSA_PrivateKey(), and Botan::RW_PrivateKey::RW_PrivateKey().
00131 { 00132 return ((a * b) / gcd(a, b)); 00133 }
| void Botan::load_be | ( | T | out[], | |
| const byte | in[], | |||
| u32bit | count | |||
| ) | [inline] |
Definition at line 260 of file loadstor.h.
References bswap_4(), and reverse_bytes().
00263 { 00264 #if defined(BOTAN_TARGET_CPU_HAS_KNOWN_ENDIANNESS) 00265 std::memcpy(out, in, sizeof(T)*count); 00266 00267 #if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN) 00268 const u32bit blocks = count - (count % 4); 00269 const u32bit left = count - blocks; 00270 00271 for(u32bit i = 0; i != blocks; i += 4) 00272 bswap_4(out + i); 00273 00274 for(u32bit i = 0; i != left; ++i) 00275 out[blocks+i] = reverse_bytes(out[blocks+i]); 00276 #endif 00277 00278 #else 00279 for(u32bit i = 0; i != count; ++i) 00280 out[i] = load_be<T>(in, i); 00281 #endif 00282 }
| void Botan::load_be | ( | const byte | in[], | |
| T & | x0, | |||
| T & | x1, | |||
| T & | x2, | |||
| T & | x3, | |||
| T & | x4, | |||
| T & | x5, | |||
| T & | x6, | |||
| T & | x7 | |||
| ) | [inline] |
Definition at line 245 of file loadstor.h.
00248 { 00249 x0 = load_be<T>(in, 0); 00250 x1 = load_be<T>(in, 1); 00251 x2 = load_be<T>(in, 2); 00252 x3 = load_be<T>(in, 3); 00253 x4 = load_be<T>(in, 4); 00254 x5 = load_be<T>(in, 5); 00255 x6 = load_be<T>(in, 6); 00256 x7 = load_be<T>(in, 7); 00257 }
| void Botan::load_be | ( | const byte | in[], | |
| T & | x0, | |||
| T & | x1, | |||
| T & | x2, | |||
| T & | x3 | |||
| ) | [inline] |
Definition at line 235 of file loadstor.h.
00237 { 00238 x0 = load_be<T>(in, 0); 00239 x1 = load_be<T>(in, 1); 00240 x2 = load_be<T>(in, 2); 00241 x3 = load_be<T>(in, 3); 00242 }
| void Botan::load_be | ( | const byte | in[], | |
| T & | x0, | |||
| T & | x1 | |||
| ) | [inline] |
| T Botan::load_be | ( | const byte | in[], | |
| u32bit | off | |||
| ) | [inline] |
Definition at line 83 of file loadstor.h.
Referenced by Botan::SHA_160::compress_n(), Botan::GOST_34_11::compress_n(), Botan::Noekeon_SIMD::decrypt_n(), and Botan::Noekeon_SIMD::encrypt_n().
00084 { 00085 in += off * sizeof(T); 00086 T out = 0; 00087 for(u32bit j = 0; j != sizeof(T); j++) 00088 out = (out << 8) | in[j]; 00089 return out; 00090 }
Referenced by Botan::AlternativeName::decode_from(), Botan::XTEA::decrypt_n(), Botan::TEA::decrypt_n(), Botan::SEED::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::CAST_256::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::AES::decrypt_n(), Botan::XTEA::encrypt_n(), Botan::TEA::encrypt_n(), Botan::SEED::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::CAST_256::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::AES::encrypt_n(), Botan::XTEA::key_schedule(), Botan::Noekeon::key_schedule(), Botan::SIMD_Scalar::load_be(), and Botan::WiderWake_41_BE::set_iv().
| void Botan::load_le | ( | T | out[], | |
| const byte | in[], | |||
| u32bit | count | |||
| ) | [inline] |
Definition at line 203 of file loadstor.h.
References bswap_4(), and reverse_bytes().
00206 { 00207 #if defined(BOTAN_TARGET_CPU_HAS_KNOWN_ENDIANNESS) 00208 std::memcpy(out, in, sizeof(T)*count); 00209 00210 #if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN) 00211 const u32bit blocks = count - (count % 4); 00212 const u32bit left = count - blocks; 00213 00214 for(u32bit i = 0; i != blocks; i += 4) 00215 bswap_4(out + i); 00216 00217 for(u32bit i = 0; i != left; ++i) 00218 out[blocks+i] = reverse_bytes(out[blocks+i]); 00219 #endif 00220 00221 #else 00222 for(u32bit i = 0; i != count; ++i) 00223 out[i] = load_le<T>(in, i); 00224 #endif 00225 }
| void Botan::load_le | ( | const byte | in[], | |
| T & | x0, | |||
| T & | x1, | |||
| T & | x2, | |||
| T & | x3, | |||
| T & | x4, | |||
| T & | x5, | |||
| T & | x6, | |||
| T & | x7 | |||
| ) | [inline] |
Definition at line 188 of file loadstor.h.
00191 { 00192 x0 = load_le<T>(in, 0); 00193 x1 = load_le<T>(in, 1); 00194 x2 = load_le<T>(in, 2); 00195 x3 = load_le<T>(in, 3); 00196 x4 = load_le<T>(in, 4); 00197 x5 = load_le<T>(in, 5); 00198 x6 = load_le<T>(in, 6); 00199 x7 = load_le<T>(in, 7); 00200 }
| void Botan::load_le | ( | const byte | in[], | |
| T & | x0, | |||
| T & | x1, | |||
| T & | x2, | |||
| T & | x3 | |||
| ) | [inline] |
Definition at line 178 of file loadstor.h.
00180 { 00181 x0 = load_le<T>(in, 0); 00182 x1 = load_le<T>(in, 1); 00183 x2 = load_le<T>(in, 2); 00184 x3 = load_le<T>(in, 3); 00185 }
| void Botan::load_le | ( | const byte | in[], | |
| T & | x0, | |||
| T & | x1 | |||
| ) | [inline] |
| T Botan::load_le | ( | const byte | in[], | |
| u32bit | off | |||
| ) | [inline] |
Definition at line 93 of file loadstor.h.
Referenced by Botan::MD5::compress_n(), and Botan::MD4::compress_n().
00094 { 00095 in += off * sizeof(T); 00096 T out = 0; 00097 for(u32bit j = 0; j != sizeof(T); j++) 00098 out = (out << 8) | in[sizeof(T)-1-j]; 00099 return out; 00100 }
Referenced by Botan::Twofish::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::RC6::decrypt_n(), Botan::RC5::decrypt_n(), Botan::MARS::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::Twofish::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::RC6::encrypt_n(), Botan::RC5::encrypt_n(), Botan::MARS::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::Serpent::key_schedule(), Botan::SIMD_Scalar::load_le(), and Botan::Salsa20::set_iv().
| bool Botan::lock_mem | ( | void * | addr, | |
| u32bit | length | |||
| ) |
Lock memory into RAM if possible
| addr | the start of the memory block | |
| length | the length of the memory block in bytes |
Definition at line 22 of file mlock.cpp.
00023 { 00024 #if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK) 00025 return (mlock(ptr, bytes) == 0); 00026 #elif defined(BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK) 00027 return (VirtualLock(ptr, bytes) != 0); 00028 #else 00029 return false; 00030 #endif 00031 }
| u32bit Botan::low_bit | ( | T | n | ) | [inline] |
| u32bit BOTAN_DLL Botan::low_zero_bits | ( | const BigInt & | n | ) |
Definition at line 77 of file numthry.cpp.
References ctz(), Botan::BigInt::is_nonzero(), Botan::BigInt::is_positive(), and Botan::BigInt::size().
Referenced by gcd(), inverse_mod(), jacobi(), Botan::MillerRabin_Test::MillerRabin_Test(), and ressol().
00078 { 00079 u32bit low_zero = 0; 00080 00081 if(n.is_positive() && n.is_nonzero()) 00082 { 00083 for(u32bit i = 0; i != n.size(); ++i) 00084 { 00085 word x = n[i]; 00086 00087 if(x) 00088 { 00089 low_zero += ctz(x); 00090 break; 00091 } 00092 else 00093 low_zero += BOTAN_MP_WORD_BITS; 00094 } 00095 } 00096 00097 return low_zero; 00098 }
| u16bit Botan::make_u16bit | ( | byte | i0, | |
| byte | i1 | |||
| ) | [inline] |
| u32bit Botan::make_u32bit | ( | byte | i0, | |
| byte | i1, | |||
| byte | i2, | |||
| byte | i3 | |||
| ) | [inline] |
Definition at line 58 of file loadstor.h.
00059 { 00060 return ((static_cast<u32bit>(i0) << 24) | 00061 (static_cast<u32bit>(i1) << 16) | 00062 (static_cast<u32bit>(i2) << 8) | 00063 (static_cast<u32bit>(i3))); 00064 }
| u64bit Botan::make_u64bit | ( | byte | i0, | |
| byte | i1, | |||
| byte | i2, | |||
| byte | i3, | |||
| byte | i4, | |||
| byte | i5, | |||
| byte | i6, | |||
| byte | i7 | |||
| ) | [inline] |
Definition at line 66 of file loadstor.h.
00068 { 00069 return ((static_cast<u64bit>(i0) << 56) | 00070 (static_cast<u64bit>(i1) << 48) | 00071 (static_cast<u64bit>(i2) << 40) | 00072 (static_cast<u64bit>(i3) << 32) | 00073 (static_cast<u64bit>(i4) << 24) | 00074 (static_cast<u64bit>(i5) << 16) | 00075 (static_cast<u64bit>(i6) << 8) | 00076 (static_cast<u64bit>(i7))); 00077 }
| BOTAN_DLL u32bit Botan::max_keylength_of | ( | const std::string & | name | ) |
Query the MAXIMUM_KEYLENGTH of an algorithm
Find out the maximum key size of a certain symmetric algorithm.
| name | the name of the algorithm |
Definition at line 105 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), mac, Botan::SymmetricAlgorithm::MAXIMUM_KEYLENGTH, Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_mac(), and Botan::Algorithm_Factory::prototype_stream_cipher().
00106 { 00107 Algorithm_Factory& af = global_state().algorithm_factory(); 00108 00109 if(const BlockCipher* bc = af.prototype_block_cipher(name)) 00110 return bc->MAXIMUM_KEYLENGTH; 00111 00112 if(const StreamCipher* sc = af.prototype_stream_cipher(name)) 00113 return sc->MAXIMUM_KEYLENGTH; 00114 00115 if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) 00116 return mac->MAXIMUM_KEYLENGTH; 00117 00118 throw Algorithm_Not_Found(name); 00119 }
| BOTAN_DLL u32bit Botan::min_keylength_of | ( | const std::string & | name | ) |
Query the MINIMUM_KEYLENGTH of an algorithm
Find out the minimum key size of a certain symmetric algorithm.
| name | the name of the algorithm |
Definition at line 86 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), mac, Botan::SymmetricAlgorithm::MINIMUM_KEYLENGTH, Botan::Algorithm_Factory::prototype_block_cipher(), Botan::Algorithm_Factory::prototype_mac(), and Botan::Algorithm_Factory::prototype_stream_cipher().
00087 { 00088 Algorithm_Factory& af = global_state().algorithm_factory(); 00089 00090 if(const BlockCipher* bc = af.prototype_block_cipher(name)) 00091 return bc->MINIMUM_KEYLENGTH; 00092 00093 if(const StreamCipher* sc = af.prototype_stream_cipher(name)) 00094 return sc->MINIMUM_KEYLENGTH; 00095 00096 if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) 00097 return mac->MINIMUM_KEYLENGTH; 00098 00099 throw Algorithm_Not_Found(name); 00100 }
| BigInt BOTAN_DLL Botan::mul_add | ( | const BigInt & | a, | |
| const BigInt & | b, | |||
| const BigInt & | c | |||
| ) |
Definition at line 33 of file mp_numth.cpp.
References bigint_add2(), bigint_mul(), Botan::BigInt::data(), Botan::BigInt::get_reg(), Botan::BigInt::is_negative(), Botan::BigInt::is_zero(), Botan::BigInt::Negative, Botan::BigInt::Positive, Botan::BigInt::sig_words(), Botan::BigInt::sign(), and Botan::BigInt::size().
Referenced by Botan::Default_IF_Op::private_op(), and Botan::Default_DSA_Op::sign().
00034 { 00035 if(c.is_negative() || c.is_zero()) 00036 throw Invalid_Argument("mul_add: Third argument must be > 0"); 00037 00038 BigInt::Sign sign = BigInt::Positive; 00039 if(a.sign() != b.sign()) 00040 sign = BigInt::Negative; 00041 00042 const u32bit a_sw = a.sig_words(); 00043 const u32bit b_sw = b.sig_words(); 00044 const u32bit c_sw = c.sig_words(); 00045 00046 BigInt r(sign, std::max(a.size() + b.size(), c_sw) + 1); 00047 SecureVector<word> workspace(r.size()); 00048 00049 bigint_mul(r.get_reg(), r.size(), workspace, 00050 a.data(), a.size(), a_sw, 00051 b.data(), b.size(), b_sw); 00052 const u32bit r_size = std::max(r.sig_words(), c_sw); 00053 bigint_add2(r.get_reg(), r_size, c.data(), c_sw); 00054 return r; 00055 }
| PointGFp BOTAN_DLL Botan::mult2 | ( | const PointGFp & | point | ) |
| PointGFp BOTAN_DLL Botan::mult_point_secure | ( | const PointGFp & | point, | |
| const BigInt & | scalar, | |||
| const BigInt & | point_order, | |||
| const BigInt & | max_secret | |||
| ) |
Definition at line 897 of file point_gfp.cpp.
References Botan::PointGFp::mult_this_secure().
00899 { 00900 PointGFp result(point); 00901 result.mult_this_secure(scalar, point_order, max_secret); 00902 return result; 00903 }
| void Botan::multimap_insert | ( | std::multimap< K, V > & | multimap, | |
| const K & | key, | |||
| const V & | value | |||
| ) | [inline] |
Definition at line 78 of file stl_util.h.
Referenced by Botan::Data_Store::add(), Botan::X509_DN::add_attribute(), Botan::AlternativeName::add_attribute(), Botan::AlternativeName::add_othername(), Botan::X509_DN::contents(), Botan::AlternativeName::contents(), and Botan::X509_DN::get_attributes().
| BOTAN_DLL bool Botan::operator!= | ( | const OctetString & | s1, | |
| const OctetString & | s2 | |||
| ) |
| bool Botan::operator!= | ( | const EC_Domain_Params & | lhs, | |
| const EC_Domain_Params & | rhs | |||
| ) | [inline] |
| bool Botan::operator!= | ( | const PointGFp & | lhs, | |
| const PointGFp & | rhs | |||
| ) | [inline] |
Definition at line 264 of file point_gfp.h.
References operator==().
00265 { 00266 return !operator==(lhs, rhs); 00267 }
| bool Botan::operator!= | ( | const GFpElement & | lhs, | |
| const GFpElement & | rhs | |||
| ) | [inline] |
Definition at line 254 of file gfp_element.h.
References operator==().
00255 { 00256 return !operator==(lhs, rhs); 00257 }
| bool Botan::operator!= | ( | const CurveGFp & | lhs, | |
| const CurveGFp & | rhs | |||
| ) | [inline] |
| bool Botan::operator!= | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) | [inline] |
| BOTAN_DLL bool Botan::operator!= | ( | const X509_Certificate & | , | |
| const X509_Certificate & | ||||
| ) |
Check two certificates for inequality
Definition at line 297 of file x509cert.cpp.
| BOTAN_DLL bool Botan::operator!= | ( | const CRL_Entry & | , | |
| const CRL_Entry & | ||||
| ) |
Test two CRL entries for inequality in at least one field.
Definition at line 55 of file crl_ent.cpp.
| bool Botan::operator!= | ( | const ECDSA_Signature & | lhs, | |
| const ECDSA_Signature & | rhs | |||
| ) | [inline] |
| bool Botan::operator!= | ( | const ASN1_EAC_String & | lhs, | |
| const ASN1_EAC_String & | rhs | |||
| ) | [inline] |
| bool Botan::operator!= | ( | EAC1_1_Req const & | lhs, | |
| EAC1_1_Req const & | rhs | |||
| ) | [inline] |
| bool Botan::operator!= | ( | EAC1_1_CVC const & | lhs, | |
| EAC1_1_CVC const & | rhs | |||
| ) | [inline] |
| bool Botan::operator!= | ( | EAC1_1_ADO const & | lhs, | |
| EAC1_1_ADO const & | rhs | |||
| ) | [inline] |
| bool BOTAN_DLL Botan::operator!= | ( | const EAC_Time & | t1, | |
| const EAC_Time & | t2 | |||
| ) |
| bool Botan::operator!= | ( | const OID & | a, | |
| const OID & | b | |||
| ) |
| bool Botan::operator!= | ( | const X509_Time & | t1, | |
| const X509_Time & | t2 | |||
| ) |
| bool BOTAN_DLL Botan::operator!= | ( | const X509_DN & | dn1, | |
| const X509_DN & | dn2 | |||
| ) |
| bool BOTAN_DLL Botan::operator!= | ( | const AlgorithmIdentifier & | a1, | |
| const AlgorithmIdentifier & | a2 | |||
| ) |
| word BOTAN_DLL Botan::operator% | ( | const BigInt & | n, | |
| word | mod | |||
| ) |
Definition at line 136 of file big_ops3.cpp.
References bigint_modop(), Botan::BigInt::Negative, power_of_2(), Botan::BigInt::sig_words(), Botan::BigInt::sign(), and Botan::BigInt::word_at().
00137 { 00138 if(mod == 0) 00139 throw BigInt::DivideByZero(); 00140 if(power_of_2(mod)) 00141 return (n.word_at(0) & (mod - 1)); 00142 00143 word remainder = 0; 00144 00145 for(u32bit j = n.sig_words(); j > 0; --j) 00146 remainder = bigint_modop(remainder, n.word_at(j-1), mod); 00147 00148 if(remainder && n.sign() == BigInt::Negative) 00149 return mod - remainder; 00150 return remainder; 00151 }
| BigInt BOTAN_DLL Botan::operator% | ( | const BigInt & | n, | |
| const BigInt & | mod | |||
| ) |
Definition at line 119 of file big_ops3.cpp.
References divide(), Botan::BigInt::is_negative(), Botan::BigInt::is_positive(), and Botan::BigInt::is_zero().
00120 { 00121 if(mod.is_zero()) 00122 throw BigInt::DivideByZero(); 00123 if(mod.is_negative()) 00124 throw Invalid_Argument("BigInt::operator%: modulus must be > 0"); 00125 if(n.is_positive() && mod.is_positive() && n < mod) 00126 return n; 00127 00128 BigInt q, r; 00129 divide(n, mod, q, r); 00130 return r; 00131 }
| PointGFp BOTAN_DLL Botan::operator* | ( | const PointGFp & | point, | |
| const BigInt & | scalar | |||
| ) |
| PointGFp BOTAN_DLL Botan::operator* | ( | const BigInt & | scalar, | |
| const PointGFp & | point | |||
| ) |
| GFpElement BOTAN_DLL Botan::operator* | ( | u32bit | lhs, | |
| const GFpElement & | rhs | |||
| ) |
| GFpElement BOTAN_DLL Botan::operator* | ( | const GFpElement & | lhs, | |
| u32bit | rhs | |||
| ) |
| GFpElement BOTAN_DLL Botan::operator* | ( | const GFpElement & | lhs, | |
| const GFpElement & | rhs | |||
| ) |
Definition at line 651 of file gfp_element.cpp.
00652 { 00653 // consider the case that lhs and rhs both use montgm: 00654 // then *= returns an element which uses montgm. 00655 // thus the return value of op* here will be an element 00656 // using montgm in this case 00657 GFpElement result(lhs); 00658 result *= rhs; 00659 return result; 00660 }
| BigInt BOTAN_DLL Botan::operator* | ( | const BigInt & | x, | |
| const BigInt & | y | |||
| ) |
Definition at line 83 of file big_ops3.cpp.
References bigint_linmul3(), bigint_mul(), Botan::BigInt::data(), Botan::BigInt::Positive, Botan::BigInt::sig_words(), Botan::BigInt::sign(), Botan::BigInt::size(), and Botan::BigInt::word_at().
00084 { 00085 const u32bit x_sw = x.sig_words(), y_sw = y.sig_words(); 00086 00087 BigInt z(BigInt::Positive, x.size() + y.size()); 00088 00089 if(x_sw == 1 && y_sw) 00090 bigint_linmul3(z.get_reg(), y.data(), y_sw, x.word_at(0)); 00091 else if(y_sw == 1 && x_sw) 00092 bigint_linmul3(z.get_reg(), x.data(), x_sw, y.word_at(0)); 00093 else if(x_sw && y_sw) 00094 { 00095 SecureVector<word> workspace(z.size()); 00096 bigint_mul(z.get_reg(), z.size(), workspace, 00097 x.data(), x.size(), x_sw, 00098 y.data(), y.size(), y_sw); 00099 } 00100 00101 if(x_sw && y_sw && x.sign() != y.sign()) 00102 z.flip_sign(); 00103 return z; 00104 }
| BOTAN_DLL OctetString Botan::operator+ | ( | const OctetString & | k1, | |
| const OctetString & | k2 | |||
| ) |
| PointGFp BOTAN_DLL Botan::operator+ | ( | const PointGFp & | lhs, | |
| PointGFp const & | rhs | |||
| ) |
| GFpElement BOTAN_DLL Botan::operator+ | ( | const GFpElement & | lhs, | |
| const GFpElement & | rhs | |||
| ) |
Definition at line 626 of file gfp_element.cpp.
00627 { 00628 // consider the case that lhs and rhs both use montgm: 00629 // then += returns an element which uses montgm. 00630 // thus the return value of op+ here will be an element 00631 // using montgm in this case 00632 // NOTE: the rhs might be transformed when using op+, the lhs never 00633 GFpElement result(lhs); 00634 result += rhs; 00635 return result; 00636 }
| BigInt BOTAN_DLL Botan::operator+ | ( | const BigInt & | x, | |
| const BigInt & | y | |||
| ) |
Definition at line 19 of file big_ops3.cpp.
References bigint_add3(), bigint_cmp(), bigint_sub3(), Botan::BigInt::data(), Botan::BigInt::Positive, Botan::BigInt::sig_words(), and Botan::BigInt::sign().
00020 { 00021 const u32bit x_sw = x.sig_words(), y_sw = y.sig_words(); 00022 00023 BigInt z(x.sign(), std::max(x_sw, y_sw) + 1); 00024 00025 if((x.sign() == y.sign())) 00026 bigint_add3(z.get_reg(), x.data(), x_sw, y.data(), y_sw); 00027 else 00028 { 00029 s32bit relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw); 00030 00031 if(relative_size < 0) 00032 { 00033 bigint_sub3(z.get_reg(), y.data(), y_sw, x.data(), x_sw); 00034 z.set_sign(y.sign()); 00035 } 00036 else if(relative_size == 0) 00037 z.set_sign(BigInt::Positive); 00038 else if(relative_size > 0) 00039 bigint_sub3(z.get_reg(), x.data(), x_sw, y.data(), y_sw); 00040 } 00041 00042 return z; 00043 }
| OID Botan::operator+ | ( | const OID & | oid, | |
| u32bit | new_comp | |||
| ) |
Append another component onto the OID.
| oid | the OID to add the new component to | |
| new_comp | the new component to add |
Definition at line 79 of file asn1_oid.cpp.
00080 { 00081 OID new_oid(oid); 00082 new_oid += component; 00083 return new_oid; 00084 }
| PointGFp BOTAN_DLL Botan::operator- | ( | const PointGFp & | lhs | ) |
| PointGFp BOTAN_DLL Botan::operator- | ( | const PointGFp & | lhs, | |
| PointGFp const & | rhs | |||
| ) |
| GFpElement BOTAN_DLL Botan::operator- | ( | const GFpElement & | lhs | ) |
| GFpElement BOTAN_DLL Botan::operator- | ( | const GFpElement & | lhs, | |
| const GFpElement & | rhs | |||
| ) |
Definition at line 638 of file gfp_element.cpp.
00639 { 00640 GFpElement result(lhs); 00641 result -= rhs; 00642 return result; 00643 // NOTE: the rhs might be transformed when using op-, the lhs never 00644 }
| BigInt BOTAN_DLL Botan::operator- | ( | const BigInt & | x, | |
| const BigInt & | y | |||
| ) |
Definition at line 48 of file big_ops3.cpp.
References bigint_add3(), bigint_cmp(), bigint_shl2(), bigint_sub3(), Botan::BigInt::data(), Botan::BigInt::Positive, Botan::BigInt::reverse_sign(), Botan::BigInt::sig_words(), and Botan::BigInt::sign().
00049 { 00050 const u32bit x_sw = x.sig_words(), y_sw = y.sig_words(); 00051 00052 s32bit relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw); 00053 00054 BigInt z(BigInt::Positive, std::max(x_sw, y_sw) + 1); 00055 00056 if(relative_size < 0) 00057 { 00058 if(x.sign() == y.sign()) 00059 bigint_sub3(z.get_reg(), y.data(), y_sw, x.data(), x_sw); 00060 else 00061 bigint_add3(z.get_reg(), x.data(), x_sw, y.data(), y_sw); 00062 z.set_sign(y.reverse_sign()); 00063 } 00064 else if(relative_size == 0) 00065 { 00066 if(x.sign() != y.sign()) 00067 bigint_shl2(z.get_reg(), x.data(), x_sw, 0, 1); 00068 } 00069 else if(relative_size > 0) 00070 { 00071 if(x.sign() == y.sign()) 00072 bigint_sub3(z.get_reg(), x.data(), x_sw, y.data(), y_sw); 00073 else 00074 bigint_add3(z.get_reg(), x.data(), x_sw, y.data(), y_sw); 00075 z.set_sign(x.sign()); 00076 } 00077 return z; 00078 }
| GFpElement BOTAN_DLL Botan::operator/ | ( | const GFpElement & | lhs, | |
| const GFpElement & | rhs | |||
| ) |
| BigInt BOTAN_DLL Botan::operator/ | ( | const BigInt & | x, | |
| const BigInt & | y | |||
| ) |
Definition at line 109 of file big_ops3.cpp.
References divide().
00110 { 00111 BigInt q, r; 00112 divide(x, y, q, r); 00113 return q; 00114 }
| bool Botan::operator< | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) | [inline] |
| BOTAN_DLL bool Botan::operator< | ( | const CRL_Entry & | , | |
| const CRL_Entry & | ||||
| ) |
Order two entries based on the revocation date.
Definition at line 63 of file crl_ent.cpp.
References Botan::X509_Time::cmp(), and Botan::CRL_Entry::expire_time().
| bool BOTAN_DLL Botan::operator< | ( | const EAC_Time & | t1, | |
| const EAC_Time & | t2 | |||
| ) |
| bool Botan::operator< | ( | const OID & | a, | |
| const OID & | b | |||
| ) |
Compare two OIDs.
Definition at line 97 of file asn1_oid.cpp.
References Botan::OID::get_id().
00098 { 00099 std::vector<u32bit> oid1 = a.get_id(); 00100 std::vector<u32bit> oid2 = b.get_id(); 00101 00102 if(oid1.size() < oid2.size()) 00103 return true; 00104 if(oid1.size() > oid2.size()) 00105 return false; 00106 for(u32bit j = 0; j != oid1.size(); ++j) 00107 { 00108 if(oid1[j] < oid2[j]) 00109 return true; 00110 if(oid1[j] > oid2[j]) 00111 return false; 00112 } 00113 return false; 00114 }
| bool BOTAN_DLL Botan::operator< | ( | const X509_DN & | dn1, | |
| const X509_DN & | dn2 | |||
| ) |
Definition at line 210 of file asn1_dn.cpp.
References Botan::X509_DN::get_attributes().
00211 { 00212 typedef std::multimap<OID, std::string>::const_iterator rdn_iter; 00213 00214 std::multimap<OID, std::string> attr1 = dn1.get_attributes(); 00215 std::multimap<OID, std::string> attr2 = dn2.get_attributes(); 00216 00217 if(attr1.size() < attr2.size()) return true; 00218 if(attr1.size() > attr2.size()) return false; 00219 00220 for(rdn_iter p1 = attr1.begin(); p1 != attr1.end(); ++p1) 00221 { 00222 std::multimap<OID, std::string>::const_iterator p2; 00223 p2 = attr2.find(p1->first); 00224 if(p2 == attr2.end()) return false; 00225 if(p1->second > p2->second) return false; 00226 if(p1->second < p2->second) return true; 00227 } 00228 return false; 00229 }
| BOTAN_DLL std::ostream & Botan::operator<< | ( | std::ostream & | output, | |
| const GFpElement & | elem | |||
| ) |
write a GFpElement to an output stream.
| output | the output stream to write to | |
| elem | the object to write |
Definition at line 597 of file gfp_element.cpp.
References Botan::GFpElement::get_p(), and Botan::GFpElement::get_value().
| std::ostream & Botan::operator<< | ( | std::ostream & | output, | |
| const CurveGFp & | elem | |||
| ) |
Definition at line 160 of file curve_gfp.cpp.
References Botan::CurveGFp::get_a(), and Botan::CurveGFp::get_b().
00161 { 00162 return output << "y^2f = x^3 + (" << elem.get_a() << ")x + (" << elem.get_b() << ")"; 00163 }
| BigInt BOTAN_DLL Botan::operator<< | ( | const BigInt & | x, | |
| u32bit | shift | |||
| ) |
Definition at line 156 of file big_ops3.cpp.
References bigint_shl2(), Botan::BigInt::data(), Botan::BigInt::get_reg(), MP_WORD_BITS, Botan::BigInt::sig_words(), and Botan::BigInt::sign().
00157 { 00158 if(shift == 0) 00159 return x; 00160 00161 const u32bit shift_words = shift / MP_WORD_BITS, 00162 shift_bits = shift % MP_WORD_BITS; 00163 00164 const u32bit x_sw = x.sig_words(); 00165 00166 BigInt y(x.sign(), x_sw + shift_words + (shift_bits ? 1 : 0)); 00167 bigint_shl2(y.get_reg(), x.data(), x_sw, shift_words, shift_bits); 00168 return y; 00169 }
| BOTAN_DLL std::ostream & Botan::operator<< | ( | std::ostream & | stream, | |
| const BigInt & | n | |||
| ) |
Definition at line 16 of file big_io.cpp.
References base, Botan::MemoryRegion< T >::begin(), Botan::BigInt::Decimal, Botan::BigInt::encode(), Botan::BigInt::Hexadecimal, Botan::BigInt::Octal, and Botan::MemoryRegion< T >::size().
00017 { 00018 BigInt::Base base = BigInt::Decimal; 00019 if(stream.flags() & std::ios::hex) 00020 base = BigInt::Hexadecimal; 00021 else if(stream.flags() & std::ios::oct) 00022 base = BigInt::Octal; 00023 00024 if(n == 0) 00025 stream.write("0", 1); 00026 else 00027 { 00028 if(n < 0) 00029 stream.write("-", 1); 00030 SecureVector<byte> buffer = BigInt::encode(n, base); 00031 u32bit skip = 0; 00032 while(buffer[skip] == '0' && skip < buffer.size()) 00033 ++skip; 00034 stream.write(reinterpret_cast<const char*>(buffer.begin()) + skip, 00035 buffer.size() - skip); 00036 } 00037 if(!stream.good()) 00038 throw Stream_IO_Error("BigInt output operator has failed"); 00039 return stream; 00040 }
| std::ostream & Botan::operator<< | ( | std::ostream & | stream, | |
| Pipe & | pipe | |||
| ) |
Definition at line 16 of file pipe_io.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::Pipe::read(), Botan::Pipe::remaining(), and Botan::MemoryRegion< T >::size().
00017 { 00018 SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); 00019 while(stream.good() && pipe.remaining()) 00020 { 00021 u32bit got = pipe.read(buffer, buffer.size()); 00022 stream.write(reinterpret_cast<const char*>(buffer.begin()), got); 00023 } 00024 if(!stream.good()) 00025 throw Stream_IO_Error("Pipe output operator (iostream) has failed"); 00026 return stream; 00027 }
| int BOTAN_DLL Botan::operator<< | ( | int | fd, | |
| Pipe & | pipe | |||
| ) |
Definition at line 17 of file fd_unix.cpp.
References Botan::Pipe::read(), Botan::Pipe::remaining(), and Botan::MemoryRegion< T >::size().
00018 { 00019 SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); 00020 while(pipe.remaining()) 00021 { 00022 u32bit got = pipe.read(buffer, buffer.size()); 00023 u32bit position = 0; 00024 while(got) 00025 { 00026 ssize_t ret = write(fd, buffer + position, got); 00027 if(ret == -1) 00028 throw Stream_IO_Error("Pipe output operator (unixfd) has failed"); 00029 position += ret; 00030 got -= ret; 00031 } 00032 } 00033 return fd; 00034 }
| bool Botan::operator<= | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) | [inline] |
| bool BOTAN_DLL Botan::operator<= | ( | const EAC_Time & | t1, | |
| const EAC_Time & | t2 | |||
| ) |
| bool Botan::operator<= | ( | const X509_Time & | t1, | |
| const X509_Time & | t2 | |||
| ) |
| BOTAN_DLL bool Botan::operator== | ( | const OctetString & | s1, | |
| const OctetString & | s2 | |||
| ) |
| bool BOTAN_DLL Botan::operator== | ( | EC_Domain_Params const & | lhs, | |
| EC_Domain_Params const & | rhs | |||
| ) |
Definition at line 572 of file ec_dompar.cpp.
References Botan::EC_Domain_Params::get_base_point(), Botan::EC_Domain_Params::get_cofactor(), Botan::EC_Domain_Params::get_curve(), and Botan::EC_Domain_Params::get_order().
00573 { 00574 return ((lhs.get_curve() == rhs.get_curve()) && 00575 (lhs.get_base_point() == rhs.get_base_point()) && 00576 (lhs.get_order() == rhs.get_order()) && 00577 (lhs.get_cofactor() == rhs.get_cofactor())); 00578 }
| bool BOTAN_DLL Botan::operator== | ( | const PointGFp & | lhs, | |
| PointGFp const & | rhs | |||
| ) |
Definition at line 847 of file point_gfp.cpp.
References Botan::PointGFp::get_curve(), Botan::PointGFp::get_jac_proj_x(), Botan::PointGFp::get_jac_proj_y(), Botan::PointGFp::get_z_to_one(), and Botan::PointGFp::is_zero().
00848 { 00849 if (lhs.is_zero() && rhs.is_zero()) 00850 { 00851 return true; 00852 } 00853 if ((lhs.is_zero() && !rhs.is_zero()) || (!lhs.is_zero() && rhs.is_zero())) 00854 { 00855 return false; 00856 } 00857 // neither operand is zero, so we can call get_z_to_one() 00858 //assert(!lhs.is_zero()); 00859 //assert(!rhs.is_zero()); 00860 PointGFp aff_lhs = lhs.get_z_to_one(); 00861 PointGFp aff_rhs = rhs.get_z_to_one(); 00862 return (aff_lhs.get_curve() == aff_rhs.get_curve() && 00863 aff_lhs.get_jac_proj_x() == aff_rhs.get_jac_proj_x() && 00864 aff_lhs.get_jac_proj_y() == aff_rhs.get_jac_proj_y()); 00865 }
| bool BOTAN_DLL Botan::operator== | ( | const GFpElement & | lhs, | |
| const GFpElement & | rhs | |||
| ) |
Definition at line 602 of file gfp_element.cpp.
References Botan::GFpElement::align_operands_res(), Botan::GFpElement::get_mres(), Botan::GFpElement::get_p(), Botan::GFpElement::get_ptr_mod(), and Botan::GFpElement::get_value().
00603 { 00604 // for effeciency reasons we firstly check whether 00605 //the modulus pointers are different in the first place: 00606 if(lhs.get_ptr_mod() != rhs.get_ptr_mod()) 00607 { 00608 if(lhs.get_p() != rhs.get_p()) 00609 { 00610 return false; 00611 } 00612 } 00613 // so the modulus is equal, now check the values 00614 bool use_mres = GFpElement::align_operands_res(lhs, rhs); 00615 00616 if(use_mres) 00617 { 00618 return (lhs.get_mres() == rhs.get_mres()); 00619 } 00620 else 00621 { 00622 return(lhs.get_value() == rhs.get_value()); 00623 } 00624 }
| bool Botan::operator== | ( | const CurveGFp & | lhs, | |
| const CurveGFp & | rhs | |||
| ) |
Definition at line 155 of file curve_gfp.cpp.
References Botan::CurveGFp::get_a(), Botan::CurveGFp::get_b(), and Botan::CurveGFp::get_p().
00156 { 00157 return (lhs.get_p() == rhs.get_p() && lhs.get_a() == rhs.get_a() && lhs.get_b() == rhs.get_b()); 00158 }
| bool Botan::operator== | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) | [inline] |
| BOTAN_DLL bool Botan::operator== | ( | const CRL_Entry & | , | |
| const CRL_Entry & | ||||
| ) |
Test two CRL entries for equality in all fields.
Definition at line 41 of file crl_ent.cpp.
References Botan::CRL_Entry::expire_time(), Botan::CRL_Entry::reason_code(), and Botan::CRL_Entry::serial_number().
00042 { 00043 if(a1.serial_number() != a2.serial_number()) 00044 return false; 00045 if(a1.expire_time() != a2.expire_time()) 00046 return false; 00047 if(a1.reason_code() != a2.reason_code()) 00048 return false; 00049 return true; 00050 }
| bool Botan::operator== | ( | const ECDSA_Signature & | lhs, | |
| const ECDSA_Signature & | rhs | |||
| ) |
Definition at line 23 of file ecdsa_sig.cpp.
References Botan::ECDSA_Signature::get_r(), and Botan::ECDSA_Signature::get_s().
| bool BOTAN_DLL Botan::operator== | ( | const EAC_Time & | t1, | |
| const EAC_Time & | t2 | |||
| ) |
| bool BOTAN_DLL Botan::operator== | ( | const ASN1_EAC_String & | lhs, | |
| const ASN1_EAC_String & | rhs | |||
| ) |
| bool Botan::operator== | ( | const X509_Time & | t1, | |
| const X509_Time & | t2 | |||
| ) |
| bool BOTAN_DLL Botan::operator== | ( | const X509_DN & | dn1, | |
| const X509_DN & | dn2 | |||
| ) |
Definition at line 172 of file asn1_dn.cpp.
References Botan::X509_DN::get_attributes(), and x500_name_cmp().
00173 { 00174 typedef std::multimap<OID, std::string>::const_iterator rdn_iter; 00175 00176 std::multimap<OID, std::string> attr1 = dn1.get_attributes(); 00177 std::multimap<OID, std::string> attr2 = dn2.get_attributes(); 00178 00179 if(attr1.size() != attr2.size()) return false; 00180 00181 rdn_iter p1 = attr1.begin(); 00182 rdn_iter p2 = attr2.begin(); 00183 00184 while(true) 00185 { 00186 if(p1 == attr1.end() && p2 == attr2.end()) 00187 break; 00188 if(p1 == attr1.end()) return false; 00189 if(p2 == attr2.end()) return false; 00190 if(p1->first != p2->first) return false; 00191 if(!x500_name_cmp(p1->second, p2->second)) 00192 return false; 00193 ++p1; 00194 ++p2; 00195 } 00196 return true; 00197 }
| bool BOTAN_DLL Botan::operator== | ( | const AlgorithmIdentifier & | a1, | |
| const AlgorithmIdentifier & | a2 | |||
| ) |
Definition at line 64 of file alg_id.cpp.
References Botan::AlgorithmIdentifier::oid, and Botan::AlgorithmIdentifier::parameters.
Referenced by operator!=().
00065 { 00066 if(a1.oid != a2.oid) 00067 return false; 00068 if(a1.parameters != a2.parameters) 00069 return false; 00070 return true; 00071 }
| bool Botan::operator> | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) | [inline] |
| bool BOTAN_DLL Botan::operator> | ( | const EAC_Time & | t1, | |
| const EAC_Time & | t2 | |||
| ) |
| bool Botan::operator>= | ( | const BigInt & | a, | |
| const BigInt & | b | |||
| ) | [inline] |
| bool BOTAN_DLL Botan::operator>= | ( | const EAC_Time & | t1, | |
| const EAC_Time & | t2 | |||
| ) |
| bool Botan::operator>= | ( | const X509_Time & | t1, | |
| const X509_Time & | t2 | |||
| ) |
| BigInt BOTAN_DLL Botan::operator>> | ( | const BigInt & | x, | |
| u32bit | shift | |||
| ) |
Definition at line 174 of file big_ops3.cpp.
References bigint_shr2(), Botan::BigInt::bits(), Botan::BigInt::data(), MP_WORD_BITS, Botan::BigInt::sig_words(), and Botan::BigInt::sign().
00175 { 00176 if(shift == 0) 00177 return x; 00178 if(x.bits() <= shift) 00179 return 0; 00180 00181 const u32bit shift_words = shift / MP_WORD_BITS, 00182 shift_bits = shift % MP_WORD_BITS, 00183 x_sw = x.sig_words(); 00184 00185 BigInt y(x.sign(), x_sw - shift_words); 00186 bigint_shr2(y.get_reg(), x.data(), x_sw, shift_words, shift_bits); 00187 return y; 00188 }
| BOTAN_DLL std::istream & Botan::operator>> | ( | std::istream & | stream, | |
| BigInt & | n | |||
| ) |
Definition at line 45 of file big_io.cpp.
00046 { 00047 std::string str; 00048 std::getline(stream, str); 00049 if(stream.bad() || (stream.fail() && !stream.eof())) 00050 throw Stream_IO_Error("BigInt input operator has failed"); 00051 n = BigInt(str); 00052 return stream; 00053 }
| std::istream & Botan::operator>> | ( | std::istream & | stream, | |
| Pipe & | pipe | |||
| ) |
Definition at line 32 of file pipe_io.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::MemoryRegion< T >::size(), and Botan::Pipe::write().
00033 { 00034 SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); 00035 while(stream.good()) 00036 { 00037 stream.read(reinterpret_cast<char*>(buffer.begin()), buffer.size()); 00038 pipe.write(buffer, stream.gcount()); 00039 } 00040 if(stream.bad() || (stream.fail() && !stream.eof())) 00041 throw Stream_IO_Error("Pipe input operator (iostream) has failed"); 00042 return stream; 00043 }
| int BOTAN_DLL Botan::operator>> | ( | int | fd, | |
| Pipe & | pipe | |||
| ) |
Definition at line 39 of file fd_unix.cpp.
References Botan::MemoryRegion< T >::size(), and Botan::Pipe::write().
00040 { 00041 SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); 00042 while(true) 00043 { 00044 ssize_t ret = read(fd, buffer, buffer.size()); 00045 if(ret == 0) break; 00046 if(ret == -1) 00047 throw Stream_IO_Error("Pipe input operator (unixfd) has failed"); 00048 pipe.write(buffer, ret); 00049 } 00050 return fd; 00051 }
| BOTAN_DLL OctetString Botan::operator^ | ( | const OctetString & | k1, | |
| const OctetString & | k2 | |||
| ) |
Definition at line 133 of file symkey.cpp.
References Botan::OctetString::begin(), Botan::MemoryRegion< T >::copy(), Botan::OctetString::length(), and xor_buf().
00134 { 00135 SecureVector<byte> ret(std::max(k1.length(), k2.length())); 00136 ret.copy(k1.begin(), k1.length()); 00137 xor_buf(ret, k2.begin(), k2.length()); 00138 return OctetString(ret); 00139 }
| PointGFp BOTAN_DLL Botan::OS2ECP | ( | MemoryRegion< byte > const & | os, | |
| const CurveGFp & | curve | |||
| ) |
Definition at line 1017 of file point_gfp.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::MemoryRegion< T >::copy(), Botan::BigInt::decode(), Botan::PointGFp::decompress(), Botan::CurveGFp::get_p(), and Botan::MemoryRegion< T >::size().
Referenced by Botan::ECKAEG_PrivateKey::derive_key(), Botan::ECDSA_PublicKey::set_domain_parameters(), and Botan::EC_PublicKey::x509_decoder().
01018 { 01019 if (os.size() == 1 && os[0] == 0) 01020 { 01021 return PointGFp(curve); // return zero 01022 } 01023 SecureVector<byte> bX; 01024 SecureVector<byte> bY; 01025 01026 GFpElement x(1,0); 01027 GFpElement y(1,0); 01028 GFpElement z(1,0); 01029 01030 const byte pc = os[0]; 01031 BigInt bi_dec_x; 01032 BigInt bi_dec_y; 01033 switch (pc) 01034 { 01035 case 2: 01036 case 3: 01037 //compressed form 01038 bX = SecureVector<byte>(os.size() - 1); 01039 bX.copy(os.begin()+1, os.size()-1); 01040 01041 /* Problem wäre, wenn decode() das erste bit als Vorzeichen interpretiert. 01042 *--------------------- 01043 * AW(FS): decode() interpretiert das erste Bit nicht als Vorzeichen 01044 */ 01045 bi_dec_x = BigInt::decode(bX, bX.size()); 01046 x = GFpElement(curve.get_p(), bi_dec_x); 01047 bool yMod2; 01048 yMod2 = (pc & 1) == 1; 01049 y = PointGFp::decompress(yMod2, x, curve); 01050 break; 01051 case 4: 01052 // uncompressed form 01053 int l; 01054 l = (os.size() -1)/2; 01055 bX = SecureVector<byte>(l); 01056 bY = SecureVector<byte>(l); 01057 bX.copy(os.begin()+1, l); 01058 bY.copy(os.begin()+1+l, l); 01059 bi_dec_x = BigInt::decode(bX.begin(), bX.size()); 01060 01061 bi_dec_y = BigInt::decode(bY.begin(),bY.size()); 01062 x = GFpElement(curve.get_p(), bi_dec_x); 01063 y = GFpElement(curve.get_p(), bi_dec_y); 01064 break; 01065 01066 case 6: 01067 case 7: 01068 //hybrid form 01069 l = (os.size() - 1)/2; 01070 bX = SecureVector<byte>(l); 01071 bY = SecureVector<byte>(l); 01072 bX.copy(os.begin() + 1, l); 01073 bY.copy(os.begin()+1+l, l); 01074 yMod2 = (pc & 0x01) == 1; 01075 if (!(PointGFp::decompress(yMod2, x, curve) == y)) 01076 { 01077 throw Illegal_Point("error during decoding hybrid format"); 01078 } 01079 break; 01080 default: 01081 throw Invalid_Argument("encountered illegal format specification while decoding point"); 01082 } 01083 z = GFpElement(curve.get_p(), BigInt(1)); 01084 //assert((x.is_trf_to_mres() && x.is_use_montgm()) || !x.is_trf_to_mres()); 01085 //assert((y.is_trf_to_mres() && y.is_use_montgm()) || !y.is_trf_to_mres()); 01086 //assert((z.is_trf_to_mres() && z.is_use_montgm()) || !z.is_trf_to_mres()); 01087 PointGFp result(curve, x, y, z); 01088 result.check_invariants(); 01089 //assert((result.get_jac_proj_x().is_trf_to_mres() && result.get_jac_proj_x().is_use_montgm()) || !result.get_jac_proj_x().is_trf_to_mres()); 01090 //assert((result.get_jac_proj_y().is_trf_to_mres() && result.get_jac_proj_y().is_use_montgm()) || !result.get_jac_proj_y().is_trf_to_mres()); 01091 //assert((result.get_jac_proj_z().is_trf_to_mres() && result.get_jac_proj_z().is_use_montgm()) || !result.get_jac_proj_z().is_trf_to_mres()); 01092 return result; 01093 }
| GFpElement BOTAN_DLL Botan::OS2FEP | ( | MemoryRegion< byte > const & | os, | |
| BigInt | p | |||
| ) |
Definition at line 686 of file gfp_element.cpp.
References Botan::MemoryRegion< T >::begin(), Botan::BigInt::decode(), and Botan::MemoryRegion< T >::size().
00687 { 00688 return GFpElement(p, BigInt::decode(os.begin(), os.size())); 00689 }
| BOTAN_DLL u32bit Botan::output_length_of | ( | const std::string & | name | ) |
Query the OUTPUT_LENGTH of a hash or MAC
Find out the output length of a certain symmetric algorithm.
| name | the name of the algorithm |
Definition at line 51 of file lookup.cpp.
References Botan::Library_State::algorithm_factory(), global_state(), mac, Botan::BufferedComputation::OUTPUT_LENGTH, Botan::Algorithm_Factory::prototype_hash_function(), and Botan::Algorithm_Factory::prototype_mac().
00052 { 00053 Algorithm_Factory& af = global_state().algorithm_factory(); 00054 00055 if(const HashFunction* hash = af.prototype_hash_function(name)) 00056 return hash->OUTPUT_LENGTH; 00057 00058 if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) 00059 return mac->OUTPUT_LENGTH; 00060 00061 throw Algorithm_Not_Found(name); 00062 }
| BOTAN_DLL std::vector< std::string > Botan::parse_algorithm_name | ( | const std::string & | namex | ) |
Definition at line 96 of file parsing.cpp.
Referenced by get_cipher_mode().
00097 { 00098 if(namex.find('(') == std::string::npos && 00099 namex.find(')') == std::string::npos) 00100 return std::vector<std::string>(1, namex); 00101 00102 std::string name = namex, substring; 00103 std::vector<std::string> elems; 00104 u32bit level = 0; 00105 00106 elems.push_back(name.substr(0, name.find('('))); 00107 name = name.substr(name.find('(')); 00108 00109 for(std::string::const_iterator j = name.begin(); j != name.end(); ++j) 00110 { 00111 char c = *j; 00112 00113 if(c == '(') 00114 ++level; 00115 if(c == ')') 00116 { 00117 if(level == 1 && j == name.end() - 1) 00118 { 00119 if(elems.size() == 1) 00120 elems.push_back(substring.substr(1)); 00121 else 00122 elems.push_back(substring); 00123 return elems; 00124 } 00125 00126 if(level == 0 || (level == 1 && j != name.end() - 1)) 00127 throw Invalid_Algorithm_Name(namex); 00128 --level; 00129 } 00130 00131 if(c == ',' && level == 1) 00132 { 00133 if(elems.size() == 1) 00134 elems.push_back(substring.substr(1)); 00135 else 00136 elems.push_back(substring); 00137 substring.clear(); 00138 } 00139 else 00140 substring += c; 00141 } 00142 00143 if(substring != "") 00144 throw Invalid_Algorithm_Name(namex); 00145 00146 return elems; 00147 }
| BOTAN_DLL std::vector< u32bit > Botan::parse_asn1_oid | ( | const std::string & | oid | ) |
Definition at line 180 of file parsing.cpp.
References to_u32bit().
Referenced by Botan::OID::OID().
00181 { 00182 std::string substring; 00183 std::vector<u32bit> oid_elems; 00184 00185 for(std::string::const_iterator j = oid.begin(); j != oid.end(); ++j) 00186 { 00187 char c = *j; 00188 00189 if(c == '.') 00190 { 00191 if(substring == "") 00192 throw Invalid_OID(oid); 00193 oid_elems.push_back(to_u32bit(substring)); 00194 substring.clear(); 00195 } 00196 else 00197 substring += c; 00198 } 00199 00200 if(substring == "") 00201 throw Invalid_OID(oid); 00202 oid_elems.push_back(to_u32bit(substring)); 00203 00204 if(oid_elems.size() < 2) 00205 throw Invalid_OID(oid); 00206 00207 return oid_elems; 00208 }
| bool BOTAN_DLL Botan::passes_mr_tests | ( | RandomNumberGenerator & | rng, | |
| const BigInt & | n, | |||
| u32bit | level | |||
| ) |
Definition at line 264 of file numthry.cpp.
References Botan::BigInt::bits(), Botan::MillerRabin_Test::passes_test(), and PRIMES.
Referenced by random_prime(), and run_primality_tests().
00266 { 00267 const u32bit PREF_NONCE_BITS = 40; 00268 00269 if(level > 2) 00270 level = 2; 00271 00272 MillerRabin_Test mr(n); 00273 00274 if(!mr.passes_test(2)) 00275 return false; 00276 00277 if(level == 0) 00278 return true; 00279 00280 const u32bit NONCE_BITS = std::min(n.bits() - 1, PREF_NONCE_BITS); 00281 00282 const bool verify = (level == 2); 00283 00284 u32bit tests = miller_rabin_test_iterations(n.bits(), verify); 00285 00286 BigInt nonce; 00287 for(u32bit i = 0; i != tests; ++i) 00288 { 00289 if(!verify && PRIMES[i] < (n-1)) 00290 nonce = PRIMES[i]; 00291 else 00292 { 00293 while(nonce < 2 || nonce >= (n-1)) 00294 nonce.randomize(rng, NONCE_BITS); 00295 } 00296 00297 if(!mr.passes_test(nonce)) 00298 return false; 00299 } 00300 return true; 00301 }
| BOTAN_DLL bool Botan::passes_self_tests | ( | Algorithm_Factory & | af | ) |
Definition at line 200 of file selftest.cpp.
References confirm_startup_self_tests().
00201 { 00202 try 00203 { 00204 confirm_startup_self_tests(af); 00205 } 00206 catch(Self_Test_Failure) 00207 { 00208 return false; 00209 } 00210 00211 return true; 00212 }
| BOTAN_DLL MemoryVector< byte > Botan::pkcs_hash_id | ( | const std::string & | name | ) |
Definition at line 62 of file hash_id.cpp.
References Botan::PKCS_IDS::MD2_ID, Botan::PKCS_IDS::MD5_ID, Botan::PKCS_IDS::RIPEMD_128_ID, Botan::PKCS_IDS::RIPEMD_160_ID, Botan::MemoryRegion< T >::set(), Botan::PKCS_IDS::SHA_160_ID, Botan::PKCS_IDS::SHA_224_ID, Botan::PKCS_IDS::SHA_256_ID, Botan::PKCS_IDS::SHA_384_ID, Botan::PKCS_IDS::SHA_512_ID, Botan::MemoryRegion< T >::size(), and Botan::PKCS_IDS::TIGER_ID.
Referenced by Botan::EMSA3::EMSA3().
00063 { 00064 MemoryVector<byte> out; 00065 00066 if(name == "Parallel(MD5,SHA-160)") 00067 return out; 00068 00069 if(name == "MD2") 00070 out.set(PKCS_IDS::MD2_ID, sizeof(PKCS_IDS::MD2_ID)); 00071 else if(name == "MD5") 00072 out.set(PKCS_IDS::MD5_ID, sizeof(PKCS_IDS::MD5_ID)); 00073 else if(name == "RIPEMD-128") 00074 out.set(PKCS_IDS::RIPEMD_128_ID, sizeof(PKCS_IDS::RIPEMD_128_ID)); 00075 else if(name == "RIPEMD-160") 00076 out.set(PKCS_IDS::RIPEMD_160_ID, sizeof(PKCS_IDS::RIPEMD_160_ID)); 00077 else if(name == "SHA-160") 00078 out.set(PKCS_IDS::SHA_160_ID, sizeof(PKCS_IDS::SHA_160_ID)); 00079 else if(name == "SHA-224") 00080 out.set(PKCS_IDS::SHA_224_ID, sizeof(PKCS_IDS::SHA_224_ID)); 00081 else if(name == "SHA-256") 00082 out.set(PKCS_IDS::SHA_256_ID, sizeof(PKCS_IDS::SHA_256_ID)); 00083 else if(name == "SHA-384") 00084 out.set(PKCS_IDS::SHA_384_ID, sizeof(PKCS_IDS::SHA_384_ID)); 00085 else if(name == "SHA-512") 00086 out.set(PKCS_IDS::SHA_512_ID, sizeof(PKCS_IDS::SHA_512_ID)); 00087 else if(name == "Tiger(24,3)") 00088 out.set(PKCS_IDS::TIGER_ID, sizeof(PKCS_IDS::TIGER_ID)); 00089 00090 if(out.size()) 00091 return out; 00092 00093 throw Invalid_Argument("No PKCS #1 identifier for " + name); 00094 }
| BigInt BOTAN_DLL Botan::power_mod | ( | const BigInt & | base, | |
| const BigInt & | exp, | |||
| const BigInt & | mod | |||
| ) |
Definition at line 187 of file numthry.cpp.
References Botan::Power_Mod::execute(), Botan::Power_Mod::set_base(), and Botan::Power_Mod::set_exponent().
Referenced by Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_Core::DH_Core(), Botan::ELG_Core::ELG_Core(), Botan::IF_Core::IF_Core(), and ressol().
00188 { 00189 Power_Mod pow_mod(mod); 00190 pow_mod.set_base(base); 00191 pow_mod.set_exponent(exp); 00192 return pow_mod.execute(); 00193 }
| bool Botan::power_of_2 | ( | T | arg | ) | [inline] |
Definition at line 20 of file bit_ops.h.
Referenced by operator%(), Botan::BigInt::operator%=(), and Botan::BigInt::operator/=().
| BigInt BOTAN_DLL Botan::random_prime | ( | RandomNumberGenerator & | rng, | |
| u32bit | bits, | |||
| const BigInt & | coprime, | |||
| u32bit | equiv, | |||
| u32bit | modulo | |||
| ) |
Definition at line 17 of file make_prm.cpp.
References Botan::BigInt::bits(), gcd(), Botan::RandomNumberGenerator::next_byte(), passes_mr_tests(), PRIME_TABLE_SIZE, PRIMES, Botan::BigInt::set_bit(), Botan::MemoryRegion< T >::size(), and to_string().
Referenced by Botan::DL_Group::DL_Group(), random_safe_prime(), Botan::RSA_PrivateKey::RSA_PrivateKey(), and Botan::RW_PrivateKey::RW_PrivateKey().
00020 { 00021 if(bits <= 1) 00022 throw Invalid_Argument("random_prime: Can't make a prime of " + 00023 to_string(bits) + " bits"); 00024 else if(bits == 2) 00025 return ((rng.next_byte() % 2) ? 2 : 3); 00026 else if(bits == 3) 00027 return ((rng.next_byte() % 2) ? 5 : 7); 00028 else if(bits == 4) 00029 return ((rng.next_byte() % 2) ? 11 : 13); 00030 00031 if(coprime <= 0) 00032 throw Invalid_Argument("random_prime: coprime must be > 0"); 00033 if(modulo % 2 == 1 || modulo == 0) 00034 throw Invalid_Argument("random_prime: Invalid modulo value"); 00035 if(equiv >= modulo || equiv % 2 == 0) 00036 throw Invalid_Argument("random_prime: equiv must be < modulo, and odd"); 00037 00038 while(true) 00039 { 00040 BigInt p(rng, bits); 00041 p.set_bit(bits - 2); 00042 p.set_bit(0); 00043 00044 if(p % modulo != equiv) 00045 p += (modulo - p % modulo) + equiv; 00046 00047 const u32bit sieve_size = std::min(bits / 2, PRIME_TABLE_SIZE); 00048 SecureVector<u32bit> sieve(sieve_size); 00049 00050 for(u32bit j = 0; j != sieve.size(); ++j) 00051 sieve[j] = p % PRIMES[j]; 00052 00053 u32bit counter = 0; 00054 while(true) 00055 { 00056 if(counter == 4096 || p.bits() > bits) 00057 break; 00058 00059 bool passes_sieve = true; 00060 ++counter; 00061 p += modulo; 00062 00063 if(p.bits() > bits) 00064 break; 00065 00066 for(u32bit j = 0; j != sieve.size(); ++j) 00067 { 00068 sieve[j] = (sieve[j] + modulo) % PRIMES[j]; 00069 if(sieve[j] == 0) 00070 passes_sieve = false; 00071 } 00072 00073 if(!passes_sieve || gcd(p - 1, coprime) != 1) 00074 continue; 00075 if(passes_mr_tests(rng, p)) 00076 return p; 00077 } 00078 } 00079 }
| BigInt BOTAN_DLL Botan::random_safe_prime | ( | RandomNumberGenerator & | rng, | |
| u32bit | bits | |||
| ) |
Definition at line 84 of file make_prm.cpp.
References is_prime(), random_prime(), and to_string().
Referenced by Botan::DL_Group::DL_Group().
00085 { 00086 if(bits <= 64) 00087 throw Invalid_Argument("random_safe_prime: Can't make a prime of " + 00088 to_string(bits) + " bits"); 00089 00090 BigInt p; 00091 do 00092 p = (random_prime(rng, bits - 1) << 1) + 1; 00093 while(!is_prime(p, rng)); 00094 return p; 00095 }
| BigInt Botan::ressol | ( | const BigInt & | x, | |
| const BigInt & | p | |||
| ) |
Definition at line 17 of file ressol.cpp.
References jacobi(), low_zero_bits(), Botan::Modular_Reducer::multiply(), Botan::BigInt::Power2, power_mod(), and Botan::Modular_Reducer::square().
Referenced by create_random_point(), and Botan::PointGFp::decompress().
00018 { 00019 if(a < 0) 00020 throw Invalid_Argument("ressol(): a to solve for must be positive"); 00021 if(p <= 1) 00022 throw Invalid_Argument("ressol(): prime must be > 1"); 00023 00024 if(a == 0) 00025 return 0; 00026 if(p == 2) 00027 return a; 00028 00029 if(jacobi(a, p) != 1) // not a quadratic residue 00030 return -BigInt(1); 00031 00032 if(p % 4 == 3) 00033 return power_mod(a, ((p+1) >> 2), p); 00034 00035 u32bit s = low_zero_bits(p - 1); 00036 BigInt q = p >> s; 00037 00038 q -= 1; 00039 q >>= 1; 00040 00041 Modular_Reducer mod_p(p); 00042 00043 BigInt r = power_mod(a, q, p); 00044 BigInt n = mod_p.multiply(a, mod_p.square(r)); 00045 r = mod_p.multiply(r, a); 00046 00047 if(n == 1) 00048 return r; 00049 00050 // find random non quadratic residue z 00051 BigInt z = 2; 00052 while(jacobi(z, p) == 1) // while z quadratic residue 00053 ++z; 00054 00055 BigInt c = power_mod(z, (q << 1) + 1, p); 00056 00057 while(n > 1) 00058 { 00059 q = n; 00060 00061 u32bit i = 0; 00062 while(q != 1) 00063 { 00064 q = mod_p.square(q); 00065 ++i; 00066 } 00067 00068 if(s <= i) 00069 return -BigInt(1); 00070 00071 c = power_mod(c, BigInt(BigInt::Power2, s-i-1), p); 00072 r = mod_p.multiply(r, c); 00073 c = mod_p.square(c); 00074 n = mod_p.multiply(n, c); 00075 s = i; 00076 } 00077 00078 return r; 00079 }
| const BlockCipher* Botan::retrieve_block_cipher | ( | const std::string & | algo_spec | ) | [inline] |
Definition at line 29 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_block_cipher().
00030 { 00031 Algorithm_Factory& af = global_state().algorithm_factory(); 00032 return af.prototype_block_cipher(algo_spec); 00033 }
| const HashFunction* Botan::retrieve_hash | ( | const std::string & | algo_spec | ) | [inline] |
Definition at line 43 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_hash_function().
Referenced by choose_sig_format().
00044 { 00045 Algorithm_Factory& af = global_state().algorithm_factory(); 00046 return af.prototype_hash_function(algo_spec); 00047 }
| const MessageAuthenticationCode* Botan::retrieve_mac | ( | const std::string & | algo_spec | ) | [inline] |
Definition at line 50 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_mac().
00051 { 00052 Algorithm_Factory& af = global_state().algorithm_factory(); 00053 return af.prototype_mac(algo_spec); 00054 }
| const StreamCipher* Botan::retrieve_stream_cipher | ( | const std::string & | algo_spec | ) | [inline] |
Definition at line 36 of file lookup.h.
References Botan::Library_State::algorithm_factory(), global_state(), and Botan::Algorithm_Factory::prototype_stream_cipher().
00037 { 00038 Algorithm_Factory& af = global_state().algorithm_factory(); 00039 return af.prototype_stream_cipher(algo_spec); 00040 }
| u64bit Botan::reverse_bytes | ( | u64bit | input | ) | [inline] |
Definition at line 49 of file bswap.h.
References reverse_bytes().
00050 { 00051 #if BOTAN_USE_GCC_INLINE_ASM && defined(BOTAN_TARGET_ARCH_IS_AMD64) 00052 // GCC-style inline assembly for x86-64 00053 asm("bswapq %0" : "=r" (input) : "0" (input)); 00054 return input; 00055 00056 #else 00057 /* Generic implementation. Defined in terms of 32-bit bswap so any 00058 * optimizations in that version can help here (particularly 00059 * useful for 32-bit x86). 00060 */ 00061 00062 u32bit hi = static_cast<u32bit>(input >> 32); 00063 u32bit lo = static_cast<u32bit>(input); 00064 00065 hi = reverse_bytes(hi); 00066 lo = reverse_bytes(lo); 00067 00068 return (static_cast<u64bit>(lo) << 32) | hi; 00069 #endif 00070 }