Update botan library.

Old version was 1.8.8, new one is 1.10.2.
We now put all the code into one pair of files (via
a botan configure option) and move platform-specific
defines into the pro/qbs files. Besides drastically
reducing the number of files, this is expected to make
future updates less messy.

Change-Id: I004166b2ab15b6a699d69aebfcfd9999c5ccdb91
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christian Kandeler
2012-06-26 09:31:01 +02:00
committed by hjk
parent c6ac435daf
commit fcc9ba4b99
1770 changed files with 64876 additions and 178421 deletions

47531
src/libs/3rdparty/botan/botan.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

16197
src/libs/3rdparty/botan/botan.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,2 @@
INCLUDEPATH *= $$PWD/build
INCLUDEPATH *= $$PWD/..
LIBS *= -l$$qtLibraryName(Botan)

View File

@@ -1,4 +1,51 @@
TEMPLATE = subdirs
CONFIG += ordered
TEMPLATE = lib
TARGET = Botan
SUBDIRS += src
PRECOMPILED_HEADER = ../precompiled_headers/botan_pch.h
include(../../../qtcreatorlibrary.pri)
CONFIG += exceptions
DEPENDPATH += .
INCLUDEPATH += .
unix:QMAKE_CXXFLAGS_DEBUG += -O2
unix:DEFINES+=BOTAN_TARGET_OS_HAS_GETTIMEOFDAY BOTAN_HAS_ALLOC_MMAP \
BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM BOTAN_HAS_ENTROPY_SRC_EGD BOTAN_HAS_ENTROPY_SRC_FTW \
BOTAN_HAS_ENTROPY_SRC_UNIX BOTAN_HAS_MUTEX_PTHREAD BOTAN_HAS_PIPE_UNIXFD_IO
*linux*:DEFINES+=BOTAN_TARGET_OS_IS_LINUX BOTAN_TARGET_OS_HAS_CLOCK_GETTIME \
BOTAN_TARGET_OS_HAS_DLOPEN BOTAN_TARGET_OS_HAS_GMTIME_R BOTAN_TARGET_OS_HAS_POSIX_MLOCK \
BOTAN_HAS_DYNAMICALLY_LOADED_ENGINE BOTAN_HAS_DYNAMIC_LOADER
macx:DEFINES+=BOTAN_TARGET_OS_IS_DARWIN
*g++*:DEFINES+=BOTAN_BUILD_COMPILER_IS_GCC
win32 {
DEFINES+=BOTAN_TARGET_OS_IS_WINDOWS BOTAN_TARGET_OS_HAS_GMTIME_S \
BOTAN_TARGET_OS_HAS_LOADLIBRARY BOTAN_TARGET_OS_HAS_WIN32_GET_SYSTEMTIME \
BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK BOTAN_HAS_DYNAMICALLY_LOADED_ENGINE \
BOTAN_HAS_DYNAMIC_LOADER BOTAN_HAS_ENTROPY_SRC_CAPI BOTAN_HAS_ENTROPY_SRC_WIN32 \
BOTAN_HAS_MUTEX_WIN32
win32-msvc* {
QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250
DEFINES += BOTAN_DLL=__declspec(dllexport) BOTAN_BUILD_COMPILER_IS_MSVC
} else {
QMAKE_CFLAGS += -fpermissive -finline-functions -Wno-long-long
QMAKE_CXXFLAGS += -fpermissive -finline-functions -Wno-long-long
}
LIBS += -ladvapi32 -luser32
}
unix:*-g++* {
QMAKE_CFLAGS += -fPIC -ansi -fpermissive -finline-functions -Wno-long-long
QMAKE_CXXFLAGS += -fPIC -ansi -fpermissive -finline-functions -Wno-long-long
QMAKE_CXXFLAGS_HIDESYMS -= -fvisibility-inlines-hidden # for ubuntu 7.04
}
HEADERS += botan.h
SOURCES += botan.cpp
linux*|freebsd* {
LIBS += -lrt
}

View File

@@ -7,25 +7,43 @@ QtcLibrary {
Depends { name: "cpp" }
Depends { name: "Qt.core" }
cpp.includePaths: [
"build",
"src"
]
cpp.includePaths: '.'
cpp.dynamicLibraries: {
if (qbs.targetOS == "linux" || qbs.targetOS == "freebsd") {
return ["rt"]
} else if (qbs.targetOS == "windows") {
if (qbs.targetOS == "windows") {
return [
"advapi32",
"user32"
]
} else {
return ["rt", "dl"]
}
}
cpp.defines: {
var result = []
if (qbs.toolchain == "msvc2005" || qbs.toolchain == "msvc2008" || qbs.toolchain == "msvc2010")
result.push("BOTAN_DLL=__declspec(dllexport)")
result.push("BOTAN_DLL=__declspec(dllexport)", "BOTAN_BUILD_COMPILER_IS_MSVC")
if (qbs.toolchain == "gcc" || qbs.toolchain == "mingw")
result.push("BOTAN_BUILD_COMPILER_IS_GCC")
if (qbs.targetOS == "linux")
result.push("BOTAN_TARGET_OS_IS_LINUX", "BOTAN_TARGET_OS_HAS_CLOCK_GETTIME",
"BOTAN_TARGET_OS_HAS_DLOPEN", " BOTAN_TARGET_OS_HAS_GMTIME_R",
"BOTAN_TARGET_OS_HAS_POSIX_MLOCK", "BOTAN_HAS_DYNAMICALLY_LOADED_ENGINE",
"BOTAN_HAS_DYNAMIC_LOADER", "BOTAN_TARGET_OS_HAS_GETTIMEOFDAY",
"BOTAN_HAS_ALLOC_MMAP", "BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM",
"BOTAN_HAS_ENTROPY_SRC_EGD", "BOTAN_HAS_ENTROPY_SRC_FTW",
"BOTAN_HAS_ENTROPY_SRC_UNIX", "BOTAN_HAS_MUTEX_PTHREAD", "BOTAN_HAS_PIPE_UNIXFD_IO")
if (qbs.targetOS == "mac")
result.push("BOTAN_TARGET_OS_IS_DARWIN", "BOTAN_TARGET_OS_HAS_GETTIMEOFDAY",
"BOTAN_HAS_ALLOC_MMAP", "BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM",
"BOTAN_HAS_ENTROPY_SRC_EGD", "BOTAN_HAS_ENTROPY_SRC_FTW",
"BOTAN_HAS_ENTROPY_SRC_UNIX", "BOTAN_HAS_MUTEX_PTHREAD", "BOTAN_HAS_PIPE_UNIXFD_IO")
if (qbs.targetOS == "windows")
result.push("BOTAN_TARGET_OS_IS_WINDOWS", "BOTAN_TARGET_OS_HAS_GMTIME_S",
"BOTAN_TARGET_OS_HAS_LOADLIBRARY", "BOTAN_TARGET_OS_HAS_WIN32_GET_SYSTEMTIME",
"BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK", "BOTAN_HAS_DYNAMICALLY_LOADED_ENGINE",
"BOTAN_HAS_DYNAMIC_LOADER", "BOTAN_HAS_ENTROPY_SRC_CAPI",
"BOTAN_HAS_ENTROPY_SRC_WIN32", "BOTAN_HAS_MUTEX_WIN32")
return result
}
@@ -38,511 +56,7 @@ QtcLibrary {
]
}
files: [
"src/algo_factory/algo_cache.h",
"src/algo_factory/algo_factory.h",
"src/alloc/allocate.h",
"src/alloc/mem_pool/mem_pool.h",
"src/alloc/secmem.h",
"src/alloc/system_alloc/defalloc.h",
"src/asn1/alg_id.h",
"src/asn1/asn1_int.h",
"src/asn1/asn1_obj.h",
"src/asn1/asn1_oid.h",
"src/asn1/ber_dec.h",
"src/asn1/der_enc.h",
"src/benchmark/benchmark.h",
"src/block/aes/aes.h",
"src/block/block_cipher.h",
"src/block/blowfish/blowfish.h",
"src/block/cast/cast128.h",
"src/block/cast/cast256.h",
"src/block/des/des.h",
"src/block/des/desx.h",
"src/block/gost_28147/gost_28147.h",
"src/block/idea/idea.h",
"src/block/kasumi/kasumi.h",
"src/block/lion/lion.h",
"src/block/lubyrack/lubyrack.h",
"src/block/mars/mars.h",
"src/block/misty1/misty1.h",
"src/block/noekeon/noekeon.h",
"src/block/rc2/rc2.h",
"src/block/rc5/rc5.h",
"src/block/rc6/rc6.h",
"src/block/safer/safer_sk.h",
"src/block/seed/seed.h",
"src/block/serpent/serpent.h",
"src/block/skipjack/skipjack.h",
"src/block/square/square.h",
"src/block/tea/tea.h",
"src/block/twofish/twofish.h",
"src/block/xtea/xtea.h",
"src/cert/x509/certstor.h",
"src/cert/x509/crl_ent.h",
"src/cert/x509/pkcs10.h",
"src/cert/x509/x509_ca.h",
"src/cert/x509/x509_crl.h",
"src/cert/x509/x509_ext.h",
"src/cert/x509/x509_obj.h",
"src/cert/x509/x509cert.h",
"src/cert/x509/x509find.h",
"src/cert/x509/x509self.h",
"src/cert/x509/x509stor.h",
"src/checksum/adler32/adler32.h",
"src/checksum/crc24/crc24.h",
"src/checksum/crc32/crc32.h",
"src/cms/cms_dec.h",
"src/cms/cms_enc.h",
"src/codec/base64/base64.h",
"src/codec/hex/hex.h",
"src/codec/openpgp/openpgp.h",
"src/codec/pem/pem.h",
"src/cryptobox/cryptobox.h",
"src/engine/def_engine/def_eng.h",
"src/engine/engine.h",
"src/entropy/entropy_src.h",
"src/filters/basefilt.h",
"src/filters/buf_filt.h",
"src/filters/data_snk.h",
"src/filters/data_src.h",
"src/filters/filter.h",
"src/filters/filters.h",
"src/filters/out_buf.h",
"src/filters/pbe.h",
"src/filters/pipe.h",
"src/filters/secqueue.h",
"src/hash/fork256/fork256.h",
"src/hash/gost_3411/gost_3411.h",
"src/hash/has160/has160.h",
"src/hash/hash.h",
"src/hash/md2/md2.h",
"src/hash/md4/md4.h",
"src/hash/md5/md5.h",
"src/hash/mdx_hash/mdx_hash.h",
"src/hash/par_hash/par_hash.h",
"src/hash/rmd128/rmd128.h",
"src/hash/rmd160/rmd160.h",
"src/hash/sha1/sha160.h",
"src/hash/sha2/sha2_32.h",
"src/hash/sha2/sha2_64.h",
"src/hash/skein/skein_512.h",
"src/hash/tiger/tiger.h",
"src/hash/whirlpool/whrlpool.h",
"src/kdf/kdf.h",
"src/kdf/kdf1/kdf1.h",
"src/kdf/kdf2/kdf2.h",
"src/kdf/mgf1/mgf1.h",
"src/kdf/ssl_prf/prf_ssl3.h",
"src/kdf/tls_prf/prf_tls.h",
"src/kdf/x942_prf/prf_x942.h",
"src/libstate/botan.h",
"src/libstate/init.h",
"src/libstate/libstate.h",
"src/libstate/look_pk.h",
"src/libstate/lookup.h",
"src/libstate/oid_lookup/oids.h",
"src/libstate/pk_engine.h",
"src/libstate/scan_name.h",
"src/mac/cbc_mac/cbc_mac.h",
"src/mac/cmac/cmac.h",
"src/mac/hmac/hmac.h",
"src/mac/mac.h",
"src/mac/ssl3mac/ssl3_mac.h",
"src/mac/x919_mac/x919_mac.h",
"src/math/bigint/bigint.h",
"src/math/bigint/divide.h",
"src/math/bigint/mp_core.h",
"src/math/bigint/mp_generic/mp_asm.h",
"src/math/bigint/mp_generic/mp_asmi.h",
"src/math/bigint/mp_types.h",
"src/math/numbertheory/blinding.h",
"src/math/numbertheory/def_powm.h",
"src/math/numbertheory/numthry.h",
"src/math/numbertheory/pow_mod.h",
"src/math/numbertheory/reducer.h",
"src/modes/cbc/cbc.h",
"src/modes/cfb/cfb.h",
"src/modes/ctr/ctr.h",
"src/modes/cts/cts.h",
"src/modes/eax/eax.h",
"src/modes/ecb/ecb.h",
"src/modes/mode_pad/mode_pad.h",
"src/modes/modebase.h",
"src/modes/ofb/ofb.h",
"src/modes/xts/xts.h",
"src/mutex/mutex.h",
"src/mutex/noop_mutex/mux_noop.h",
"src/pbe/get_pbe.h",
"src/pbe/pbes1/pbes1.h",
"src/pbe/pbes2/pbes2.h",
"src/pk_pad/eme.h",
"src/pk_pad/eme1/eme1.h",
"src/pk_pad/eme_pkcs/eme_pkcs.h",
"src/pk_pad/emsa.h",
"src/pk_pad/emsa1/emsa1.h",
"src/pk_pad/emsa1_bsi/emsa1_bsi.h",
"src/pk_pad/emsa2/emsa2.h",
"src/pk_pad/emsa3/emsa3.h",
"src/pk_pad/emsa4/emsa4.h",
"src/pk_pad/emsa_raw/emsa_raw.h",
"src/pk_pad/hash_id/hash_id.h",
"src/pubkey/dh/dh.h",
"src/pubkey/dh/dh_core.h",
"src/pubkey/dh/dh_op.h",
"src/pubkey/dl_algo/dl_algo.h",
"src/pubkey/dl_group/dl_group.h",
"src/pubkey/dlies/dlies.h",
"src/pubkey/dsa/dsa.h",
"src/pubkey/dsa/dsa_core.h",
"src/pubkey/dsa/dsa_op.h",
"src/pubkey/elgamal/elg_core.h",
"src/pubkey/elgamal/elg_op.h",
"src/pubkey/elgamal/elgamal.h",
"src/pubkey/if_algo/if_algo.h",
"src/pubkey/if_algo/if_core.h",
"src/pubkey/if_algo/if_op.h",
"src/pubkey/keypair/keypair.h",
"src/pubkey/nr/nr.h",
"src/pubkey/nr/nr_core.h",
"src/pubkey/nr/nr_op.h",
"src/pubkey/pk_algs.h",
"src/pubkey/pk_codecs/pkcs8.h",
"src/pubkey/pk_codecs/x509_key.h",
"src/pubkey/pk_filts.h",
"src/pubkey/pk_keys.h",
"src/pubkey/pubkey.h",
"src/pubkey/pubkey_enums.h",
"src/pubkey/rsa/rsa.h",
"src/pubkey/rw/rw.h",
"src/rng/auto_rng/auto_rng.h",
"src/rng/hmac_rng/hmac_rng.h",
"src/rng/randpool/randpool.h",
"src/rng/rng.h",
"src/rng/x931_rng/x931_rng.h",
"src/s2k/pbkdf1/pbkdf1.h",
"src/s2k/pbkdf2/pbkdf2.h",
"src/s2k/pgps2k/pgp_s2k.h",
"src/s2k/s2k.h",
"src/selftest/selftest.h",
"src/stream/arc4/arc4.h",
"src/stream/salsa20/salsa20.h",
"src/stream/stream_cipher.h",
"src/stream/turing/turing.h",
"src/stream/wid_wake/wid_wake.h",
"src/sym_algo/sym_algo.h",
"src/sym_algo/symkey.h",
"src/timer/timer.h",
"src/utils/bit_ops.h",
"src/utils/bswap.h",
"src/utils/buf_comp/buf_comp.h",
"src/utils/charset.h",
"src/utils/datastor/datastor.h",
"src/utils/exceptn.h",
"src/utils/loadstor.h",
"src/utils/mem_ops.h",
"src/utils/parsing.h",
"src/utils/rotate.h",
"src/utils/stl_util.h",
"src/utils/types.h",
"src/utils/ui.h",
"src/utils/util.h",
"src/utils/version.h",
"src/utils/xor_buf.h",
"src/utils/sharedpointer.h",
"src/algo_factory/algo_factory.cpp",
"src/algo_factory/prov_weight.cpp",
"src/alloc/mem_pool/mem_pool.cpp",
"src/alloc/system_alloc/defalloc.cpp",
"src/asn1/alg_id.cpp",
"src/asn1/asn1_alt.cpp",
"src/asn1/asn1_att.cpp",
"src/asn1/asn1_dn.cpp",
"src/asn1/asn1_int.cpp",
"src/asn1/asn1_oid.cpp",
"src/asn1/asn1_str.cpp",
"src/asn1/asn1_tm.cpp",
"src/asn1/ber_dec.cpp",
"src/asn1/der_enc.cpp",
"src/benchmark/benchmark.cpp",
"src/block/aes/aes.cpp",
"src/block/aes/aes_tab.cpp",
"src/block/blowfish/blfs_tab.cpp",
"src/block/blowfish/blowfish.cpp",
"src/block/cast/cast128.cpp",
"src/block/cast/cast256.cpp",
"src/block/cast/cast_tab.cpp",
"src/block/des/des.cpp",
"src/block/des/des_tab.cpp",
"src/block/des/desx.cpp",
"src/block/gost_28147/gost_28147.cpp",
"src/block/idea/idea.cpp",
"src/block/kasumi/kasumi.cpp",
"src/block/lion/lion.cpp",
"src/block/lubyrack/lubyrack.cpp",
"src/block/mars/mars.cpp",
"src/block/mars/mars_tab.cpp",
"src/block/misty1/misty1.cpp",
"src/block/noekeon/noekeon.cpp",
"src/block/rc2/rc2.cpp",
"src/block/rc5/rc5.cpp",
"src/block/rc6/rc6.cpp",
"src/block/safer/safe_tab.cpp",
"src/block/safer/safer_sk.cpp",
"src/block/seed/seed.cpp",
"src/block/seed/seed_tab.cpp",
"src/block/serpent/serpent.cpp",
"src/block/skipjack/skipjack.cpp",
"src/block/square/sqr_tab.cpp",
"src/block/square/square.cpp",
"src/block/tea/tea.cpp",
"src/block/twofish/two_tab.cpp",
"src/block/twofish/twofish.cpp",
"src/block/xtea/xtea.cpp",
"src/cert/x509/certstor.cpp",
"src/cert/x509/crl_ent.cpp",
"src/cert/x509/pkcs10.cpp",
"src/cert/x509/x509_ca.cpp",
"src/cert/x509/x509_crl.cpp",
"src/cert/x509/x509_ext.cpp",
"src/cert/x509/x509_obj.cpp",
"src/cert/x509/x509cert.cpp",
"src/cert/x509/x509find.cpp",
"src/cert/x509/x509opt.cpp",
"src/cert/x509/x509self.cpp",
"src/cert/x509/x509stor.cpp",
"src/checksum/adler32/adler32.cpp",
"src/checksum/crc24/crc24.cpp",
"src/checksum/crc32/crc32.cpp",
"src/cms/cms_algo.cpp",
"src/cms/cms_comp.cpp",
"src/cms/cms_dalg.cpp",
"src/cms/cms_dec.cpp",
"src/cms/cms_ealg.cpp",
"src/cms/cms_enc.cpp",
"src/codec/base64/b64_char.cpp",
"src/codec/base64/base64.cpp",
"src/codec/hex/hex.cpp",
"src/codec/hex/hex_char.cpp",
"src/codec/openpgp/openpgp.cpp",
"src/codec/pem/pem.cpp",
"src/cryptobox/cryptobox.cpp",
"src/engine/def_engine/def_mode.cpp",
"src/engine/def_engine/def_pk_ops.cpp",
"src/engine/def_engine/def_powm.cpp",
"src/engine/def_engine/lookup_block.cpp",
"src/engine/def_engine/lookup_hash.cpp",
"src/engine/def_engine/lookup_mac.cpp",
"src/engine/def_engine/lookup_stream.cpp",
"src/filters/algo_filt.cpp",
"src/filters/basefilt.cpp",
"src/filters/buf_filt.cpp",
"src/filters/data_snk.cpp",
"src/filters/data_src.cpp",
"src/filters/filter.cpp",
"src/filters/out_buf.cpp",
"src/filters/pipe.cpp",
"src/filters/pipe_io.cpp",
"src/filters/pipe_rw.cpp",
"src/filters/secqueue.cpp",
"src/hash/fork256/fork256.cpp",
"src/hash/gost_3411/gost_3411.cpp",
"src/hash/has160/has160.cpp",
"src/hash/md2/md2.cpp",
"src/hash/md4/md4.cpp",
"src/hash/md5/md5.cpp",
"src/hash/mdx_hash/mdx_hash.cpp",
"src/hash/par_hash/par_hash.cpp",
"src/hash/rmd128/rmd128.cpp",
"src/hash/rmd160/rmd160.cpp",
"src/hash/sha1/sha160.cpp",
"src/hash/sha2/sha2_32.cpp",
"src/hash/sha2/sha2_64.cpp",
"src/hash/skein/skein_512.cpp",
"src/hash/tiger/tig_tab.cpp",
"src/hash/tiger/tiger.cpp",
"src/hash/whirlpool/whrl_tab.cpp",
"src/hash/whirlpool/whrlpool.cpp",
"src/kdf/kdf.cpp",
"src/kdf/kdf1/kdf1.cpp",
"src/kdf/kdf2/kdf2.cpp",
"src/kdf/mgf1/mgf1.cpp",
"src/kdf/ssl_prf/prf_ssl3.cpp",
"src/kdf/tls_prf/prf_tls.cpp",
"src/kdf/x942_prf/prf_x942.cpp",
"src/libstate/get_enc.cpp",
"src/libstate/init.cpp",
"src/libstate/libstate.cpp",
"src/libstate/look_pk.cpp",
"src/libstate/lookup.cpp",
"src/libstate/oid_lookup/oids.cpp",
"src/libstate/pk_engine.cpp",
"src/libstate/policy.cpp",
"src/libstate/scan_name.cpp",
"src/mac/cbc_mac/cbc_mac.cpp",
"src/mac/cmac/cmac.cpp",
"src/mac/hmac/hmac.cpp",
"src/mac/mac.cpp",
"src/mac/ssl3mac/ssl3_mac.cpp",
"src/mac/x919_mac/x919_mac.cpp",
"src/math/bigint/big_code.cpp",
"src/math/bigint/big_io.cpp",
"src/math/bigint/big_ops2.cpp",
"src/math/bigint/big_ops3.cpp",
"src/math/bigint/big_rand.cpp",
"src/math/bigint/bigint.cpp",
"src/math/bigint/divide.cpp",
"src/math/bigint/monty_generic/mp_monty.cpp",
"src/math/bigint/mp_asm.cpp",
"src/math/bigint/mp_comba.cpp",
"src/math/bigint/mp_karat.cpp",
"src/math/bigint/mp_misc.cpp",
"src/math/bigint/mp_shift.cpp",
"src/math/bigint/mulop_generic/mp_mulop.cpp",
"src/math/numbertheory/blinding.cpp",
"src/math/numbertheory/dsa_gen.cpp",
"src/math/numbertheory/jacobi.cpp",
"src/math/numbertheory/make_prm.cpp",
"src/math/numbertheory/mp_numth.cpp",
"src/math/numbertheory/numthry.cpp",
"src/math/numbertheory/pow_mod.cpp",
"src/math/numbertheory/powm_fw.cpp",
"src/math/numbertheory/powm_mnt.cpp",
"src/math/numbertheory/primes.cpp",
"src/math/numbertheory/reducer.cpp",
"src/math/numbertheory/ressol.cpp",
"src/modes/cbc/cbc.cpp",
"src/modes/cfb/cfb.cpp",
"src/modes/ctr/ctr.cpp",
"src/modes/cts/cts.cpp",
"src/modes/eax/eax.cpp",
"src/modes/eax/eax_dec.cpp",
"src/modes/ecb/ecb.cpp",
"src/modes/mode_pad/mode_pad.cpp",
"src/modes/modebase.cpp",
"src/modes/ofb/ofb.cpp",
"src/modes/xts/xts.cpp",
"src/mutex/noop_mutex/mux_noop.cpp",
"src/pbe/get_pbe.cpp",
"src/pbe/pbes1/pbes1.cpp",
"src/pbe/pbes2/pbes2.cpp",
"src/pk_pad/eme.cpp",
"src/pk_pad/eme1/eme1.cpp",
"src/pk_pad/eme_pkcs/eme_pkcs.cpp",
"src/pk_pad/emsa1/emsa1.cpp",
"src/pk_pad/emsa1_bsi/emsa1_bsi.cpp",
"src/pk_pad/emsa2/emsa2.cpp",
"src/pk_pad/emsa3/emsa3.cpp",
"src/pk_pad/emsa4/emsa4.cpp",
"src/pk_pad/emsa_raw/emsa_raw.cpp",
"src/pk_pad/hash_id/hash_id.cpp",
"src/pubkey/dh/dh.cpp",
"src/pubkey/dh/dh_core.cpp",
"src/pubkey/dl_algo/dl_algo.cpp",
"src/pubkey/dl_group/dl_group.cpp",
"src/pubkey/dlies/dlies.cpp",
"src/pubkey/dsa/dsa.cpp",
"src/pubkey/dsa/dsa_core.cpp",
"src/pubkey/dsa/dsa_op.cpp",
"src/pubkey/elgamal/elg_core.cpp",
"src/pubkey/elgamal/elg_op.cpp",
"src/pubkey/elgamal/elgamal.cpp",
"src/pubkey/if_algo/if_algo.cpp",
"src/pubkey/if_algo/if_core.cpp",
"src/pubkey/if_algo/if_op.cpp",
"src/pubkey/keypair/keypair.cpp",
"src/pubkey/nr/nr.cpp",
"src/pubkey/nr/nr_core.cpp",
"src/pubkey/nr/nr_op.cpp",
"src/pubkey/pk_algs.cpp",
"src/pubkey/pk_codecs/pkcs8.cpp",
"src/pubkey/pk_codecs/x509_key.cpp",
"src/pubkey/pk_filts.cpp",
"src/pubkey/pk_keys.cpp",
"src/pubkey/pubkey.cpp",
"src/pubkey/pubkey_enums.cpp",
"src/pubkey/rsa/rsa.cpp",
"src/pubkey/rw/rw.cpp",
"src/rng/auto_rng/auto_rng.cpp",
"src/rng/hmac_rng/hmac_rng.cpp",
"src/rng/randpool/randpool.cpp",
"src/rng/rng.cpp",
"src/rng/x931_rng/x931_rng.cpp",
"src/s2k/pbkdf1/pbkdf1.cpp",
"src/s2k/pbkdf2/pbkdf2.cpp",
"src/s2k/pgps2k/pgp_s2k.cpp",
"src/s2k/s2k.cpp",
"src/selftest/selftest.cpp",
"src/stream/arc4/arc4.cpp",
"src/stream/salsa20/salsa20.cpp",
"src/stream/stream_cipher.cpp",
"src/stream/turing/tur_tab.cpp",
"src/stream/turing/turing.cpp",
"src/stream/wid_wake/wid_wake.cpp",
"src/sym_algo/symkey.cpp",
"src/timer/timer.cpp",
"src/utils/charset.cpp",
"src/utils/datastor/datastor.cpp",
"src/utils/exceptn.cpp",
"src/utils/mlock.cpp",
"src/utils/parsing.cpp",
"src/utils/ui.cpp",
"src/utils/util.cpp",
"src/utils/version.cpp"
]
Group {
condition: qbs.targetOS == "windows"
files: [
"src/entropy/cryptoapi_rng/es_capi.cpp",
"src/entropy/win32_stats/es_win32.cpp",
"src/mutex/win32_crit_section/mux_win32.cpp",
"src/timer/win32_query_perf_ctr/tm_win32.cpp",
]
}
Group {
condition: qbs.targetOS == "linux" || qbs.targetOS == "mac"
files: [
"src/alloc/alloc_mmap/mmap_mem.cpp",
"src/cert/cvc/asn1_eac_str.cpp",
"src/cert/cvc/asn1_eac_tm.cpp",
"src/cert/cvc/cvc_ado.cpp",
"src/cert/cvc/cvc_ca.cpp",
"src/cert/cvc/cvc_cert.cpp",
"src/cert/cvc/cvc_req.cpp",
"src/cert/cvc/cvc_self.cpp",
"src/cert/cvc/ecdsa_sig.cpp",
"src/cert/cvc/signed_obj.cpp",
"src/entropy/dev_random/es_dev.cpp",
"src/entropy/egd/es_egd.cpp",
"src/entropy/proc_walk/es_ftw.cpp",
"src/entropy/unix_procs/es_unix.cpp",
"src/entropy/unix_procs/unix_cmd.cpp",
"src/entropy/unix_procs/unix_src.cpp",
"src/filters/fd_unix/fd_unix.cpp",
"src/math/gfpmath/curve_gfp.cpp",
"src/math/gfpmath/gfp_element.cpp",
"src/math/gfpmath/point_gfp.cpp",
"src/mutex/pthreads/mux_pthr.cpp",
"src/pubkey/ec_dompar/ec_dompar.cpp",
"src/pubkey/ecc_key/ecc_key.cpp",
"src/pubkey/ecdsa/ecdsa.cpp",
"src/pubkey/ecdsa/ecdsa_core.cpp",
"src/pubkey/ecdsa/ecdsa_op.cpp",
"src/pubkey/eckaeg/eckaeg.cpp",
"src/pubkey/eckaeg/eckaeg_core.cpp",
"src/pubkey/eckaeg/eckaeg_op.cpp",
"src/timer/gettimeofday/tm_unix.cpp"
]
}
Group {
condition: qbs.targetOS == "linux"
files: [
"src/timer/posix_rt/tm_posix.cpp"
]
}
files: [ "botan.h", "botan.cpp" ]
ProductModule {
Depends { name: "cpp" }
@@ -551,5 +65,6 @@ QtcLibrary {
return ["--enable-auto-import"]
}
}
cpp.includePaths: '..'
}
}

View File

@@ -1,35 +0,0 @@
/*
* Adler32
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ADLER32_H__
#define BOTAN_ADLER32_H__
#include <botan/hash.h>
namespace Botan {
/*
* Adler32
*/
class BOTAN_DLL Adler32 : public HashFunction
{
public:
void clear() throw() { S1 = 1; S2 = 0; }
std::string name() const { return "Adler32"; }
HashFunction* clone() const { return new Adler32; }
Adler32() : HashFunction(4) { clear(); }
~Adler32() { clear(); }
private:
void add_data(const byte[], u32bit);
void final_result(byte[]);
void hash(const byte[], u32bit);
u16bit S1, S2;
};
}
#endif

View File

@@ -1,81 +0,0 @@
/**
* AES
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_AES_H__
#define BOTAN_AES_H__
#include <botan/block_cipher.h>
namespace Botan {
/**
* Rijndael aka AES
*/
class BOTAN_DLL AES : public BlockCipher
{
public:
void clear() throw();
std::string name() const { return "AES"; }
BlockCipher* clone() const { return new AES; }
AES() : BlockCipher(16, 16, 32, 8) { ROUNDS = 14; }
AES(u32bit);
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
static u32bit S(u32bit);
static const byte SE[256];
static const byte SD[256];
static const u32bit TE[1024];
static const u32bit TD[1024];
u32bit ROUNDS;
SecureBuffer<u32bit, 56> EK;
SecureBuffer<byte, 16> ME;
SecureBuffer<u32bit, 56> DK;
SecureBuffer<byte, 16> MD;
};
/**
* AES-128
*/
class BOTAN_DLL AES_128 : public AES
{
public:
std::string name() const { return "AES-128"; }
BlockCipher* clone() const { return new AES_128; }
AES_128() : AES(16) {}
};
/**
* AES-192
*/
class BOTAN_DLL AES_192 : public AES
{
public:
std::string name() const { return "AES-192"; }
BlockCipher* clone() const { return new AES_192; }
AES_192() : AES(24) {}
};
/**
* AES-256
*/
class BOTAN_DLL AES_256 : public AES
{
public:
std::string name() const { return "AES-256"; }
BlockCipher* clone() const { return new AES_256; }
AES_256() : AES(32) {}
};
}
#endif

View File

@@ -1,49 +0,0 @@
/*
* Algorithm Identifier
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ALGORITHM_IDENTIFIER_H__
#define BOTAN_ALGORITHM_IDENTIFIER_H__
#include <botan/asn1_int.h>
#include <botan/asn1_oid.h>
#include <string>
namespace Botan {
/*
* Algorithm Identifier
*/
class BOTAN_DLL AlgorithmIdentifier : public ASN1_Object
{
public:
enum Encoding_Option { USE_NULL_PARAM };
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
AlgorithmIdentifier() {}
AlgorithmIdentifier(const OID&, Encoding_Option);
AlgorithmIdentifier(const std::string&, Encoding_Option);
AlgorithmIdentifier(const OID&, const MemoryRegion<byte>&);
AlgorithmIdentifier(const std::string&, const MemoryRegion<byte>&);
OID oid;
SecureVector<byte> parameters;
};
/*
* Comparison Operations
*/
bool BOTAN_DLL operator==(const AlgorithmIdentifier&,
const AlgorithmIdentifier&);
bool BOTAN_DLL operator!=(const AlgorithmIdentifier&,
const AlgorithmIdentifier&);
}
#endif

View File

@@ -1,224 +0,0 @@
/**
* An algorithm cache (used by Algorithm_Factory)
*/
#ifndef BOTAN_ALGORITHM_CACHE_TEMPLATE_H__
#define BOTAN_ALGORITHM_CACHE_TEMPLATE_H__
#include <botan/mutex.h>
#include <botan/stl_util.h>
#include <string>
#include <vector>
#include <map>
namespace Botan {
/**
* @param prov_name a provider name
* @return weight for this provider
*/
u32bit static_provider_weight(const std::string& prov_name);
/**
* Algorithm_Cache (used by Algorithm_Factory)
*/
template<typename T>
class Algorithm_Cache
{
public:
const T* get(const std::string& algo_spec,
const std::string& pref_provider);
/**
* Add a new algorithm implementation to the cache
*/
void add(T* algo,
const std::string& requested_name,
const std::string& provider_name);
/**
* Set the preferred provider
*/
void set_preferred_provider(const std::string& algo_spec,
const std::string& provider);
/**
* Return the list of providers of this algorithm
*/
std::vector<std::string> providers_of(const std::string& algo_name);
Algorithm_Cache(Mutex* m) : mutex(m) {}
~Algorithm_Cache();
private:
typedef typename std::map<std::string, std::map<std::string, T*> >::iterator
algorithms_iterator;
typedef typename std::map<std::string, T*>::iterator provider_iterator;
algorithms_iterator find_algorithm(const std::string& algo_spec);
Mutex* mutex;
std::map<std::string, std::string> aliases;
std::map<std::string, std::string> pref_providers;
std::map<std::string, std::map<std::string, T*> > algorithms;
};
/**
* Look for an algorithm implementation in the cache, also checking aliases
* Assumes object lock is held
*/
template<typename T>
typename Algorithm_Cache<T>::algorithms_iterator
Algorithm_Cache<T>::find_algorithm(const std::string& algo_spec)
{
algorithms_iterator algo = algorithms.find(algo_spec);
// Not found? Check if a known alias
if(algo == algorithms.end())
{
std::map<std::string, std::string>::const_iterator alias =
aliases.find(algo_spec);
if(alias != aliases.end())
algo = algorithms.find(alias->second);
}
return algo;
}
/**
* Look for an algorithm implementation by a particular provider
*/
template<typename T>
const T* Algorithm_Cache<T>::get(const std::string& algo_spec,
const std::string& requested_provider)
{
Mutex_Holder lock(mutex);
algorithms_iterator algo = find_algorithm(algo_spec);
if(algo == algorithms.end()) // algo not found at all (no providers)
return 0;
// If a provider is requested specifically, return it or fail entirely
if(requested_provider != "")
{
provider_iterator prov = algo->second.find(requested_provider);
if(prov != algo->second.end())
return prov->second;
return 0;
}
const T* prototype = 0;
std::string prototype_provider;
u32bit prototype_prov_weight = 0;
const std::string pref_provider = search_map(pref_providers, algo_spec);
for(provider_iterator i = algo->second.begin(); i != algo->second.end(); ++i)
{
const std::string prov_name = i->first;
const u32bit prov_weight = static_provider_weight(prov_name);
// preferred prov exists, return immediately
if(prov_name == pref_provider)
return i->second;
if(prototype == 0 || prov_weight > prototype_prov_weight)
{
prototype = i->second;
prototype_provider = i->first;
prototype_prov_weight = prov_weight;
}
}
return prototype;
}
/**
* Add an implementation to the cache
*/
template<typename T>
void Algorithm_Cache<T>::add(T* algo,
const std::string& requested_name,
const std::string& provider)
{
if(!algo)
return;
Mutex_Holder lock(mutex);
delete algorithms[algo->name()][provider];
algorithms[algo->name()][provider] = algo;
if(algo->name() != requested_name &&
aliases.find(requested_name) == aliases.end())
{
aliases[requested_name] = algo->name();
}
}
/**
* Find the providers of this algo (if any)
*/
template<typename T> std::vector<std::string>
Algorithm_Cache<T>::providers_of(const std::string& algo_name)
{
Mutex_Holder lock(mutex);
std::vector<std::string> providers;
algorithms_iterator algo = find_algorithm(algo_name);
if(algo != algorithms.end())
{
provider_iterator provider = algo->second.begin();
while(provider != algo->second.end())
{
providers.push_back(provider->first);
++provider;
}
}
return providers;
}
/**
* Set the preferred provider for an algorithm
*/
template<typename T>
void Algorithm_Cache<T>::set_preferred_provider(const std::string& algo_spec,
const std::string& provider)
{
Mutex_Holder lock(mutex);
pref_providers[algo_spec] = provider;
}
/**
* Algorithm_Cache<T> Destructor
*/
template<typename T>
Algorithm_Cache<T>::~Algorithm_Cache()
{
algorithms_iterator algo = algorithms.begin();
while(algo != algorithms.end())
{
provider_iterator provider = algo->second.begin();
while(provider != algo->second.end())
{
delete provider->second;
++provider;
}
++algo;
}
delete mutex;
}
}
#endif

View File

@@ -1,132 +0,0 @@
/**
* Algorithm Factory
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ALGORITHM_FACTORY_H__
#define BOTAN_ALGORITHM_FACTORY_H__
#include <botan/mutex.h>
#include <string>
#include <vector>
namespace Botan {
/**
* Forward declarations (don't need full definitions here)
*/
class BlockCipher;
class StreamCipher;
class HashFunction;
class MessageAuthenticationCode;
template<typename T> class Algorithm_Cache;
class Engine;
/**
* Algorithm Factory
*/
class BOTAN_DLL Algorithm_Factory
{
public:
/**
* Constructor
* @param engines_in the list of engines to use
* @param mf a mutex factory
*/
Algorithm_Factory(const std::vector<Engine*>& engines_in,
Mutex_Factory& mf);
/**
* Destructor
*/
~Algorithm_Factory();
/*
* Provider management
*/
std::vector<std::string> providers_of(const std::string& algo_spec);
void set_preferred_provider(const std::string& algo_spec,
const std::string& provider);
/*
* Block cipher operations
*/
const BlockCipher*
prototype_block_cipher(const std::string& algo_spec,
const std::string& provider = "");
BlockCipher* make_block_cipher(const std::string& algo_spec,
const std::string& provider = "");
void add_block_cipher(BlockCipher* hash, const std::string& provider);
/*
* Stream cipher operations
*/
const StreamCipher*
prototype_stream_cipher(const std::string& algo_spec,
const std::string& provider = "");
StreamCipher* make_stream_cipher(const std::string& algo_spec,
const std::string& provider = "");
void add_stream_cipher(StreamCipher* hash, const std::string& provider);
/*
* Hash function operations
*/
const HashFunction*
prototype_hash_function(const std::string& algo_spec,
const std::string& provider = "");
HashFunction* make_hash_function(const std::string& algo_spec,
const std::string& provider = "");
void add_hash_function(HashFunction* hash, const std::string& provider);
/*
* MAC operations
*/
const MessageAuthenticationCode*
prototype_mac(const std::string& algo_spec,
const std::string& provider = "");
MessageAuthenticationCode* make_mac(const std::string& algo_spec,
const std::string& provider = "");
void add_mac(MessageAuthenticationCode* mac,
const std::string& provider);
/*
* Deprecated
*/
class BOTAN_DLL Engine_Iterator
{
public:
class Engine* next() { return af.get_engine_n(n++); }
Engine_Iterator(const Algorithm_Factory& a) : af(a) { n = 0; }
private:
const Algorithm_Factory& af;
u32bit n;
};
friend class Engine_Iterator;
private:
class Engine* get_engine_n(u32bit) const;
std::vector<class Engine*> engines;
Algorithm_Cache<BlockCipher>* block_cipher_cache;
Algorithm_Cache<StreamCipher>* stream_cipher_cache;
Algorithm_Cache<HashFunction>* hash_cache;
Algorithm_Cache<MessageAuthenticationCode>* mac_cache;
};
}
#endif

View File

@@ -1,37 +0,0 @@
/*
* Allocator
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ALLOCATOR_H__
#define BOTAN_ALLOCATOR_H__
#include <botan/types.h>
#include <string>
namespace Botan {
/*
* Allocator Interface
*/
class BOTAN_DLL Allocator
{
public:
static Allocator* get(bool);
virtual void* allocate(u32bit) = 0;
virtual void deallocate(void*, u32bit) = 0;
virtual std::string type() const = 0;
virtual void init() {}
virtual void destroy() {}
virtual ~Allocator() {}
};
}
#endif

View File

@@ -1,41 +0,0 @@
/*
* ARC4
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ARC4_H__
#define BOTAN_ARC4_H__
#include <botan/stream_cipher.h>
#include <botan/types.h>
namespace Botan {
/*
* ARC4
*/
class BOTAN_DLL ARC4 : public StreamCipher
{
public:
void clear() throw();
std::string name() const;
StreamCipher* clone() const { return new ARC4(SKIP); }
ARC4(u32bit = 0);
~ARC4() { clear(); }
private:
void cipher(const byte[], byte[], u32bit);
void key_schedule(const byte[], u32bit);
void generate();
const u32bit SKIP;
SecureBuffer<byte, DEFAULT_BUFFERSIZE> buffer;
SecureBuffer<u32bit, 256> state;
u32bit X, Y, position;
};
}
#endif

View File

@@ -1,108 +0,0 @@
/*
* ASN.1 Internals
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ASN1_H__
#define BOTAN_ASN1_H__
#include <botan/secmem.h>
#include <botan/exceptn.h>
namespace Botan {
/*
* ASN.1 Type and Class Tags
*/
enum ASN1_Tag {
UNIVERSAL = 0x00,
APPLICATION = 0x40,
CONTEXT_SPECIFIC = 0x80,
PRIVATE = 0xC0,
CONSTRUCTED = 0x20,
EOC = 0x00,
BOOLEAN = 0x01,
INTEGER = 0x02,
BIT_STRING = 0x03,
OCTET_STRING = 0x04,
NULL_TAG = 0x05,
OBJECT_ID = 0x06,
ENUMERATED = 0x0A,
SEQUENCE = 0x10,
SET = 0x11,
UTF8_STRING = 0x0C,
NUMERIC_STRING = 0x12,
PRINTABLE_STRING = 0x13,
T61_STRING = 0x14,
IA5_STRING = 0x16,
VISIBLE_STRING = 0x1A,
BMP_STRING = 0x1E,
UTC_TIME = 0x17,
GENERALIZED_TIME = 0x18,
NO_OBJECT = 0xFF00,
DIRECTORY_STRING = 0xFF01
};
/*
* Basic ASN.1 Object Interface
*/
class BOTAN_DLL ASN1_Object
{
public:
virtual void encode_into(class DER_Encoder&) const = 0;
virtual void decode_from(class BER_Decoder&) = 0;
virtual ~ASN1_Object() {}
};
/*
* BER Encoded Object
*/
class BOTAN_DLL BER_Object
{
public:
void assert_is_a(ASN1_Tag, ASN1_Tag);
ASN1_Tag type_tag, class_tag;
SecureVector<byte> value;
};
/*
* ASN.1 Utility Functions
*/
class DataSource;
namespace ASN1 {
SecureVector<byte> put_in_sequence(const MemoryRegion<byte>&);
std::string to_string(const BER_Object&);
bool maybe_BER(DataSource&);
}
/*
* General BER Decoding Error Exception
*/
struct BER_Decoding_Error : public Decoding_Error
{
BER_Decoding_Error(const std::string&);
};
/*
* Exception For Incorrect BER Taggings
*/
struct BER_Bad_Tag : public BER_Decoding_Error
{
BER_Bad_Tag(const std::string&, ASN1_Tag);
BER_Bad_Tag(const std::string&, ASN1_Tag, ASN1_Tag);
};
}
#endif

View File

@@ -1,160 +0,0 @@
/*
* Common ASN.1 Objects
* (C) 1999-2007 Jack Lloyd
* 2007 Yves Jerschow
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ASN1_OBJ_H__
#define BOTAN_ASN1_OBJ_H__
#include <botan/asn1_int.h>
#include <botan/asn1_oid.h>
#include <botan/alg_id.h>
#include <vector>
#include <map>
namespace Botan {
/*
* Attribute
*/
class BOTAN_DLL Attribute : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
OID oid;
MemoryVector<byte> parameters;
Attribute() {}
Attribute(const OID&, const MemoryRegion<byte>&);
Attribute(const std::string&, const MemoryRegion<byte>&);
};
/*
* X.509 Time
*/
class BOTAN_DLL X509_Time : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
std::string as_string() const;
std::string readable_string() const;
bool time_is_set() const;
s32bit cmp(const X509_Time&) const;
void set_to(const std::string&);
void set_to(const std::string&, ASN1_Tag);
X509_Time(u64bit);
X509_Time(const std::string& = "");
X509_Time(const std::string&, ASN1_Tag);
private:
bool passes_sanity_check() const;
u32bit year, month, day, hour, minute, second;
ASN1_Tag tag;
};
/*
* Simple String
*/
class BOTAN_DLL ASN1_String : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
std::string value() const;
std::string iso_8859() const;
ASN1_Tag tagging() const;
ASN1_String(const std::string& = "");
ASN1_String(const std::string&, ASN1_Tag);
private:
std::string iso_8859_str;
ASN1_Tag tag;
};
/*
* Distinguished Name
*/
class BOTAN_DLL X509_DN : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
std::multimap<OID, std::string> get_attributes() const;
std::vector<std::string> get_attribute(const std::string&) const;
std::multimap<std::string, std::string> contents() const;
void add_attribute(const std::string&, const std::string&);
void add_attribute(const OID&, const std::string&);
static std::string deref_info_field(const std::string&);
void do_decode(const MemoryRegion<byte>&);
MemoryVector<byte> get_bits() const;
X509_DN();
X509_DN(const std::multimap<OID, std::string>&);
X509_DN(const std::multimap<std::string, std::string>&);
private:
std::multimap<OID, ASN1_String> dn_info;
MemoryVector<byte> dn_bits;
};
/*
* Alternative Name
*/
class BOTAN_DLL AlternativeName : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
std::multimap<std::string, std::string> contents() const;
void add_attribute(const std::string&, const std::string&);
std::multimap<std::string, std::string> get_attributes() const;
void add_othername(const OID&, const std::string&, ASN1_Tag);
std::multimap<OID, ASN1_String> get_othernames() const;
bool has_items() const;
AlternativeName(const std::string& = "", const std::string& = "",
const std::string& = "", const std::string& = "");
private:
std::multimap<std::string, std::string> alt_info;
std::multimap<OID, ASN1_String> othernames;
};
/*
* Comparison Operations
*/
bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&);
bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&);
bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&);
bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&);
bool BOTAN_DLL operator==(const X509_DN&, const X509_DN&);
bool BOTAN_DLL operator!=(const X509_DN&, const X509_DN&);
bool BOTAN_DLL operator<(const X509_DN&, const X509_DN&);
/*
* Helper Functions
*/
bool BOTAN_DLL is_string_type(ASN1_Tag);
}
#endif

View File

@@ -1,96 +0,0 @@
/*
* ASN.1 OID
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ASN1_OID_H__
#define BOTAN_ASN1_OID_H__
#include <botan/asn1_int.h>
#include <string>
#include <vector>
namespace Botan {
/**
* This class represents ASN.1 object identifiers.
*/
class BOTAN_DLL OID : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
/**
* Find out whether this OID is empty
* @return true is no OID value is set
*/
bool is_empty() const { return id.size() == 0; }
/**
* Get this OID as list (vector) of its components.
* @return a vector representing this OID
*/
std::vector<u32bit> get_id() const { return id; }
/**
* Get this OID as a string
* @return a string representing this OID
*/
std::string as_string() const;
/**
* Compare two OIDs.
* @return true if they are equal, false otherwise
*/
bool operator==(const OID&) const;
/**
* Reset this instance to an empty OID.
*/
void clear();
/**
* Add a component to this OID.
* @param new_comp the new component to add to the end of this OID
* @return a reference to *this
*/
OID& operator+=(u32bit new_comp);
/**
* Construct an OID from a string.
* @param str a string in the form "a.b.c" etc., where a,b,c are numbers
*/
OID(const std::string& str = std::string());
private:
std::vector<u32bit> id;
};
/**
* Append another component onto the OID.
* @param oid the OID to add the new component to
* @param new_comp the new component to add
*/
OID operator+(const OID& oid, u32bit new_comp);
/**
* Compare two OIDs.
* @param a the first OID
* @param b the second OID
* @return true if a is not equal to b
*/
bool operator!=(const OID& a, const OID& b);
/**
* Compare two OIDs.
* @param a the first OID
* @param b the second OID
* @return true if a is lexicographically smaller than b
*/
bool operator<(const OID& a, const OID& b);
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* Auto Seeded RNG
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_AUTO_SEEDING_RNG_H__
#define BOTAN_AUTO_SEEDING_RNG_H__
#include <botan/rng.h>
#include <string>
namespace Botan {
/**
* RNG that attempts to seed itself
*/
class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator
{
public:
void randomize(byte out[], u32bit len)
{ rng->randomize(out, len); }
bool is_seeded() const
{ return rng->is_seeded(); }
void clear() throw() { rng->clear(); }
std::string name() const
{ return "AutoSeeded(" + rng->name() + ")"; }
void reseed(u32bit poll_bits = 256) { rng->reseed(poll_bits); }
void add_entropy_source(EntropySource* es)
{ rng->add_entropy_source(es); }
void add_entropy(const byte in[], u32bit len)
{ rng->add_entropy(in, len); }
AutoSeeded_RNG(u32bit poll_bits = 256);
~AutoSeeded_RNG() { delete rng; }
private:
RandomNumberGenerator* rng;
};
}
#endif

View File

@@ -1,94 +0,0 @@
/*
* Base64 Encoder/Decoder
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BASE64_H__
#define BOTAN_BASE64_H__
#include <botan/filter.h>
namespace Botan {
/**
* This class represents a Base64 encoder.
*/
class BOTAN_DLL Base64_Encoder : public Filter
{
public:
static void encode(const byte in[3], byte out[4]);
/**
* Input a part of a message to the encoder.
* @param input the message to input as a byte array
* @param length the length of the byte array input
*/
void write(const byte input[], u32bit length);
/**
* Inform the Encoder that the current message shall be closed.
*/
void end_msg();
/**
* Create a base64 encoder.
* @param breaks whether to use line breaks in the Streamcipheroutput
* @param length the length of the lines of the output
* @param t_n whether to use a trailing newline
*/
Base64_Encoder(bool breaks = false, u32bit length = 72,
bool t_n = false);
private:
void encode_and_send(const byte[], u32bit);
void do_output(const byte[], u32bit);
static const byte BIN_TO_BASE64[64];
const u32bit line_length;
const bool trailing_newline;
SecureVector<byte> in, out;
u32bit position, counter;
};
/**
* This object represents a Base64 decoder.
*/
class BOTAN_DLL Base64_Decoder : public Filter
{
public:
static void decode(const byte input[4], byte output[3]);
static bool is_valid(byte);
/**
* Input a part of a message to the decoder.
* @param input the message to input as a byte array
* @param length the length of the byte array input
*/
void write(const byte input[], u32bit length);
/**
* Inform the Encoder that the current message shall be closed.
*/
void end_msg();
/**
* Create a base64 encoder.
* @param checking the type of checking that shall be performed by
* the decoder
*/
Base64_Decoder(Decoder_Checking checking = NONE);
private:
void decode_and_send(const byte[], u32bit);
void handle_bad_char(byte);
static const byte BASE64_TO_BIN[256];
const Decoder_Checking checking;
SecureVector<byte> in, out;
u32bit position;
};
}
#endif

View File

@@ -1,99 +0,0 @@
/*
* Basic Filters
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BASEFILT_H__
#define BOTAN_BASEFILT_H__
#include <botan/filter.h>
#include <botan/sym_algo.h>
namespace Botan {
/**
* This class represents Filter chains. A Filter chain is an ordered
* concatenation of Filters, the input to a Chain sequentially passes
* through all the Filters contained in the Chain.
*/
class BOTAN_DLL Chain : public Fanout_Filter
{
public:
void write(const byte input[], u32bit length) { send(input, length); }
/**
* Construct a chain of up to four filters. The filters are set
* up in the same order as the arguments.
*/
Chain(Filter* = 0, Filter* = 0, Filter* = 0, Filter* = 0);
/**
* Construct a chain from range of filters
* @param filter_arr the list of filters
* @param length how many filters
*/
Chain(Filter* filter_arr[], u32bit length);
};
/**
* This class represents a fork filter, whose purpose is to fork the
* flow of data. It causes an input message to result in n messages at
* the end of the filter, where n is the number of forks.
*/
class BOTAN_DLL Fork : public Fanout_Filter
{
public:
void write(const byte input[], u32bit length) { send(input, length); }
void set_port(u32bit n) { Fanout_Filter::set_port(n); }
/**
* Construct a Fork filter with up to four forks.
*/
Fork(Filter*, Filter*, Filter* = 0, Filter* = 0);
/**
* Construct a Fork from range of filters
* @param filter_arr the list of filters
* @param length how many filters
*/
Fork(Filter* filter_arr[], u32bit length);
};
/**
* This class represents keyed filters, i.e. filters that have to be
* fed with a key in order to function.
*/
class BOTAN_DLL Keyed_Filter : public Filter
{
public:
/**
* Set the key of this filter.
* @param key the key to set
*/
virtual void set_key(const SymmetricKey& key);
/**
* Set the initialization vector of this filter.
* @param iv the initialization vector to set
*/
virtual void set_iv(const InitializationVector&) {}
/**
* Check whether a key length is valid for this filter.
* @param length the key length to be checked for validity
* @return true if the key length is valid, false otherwise
*/
virtual bool valid_keylength(u32bit length) const;
Keyed_Filter() { base_ptr = 0; }
protected:
SymmetricAlgorithm* base_ptr;
};
}
#endif

View File

@@ -1,59 +0,0 @@
/**
* Runtime benchmarking
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_RUNTIME_BENCHMARK_H__
#define BOTAN_RUNTIME_BENCHMARK_H__
#include <botan/algo_factory.h>
#include <botan/timer.h>
#include <botan/rng.h>
#include <map>
#include <string>
/**
* Choose some sort of default timer implementation to use, since some
* (like hardware tick counters and current Win32 timer) are not
* reliable for benchmarking.
*/
#if defined(BOTAN_HAS_TIMER_POSIX)
#include <botan/tm_posix.h>
#elif defined(BOTAN_HAS_TIMER_UNIX)
#include <botan/tm_unix.h>
#endif
namespace Botan {
#if defined(BOTAN_HAS_TIMER_POSIX)
typedef POSIX_Timer Default_Benchmark_Timer;
#elif defined(BOTAN_HAS_TIMER_UNIX)
typedef Unix_Timer Default_Benchmark_Timer;
#else
/* I have not had good success using clock(), the results seem
* pretty bogus, but as a last resort it works.
*/
typedef ANSI_Clock_Timer Default_Benchmark_Timer;
#endif
/**
* Algorithm benchmark
* @param name the name of the algorithm to test (cipher, hash, or MAC)
* @param milliseconds total time for the benchmark to run
* @param timer the timer to use
* @param rng the rng to use to generate random inputs
* @param af the algorithm factory used to create objects
* @return results a map from provider to speed in mebibytes per second
*/
std::map<std::string, double>
algorithm_benchmark(const std::string& name,
u32bit milliseconds,
Timer& timer,
RandomNumberGenerator& rng,
Algorithm_Factory& af);
}
#endif

View File

@@ -1,122 +0,0 @@
/*
* BER Decoder
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BER_DECODER_H__
#define BOTAN_BER_DECODER_H__
#include <botan/asn1_oid.h>
#include <botan/data_src.h>
namespace Botan {
/*
* BER Decoding Object
*/
class BOTAN_DLL BER_Decoder
{
public:
BER_Object get_next_object();
void push_back(const BER_Object&);
bool more_items() const;
BER_Decoder& verify_end();
BER_Decoder& discard_remaining();
BER_Decoder start_cons(ASN1_Tag, ASN1_Tag = UNIVERSAL);
BER_Decoder& end_cons();
BER_Decoder& raw_bytes(MemoryRegion<byte>&);
BER_Decoder& decode_null();
BER_Decoder& decode(bool&);
BER_Decoder& decode(u32bit&);
BER_Decoder& decode(class BigInt&);
BER_Decoder& decode(MemoryRegion<byte>&, ASN1_Tag);
BER_Decoder& decode(bool&, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
BER_Decoder& decode(u32bit&, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
BER_Decoder& decode(class BigInt&,
ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
BER_Decoder& decode(MemoryRegion<byte>&, ASN1_Tag,
ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
BER_Decoder& decode(class ASN1_Object&);
template<typename T>
BER_Decoder& decode_optional(T&, ASN1_Tag, ASN1_Tag, const T& = T());
template<typename T>
BER_Decoder& decode_list(std::vector<T>&, bool = true);
BER_Decoder& decode_optional_string(MemoryRegion<byte>&,
ASN1_Tag, u16bit);
BER_Decoder(DataSource&);
BER_Decoder(const byte[], u32bit);
BER_Decoder(const MemoryRegion<byte>&);
BER_Decoder(const BER_Decoder&);
~BER_Decoder();
private:
BER_Decoder& operator=(const BER_Decoder&) { return (*this); }
BER_Decoder* parent;
DataSource* source;
BER_Object pushed;
mutable bool owns;
};
/*
* Decode an OPTIONAL or DEFAULT element
*/
template<typename T>
BER_Decoder& BER_Decoder::decode_optional(T& out,
ASN1_Tag type_tag,
ASN1_Tag class_tag,
const T& default_value)
{
BER_Object obj = get_next_object();
if(obj.type_tag == type_tag && obj.class_tag == class_tag)
{
if(class_tag & CONSTRUCTED)
BER_Decoder(obj.value).decode(out).verify_end();
else
{
push_back(obj);
decode(out, type_tag, class_tag);
}
}
else
{
out = default_value;
push_back(obj);
}
return (*this);
}
/*
* Decode a list of homogenously typed values
*/
template<typename T>
BER_Decoder& BER_Decoder::decode_list(std::vector<T>& vec, bool clear_it)
{
if(clear_it)
vec.clear();
while(more_items())
{
T value;
decode(value);
vec.push_back(value);
}
return (*this);
}
}
#endif

View File

@@ -1,534 +0,0 @@
/*
* BigInt
* (C) 1999-2008 Jack Lloyd
* 2007 FlexSecure
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BIGINT_H__
#define BOTAN_BIGINT_H__
#include <botan/rng.h>
#include <botan/secmem.h>
#include <botan/mp_types.h>
#include <iosfwd>
namespace Botan {
/**
* Big Integer representation. This class defines an integer type,
* that can be very big. Additionally some helper functions are
* defined to work more comfortably.
*/
class BOTAN_DLL BigInt
{
public:
/**
* Base-Enumerator (currently 8,10,16 and 256 are defined)
*/
enum Base { Octal = 8, Decimal = 10, Hexadecimal = 16, Binary = 256 };
/**
* Sign symbol definitions for positive and negative numbers
*/
enum Sign { Negative = 0, Positive = 1 };
/**
* Number types (Powers of 2)
*/
enum NumberType { Power2 };
/**
* DivideByZero Exception
*/
struct DivideByZero : public Exception
{ DivideByZero() : Exception("BigInt divide by zero") {} };
/*************
* operators
*************/
/**
* += Operator
* @param y the BigInt to add to the local value
*/
BigInt& operator+=(const BigInt& y);
/**
* -= Operator
* @param y the BigInt to subtract from the local value
*/
BigInt& operator-=(const BigInt& y);
/**
* *= Operator
* @param y the BigInt to multiply with the local value
*/
BigInt& operator*=(const BigInt& y);
/**
* /= Operator
* @param y the BigInt to divide the local value by
*/
BigInt& operator/=(const BigInt& y);
/**
* %= Operator, modulo operator.
* @param y the modulus to reduce the local value by
*/
BigInt& operator%=(const BigInt& y);
/**
* %= Operator
* @param y the modulus (word) to reduce the local value by
*/
word operator%=(word y);
/**
* <<= Operator
* @param y the amount of bits to shift the local value left
*/
BigInt& operator<<=(u32bit y);
/**
* >>= Operator
* @param y the amount of bits to shift the local value right
*/
BigInt& operator>>=(u32bit y);
/**
* ++ Operator
*/
BigInt& operator++() { return (*this += 1); }
/**
* -- Operator
*/
BigInt& operator--() { return (*this -= 1); }
/**
* ++ Operator (postfix)
*/
BigInt operator++(int) { BigInt x = (*this); ++(*this); return x; }
/**
* -- Operator (postfix)
*/
BigInt operator--(int) { BigInt x = (*this); --(*this); return x; }
/**
* - Operator
*/
BigInt operator-() const;
/**
* ! Operator
*/
bool operator !() const { return (!is_nonzero()); }
/**
* [] Operator (array access)
*/
word& operator[](u32bit i) { return reg[i]; }
/**
* [] Operator (array access)
*/
word operator[](u32bit i) const { return reg[i]; }
/**
* Zeroize the BigInt
*/
void clear() { get_reg().clear(); }
/*************
* functions
************/
/**
* Compare *this to another BigInt.
* @param n the BigInt value to compare to the local value.
* @param check_signs Include sign in comparison?
* @result if (this<n) return -1, if (this>n) return 1, if both
* values are identical return 0.
*/
s32bit cmp(const BigInt& n, bool check_signs = true) const;
/**
* Test if the integer has an even value
* @result true, if the integer an even value, false otherwise
*/
bool is_even() const { return (get_bit(0) == 0); }
/**
* Test if the integer has an odd value
* @result true, if the integer an odd value, false otherwise
*/
bool is_odd() const { return (get_bit(0) == 1); }
/**
* Test if the integer is not zero.
* @result true, if the integer has a non-zero value, false otherwise
*/
bool is_nonzero() const { return (!is_zero()); }
/**
* Test if the integer is zero.
* @result true, if the integer has the value zero, false otherwise
*/
bool is_zero() const
{
const u32bit sw = sig_words();
for(u32bit i = 0; i != sw; ++i)
if(reg[i])
return false;
return true;
}
/**
* Set bit at specified position
* @param n bit position to set
*/
void set_bit(u32bit n);
/**
* Clear bit at specified position
* @param n bit position to clear
*/
void clear_bit(u32bit n);
/**
* Clear all but the lowest n bits
* @param n amount of bits to keep
*/
void mask_bits(u32bit n);
/**
* Return bit value at specified position
* @param n the bit offset to test
* @result true, if the bit at position n is set, false otherwise
*/
bool get_bit(u32bit n) const;
/**
* Return (a maximum of) 32 bits of the complete value
* @param offset the offset to start extracting
* @param length amount of bits to extract (starting at offset)
* @result the integer extracted from the register starting at
* offset with specified length
*/
u32bit get_substring(u32bit offset, u32bit length) const;
byte byte_at(u32bit) const;
/**
* Return the word at a specified position of the internal register
* @param n position in the register
* @return the value at position n
*/
word word_at(u32bit n) const
{ return ((n < size()) ? reg[n] : 0); }
/**
* Return the integer as an unsigned 32bit-integer-value. If the
* value is negative OR to big to be stored in 32bits, this
* function will throw an exception.
* @result a 32bit-integer
*/
u32bit to_u32bit() const;
/**
* Tests if the sign of the integer is negative.
* @result true, if the integer has a negative sign,
*/
bool is_negative() const { return (sign() == Negative); }
/**
* Tests if the sign of the integer is positive.
* @result true, if the integer has a positive sign,
*/
bool is_positive() const { return (sign() == Positive); }
/**
* Return the sign of the integer
* @result the sign of the integer
*/
Sign sign() const { return (signedness); }
/**
* Return the opposite sign of the represented integer value
* @result the opposite sign of the represented integer value
*/
Sign reverse_sign() const;
/**
* Flip (change!) the sign of the integer to its opposite value
*/
void flip_sign();
/**
* Set sign of the integer
* @param sign new Sign to set
*/
void set_sign(Sign sign);
/**
* Give absolute (positive) value of the integer
* @result absolute (positive) value of the integer
*/
BigInt abs() const;
/**
* Give size of internal register
* @result size of internal register in words
*/
u32bit size() const { return get_reg().size(); }
/**
* Give significant words of the represented integer value
* @result significant words of the represented integer value
*/
u32bit sig_words() const
{
const word* x = reg.begin();
u32bit sig = reg.size();
while(sig && (x[sig-1] == 0))
sig--;
return sig;
}
/**
* Give byte-length of the integer
* @result byte-length of the represented integer value
*/
u32bit bytes() const;
/**
* Get the bit-length of the integer.
* @result bit-length of the represented integer value
*/
u32bit bits() const;
/**
* Return a pointer to the big integer word register.
* @result a pointer to the start of the internal register of
* the integer value
*/
const word* data() const { return reg.begin(); }
/**
* return a reference to the internal register containing the value
* @result a reference to the word-array (SecureVector<word>)
* with the internal register value (containing the integer
* value)
*/
SecureVector<word>& get_reg() { return reg; }
/**
* return a const reference to the internal register containing the value
* @result a const reference to the word-array (SecureVector<word>)
* with the internal register value (containing the integer
* value)
*/
const SecureVector<word>& get_reg() const { return reg; }
/**
* Increase internal register buffer by n words
* @param n increase by n words
*/
void grow_reg(u32bit n);
void grow_to(u32bit n);
/**
* Fill BigInt with a random number with size of bitsize
* @param rng the random number generator to use
* @param bitsize number of bits the created random value should have
*/
void randomize(RandomNumberGenerator& rng, u32bit bitsize = 0);
/**
* Store BigInt-value in a given byte array
* @param buf destination byte array for the integer value
*/
void binary_encode(byte buf[]) const;
/**
* Read integer value from a byte array with given size
* @param buf byte array buffer containing the integer
* @param length size of buf
*/
void binary_decode(const byte buf[], u32bit length);
/**
* Read integer value from a byte array (MemoryRegion<byte>)
* @param buf the BigInt value to compare to the local value.
*/
void binary_decode(const MemoryRegion<byte>& buf);
u32bit encoded_size(Base = Binary) const;
/**
@param rng a random number generator
@result a random integer between min and max
*/
static BigInt random_integer(RandomNumberGenerator& rng,
const BigInt& min, const BigInt& max);
/**
* Encode the integer value from a BigInt to a SecureVector of bytes
* @param n the BigInt to use as integer source
* @param base number-base of resulting byte array representation
* @result SecureVector of bytes containing the integer with given base
*/
static SecureVector<byte> encode(const BigInt& n, Base base = Binary);
/**
* Encode the integer value from a BigInt to a byte array
* @param buf destination byte array for the encoded integer
* value with given base
* @param n the BigInt to use as integer source
* @param base number-base of resulting byte array representation
*/
static void encode(byte buf[], const BigInt& n, Base base = Binary);
/**
* Create a BigInt from an integer in a byte array
* @param buf the BigInt value to compare to the local value.
* @param length size of buf
* @param base number-base of the integer in buf
* @result BigInt-representing the given integer read from the byte array
*/
static BigInt decode(const byte buf[], u32bit length,
Base base = Binary);
static BigInt decode(const MemoryRegion<byte>&, Base = Binary);
/**
* Encode a Big Integer to a byte array according to IEEE1363.
* @param n the Big Integer to encode
* @param bytes the length of the resulting SecureVector<byte>
* @result a SecureVector<byte> containing the encoded Big Integer
*/
static SecureVector<byte> encode_1363(const BigInt& n, u32bit bytes);
/**
* Swap BigInt-value with given BigInt.
* @param bigint the BigInt to swap values with
*/
void swap(BigInt& bigint);
/**
* constructors
*/
/**
* Create empty BigInt
*/
BigInt() { signedness = Positive; }
/**
* Create BigInt from 64bit-Integer value
* @param n 64bit-integer
*/
BigInt(u64bit n);
/**
* Copy-Constructor: clone given BigInt
* @param bigint the BigInt to clone
*/
BigInt(const BigInt& bigint);
/**
* Create BigInt from a string.
* If the string starts with 0x the rest of the string will be
* interpreted as hexadecimal digits.
* If the string starts with 0 and the second character is NOT
* an 'x' the string will be interpreted as octal digits.
* If the string starts with non-zero digit, it will be
* interpreted as a decimal number.
* @param str the string to parse for an integer value
*/
BigInt(const std::string& str);
/**
* Create a BigInt from an integer in a byte array
* @param buf the BigInt value to compare to the local value.
* @param length size of buf
* @param base number-base of the integer in buf
*/
BigInt(const byte buf[], u32bit length, Base base = Binary);
/**
* Create a random BigInt of the specified size
* @param rng random number generator
* @param bits size in bits
*/
BigInt(RandomNumberGenerator& rng, u32bit bits);
/**
* Create BigInt from unsigned 32 bit integer value and an
* also specify the sign of the value
* @param n integer value
*/
BigInt(Sign, u32bit n);
/**
* Create a number of the specified type and size
* @param type the type of number to create
* @param n the size
*/
BigInt(NumberType type, u32bit n);
private:
SecureVector<word> reg;
Sign signedness;
};
/*
* Arithmetic Operators
*/
BigInt BOTAN_DLL operator+(const BigInt&, const BigInt&);
BigInt BOTAN_DLL operator-(const BigInt&, const BigInt&);
BigInt BOTAN_DLL operator*(const BigInt&, const BigInt&);
BigInt BOTAN_DLL operator/(const BigInt&, const BigInt&);
BigInt BOTAN_DLL operator%(const BigInt&, const BigInt&);
word BOTAN_DLL operator%(const BigInt&, word);
BigInt BOTAN_DLL operator<<(const BigInt&, u32bit);
BigInt BOTAN_DLL operator>>(const BigInt&, u32bit);
/*
* Comparison Operators
*/
inline bool operator==(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) == 0); }
inline bool operator!=(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) != 0); }
inline bool operator<=(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) <= 0); }
inline bool operator>=(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) >= 0); }
inline bool operator<(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) < 0); }
inline bool operator>(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) > 0); }
/*
* I/O Operators
*/
BOTAN_DLL std::ostream& operator<<(std::ostream&, const BigInt&);
BOTAN_DLL std::istream& operator>>(std::istream&, BigInt&);
}
namespace std {
inline void swap(Botan::BigInt& a, Botan::BigInt& b) { a.swap(b); }
}
#endif

View File

@@ -1,91 +0,0 @@
/*
* Bit/Word Operations
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BIT_OPS_H__
#define BOTAN_BIT_OPS_H__
#include <botan/types.h>
namespace Botan {
/*
* Return true iff arg is 2**n for some n > 0
* T should be an unsigned integer type
*/
template<typename T>
inline bool power_of_2(T arg)
{
return ((arg != 0 && arg != 1) && ((arg & (arg-1)) == 0));
}
/*
* Return the index of the highest set bit
* T is an unsigned integer type
*/
template<typename T>
inline u32bit high_bit(T n)
{
for(u32bit i = 8*sizeof(T); i > 0; --i)
if((n >> (i - 1)) & 0x01)
return i;
return 0;
}
/*
* Return the index of the lowest set bit
*/
template<typename T>
inline u32bit low_bit(T n)
{
for(u32bit i = 0; i != 8*sizeof(T); ++i)
if((n >> i) & 0x01)
return (i + 1);
return 0;
}
/*
* Return the number of significant bytes in n
*/
template<typename T>
inline u32bit significant_bytes(T n)
{
for(u32bit j = 0; j != sizeof(T); ++j)
if(get_byte(j, n))
return sizeof(T)-j;
return 0;
}
/*
* Return the Hamming weight of n
*/
template<typename T>
inline u32bit hamming_weight(T n)
{
const byte NIBBLE_WEIGHTS[] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
u32bit weight = 0;
for(u32bit i = 0; i != 2*sizeof(T); ++i)
weight += NIBBLE_WEIGHTS[(n >> (4*i)) & 0x0F];
return weight;
}
/*
* Count the trailing zero bits in n
*/
template<typename T>
inline u32bit ctz(T n)
{
for(u32bit i = 0; i != 8*sizeof(T); ++i)
if((n >> i) & 0x01)
return i;
return 8*sizeof(T);
}
}
#endif

View File

@@ -1,34 +0,0 @@
/*
* Blinder
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BLINDER_H__
#define BOTAN_BLINDER_H__
#include <botan/bigint.h>
#include <botan/reducer.h>
namespace Botan {
/*
* Blinding Function Object
*/
class BOTAN_DLL Blinder
{
public:
BigInt blind(const BigInt&) const;
BigInt unblind(const BigInt&) const;
Blinder() {}
Blinder(const BigInt&, const BigInt&, const BigInt&);
private:
Modular_Reducer reducer;
mutable BigInt e, d;
};
}
#endif

View File

@@ -1,100 +0,0 @@
/**
* Block Cipher Base Class
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BLOCK_CIPHER_H__
#define BOTAN_BLOCK_CIPHER_H__
#include <botan/sym_algo.h>
namespace Botan {
/**
* This class represents a block cipher object.
*
* It would be very useful to extend this interface to support the
* encryption of multiple blocks at a time. This could help
* performance, wrt cache effects in the software implementations, and
* could be a big deal when supporting block ciphers implemented as
* hardware devices. It could be used by implementations of ECB, and
* more importantly counter mode (which most designs are moving to, due
* to the parallelism possible in counter mode which is not the case
* with feedback-based modes like CBC).
*
* Probable future API here:
* virtual void encrypt_n(const byte in[], byte out[],
* u32bit blocks) const = 0;
* virtual void decrypt_n(const byte in[], byte out[],
* u32bit blocks) const = 0;
*/
class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
{
public:
/**
* The block size of this algorithm.
*/
const u32bit BLOCK_SIZE;
/**
* Encrypt a block.
* @param in The plaintext block to be encrypted as a byte array.
* Must be of length BLOCK_SIZE.
* @param out The byte array designated to hold the encrypted block.
* Must be of length BLOCK_SIZE.
*/
void encrypt(const byte in[], byte out[]) const { enc(in, out); }
/**
* Decrypt a block.
* @param in The ciphertext block to be decypted as a byte array.
* Must be of length BLOCK_SIZE.
* @param out The byte array designated to hold the decrypted block.
* Must be of length BLOCK_SIZE.
*/
void decrypt(const byte in[], byte out[]) const { dec(in, out); }
/**
* Encrypt a block.
* @param in The plaintext block to be encrypted as a byte array.
* Must be of length BLOCK_SIZE. Will hold the result when the function
* has finished.
*/
void encrypt(byte block[]) const { enc(block, block); }
/**
* Decrypt a block.
* @param in The ciphertext block to be decrypted as a byte array.
* Must be of length BLOCK_SIZE. Will hold the result when the function
* has finished.
*/
void decrypt(byte block[]) const { dec(block, block); }
/**
* Get a new object representing the same algorithm as *this
*/
virtual BlockCipher* clone() const = 0;
/**
* Zeroize internal state
*/
virtual void clear() throw() = 0;
BlockCipher(u32bit block_size,
u32bit key_min,
u32bit key_max = 0,
u32bit key_mod = 1) :
SymmetricAlgorithm(key_min, key_max, key_mod),
BLOCK_SIZE(block_size) {}
virtual ~BlockCipher() {}
private:
virtual void enc(const byte[], byte[]) const = 0;
virtual void dec(const byte[], byte[]) const = 0;
};
}
#endif

View File

@@ -1,40 +0,0 @@
/*
* Blowfish
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BLOWFISH_H__
#define BOTAN_BLOWFISH_H__
#include <botan/block_cipher.h>
namespace Botan {
/*
* Blowfish
*/
class BOTAN_DLL Blowfish : public BlockCipher
{
public:
void clear() throw();
std::string name() const { return "Blowfish"; }
BlockCipher* clone() const { return new Blowfish; }
Blowfish() : BlockCipher(8, 1, 56) {}
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
void generate_sbox(u32bit[], u32bit, u32bit&, u32bit&) const;
static const u32bit P_INIT[18];
static const u32bit S_INIT[1024];
SecureBuffer<u32bit, 1024> S;
SecureBuffer<u32bit, 18> P;
};
}
#endif

View File

@@ -1,18 +0,0 @@
/**
* A vague catch all include file for Botan
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/init.h>
#include <botan/lookup.h>
#include <botan/libstate.h>
#include <botan/version.h>
#include <botan/parsing.h>
#include <botan/rng.h>
#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
#include <botan/auto_rng.h>
#endif

View File

@@ -1,62 +0,0 @@
/*
* Byte Swapping Operations
* (C) 1999-2008 Jack Lloyd
* (C) 2007 Yves Jerschow
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BYTE_SWAP_H__
#define BOTAN_BYTE_SWAP_H__
#include <botan/types.h>
#include <botan/rotate.h>
namespace Botan {
/*
* Byte Swapping Functions
*/
inline u16bit reverse_bytes(u16bit input)
{
return rotate_left(input, 8);
}
inline u32bit reverse_bytes(u32bit input)
{
#if BOTAN_USE_GCC_INLINE_ASM && \
(defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64))
/* GCC-style inline assembly for x86 or x86-64 */
asm("bswapl %0" : "=r" (input) : "0" (input));
return input;
#elif defined(_MSC_VER) && defined(BOTAN_TARGET_ARCH_IS_IA32)
/* Visual C++ inline asm for 32-bit x86, by Yves Jerschow */
__asm mov eax, input;
__asm bswap eax;
#else
/* Generic implementation */
input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8);
return rotate_left(input, 16);
#endif
}
inline u64bit reverse_bytes(u64bit input)
{
#if BOTAN_USE_GCC_INLINE_ASM && defined(BOTAN_TARGET_ARCH_IS_AMD64)
asm("bswapq %0" : "=r" (input) : "0" (input));
return input;
#else
u32bit hi = ((input >> 40) & 0x00FF00FF) | ((input >> 24) & 0xFF00FF00);
u32bit lo = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8);
hi = (hi << 16) | (hi >> 16);
lo = (lo << 16) | (lo >> 16);
return (static_cast<u64bit>(lo) << 32) | hi;
#endif
}
}
#endif

View File

@@ -1,126 +0,0 @@
/**
* BufferedComputation
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BUFFERED_COMPUTATION_H__
#define BOTAN_BUFFERED_COMPUTATION_H__
#include <botan/secmem.h>
namespace Botan {
/**
* This class represents any kind of computation which
* uses an internal state,
* such as hash functions.
*/
class BOTAN_DLL BufferedComputation
{
public:
/**
* The length of the output of this function in bytes.
*/
const u32bit OUTPUT_LENGTH;
/**
* Add new input to process.
* @param in the input to process as a byte array
* @param the length of the byte array
*/
void update(const byte in[], u32bit length) { add_data(in, length); }
/**
* Add new input to process.
* @param in the input to process as a MemoryRegion
*/
void update(const MemoryRegion<byte>& in) { add_data(in, in.size()); }
/**
* Add new input to process.
* @param str the input to process as a std::string. Will be interpreted
* as a byte array based on
* the strings encoding.
*/
void update(const std::string& str)
{
add_data(reinterpret_cast<const byte*>(str.data()), str.size());
}
/**
* Process a single byte.
* @param in the byte to process
*/
void update(byte in) { add_data(&in, 1); }
/**
* Complete the computation and retrieve the
* final result.
* @param out The byte array to be filled with the result.
* Must be of length OUTPUT_LENGTH.
*/
void final(byte out[]) { final_result(out); }
/**
* Complete the computation and retrieve the
* final result.
* @return a SecureVector holding the result
*/
SecureVector<byte> final()
{
SecureVector<byte> output(OUTPUT_LENGTH);
final_result(output);
return output;
}
/**
* Update and finalize computation. Does the same as calling update()
* and final() consecutively.
* @param in the input to process as a byte array
* @param length the length of the byte array
* @result the result of the call to final()
*/
SecureVector<byte> process(const byte in[], u32bit length)
{
add_data(in, length);
return final();
}
/**
* Update and finalize computation. Does the same as calling update()
* and final() consecutively.
* @param in the input to process
* @result the result of the call to final()
*/
SecureVector<byte> process(const MemoryRegion<byte>& in)
{
add_data(in, in.size());
return final();
}
/**
* Update and finalize computation. Does the same as calling update()
* and final() consecutively.
* @param in the input to process as a string
* @result the result of the call to final()
*/
SecureVector<byte> process(const std::string& in)
{
update(in);
return final();
}
BufferedComputation(u32bit out_len) : OUTPUT_LENGTH(out_len) {}
virtual ~BufferedComputation() {}
private:
BufferedComputation& operator=(const BufferedComputation&);
virtual void add_data(const byte[], u32bit) = 0;
virtual void final_result(byte[]) = 0;
};
}
#endif

View File

@@ -1,39 +0,0 @@
/*
* Buffering Filter
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BUFFERING_FILTER_H__
#define BOTAN_BUFFERING_FILTER_H__
#include <botan/filter.h>
namespace Botan {
/**
* Buffering_Filter: This class represents filters for operations that
* maintain an internal state.
*/
class BOTAN_DLL Buffering_Filter : public Filter
{
public:
void write(const byte[], u32bit);
virtual void end_msg();
Buffering_Filter(u32bit, u32bit = 0);
virtual ~Buffering_Filter() {}
protected:
virtual void initial_block(const byte[]) {}
virtual void main_block(const byte[]) = 0;
virtual void final_block(const byte[], u32bit) = 0;
private:
const u32bit INITIAL_BLOCK_SIZE, BLOCK_SIZE;
SecureVector<byte> initial, block;
u32bit initial_block_pos, block_pos;
};
}
#endif

View File

@@ -1,51 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef BOTAN_BUILD_CONFIG_H_QT
#define BOTAN_BUILD_CONFIG_H_QT
#include <qglobal.h>
#if defined(Q_OS_WIN)
# include "build_windows.h"
#elif defined(Q_OS_UNIX)
# include "build_unix.h"
#endif
#ifdef QT_ARCH_I386
#define BOTAN_TARGET_ARCH_IS_IA32
#define BOTAN_TARGET_CPU_IS_I686
#elif defined(QT_ARCH_X86_64)
#define BOTAN_TARGET_ARCH_IS_AMD64
#endif
#endif

View File

@@ -1,353 +0,0 @@
#ifndef BOTAN_BUILD_CONFIG_H__
#define BOTAN_BUILD_CONFIG_H__
/* This file was automatically generated Tue Jan 12 09:38:57 2010 UTC */
#define BOTAN_VERSION_MAJOR 1
#define BOTAN_VERSION_MINOR 8
#define BOTAN_VERSION_PATCH 8
#ifndef BOTAN_DLL
#define BOTAN_DLL __attribute__ ((visibility("default")))
#endif
/* Chunk sizes */
#define BOTAN_DEFAULT_BUFFER_SIZE 4096
#define BOTAN_MEM_POOL_CHUNK_SIZE 64*1024
/* BigInt toggles */
#define BOTAN_MP_WORD_BITS 32
#define BOTAN_KARAT_MUL_THRESHOLD 32
#define BOTAN_KARAT_SQR_THRESHOLD 32
#define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64
/* PK key consistency checking toggles */
#define BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD 1
#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD 1
#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE 1
/* Should we use GCC-style inline assembler? */
#if !defined(BOTAN_USE_GCC_INLINE_ASM) && defined(__GNUG__)
#define BOTAN_USE_GCC_INLINE_ASM 1
#endif
#ifndef BOTAN_USE_GCC_INLINE_ASM
#define BOTAN_USE_GCC_INLINE_ASM 0
#endif
#define BOTAN_USE_QT_SHARED_POINTER
#define BOTAN_USE_STD_TR1
/* Module definitions */
#define BOTAN_HAS_ADLER32
#define BOTAN_HAS_AES
#define BOTAN_HAS_ALGORITHM_FACTORY
#define BOTAN_HAS_ALLOC_MMAP
#define BOTAN_HAS_ANSI_X919_MAC
#define BOTAN_HAS_ARC4
#define BOTAN_HAS_ASN1
#define BOTAN_HAS_AUTO_SEEDING_RNG
#define BOTAN_HAS_BASE64_CODEC
#define BOTAN_HAS_BIGINT
#define BOTAN_HAS_BIGINT_GFP
#define BOTAN_HAS_BIGINT_MATH
#define BOTAN_HAS_BLOCK_CIPHER
#define BOTAN_HAS_BLOWFISH
#define BOTAN_HAS_CARD_VERIFIABLE_CERTIFICATES
#define BOTAN_HAS_CAST
#define BOTAN_HAS_CBC
#define BOTAN_HAS_CBC_MAC
#define BOTAN_HAS_CFB
#define BOTAN_HAS_CIPHER_MODEBASE
#define BOTAN_HAS_CIPHER_MODE_PADDING
#define BOTAN_HAS_CMAC
#define BOTAN_HAS_CMS
#define BOTAN_HAS_CRC24
#define BOTAN_HAS_CRC32
#define BOTAN_HAS_CRYPTO_BOX
#define BOTAN_HAS_CTR
#define BOTAN_HAS_CTS
#define BOTAN_HAS_DEFAULT_ENGINE
#define BOTAN_HAS_DES
#define BOTAN_HAS_DIFFIE_HELLMAN
#define BOTAN_HAS_DLIES
#define BOTAN_HAS_DL_GROUP
#define BOTAN_HAS_DL_PUBLIC_KEY_FAMILY
#define BOTAN_HAS_DSA
#define BOTAN_HAS_EAX
#define BOTAN_HAS_ECB
#define BOTAN_HAS_ECC_DOMAIN_PARAMATERS
#define BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO
#define BOTAN_HAS_ECDSA
#define BOTAN_HAS_ECKAEG
#define BOTAN_HAS_ELGAMAL
#define BOTAN_HAS_EME1
#define BOTAN_HAS_EME_PKCS1v15
#define BOTAN_HAS_EMSA1
#define BOTAN_HAS_EMSA1_BSI
#define BOTAN_HAS_EMSA2
#define BOTAN_HAS_EMSA3
#define BOTAN_HAS_EMSA4
#define BOTAN_HAS_EMSA_RAW
#define BOTAN_HAS_ENGINES
#define BOTAN_HAS_ENTROPY_SRC_DEVICE
#define BOTAN_HAS_ENTROPY_SRC_EGD
#define BOTAN_HAS_ENTROPY_SRC_FTW
#define BOTAN_HAS_ENTROPY_SRC_UNIX
#define BOTAN_HAS_FILTERS
#define BOTAN_HAS_FORK_256
#define BOTAN_HAS_GOST_28147_89
#define BOTAN_HAS_GOST_34_11
#define BOTAN_HAS_HASH_ID
#define BOTAN_HAS_HAS_160
#define BOTAN_HAS_HEX_CODEC
#define BOTAN_HAS_HMAC
#define BOTAN_HAS_HMAC_RNG
#define BOTAN_HAS_IDEA
#define BOTAN_HAS_IF_PUBLIC_KEY_FAMILY
#define BOTAN_HAS_KASUMI
#define BOTAN_HAS_KDF1
#define BOTAN_HAS_KDF2
#define BOTAN_HAS_KDF_BASE
#define BOTAN_HAS_KEYPAIR_TESTING
#define BOTAN_HAS_LIBSTATE_MODULE
#define BOTAN_HAS_LION
#define BOTAN_HAS_LUBY_RACKOFF
#define BOTAN_HAS_MARS
#define BOTAN_HAS_MD2
#define BOTAN_HAS_MD4
#define BOTAN_HAS_MD5
#define BOTAN_HAS_MDX_HASH_FUNCTION
#define BOTAN_HAS_MGF1
#define BOTAN_HAS_MISTY1
#define BOTAN_HAS_MUTEX_NOOP
#define BOTAN_HAS_MUTEX_PTHREAD
#define BOTAN_HAS_MUTEX_WRAPPERS
#define BOTAN_HAS_NOEKEON
#define BOTAN_HAS_NYBERG_RUEPPEL
#define BOTAN_HAS_OFB
#define BOTAN_HAS_OID_LOOKUP
#define BOTAN_HAS_OPENPGP_CODEC
#define BOTAN_HAS_PARALLEL_HASH
#define BOTAN_HAS_PASSWORD_BASED_ENCRYPTION
#define BOTAN_HAS_PBE_PKCS_V15
#define BOTAN_HAS_PBE_PKCS_V20
#define BOTAN_HAS_PBKDF1
#define BOTAN_HAS_PBKDF2
#define BOTAN_HAS_PEM_CODEC
#define BOTAN_HAS_PGPS2K
#define BOTAN_HAS_PIPE_UNIXFD_IO
#define BOTAN_HAS_PK_PADDING
#define BOTAN_HAS_PUBLIC_KEY_CRYPTO
#define BOTAN_HAS_RANDPOOL
#define BOTAN_HAS_RC2
#define BOTAN_HAS_RC5
#define BOTAN_HAS_RC6
#define BOTAN_HAS_RIPEMD_128
#define BOTAN_HAS_RIPEMD_160
#define BOTAN_HAS_RSA
#define BOTAN_HAS_RUNTIME_BENCHMARKING
#define BOTAN_HAS_RW
#define BOTAN_HAS_SAFER
#define BOTAN_HAS_SALSA20
#define BOTAN_HAS_SEED
#define BOTAN_HAS_SELFTESTS
#define BOTAN_HAS_SERPENT
#define BOTAN_HAS_SHA1
#define BOTAN_HAS_SHA2
#define BOTAN_HAS_SKEIN_512
#define BOTAN_HAS_SKIPJACK
#define BOTAN_HAS_SQUARE
#define BOTAN_HAS_SSL3_MAC
#define BOTAN_HAS_SSL_V3_PRF
#define BOTAN_HAS_STREAM_CIPHER
#define BOTAN_HAS_TEA
#define BOTAN_HAS_TIGER
#define BOTAN_HAS_TIMER
#ifndef Q_OS_MAC
#define BOTAN_HAS_TIMER_POSIX
#endif
#define BOTAN_HAS_TIMER_UNIX
#define BOTAN_HAS_TLS_V10_PRF
#define BOTAN_HAS_TURING
#define BOTAN_HAS_TWOFISH
#define BOTAN_HAS_UTIL_FUNCTIONS
#define BOTAN_HAS_WHIRLPOOL
#define BOTAN_HAS_WID_WAKE
#define BOTAN_HAS_X509
#define BOTAN_HAS_X931_RNG
#define BOTAN_HAS_X942_PRF
#define BOTAN_HAS_XTEA
#define BOTAN_HAS_XTS
/* Local configuration options */
/*
christian@christian-linux ran 'configure.py --os=linux --cpu=ia32 --cc=gcc --disable-asm'
Target
-------
Compiler: g++ -O2 -finline-functions
Arch: ia32/ia32
OS: linux
Modules
-------
adler32 (Adler32)
aes (AES)
algo_factory (Algorithm Factory)
alloc (Allocator)
alloc_mmap (Disk Based Allocation System)
arc4 (ARC4)
asn1 (ASN.1/BER/DER module)
auto_rng (Auto-seeded Random Number Generator)
base64 (Base64 Codec)
benchmark (Benchmarking)
bigint (BigInt)
block (Block Ciphers)
blowfish (Blowfish)
buf_comp (Buffered Computation)
cast (CAST)
cbc (CBC block cipher mode)
cbc_mac (CBC-MAC)
cfb (CFB block cipher mode)
cmac (CMAC)
cms (CMS)
crc24 (CRC-24)
crc32 (CRC-32)
cryptobox (Crypto Box)
ctr (CTR block cipher mode)
cts (CTS block cipher mode)
cvc (Card Verifiable Certificates)
datastor (Datastore)
def_engine (Default Engine)
des (DES)
dev_random (RNG Device Reader)
dh (Diffie-Hellman Key Agreement)
dl_algo (Discrete Logarithm PK Algorithms)
dl_group (DL Group)
dlies (DLIES)
dsa (DSA)
eax (EAX block cipher mode)
ec_dompar (ECC Domain Parameters)
ecb (ECB block cipher mode)
ecc_key (ECC Public Key)
ecdsa (ECDSA)
eckaeg (ECKAEG)
egd (EGD Entropy Source)
elgamal (ElGamal)
eme1 (EME1)
eme_pkcs (PKCSv1 v1.5 EME)
emsa1 (EMSA1)
emsa1_bsi (EMSA1 (BSI variant))
emsa2 (EMSA2)
emsa3 (EMSA3)
emsa4 (EMSA4)
emsa_raw (EMSA-Raw)
engine (Engines)
entropy (Entropy Sources)
fd_unix (Unix I/O support for Pipe)
filters (Pipe/Filter)
fork256 (FORK-256)
gettimeofday (Unix Timer)
gfpmath (GF(p) Math)
gost_28147 (GOST 28147-89)
gost_3411 (GOST 34.11)
has160 (HAS-160)
hash (Hash Functions)
hash_id (Hash Function Identifiers)
hex (Hex Codec)
hmac (HMAC)
hmac_rng (HMAC RNG)
idea (IDEA)
if_algo (Integer Factorization Algorithms)
kasumi (Kasumi)
kdf (KDF Base Class)
kdf1 (KDF1)
kdf2 (KDF2)
keypair (Keypair Testing)
libstate (Botan Libstate Module)
lion (Lion)
lubyrack (Luby-Rackoff)
mac (Message Authentication Codes)
mars (MARS)
md2 (MD2)
md4 (MD4)
md5 (MD5)
mdx_hash (MDx Hash Base)
mem_pool (Memory Pool Allocator)
mgf1 (MGF1)
misty1 (MISTY-1)
mode_pad (Cipher Mode Padding Method)
modes (Cipher Mode Base Class)
monty_generic (Montgomery Reduction)
mp_generic (MPI Core (C++))
mulop_generic (BigInt Multiply-Add)
mutex (Mutex Wrappers)
noekeon (Noekeon)
noop_mutex (No-Op Mutex)
nr (Nyberg-Rueppel)
numbertheory (Math Functions)
ofb (OFB block cipher mode)
oid_lookup (OID Lookup)
openpgp (OpenPGP Codec)
par_hash (Parallel Hash)
pbe (PBE Base)
pbes1 (PKCS5 v1.5 PBE)
pbes2 (PKCS5 v2.0 PBE)
pbkdf1 (Pbkdf1)
pbkdf2 (Pbkdf2)
pem (PEM Codec)
pgps2k (Pgps2k)
pk_codecs (PK codecs (PKCS8, X.509))
pk_pad (Public Key EME/EMSA Padding Modes)
posix_rt (POSIX Timer)
proc_walk (File Tree Walking Entropy Source)
pthreads (Pthread Mutex)
pubkey (Public Key Base)
randpool (Randpool RNG)
rc2 (RC2)
rc5 (RC5)
rc6 (RC6)
rmd128 (RIPEMD-128)
rmd160 (RIPEMD-160)
rng (Random Number Generators)
rsa (RSA)
rw (Rabin-Williams)
s2k (String to Key Functions)
safer (SAFER)
salsa20 (Salsa20)
seed (SEED)
selftest (Selftests)
serpent (Serpent)
sha1 (SHA-1)
sha2 (SHA-2 (224, 256, 384, 512))
skein (Skein)
skipjack (Skipjack)
square (Square)
ssl3mac (SSLv3 MAC)
ssl_prf (SSLv3 PRF)
stream (Stream Ciphers)
sym_algo (Symmetric Algorithms)
system_alloc (Default (Malloc) Allocators)
tea (TEA)
tiger (Tiger)
timer (Timer Base Class)
tls_prf (TLS v1.0 PRF)
turing (Turing)
twofish (Twofish)
unix_procs (Generic Unix Entropy Source)
utils (Utility Functions)
whirlpool (Whirlpool)
wid_wake (WiderWake)
x509 (X.509)
x919_mac (ANSI X9.19 MAC)
x931_rng (ANSI X9.31 PRNG)
x942_prf (X942 PRF)
xtea (XTEA)
xts (XTS block cipher mode)
*/
#endif

View File

@@ -1,337 +0,0 @@
#ifndef BOTAN_BUILD_CONFIG_H__
#define BOTAN_BUILD_CONFIG_H__
/* This file was automatically generated Mon Jan 11 14:51:24 2010 UTC */
#define BOTAN_VERSION_MAJOR 1
#define BOTAN_VERSION_MINOR 8
#define BOTAN_VERSION_PATCH 8
#ifndef BOTAN_DLL
# if !defined(Q_CC_MINGW)
# define BOTAN_DLL __declspec(dllexport)
# else
# define BOTAN_DLL
# endif
#endif
/* Chunk sizes */
#define BOTAN_DEFAULT_BUFFER_SIZE 4096
#define BOTAN_MEM_POOL_CHUNK_SIZE 64*1024
/* BigInt toggles */
#define BOTAN_MP_WORD_BITS 32
#define BOTAN_KARAT_MUL_THRESHOLD 32
#define BOTAN_KARAT_SQR_THRESHOLD 32
#define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64
/* PK key consistency checking toggles */
#define BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD 1
#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD 1
#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE 1
/* Should we use GCC-style inline assembler? */
#if !defined(BOTAN_USE_GCC_INLINE_ASM) && defined(__GNUG__)
#define BOTAN_USE_GCC_INLINE_ASM 1
#endif
#ifndef BOTAN_USE_GCC_INLINE_ASM
#define BOTAN_USE_GCC_INLINE_ASM 0
#endif
/* Target identification and feature test macros */
#define BOTAN_TARGET_OS_IS_WINDOWS
#define BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK
#define BOTAN_USE_QT_SHARED_POINTER
/* Module definitions */
#if defined(Q_CC_MINGW)
# define BOTAN_USE_STD_TR1
# define BOTAN_HAS_BIGINT_GFP
# define BOTAN_HAS_CARD_VERIFIABLE_CERTIFICATES
# define BOTAN_HAS_ECC_DOMAIN_PARAMATERS
# define BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO
#endif
#define BOTAN_HAS_ADLER32
#define BOTAN_HAS_AES
#define BOTAN_HAS_ALGORITHM_FACTORY
#define BOTAN_HAS_ANSI_X919_MAC
#define BOTAN_HAS_ARC4
#define BOTAN_HAS_ASN1
#define BOTAN_HAS_AUTO_SEEDING_RNG
#define BOTAN_HAS_BASE64_CODEC
#define BOTAN_HAS_BIGINT
#define BOTAN_HAS_BIGINT_MATH
#define BOTAN_HAS_BLOCK_CIPHER
#define BOTAN_HAS_BLOWFISH
#define BOTAN_HAS_CAST
#define BOTAN_HAS_CBC
#define BOTAN_HAS_CBC_MAC
#define BOTAN_HAS_CFB
#define BOTAN_HAS_CIPHER_MODEBASE
#define BOTAN_HAS_CIPHER_MODE_PADDING
#define BOTAN_HAS_CMAC
#define BOTAN_HAS_CMS
#define BOTAN_HAS_CRC24
#define BOTAN_HAS_CRC32
#define BOTAN_HAS_CRYPTO_BOX
#define BOTAN_HAS_CTR
#define BOTAN_HAS_CTS
#define BOTAN_HAS_DEFAULT_ENGINE
#define BOTAN_HAS_DES
#define BOTAN_HAS_DIFFIE_HELLMAN
#define BOTAN_HAS_DLIES
#define BOTAN_HAS_DL_GROUP
#define BOTAN_HAS_DL_PUBLIC_KEY_FAMILY
#define BOTAN_HAS_DSA
#define BOTAN_HAS_EAX
#define BOTAN_HAS_ECB
#define BOTAN_HAS_ELGAMAL
#define BOTAN_HAS_EME1
#define BOTAN_HAS_EME_PKCS1v15
#define BOTAN_HAS_EMSA1
#define BOTAN_HAS_EMSA1_BSI
#define BOTAN_HAS_EMSA2
#define BOTAN_HAS_EMSA3
#define BOTAN_HAS_EMSA4
#define BOTAN_HAS_EMSA_RAW
#define BOTAN_HAS_ENGINES
#define BOTAN_HAS_ENTROPY_SRC_CAPI
#define BOTAN_HAS_ENTROPY_SRC_WIN32
#define BOTAN_HAS_FILTERS
#define BOTAN_HAS_FORK_256
#define BOTAN_HAS_GOST_28147_89
#define BOTAN_HAS_GOST_34_11
#define BOTAN_HAS_HASH_ID
#define BOTAN_HAS_HAS_160
#define BOTAN_HAS_HEX_CODEC
#define BOTAN_HAS_HMAC
#define BOTAN_HAS_HMAC_RNG
#define BOTAN_HAS_IDEA
#define BOTAN_HAS_IF_PUBLIC_KEY_FAMILY
#define BOTAN_HAS_KASUMI
#define BOTAN_HAS_KDF1
#define BOTAN_HAS_KDF2
#define BOTAN_HAS_KDF_BASE
#define BOTAN_HAS_KEYPAIR_TESTING
#define BOTAN_HAS_LIBSTATE_MODULE
#define BOTAN_HAS_LION
#define BOTAN_HAS_LUBY_RACKOFF
#define BOTAN_HAS_MARS
#define BOTAN_HAS_MD2
#define BOTAN_HAS_MD4
#define BOTAN_HAS_MD5
#define BOTAN_HAS_MDX_HASH_FUNCTION
#define BOTAN_HAS_MGF1
#define BOTAN_HAS_MISTY1
#define BOTAN_HAS_MUTEX_NOOP
#define BOTAN_HAS_MUTEX_WIN32
#define BOTAN_HAS_MUTEX_WRAPPERS
#define BOTAN_HAS_NOEKEON
#define BOTAN_HAS_NYBERG_RUEPPEL
#define BOTAN_HAS_OFB
#define BOTAN_HAS_OID_LOOKUP
#define BOTAN_HAS_OPENPGP_CODEC
#define BOTAN_HAS_PARALLEL_HASH
#define BOTAN_HAS_PASSWORD_BASED_ENCRYPTION
#define BOTAN_HAS_PBE_PKCS_V15
#define BOTAN_HAS_PBE_PKCS_V20
#define BOTAN_HAS_PBKDF1
#define BOTAN_HAS_PBKDF2
#define BOTAN_HAS_PEM_CODEC
#define BOTAN_HAS_PGPS2K
#define BOTAN_HAS_PK_PADDING
#define BOTAN_HAS_PUBLIC_KEY_CRYPTO
#define BOTAN_HAS_RANDPOOL
#define BOTAN_HAS_RC2
#define BOTAN_HAS_RC5
#define BOTAN_HAS_RC6
#define BOTAN_HAS_RIPEMD_128
#define BOTAN_HAS_RIPEMD_160
#define BOTAN_HAS_RSA
#define BOTAN_HAS_RUNTIME_BENCHMARKING
#define BOTAN_HAS_RW
#define BOTAN_HAS_SAFER
#define BOTAN_HAS_SALSA20
#define BOTAN_HAS_SEED
#define BOTAN_HAS_SELFTESTS
#define BOTAN_HAS_SERPENT
#define BOTAN_HAS_SHA1
#define BOTAN_HAS_SHA2
#define BOTAN_HAS_SKEIN_512
#define BOTAN_HAS_SKIPJACK
#define BOTAN_HAS_SQUARE
#define BOTAN_HAS_SSL3_MAC
#define BOTAN_HAS_SSL_V3_PRF
#define BOTAN_HAS_STREAM_CIPHER
#define BOTAN_HAS_TEA
#define BOTAN_HAS_TIGER
#define BOTAN_HAS_TIMER
#define BOTAN_HAS_TIMER_WIN32
#define BOTAN_HAS_TLS_V10_PRF
#define BOTAN_HAS_TURING
#define BOTAN_HAS_TWOFISH
#define BOTAN_HAS_UTIL_FUNCTIONS
#define BOTAN_HAS_WHIRLPOOL
#define BOTAN_HAS_WID_WAKE
#define BOTAN_HAS_X509
#define BOTAN_HAS_X931_RNG
#define BOTAN_HAS_X942_PRF
#define BOTAN_HAS_XTEA
#define BOTAN_HAS_XTS
/* Local configuration options */
/*
Modules
-------
adler32 (Adler32)
aes (AES)
algo_factory (Algorithm Factory)
alloc (Allocator)
arc4 (ARC4)
asn1 (ASN.1/BER/DER module)
auto_rng (Auto-seeded Random Number Generator)
base64 (Base64 Codec)
benchmark (Benchmarking)
bigint (BigInt)
block (Block Ciphers)
blowfish (Blowfish)
buf_comp (Buffered Computation)
cast (CAST)
cbc (CBC block cipher mode)
cbc_mac (CBC-MAC)
cfb (CFB block cipher mode)
cmac (CMAC)
cms (CMS)
crc24 (CRC-24)
crc32 (CRC-32)
cryptoapi_rng (Win32 CryptoAPI Entropy Source)
cryptobox (Crypto Box)
ctr (CTR block cipher mode)
cts (CTS block cipher mode)
datastor (Datastore)
def_engine (Default Engine)
des (DES)
dh (Diffie-Hellman Key Agreement)
dl_algo (Discrete Logarithm PK Algorithms)
dl_group (DL Group)
dlies (DLIES)
dsa (DSA)
eax (EAX block cipher mode)
ecb (ECB block cipher mode)
elgamal (ElGamal)
eme1 (EME1)
eme_pkcs (PKCSv1 v1.5 EME)
emsa1 (EMSA1)
emsa1_bsi (EMSA1 (BSI variant))
emsa2 (EMSA2)
emsa3 (EMSA3)
emsa4 (EMSA4)
emsa_raw (EMSA-Raw)
engine (Engines)
entropy (Entropy Sources)
filters (Pipe/Filter)
fork256 (FORK-256)
gost_28147 (GOST 28147-89)
gost_3411 (GOST 34.11)
has160 (HAS-160)
hash (Hash Functions)
hash_id (Hash Function Identifiers)
hex (Hex Codec)
hmac (HMAC)
hmac_rng (HMAC RNG)
idea (IDEA)
if_algo (Integer Factorization Algorithms)
kasumi (Kasumi)
kdf (KDF Base Class)
kdf1 (KDF1)
kdf2 (KDF2)
keypair (Keypair Testing)
libstate (Botan Libstate Module)
lion (Lion)
lubyrack (Luby-Rackoff)
mac (Message Authentication Codes)
mars (MARS)
md2 (MD2)
md4 (MD4)
md5 (MD5)
mdx_hash (MDx Hash Base)
mem_pool (Memory Pool Allocator)
mgf1 (MGF1)
misty1 (MISTY-1)
mode_pad (Cipher Mode Padding Method)
modes (Cipher Mode Base Class)
monty_generic (Montgomery Reduction)
mp_generic (MPI Core (C++))
mulop_generic (BigInt Multiply-Add)
mutex (Mutex Wrappers)
noekeon (Noekeon)
noop_mutex (No-Op Mutex)
nr (Nyberg-Rueppel)
numbertheory (Math Functions)
ofb (OFB block cipher mode)
oid_lookup (OID Lookup)
openpgp (OpenPGP Codec)
par_hash (Parallel Hash)
pbe (PBE Base)
pbes1 (PKCS5 v1.5 PBE)
pbes2 (PKCS5 v2.0 PBE)
pbkdf1 (Pbkdf1)
pbkdf2 (Pbkdf2)
pem (PEM Codec)
pgps2k (Pgps2k)
pk_codecs (PK codecs (PKCS8, X.509))
pk_pad (Public Key EME/EMSA Padding Modes)
pubkey (Public Key Base)
randpool (Randpool RNG)
rc2 (RC2)
rc5 (RC5)
rc6 (RC6)
rmd128 (RIPEMD-128)
rmd160 (RIPEMD-160)
rng (Random Number Generators)
rsa (RSA)
rw (Rabin-Williams)
s2k (String to Key Functions)
safer (SAFER)
salsa20 (Salsa20)
seed (SEED)
selftest (Selftests)
serpent (Serpent)
sha1 (SHA-1)
sha2 (SHA-2 (224, 256, 384, 512))
skein (Skein)
skipjack (Skipjack)
square (Square)
ssl3mac (SSLv3 MAC)
ssl_prf (SSLv3 PRF)
stream (Stream Ciphers)
sym_algo (Symmetric Algorithms)
system_alloc (Default (Malloc) Allocators)
tea (TEA)
tiger (Tiger)
timer (Timer Base Class)
tls_prf (TLS v1.0 PRF)
turing (Turing)
twofish (Twofish)
utils (Utility Functions)
whirlpool (Whirlpool)
wid_wake (WiderWake)
win32_crit_section (Win32 Mutex)
win32_query_perf_ctr (Win32 Timer)
win32_stats (Win32 Entropy Source)
x509 (X.509)
x919_mac (ANSI X9.19 MAC)
x931_rng (ANSI X9.31 PRNG)
x942_prf (X942 PRF)
xtea (XTEA)
xts (XTS block cipher mode)
*/
#endif

View File

@@ -1,47 +0,0 @@
/*
* CAST-128
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CAST128_H__
#define BOTAN_CAST128_H__
#include <botan/block_cipher.h>
namespace Botan {
/*
* CAST-128
*/
class BOTAN_DLL CAST_128 : public BlockCipher
{
public:
void clear() throw() { MK.clear(); RK.clear(); }
std::string name() const { return "CAST-128"; }
BlockCipher* clone() const { return new CAST_128; }
CAST_128() : BlockCipher(8, 11, 16) {}
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
static void key_schedule(u32bit[16], u32bit[4]);
static const u32bit S5[256];
static const u32bit S6[256];
static const u32bit S7[256];
static const u32bit S8[256];
SecureBuffer<u32bit, 16> MK, RK;
};
extern const u32bit CAST_SBOX1[256];
extern const u32bit CAST_SBOX2[256];
extern const u32bit CAST_SBOX3[256];
extern const u32bit CAST_SBOX4[256];
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* CAST-256
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CAST256_H__
#define BOTAN_CAST256_H__
#include <botan/block_cipher.h>
namespace Botan {
/*
* CAST-256
*/
class BOTAN_DLL CAST_256 : public BlockCipher
{
public:
void clear() throw() { MK.clear(); RK.clear(); }
std::string name() const { return "CAST-256"; }
BlockCipher* clone() const { return new CAST_256; }
CAST_256() : BlockCipher(16, 4, 32, 4) {}
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
static const u32bit KEY_MASK[192];
static const byte KEY_ROT[32];
SecureBuffer<u32bit, 48> MK;
SecureBuffer<byte, 48> RK;
};
extern const u32bit CAST_SBOX1[256];
extern const u32bit CAST_SBOX2[256];
extern const u32bit CAST_SBOX3[256];
extern const u32bit CAST_SBOX4[256];
}
#endif

View File

@@ -1,55 +0,0 @@
/*
* CBC Mode
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CBC_H__
#define BOTAN_CBC_H__
#include <botan/modebase.h>
#include <botan/mode_pad.h>
namespace Botan {
/*
* CBC Encryption
*/
class BOTAN_DLL CBC_Encryption : public BlockCipherMode
{
public:
CBC_Encryption(BlockCipher*, BlockCipherModePaddingMethod*);
CBC_Encryption(BlockCipher*, BlockCipherModePaddingMethod*,
const SymmetricKey&, const InitializationVector&);
~CBC_Encryption() { delete padder; }
private:
std::string name() const;
void write(const byte[], u32bit);
void end_msg();
const BlockCipherModePaddingMethod* padder;
};
/*
* CBC Decryption
*/
class BOTAN_DLL CBC_Decryption : public BlockCipherMode
{
public:
CBC_Decryption(BlockCipher*, BlockCipherModePaddingMethod*);
CBC_Decryption(BlockCipher*, BlockCipherModePaddingMethod*,
const SymmetricKey&, const InitializationVector&);
~CBC_Decryption() { delete padder; }
private:
std::string name() const;
void write(const byte[], u32bit);
void end_msg();
const BlockCipherModePaddingMethod* padder;
SecureVector<byte> temp;
};
}
#endif

View File

@@ -1,40 +0,0 @@
/*
* CBC-MAC
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CBC_MAC_H__
#define BOTAN_CBC_MAC_H__
#include <botan/mac.h>
#include <botan/block_cipher.h>
namespace Botan {
/*
* CBC-MAC
*/
class BOTAN_DLL CBC_MAC : public MessageAuthenticationCode
{
public:
void clear() throw();
std::string name() const;
MessageAuthenticationCode* clone() const;
CBC_MAC(BlockCipher* e);
~CBC_MAC();
private:
void add_data(const byte[], u32bit);
void final_result(byte[]);
void key_schedule(const byte[], u32bit);
BlockCipher* e;
SecureVector<byte> state;
u32bit position;
};
}
#endif

View File

@@ -1,39 +0,0 @@
/*
* Certificate Store
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CERT_STORE_H__
#define BOTAN_CERT_STORE_H__
#include <botan/x509cert.h>
#include <botan/x509_crl.h>
namespace Botan {
/*
* Certificate Store Interface
*/
class BOTAN_DLL Certificate_Store
{
public:
virtual std::vector<X509_Certificate>
by_SKID(const MemoryRegion<byte>&) const = 0;
virtual std::vector<X509_Certificate> by_name(const std::string&) const;
virtual std::vector<X509_Certificate> by_email(const std::string&) const;
virtual std::vector<X509_Certificate> by_dn(const X509_DN&) const;
virtual std::vector<X509_CRL>
get_crls_for(const X509_Certificate&) const;
virtual Certificate_Store* clone() const = 0;
virtual ~Certificate_Store() {}
};
}
#endif

View File

@@ -1,47 +0,0 @@
/*
* CFB Mode
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CFB_H__
#define BOTAN_CFB_H__
#include <botan/modebase.h>
namespace Botan {
/*
* CFB Encryption
*/
class BOTAN_DLL CFB_Encryption : public BlockCipherMode
{
public:
CFB_Encryption(BlockCipher*, u32bit = 0);
CFB_Encryption(BlockCipher*, const SymmetricKey&,
const InitializationVector&, u32bit = 0);
private:
void write(const byte[], u32bit);
void feedback();
const u32bit FEEDBACK_SIZE;
};
/*
* CFB Decryption
*/
class BOTAN_DLL CFB_Decryption : public BlockCipherMode
{
public:
CFB_Decryption(BlockCipher*, u32bit = 0);
CFB_Decryption(BlockCipher*, const SymmetricKey&,
const InitializationVector&, u32bit = 0);
private:
void write(const byte[], u32bit);
void feedback();
const u32bit FEEDBACK_SIZE;
};
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* Character Set Handling
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CHARSET_H__
#define BOTAN_CHARSET_H__
#include <botan/types.h>
#include <string>
namespace Botan {
/**
* The different charsets (nominally) supported by Botan.
*/
enum Character_Set {
LOCAL_CHARSET,
UCS2_CHARSET,
UTF8_CHARSET,
LATIN1_CHARSET
};
namespace Charset {
/*
* Character Set Handling
*/
std::string transcode(const std::string&, Character_Set, Character_Set);
bool is_digit(char);
bool is_space(char);
bool caseless_cmp(char, char);
byte char2digit(char);
char digit2char(byte);
}
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* CMAC
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CMAC_H__
#define BOTAN_CMAC_H__
#include <botan/mac.h>
#include <botan/block_cipher.h>
namespace Botan {
/*
* CMAC
*/
class BOTAN_DLL CMAC : public MessageAuthenticationCode
{
public:
void clear() throw();
std::string name() const;
MessageAuthenticationCode* clone() const;
static SecureVector<byte> poly_double(const MemoryRegion<byte>& in,
byte polynomial);
CMAC(BlockCipher* e);
~CMAC();
private:
void add_data(const byte[], u32bit);
void final_result(byte[]);
void key_schedule(const byte[], u32bit);
BlockCipher* e;
SecureVector<byte> buffer, state, B, P;
u32bit position;
byte polynomial;
};
}
#endif

View File

@@ -1,65 +0,0 @@
/*
* CMS Decoding
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CMS_DECODER_H__
#define BOTAN_CMS_DECODER_H__
#include <botan/x509cert.h>
#include <botan/x509stor.h>
#include <botan/pkcs8.h>
#include <botan/ber_dec.h>
#include <botan/ui.h>
namespace Botan {
/*
* CMS Decoding Operation
*/
class BOTAN_DLL CMS_Decoder
{
public:
enum Status { GOOD, BAD, NO_KEY, FAILURE };
enum Content_Type { DATA, UNKNOWN, COMPRESSED, ENVELOPED, SIGNED,
AUTHENTICATED, DIGESTED };
Status layer_status() const;
Content_Type layer_type() const;
std::string layer_info() const;
std::string layer_algo() const;
std::string get_data() const;
std::vector<X509_Certificate> get_certs() const;
std::vector<X509_CRL> get_crls() const;
void next_layer() { decode_layer(); }
void add_key(PKCS8_PrivateKey*);
CMS_Decoder(DataSource&, const X509_Store&, User_Interface&,
PKCS8_PrivateKey* = 0);
private:
std::string get_passphrase(const std::string&);
void read_econtent(BER_Decoder&);
void initial_read(DataSource&);
void decode_layer();
void decompress(BER_Decoder&);
User_Interface& ui;
X509_Store store;
std::vector<std::string> passphrases;
std::vector<PKCS8_PrivateKey*> keys;
OID type, next_type;
SecureVector<byte> data;
Status status;
std::string info;
};
}
#endif

View File

@@ -1,92 +0,0 @@
/*
* CMS Encoding
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CMS_ENCODER_H__
#define BOTAN_CMS_ENCODER_H__
#include <botan/x509cert.h>
#include <botan/x509stor.h>
#include <botan/pkcs8.h>
#include <botan/symkey.h>
namespace Botan {
/*
* CMS Encoding Operation
*/
class BOTAN_DLL CMS_Encoder
{
public:
void encrypt(RandomNumberGenerator&,
const X509_Certificate&, const std::string = "");
void encrypt(RandomNumberGenerator& rng,
const std::string&, const std::string& = "");
void encrypt(RandomNumberGenerator& rng,
const SymmetricKey&, const std::string& = "");
void authenticate(const X509_Certificate&, const std::string& = "");
void authenticate(const std::string&, const std::string& = "");
void authenticate(const SymmetricKey&, const std::string& = "");
void sign(const X509_Certificate& cert,
const PKCS8_PrivateKey& key,
RandomNumberGenerator& rng,
const std::vector<X509_Certificate>& cert_chain,
const std::string& hash,
const std::string& padding);
void digest(const std::string& = "");
void compress(const std::string&);
static bool can_compress_with(const std::string&);
SecureVector<byte> get_contents();
std::string PEM_contents();
void set_data(const std::string&);
void set_data(const byte[], u32bit);
CMS_Encoder(const std::string& str) { set_data(str); }
CMS_Encoder(const byte buf[], u32bit length) { set_data(buf, length); }
private:
void add_layer(const std::string&, DER_Encoder&);
void encrypt_ktri(RandomNumberGenerator&,
const X509_Certificate&, PK_Encrypting_Key*,
const std::string&);
void encrypt_kari(RandomNumberGenerator&,
const X509_Certificate&, X509_PublicKey*,
const std::string&);
SecureVector<byte> do_encrypt(RandomNumberGenerator& rng,
const SymmetricKey&, const std::string&);
static SecureVector<byte> make_econtent(const SecureVector<byte>&,
const std::string&);
static SymmetricKey setup_key(RandomNumberGenerator& rng,
const std::string&);
static SecureVector<byte> wrap_key(RandomNumberGenerator& rng,
const std::string&,
const SymmetricKey&,
const SymmetricKey&);
static SecureVector<byte> encode_params(const std::string&,
const SymmetricKey&,
const InitializationVector&);
SecureVector<byte> data;
std::string type;
};
}
#endif

View File

@@ -1,34 +0,0 @@
/*
* CRC24
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CRC24_H__
#define BOTAN_CRC24_H__
#include <botan/hash.h>
namespace Botan {
/*
* CRC24
*/
class BOTAN_DLL CRC24 : public HashFunction
{
public:
void clear() throw() { crc = 0xB704CE; }
std::string name() const { return "CRC24"; }
HashFunction* clone() const { return new CRC24; }
CRC24() : HashFunction(3) { clear(); }
~CRC24() { clear(); }
private:
void add_data(const byte[], u32bit);
void final_result(byte[]);
u32bit crc;
};
}
#endif

View File

@@ -1,34 +0,0 @@
/*
* CRC32
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CRC32_H__
#define BOTAN_CRC32_H__
#include <botan/hash.h>
namespace Botan {
/*
* CRC32
*/
class BOTAN_DLL CRC32 : public HashFunction
{
public:
void clear() throw() { crc = 0xFFFFFFFF; }
std::string name() const { return "CRC32"; }
HashFunction* clone() const { return new CRC32; }
CRC32() : HashFunction(4) { clear(); }
~CRC32() { clear(); }
private:
void add_data(const byte[], u32bit);
void final_result(byte[]);
u32bit crc;
};
}
#endif

View File

@@ -1,78 +0,0 @@
/*
* CRL Entry
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CRL_ENTRY_H__
#define BOTAN_CRL_ENTRY_H__
#include <botan/x509cert.h>
namespace Botan {
/**
* This class represents CRL entries
*/
class BOTAN_DLL CRL_Entry : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
/**
* Get the serial number of the certificate associated with this entry.
* @return the certificate's serial number
*/
MemoryVector<byte> serial_number() const { return serial; }
/**
* Get the revocation date of the certificate associated with this entry
* @return the certificate's revocation date
*/
X509_Time expire_time() const { return time; }
/**
* Get the entries reason code
* @return the reason code
*/
CRL_Code reason_code() const { return reason; }
/**
* Construct an empty CRL entry.
*/
CRL_Entry(bool throw_on_unknown_critical_extension = false);
/**
* Construct an CRL entry.
* @param cert the certificate to revoke
* @param reason the reason code to set in the entry
*/
CRL_Entry(const X509_Certificate&, CRL_Code = UNSPECIFIED);
private:
bool throw_on_unknown_critical;
MemoryVector<byte> serial;
X509_Time time;
CRL_Code reason;
};
/**
* Test two CRL entries for equality in all fields.
*/
BOTAN_DLL bool operator==(const CRL_Entry&, const CRL_Entry&);
/**
* Test two CRL entries for inequality in at least one field.
*/
BOTAN_DLL bool operator!=(const CRL_Entry&, const CRL_Entry&);
/**
* Order two entries based on the revocation date.
*/
BOTAN_DLL bool operator<(const CRL_Entry&, const CRL_Entry&);
}
#endif

View File

@@ -1,42 +0,0 @@
/*
* Cryptobox Message Routines
* (C) 2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CRYPTOBOX_H__
#define BOTAN_CRYPTOBOX_H__
#include <string>
#include <botan/rng.h>
namespace Botan {
namespace CryptoBox {
/**
* Encrypt a message
* @param input the input data
* @param input_len the length of input in bytes
* @param passphrase the passphrase used to encrypt the message
* @param rng a ref to a random number generator, such as AutoSeeded_RNG
*/
BOTAN_DLL std::string encrypt(const byte input[], u32bit input_len,
const std::string& passphrase,
RandomNumberGenerator& rng);
/**
* Decrypt a message encrypted with CryptoBox::encrypt
* @param input the input data
* @param input_len the length of input in bytes
* @param passphrase the passphrase used to encrypt the message
*/
BOTAN_DLL std::string decrypt(const byte input[], u32bit input_len,
const std::string& passphrase);
}
}
#endif

View File

@@ -1,31 +0,0 @@
/*
* CTR Mode
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_COUNTER_MODE_H__
#define BOTAN_COUNTER_MODE_H__
#include <botan/modebase.h>
#include <botan/modebase.h>
namespace Botan {
/*
* CTR-BE Mode
*/
class BOTAN_DLL CTR_BE : public BlockCipherMode
{
public:
CTR_BE(BlockCipher*);
CTR_BE(BlockCipher*, const SymmetricKey&, const InitializationVector&);
private:
void write(const byte[], u32bit);
void increment_counter();
};
}
#endif

View File

@@ -1,60 +0,0 @@
/*
* CTS Mode
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CTS_H__
#define BOTAN_CTS_H__
#include <botan/modebase.h>
#include <botan/block_cipher.h>
namespace Botan {
/*
* CTS Encryption
*/
class BOTAN_DLL CTS_Encryption : public BlockCipherMode
{
public:
CTS_Encryption(BlockCipher* ciph) :
BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) {}
CTS_Encryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv) :
BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2)
{ set_key(key); set_iv(iv); }
private:
void write(const byte[], u32bit);
void end_msg();
void encrypt(const byte[]);
};
/*
* CTS Decryption
*/
class BOTAN_DLL CTS_Decryption : public BlockCipherMode
{
public:
CTS_Decryption(BlockCipher* ciph) :
BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2)
{ temp.create(BLOCK_SIZE); }
CTS_Decryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv) :
BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2)
{ set_key(key); set_iv(iv); temp.create(BLOCK_SIZE); }
private:
void write(const byte[], u32bit);
void end_msg();
void decrypt(const byte[]);
SecureVector<byte> temp;
};
}
#endif

View File

@@ -1,177 +0,0 @@
/******
* Elliptic curves over GF(p) (header file)
*
* (C) 2007 Martin Doering
* doering@cdc.informatik.tu-darmstadt.de
* Christoph Ludwig
* ludwig@fh-worms.de
* Falko Strenzke
* strenzke@flexsecure.de
******/
#ifndef BOTAN_GFP_CURVE_H__
#define BOTAN_GFP_CURVE_H__
#include <botan/bigint.h>
#include <botan/gfp_element.h>
#include <iosfwd>
namespace Botan {
/**
* This class represents an elliptic curve over GF(p)
*
* Distributed under the terms of the Botan license
*/
class BOTAN_DLL CurveGFp
{
public:
/**
* Construct the elliptic curve E: y^2 = x^3 + ax + b over GF(p)
* @param a first coefficient
* @param b second coefficient
* @param p prime number of the field
*/
CurveGFp(const GFpElement& a, const GFpElement& b,
const BigInt& p);
/**
* Copy constructor
* @param other The curve to clone
*/
CurveGFp(const CurveGFp& other);
/**
* Assignment operator
* @param other The curve to use as source for the assignment
*/
const CurveGFp& operator=(const CurveGFp& other);
/**
* Set the shared GFpModulus object.
* Warning: do not use this function unless you know in detail how
* the sharing of values
* in the various EC related objects works.
* Do NOT spread pointers to a GFpModulus over different threads!
* @param mod a shared pointer to a GFpModulus object suitable for
* *this.
*/
void set_shrd_mod(const SharedPointer<GFpModulus> mod);
// getters
/**
* Get coefficient a
* @result coefficient a
*/
const GFpElement& get_a() const;
/**
* Get coefficient b
* @result coefficient b
*/
const GFpElement& get_b() const;
/**
* Get the GFpElement coefficient a transformed
* to its m-residue. This can be used for efficency reasons: the curve
* stores the transformed version after the first invocation of this
* function.
* @result the coefficient a, transformed to its m-residue
*/
GFpElement const get_mres_a() const;
/**
* Get the GFpElement coefficient b transformed
* to its m-residue. This can be used for efficency reasons: the curve
* stores the transformed version after the first invocation of this
* function.
* @result the coefficient b, transformed to its m-residue
*/
GFpElement const get_mres_b() const;
/**
* Get the GFpElement 1 transformed
* to its m-residue. This can be used for efficency reasons: the curve
* stores the transformed version after the first invocation of this
* function.
* @result the GFpElement 1, transformed to its m-residue
*/
SharedPointer<GFpElement const> const get_mres_one() const;
/**
* Get prime modulus of the field of the curve
* @result prime modulus of the field of the curve
*/
BigInt const get_p() const;
/*inline SharedPointer<BigInt> const get_ptr_p() const
{
return mp_p;
}*/
/**
* Retrieve a shared pointer to the curves GFpModulus object for efficient storage
* and computation of montgomery multiplication related data members and functions.
* Warning: do not use this function unless you know in detail how the sharing of values
* in the various EC related objects works.
* Do NOT spread pointers to a GFpModulus over different threads!
* @result a shared pointer to a GFpModulus object
*/
inline SharedPointer<GFpModulus> const get_ptr_mod() const
{
return mp_mod;
}
/**
* swaps the states of *this and other, does not throw
* @param other The curve to swap values with
*/
void swap(CurveGFp& other);
private:
SharedPointer<GFpModulus> mp_mod;
GFpElement mA;
GFpElement mB;
mutable SharedPointer<GFpElement> mp_mres_a;
mutable SharedPointer<GFpElement> mp_mres_b;
mutable SharedPointer<GFpElement> mp_mres_one;
};
// relational operators
bool operator==(const CurveGFp& lhs, const CurveGFp& rhs);
inline bool operator!=(const CurveGFp& lhs, const CurveGFp& rhs)
{
return !(lhs == rhs);
}
// io operators
std::ostream& operator<<(std::ostream& output, const CurveGFp& elem);
// swaps the states of curve1 and curve2, does not throw!
// cf. Meyers, Item 25
inline
void swap(CurveGFp& curve1, CurveGFp& curve2)
{
curve1.swap(curve2);
}
} // namespace Botan
namespace std {
// swaps the states of curve1 and curve2, does not throw!
// cf. Meyers, Item 25
template<> inline
void swap<Botan::CurveGFp>(Botan::CurveGFp& curve1,
Botan::CurveGFp& curve2)
{
curve1.swap(curve2);
}
} // namespace std
#endif

View File

@@ -1,101 +0,0 @@
/*
* EAC1_1 CVC ADO
* (C) 2008 Falko Strenzke
* strenzke@flexsecure.de
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAC_CVC_ADO_H__
#define BOTAN_EAC_CVC_ADO_H__
#include <botan/x509_key.h>
#include <botan/pubkey_enums.h>
#include <botan/pubkey.h>
#include <botan/ecdsa.h>
#include <botan/eac_obj.h>
#include <botan/cvc_req.h>
#include <string>
namespace Botan {
/**
* This class represents a TR03110 (EAC) v1.1 CVC ADO request
*/
// CRTP continuation from EAC1_1_obj
class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO>
{
public:
friend class EAC1_1_obj<EAC1_1_ADO>;
/**
* Construct a CVC ADO request from a DER encoded CVC ADO request file.
* @param str the path to the DER encoded file
*/
EAC1_1_ADO(const std::string& str);
/**
* Construct a CVC ADO request from a data source
* @param source the data source
*/
EAC1_1_ADO(SharedPointer<DataSource> source);
/**
* Create a signed CVC ADO request from to be signed (TBS) data
* @param signer the signer used to sign the CVC ADO request
* @param tbs_bits the TBS data to sign
*/
static MemoryVector<byte> make_signed(
std::auto_ptr<PK_Signer> signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng);
/**
* Get the CAR of this CVC ADO request
* @result the CAR of this CVC ADO request
*/
ASN1_Car get_car() const;
/**
* Get the CVC request contained in this object.
* @result the CVC request inside this CVC ADO request
*/
EAC1_1_Req get_request() const;
/**
* Encode this object into a pipe. Only DER is supported.
* @param out the pipe to encode this object into
* @param encoding the encoding type to use, must be DER
*/
void encode(Pipe& out, X509_Encoding encoding) const;
bool operator==(EAC1_1_ADO const& rhs) const;
/**
* Get the TBS data of this CVC ADO request.
* @result the TBS data
*/
SecureVector<byte> tbs_data() const;
virtual ~EAC1_1_ADO() {}
private:
ASN1_Car m_car;
EAC1_1_Req m_req;
void force_decode();
static void decode_info(SharedPtrConverter<DataSource> source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig);
};
inline bool operator!=(EAC1_1_ADO const& lhs, EAC1_1_ADO const& rhs)
{
return (!(lhs == rhs));
}
}
#endif

View File

@@ -1,51 +0,0 @@
/*
* EAC1.1 CVC Certificate Authority
* (C) 2007 FlexSecure GmbH
* 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CVC_CA_H__
#define BOTAN_CVC_CA_H__
#include <botan/pkcs8.h>
#include <botan/pkcs10.h>
#include <botan/pubkey.h>
#include <botan/cvc_cert.h>
namespace Botan {
/**
* This class represents a CVC CA.
*/
class BOTAN_DLL EAC1_1_CVC_CA
{
public:
/**
* Create an arbitrary EAC 1.1 CVC.
* The desired key encoding must be set within the key (if applicable).
* @param signer the signer used to sign the certificate
* @param public_key the DER encoded public key to appear in
* the certificate
* @param car the CAR of the certificate
* @param chr the CHR of the certificate
* @param holder_auth_templ the holder authorization value byte to
* appear in the CHAT of the certificate
* @param ced the CED to appear in the certificate
* @param ced the CEX to appear in the certificate
*/
static EAC1_1_CVC make_cert(std::auto_ptr<PK_Signer> signer,
MemoryRegion<byte> const& public_key,
ASN1_Car const& car,
ASN1_Chr const& chr,
byte holder_auth_templ,
ASN1_Ced ced,
ASN1_Cex cex,
RandomNumberGenerator& rng);
};
}
#endif

View File

@@ -1,94 +0,0 @@
/*
* EAC1_1 CVC
* (C) 2008 Falko Strenzke
* 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CVC_EAC_H__
#define BOTAN_CVC_EAC_H__
#include <botan/x509_key.h>
#include <botan/pubkey_enums.h>
#include <botan/signed_obj.h>
#include <botan/pubkey.h>
#include <botan/ecdsa.h>
#include <botan/ecdsa_sig.h>
#include <botan/eac_obj.h>
#include <botan/cvc_gen_cert.h>
#include <string>
namespace Botan {
/**
* This class represents TR03110 (EAC) v1.1 CV Certificates
*/
class BOTAN_DLL EAC1_1_CVC : public EAC1_1_gen_CVC<EAC1_1_CVC>//Signed_Object
{
public:
friend class EAC1_1_obj<EAC1_1_CVC>;
/**
* Get the CAR of the certificate.
* @result the CAR of the certificate
*/
ASN1_Car get_car() const;
/**
* Get the CED of this certificate.
* @result the CED this certificate
*/
ASN1_Ced get_ced() const;
/**
* Get the CEX of this certificate.
* @result the CEX this certificate
*/
ASN1_Cex get_cex() const;
/**
* Get the CHAT value.
* @result the CHAT value
*/
u32bit get_chat_value() const;
bool operator==(const EAC1_1_CVC&) const;
/**
* Construct a CVC from a data source
* @param source the data source
*/
EAC1_1_CVC(SharedPointer<DataSource>& source);
/**
* Construct a CVC from a file
* @param str the path to the certificate file
*/
EAC1_1_CVC(const std::string& str);
virtual ~EAC1_1_CVC() {}
private:
void force_decode();
friend class EAC1_1_CVC_CA;
EAC1_1_CVC() {}
ASN1_Car m_car;
ASN1_Ced m_ced;
ASN1_Cex m_cex;
byte m_chat_val;
OID m_chat_oid;
};
/*
* Comparison
*/
inline bool operator!=(EAC1_1_CVC const& lhs, EAC1_1_CVC const& rhs)
{
return !(lhs == rhs);
}
}
#endif

View File

@@ -1,178 +0,0 @@
/*
* EAC1_1 general CVC
* (C) 2008 Falko Strenzke
* 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAC_CVC_GEN_CERT_H__
#define BOTAN_EAC_CVC_GEN_CERT_H__
#include <botan/x509_key.h>
#include <botan/eac_asn_obj.h>
#include <botan/pubkey_enums.h>
#include <botan/pubkey.h>
#include <botan/ecdsa_sig.h>
#include <string>
#include <memory>
#include <assert.h>
namespace Botan {
/**
* This class represents TR03110 (EAC) v1.1 generalized CV Certificates
*/
template<typename Derived>
class BOTAN_DLL EAC1_1_gen_CVC : public EAC1_1_obj<Derived> // CRTP continuation from EAC1_1_obj
{
friend class EAC1_1_obj<EAC1_1_gen_CVC>;
public:
/**
* Get this certificates public key.
* @result this certificates public key
*/
std::auto_ptr<Public_Key> subject_public_key() const;
/**
* Find out whether this object is self signed.
* @result true if this object is self signed
*/
bool is_self_signed() const;
/**
* Get the CHR of the certificate.
* @result the CHR of the certificate
*/
ASN1_Chr get_chr() const;
/**
* Put the DER encoded version of this object into a pipe. PEM
* is not supported.
* @param out the pipe to push the DER encoded version into
* @param encoding the encoding to use. Must be DER.
*/
void encode(Pipe& out, X509_Encoding encoding) const;
/**
* Get the to-be-signed (TBS) data of this object.
* @result the TBS data of this object
*/
SecureVector<byte> tbs_data() const;
/**
* Build the DER encoded certifcate body of an object
* @param tbs the data to be signed
* @result the correctly encoded body of the object
*/
static SecureVector<byte> build_cert_body(MemoryRegion<byte> const& tbs);
/**
* Create a signed generalized CVC object.
* @param signer the signer used to sign this object
* @param tbs_bits the body the generalized CVC object to be signed
* @result the DER encoded signed generalized CVC object
*/
static MemoryVector<byte> make_signed(
std::auto_ptr<PK_Signer> signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng);
virtual ~EAC1_1_gen_CVC<Derived>()
{}
protected:
ECDSA_PublicKey m_pk; // public key
ASN1_Chr m_chr;
bool self_signed;
static void decode_info(SharedPtrConverter<DataSource> source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig);
};
template<typename Derived> ASN1_Chr EAC1_1_gen_CVC<Derived>::get_chr() const
{
return m_chr;
}
template<typename Derived> bool EAC1_1_gen_CVC<Derived>::is_self_signed() const
{
return self_signed;
}
template<typename Derived> MemoryVector<byte> EAC1_1_gen_CVC<Derived>::make_signed(
std::auto_ptr<PK_Signer> signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng) // static
{
SecureVector<byte> concat_sig = EAC1_1_obj<Derived>::make_signature(signer.get(), tbs_bits, rng);
assert(concat_sig.size() % 2 == 0);
return DER_Encoder()
.start_cons(ASN1_Tag(33), APPLICATION)
.raw_bytes(tbs_bits)
.encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
.end_cons()
.get_contents();
}
template<typename Derived> std::auto_ptr<Public_Key> EAC1_1_gen_CVC<Derived>::subject_public_key() const
{
return std::auto_ptr<Public_Key>(new ECDSA_PublicKey(m_pk));
}
template<typename Derived> SecureVector<byte> EAC1_1_gen_CVC<Derived>::build_cert_body(MemoryRegion<byte> const& tbs)
{
return DER_Encoder()
.start_cons(ASN1_Tag(78), APPLICATION)
.raw_bytes(tbs)
.end_cons().get_contents();
}
template<typename Derived> SecureVector<byte> EAC1_1_gen_CVC<Derived>::tbs_data() const
{
return build_cert_body(EAC1_1_obj<Derived>::tbs_bits);
}
template<typename Derived> void EAC1_1_gen_CVC<Derived>::encode(Pipe& out, X509_Encoding encoding) const
{
SecureVector<byte> concat_sig(EAC1_1_obj<Derived>::m_sig.get_concatenation());
SecureVector<byte> der = DER_Encoder()
.start_cons(ASN1_Tag(33), APPLICATION)
.start_cons(ASN1_Tag(78), APPLICATION)
.raw_bytes(EAC1_1_obj<Derived>::tbs_bits)
.end_cons()
.encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
.end_cons()
.get_contents();
if (encoding == PEM)
throw Invalid_Argument("EAC1_1_gen_CVC::encode() cannot PEM encode an EAC object");
else
out.write(der);
}
template<typename Derived>
void EAC1_1_gen_CVC<Derived>::decode_info(
SharedPtrConverter<DataSource> source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig)
{
SecureVector<byte> concat_sig;
BER_Decoder(*source.get_shared().get())
.start_cons(ASN1_Tag(33))
.start_cons(ASN1_Tag(78))
.raw_bytes(res_tbs_bits)
.end_cons()
.decode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
.end_cons();
res_sig = decode_concatenation(concat_sig);
}
}
#endif

View File

@@ -1,54 +0,0 @@
/*
* EAC CVC Public Key
* (C) 2008 FlexSecure Gmbh
* Falko Strenzke
* strenzke@flexsecure.de
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAC1_1_CVC_PUBLIC_KEY_H__
#define BOTAN_EAC1_1_CVC_PUBLIC_KEY_H__
#include <botan/pipe.h>
#include <botan/pk_keys.h>
#include <botan/alg_id.h>
namespace Botan {
/**
* This class represents EAC 1.1 CVC public key encoders.
*/
class BOTAN_DLL EAC1_1_CVC_Encoder
{
public:
/**
* Get the DER encoded CVC public key.
* @param alg_id the algorithm identifier to use in the encoding
* @return the DER encoded public key
*/
virtual MemoryVector<byte>
public_key(const AlgorithmIdentifier& enc) const = 0;
virtual ~EAC1_1_CVC_Encoder() {}
};
/**
* This class represents EAC 1.1 CVC public key decoders.
*/
class BOTAN_DLL EAC1_1_CVC_Decoder
{
public:
/**
* Decode a CVC public key.
* @param enc the DER encoded public key to decode
* @return the algorithm identifier found in the encoded public key
*/
virtual AlgorithmIdentifier const
public_key(const MemoryRegion<byte>& enc) = 0;
virtual ~EAC1_1_CVC_Decoder() {}
};
}
#endif

View File

@@ -1,62 +0,0 @@
/*
* EAC1_1 CVC Request
* (C) 2008 Falko Strenzke
* strenzke@flexsecure.de
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAC_CVC_REQ_H__
#define BOTAN_EAC_CVC_REQ_H__
#include <botan/x509_key.h>
#include <botan/pubkey_enums.h>
#include <botan/cvc_gen_cert.h>
namespace Botan {
/**
* This class represents TR03110 v1.1 EAC CV Certificate Requests.
*/
class BOTAN_DLL EAC1_1_Req : public EAC1_1_gen_CVC<EAC1_1_Req>
{
public:
friend class EAC1_1_Req_CA;
friend class EAC1_1_ADO;
friend class EAC1_1_obj<EAC1_1_Req>;
/**
* Compare for equality with other
* @param other compare for equality with this object
*/
bool operator==(const EAC1_1_Req& other) const;
/**
* Construct a CVC request from a data source.
* @param source the data source
*/
EAC1_1_Req(SharedPointer<DataSource> source);
/**
* Construct a CVC request from a DER encoded CVC reqeust file.
* @param str the path to the DER encoded file
*/
EAC1_1_Req(const std::string& str);
virtual ~EAC1_1_Req(){}
private:
void force_decode();
EAC1_1_Req() {}
};
/*
* Comparison Operator
*/
inline bool operator!=(EAC1_1_Req const& lhs, EAC1_1_Req const& rhs)
{
return !(lhs == rhs);
}
}
#endif

View File

@@ -1,167 +0,0 @@
/*
* CVC Self-Signed Certificate
* (C) 2007 FlexSecure GmbH
* 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CVC_EAC_SELF_H__
#define BOTAN_CVC_EAC_SELF_H__
#include <botan/pkcs8.h>
#include <botan/pkcs10.h>
#include <botan/cvc_cert.h>
#include <botan/ecdsa.h>
#include <botan/asn1_obj.h>
#include <botan/cvc_req.h>
#include <botan/cvc_ado.h>
namespace Botan {
/**
* This class represents a set of options used for the creation of CVC certificates
*/
class BOTAN_DLL EAC1_1_CVC_Options
{
public:
ASN1_Car car;
ASN1_Chr chr;
byte holder_auth_templ;
ASN1_Ced ced;
ASN1_Cex cex;
std::string hash_alg;
};
/**
* This namespace represents general EAC 1.1 convenience functions.
*/
namespace CVC_EAC {
/**
* Create a selfsigned CVCA
* @param rng the rng to use
* @param key the ECDSA private key to be used to sign the certificate
* @param opts used to set several parameters. Necessary are:
* car, holder_auth_templ, hash_alg, ced, cex and hash_alg
* @result the self signed certificate
*/
EAC1_1_CVC create_self_signed_cert(Private_Key const& key,
EAC1_1_CVC_Options const& opts,
RandomNumberGenerator& rng);
/**
* Create a CVC request. The key encoding will be according to the provided private key.
* @param priv_key the private key associated with the requesting entity
* @param chr the chr to appear in the certificate (to be provided without
* sequence number)
* @param hash_alg the string defining the hash algorithm to be used for the creation
* of the signature
* @param rng the rng to use
* @result the new request
*/
EAC1_1_Req create_cvc_req(Private_Key const& priv_key,
ASN1_Chr const& chr,
std::string const& hash_alg,
RandomNumberGenerator& rng);
/**
* Create an ADO from a request object.
* @param priv_key the private key used to sign the ADO
* @param req the request forming the body of the ADO
* @param car the CAR forming the body of the ADO, i.e. the
* CHR of the entity associated with the provided private key
* @param rng the rng to use
*/
EAC1_1_ADO create_ado_req(Private_Key const& priv_key,
EAC1_1_Req const& req,
ASN1_Car const& car,
RandomNumberGenerator& rng);
}
/**
* This namespace represents EAC 1.1 CVC convenience functions following the specific german
* requirements.
*/
namespace DE_EAC {
/**
* Create a CVCA certificate.
* @param priv_key the private key associated with the CVCA certificate
* to be created
* @param hash the string identifying the hash algorithm to be used
* for signing the certificate to be created
* @param car the CAR of the certificate to be created
* @param iris indicates whether the entity associated with the certificate
* shall be entitled to read the biometrical iris image
* @param fingerpr indicates whether the entity associated with the certificate
* shall be entitled to read the biometrical fingerprint image
* @param rng the rng to use
* @result the CVCA certificate created
*/
EAC1_1_CVC create_cvca(Private_Key const& priv_key,
std::string const& hash,
ASN1_Car const& car,
bool iris,
bool fingerpr,
u32bit cvca_validity_months,
RandomNumberGenerator& rng);
/**
* Create a link certificate between two CVCA certificates. The key
* encoding will be implicitCA.
* @param signer the cvca certificate associated with the signing
* entity
* @param priv_key the private key associated with the signer
* @param to_be_signed the certificate which whose CAR/CHR will be
* the holder of the link certificate
* @param rng a random number generator
*/
EAC1_1_CVC link_cvca(EAC1_1_CVC const& signer,
Private_Key const& priv_key,
EAC1_1_CVC const& to_be_signed,
RandomNumberGenerator& rng);
/**
* Create a CVC request. The key encoding will be implicitCA.
* @param priv_key the private key associated with the requesting entity
* @param chr the chr to appear in the certificate (to be provided without
* sequence number)
* @param hash_alg the string defining the hash algorithm to be used for the creation
* of the signature
* @param rng a random number generator
* @result the new request
*/
EAC1_1_Req create_cvc_req(Private_Key const& priv_key,
ASN1_Chr const& chr,
std::string const& hash_alg,
RandomNumberGenerator& rng);
/**
* Sign a CVC request.
* @param signer_cert the certificate of the signing entity
* @param priv_key the private key of the signing entity
* @param req the request to be signed
* @param seqnr the sequence number of the certificate to be created
* @param seqnr_len the number of digits the sequence number will be
* encoded in
* @param domestic indicates whether to sign a domestic or a foreign certificate:
* set to true for domestic
* @param rng a random number generator
* @result the new certificate
*
**/
EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
Private_Key const& priv_key,
EAC1_1_Req const& req,
u32bit seqnr,
u32bit seqnr_len,
bool domestic,
u32bit dvca_validity_months,
u32bit ca_is_validity_months,
RandomNumberGenerator& rng);
}
}
#endif

View File

@@ -1,65 +0,0 @@
/*
* DataSink
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DATA_SINK_H__
#define BOTAN_DATA_SINK_H__
#include <botan/filter.h>
#include <iosfwd>
namespace Botan {
/**
* This class represents abstract data sink objects.
*/
class BOTAN_DLL DataSink : public Filter
{
public:
bool attachable() { return false; }
DataSink() {}
virtual ~DataSink() {}
private:
DataSink& operator=(const DataSink&) { return (*this); }
DataSink(const DataSink&);
};
/**
* This class represents a data sink which writes its output to a stream.
*/
class BOTAN_DLL DataSink_Stream : public DataSink
{
public:
void write(const byte[], u32bit);
/**
* Construct a DataSink_Stream from a stream.
* @param stream the stream to write to
* @param name identifier
*/
DataSink_Stream(std::ostream& stream,
const std::string& name = "");
/**
* Construct a DataSink_Stream from a stream.
* @param file the name of the file to open a stream to
* @param use_binary indicates whether to treat the file
* as a binary file or not
*/
DataSink_Stream(const std::string& filename,
bool use_binary = false);
~DataSink_Stream();
private:
const std::string identifier;
const bool owner;
std::ostream* sink;
};
}
#endif

View File

@@ -1,150 +0,0 @@
/*
* DataSource
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DATA_SRC_H__
#define BOTAN_DATA_SRC_H__
#include <botan/secmem.h>
#include <string>
#include <iosfwd>
namespace Botan {
/**
* This class represents an abstract data source object.
*/
class BOTAN_DLL DataSource
{
public:
/**
* Read from the source. Moves the internal offset so that
* every call to read will return a new portion of the source.
* @param out the byte array to write the result to
* @param length the length of the byte array out
* @return the length in bytes that was actually read and put
* into out
*/
virtual u32bit read(byte out[], u32bit length) = 0;
/**
* Read from the source but do not modify the internal offset. Consecutive
* calls to peek() will return portions of the source starting at the same
* position.
* @param out the byte array to write the output to
* @param length the length of the byte array out
* @return the length in bytes that was actually read and put
* into out
*/
virtual u32bit peek(byte out[], u32bit length,
u32bit peek_offset) const = 0;
/**
* Test whether the source still has data that can be read.
* @return true if there is still data to read, false otherwise
*/
virtual bool end_of_data() const = 0;
/**
* return the id of this data source
* @return the std::string representing the id of this data source
*/
virtual std::string id() const { return ""; }
/**
* Read one byte.
* @param the byte to read to
* @return the length in bytes that was actually read and put
* into out
*/
u32bit read_byte(byte& out);
/**
* Peek at one byte.
* @param the byte to read to
* @return the length in bytes that was actually read and put
* into out
*/
u32bit peek_byte(byte& out) const;
/**
* Discard the next N bytes of the data
* @param N the number of bytes to discard
* @return the number of bytes actually discarded
*/
u32bit discard_next(u32bit N);
DataSource() {}
virtual ~DataSource() {}
private:
DataSource& operator=(const DataSource&) { return (*this); }
DataSource(const DataSource&);
};
/**
* This class represents a Memory-Based DataSource
*/
class BOTAN_DLL DataSource_Memory : public DataSource
{
public:
u32bit read(byte[], u32bit);
u32bit peek(byte[], u32bit, u32bit) const;
bool end_of_data() const;
/**
* Construct a memory source that reads from a string
* @param in the string to read from
*/
DataSource_Memory(const std::string& in);
/**
* Construct a memory source that reads from a byte array
* @param in the byte array to read from
* @param length the length of the byte array
*/
DataSource_Memory(const byte in[], u32bit length);
/**
* Construct a memory source that reads from a MemoryRegion
* @param in the MemoryRegion to read from
*/
DataSource_Memory(const MemoryRegion<byte>& in);
private:
SecureVector<byte> source;
u32bit offset;
};
/**
* This class represents a Stream-Based DataSource.
*/
class BOTAN_DLL DataSource_Stream : public DataSource
{
public:
u32bit read(byte[], u32bit);
u32bit peek(byte[], u32bit, u32bit) const;
bool end_of_data() const;
std::string id() const;
DataSource_Stream(std::istream&, const std::string& id = "");
/**
* Construct a Stream-Based DataSource from file
* @param file the name of the file
* @param use_binary whether to treat the file as binary or not
*/
DataSource_Stream(const std::string& file, bool use_binary = false);
~DataSource_Stream();
private:
const std::string identifier;
const bool owner;
std::istream* source;
u32bit total_read;
};
}
#endif

View File

@@ -1,61 +0,0 @@
/*
* Data Store
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DATA_STORE_H__
#define BOTAN_DATA_STORE_H__
#include <botan/secmem.h>
#include <utility>
#include <string>
#include <vector>
#include <map>
namespace Botan {
/**
* Data Store
*/
class BOTAN_DLL Data_Store
{
public:
class BOTAN_DLL Matcher
{
public:
virtual bool operator()(const std::string&,
const std::string&) const = 0;
virtual std::pair<std::string, std::string>
transform(const std::string&, const std::string&) const;
virtual ~Matcher() {}
};
bool operator==(const Data_Store&) const;
std::multimap<std::string, std::string>
search_with(const Matcher&) const;
std::vector<std::string> get(const std::string&) const;
std::string get1(const std::string&) const;
MemoryVector<byte> get1_memvec(const std::string&) const;
u32bit get1_u32bit(const std::string&, u32bit = 0) const;
bool has_value(const std::string&) const;
void add(const std::multimap<std::string, std::string>&);
void add(const std::string&, const std::string&);
void add(const std::string&, u32bit);
void add(const std::string&, const MemoryRegion<byte>&);
private:
std::multimap<std::string, std::string> contents;
};
}
#endif

View File

@@ -1,83 +0,0 @@
/*
* Default Engine
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DEFAULT_ENGINE_H__
#define BOTAN_DEFAULT_ENGINE_H__
#include <botan/engine.h>
namespace Botan {
/*
* Default Engine
*/
class BOTAN_DLL Default_Engine : public Engine
{
public:
std::string provider_name() const { return "core"; }
#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&,
const BigInt&, const BigInt&, const BigInt&,
const BigInt&, const BigInt&) const;
#endif
#if defined(BOTAN_HAS_DSA)
DSA_Operation* dsa_op(const DL_Group&, const BigInt&,
const BigInt&) const;
#endif
#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
NR_Operation* nr_op(const DL_Group&, const BigInt&, const BigInt&) const;
#endif
#if defined(BOTAN_HAS_ELGAMAL)
ELG_Operation* elg_op(const DL_Group&, const BigInt&,
const BigInt&) const;
#endif
#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
DH_Operation* dh_op(const DL_Group&, const BigInt&) const;
#endif
#if defined(BOTAN_HAS_ECDSA)
virtual ECDSA_Operation* ecdsa_op(const EC_Domain_Params&,
const BigInt&,
const PointGFp&) const;
#endif
#if defined(BOTAN_HAS_ECKAEG)
virtual ECKAEG_Operation* eckaeg_op(const EC_Domain_Params&,
const BigInt&,
const PointGFp&) const;
#endif
Modular_Exponentiator* mod_exp(const BigInt&,
Power_Mod::Usage_Hints) const;
virtual bool can_add_algorithms() { return true; }
Keyed_Filter* get_cipher(const std::string&, Cipher_Dir,
Algorithm_Factory&);
private:
BlockCipher* find_block_cipher(const SCAN_Name&,
Algorithm_Factory&) const;
StreamCipher* find_stream_cipher(const SCAN_Name&,
Algorithm_Factory&) const;
HashFunction* find_hash(const SCAN_Name& reqeust,
Algorithm_Factory&) const;
MessageAuthenticationCode* find_mac(const SCAN_Name& reqeust,
Algorithm_Factory&) const;
};
}
#endif

View File

@@ -1,64 +0,0 @@
/*
* Modular Exponentiation
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DEFAULT_MODEXP_H__
#define BOTAN_DEFAULT_MODEXP_H__
#include <botan/pow_mod.h>
#include <botan/reducer.h>
#include <vector>
namespace Botan {
/*
* Fixed Window Exponentiator
*/
class BOTAN_DLL Fixed_Window_Exponentiator : public Modular_Exponentiator
{
public:
void set_exponent(const BigInt&);
void set_base(const BigInt&);
BigInt execute() const;
Modular_Exponentiator* copy() const
{ return new Fixed_Window_Exponentiator(*this); }
Fixed_Window_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
private:
Modular_Reducer reducer;
BigInt exp;
u32bit window_bits;
std::vector<BigInt> g;
Power_Mod::Usage_Hints hints;
};
/*
* Montgomery Exponentiator
*/
class BOTAN_DLL Montgomery_Exponentiator : public Modular_Exponentiator
{
public:
void set_exponent(const BigInt&);
void set_base(const BigInt&);
BigInt execute() const;
Modular_Exponentiator* copy() const
{ return new Montgomery_Exponentiator(*this); }
Montgomery_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
private:
BigInt exp, modulus;
BigInt R2, R_mod;
std::vector<BigInt> g;
word mod_prime;
u32bit mod_words, exp_bits, window_bits;
Power_Mod::Usage_Hints hints;
};
}
#endif

View File

@@ -1,43 +0,0 @@
/*
* Basic Allocators
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_BASIC_ALLOC_H__
#define BOTAN_BASIC_ALLOC_H__
#include <botan/mem_pool.h>
namespace Botan {
/*
* Malloc Allocator
*/
class BOTAN_DLL Malloc_Allocator : public Allocator
{
public:
void* allocate(u32bit);
void deallocate(void*, u32bit);
std::string type() const { return "malloc"; }
};
/*
* Locking Allocator
*/
class BOTAN_DLL Locking_Allocator : public Pooling_Allocator
{
public:
Locking_Allocator(Mutex* m) : Pooling_Allocator(m) {}
std::string type() const { return "locking"; }
private:
void* alloc_block(u32bit);
void dealloc_block(void*, u32bit);
};
}
#endif

View File

@@ -1,91 +0,0 @@
/*
* DER Encoder
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DER_ENCODER_H__
#define BOTAN_DER_ENCODER_H__
#include <botan/asn1_int.h>
#include <vector>
namespace Botan {
/*
* General DER Encoding Object
*/
class BOTAN_DLL DER_Encoder
{
public:
SecureVector<byte> get_contents();
DER_Encoder& start_cons(ASN1_Tag, ASN1_Tag = UNIVERSAL);
DER_Encoder& end_cons();
DER_Encoder& start_explicit(u16bit);
DER_Encoder& end_explicit();
DER_Encoder& raw_bytes(const byte[], u32bit);
DER_Encoder& raw_bytes(const MemoryRegion<byte>&);
DER_Encoder& encode_null();
DER_Encoder& encode(bool);
DER_Encoder& encode(u32bit);
DER_Encoder& encode(const class BigInt&);
DER_Encoder& encode(const MemoryRegion<byte>&, ASN1_Tag);
DER_Encoder& encode(const byte[], u32bit, ASN1_Tag);
DER_Encoder& encode(bool, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
DER_Encoder& encode(u32bit, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
DER_Encoder& encode(const class BigInt&, ASN1_Tag,
ASN1_Tag = CONTEXT_SPECIFIC);
DER_Encoder& encode(const MemoryRegion<byte>&, ASN1_Tag,
ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
DER_Encoder& encode(const byte[], u32bit, ASN1_Tag,
ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
template<typename T>
DER_Encoder& encode_optional(const T& value, const T& default_value)
{
if(value != default_value)
encode(value);
return (*this);
}
template<typename T>
DER_Encoder& encode_list(const std::vector<T>& values)
{
for(u32bit j = 0; j != values.size(); ++j)
encode(values[j]);
return (*this);
}
DER_Encoder& encode(const class ASN1_Object&);
DER_Encoder& encode_if(bool, DER_Encoder&);
DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, const byte[], u32bit);
DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, const MemoryRegion<byte>&);
DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, const std::string&);
DER_Encoder& add_object(ASN1_Tag, ASN1_Tag, byte);
private:
class DER_Sequence
{
public:
ASN1_Tag tag_of() const;
SecureVector<byte> get_contents();
void add_bytes(const byte[], u32bit);
DER_Sequence(ASN1_Tag, ASN1_Tag);
private:
ASN1_Tag type_tag, class_tag;
SecureVector<byte> contents;
std::vector< SecureVector<byte> > set_contents;
};
SecureVector<byte> contents;
std::vector<DER_Sequence> subsequences;
};
}
#endif

View File

@@ -1,70 +0,0 @@
/*
* DES
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DES_H__
#define BOTAN_DES_H__
#include <botan/block_cipher.h>
namespace Botan {
/*
* DES
*/
class BOTAN_DLL DES : public BlockCipher
{
public:
void clear() throw() { round_key.clear(); }
std::string name() const { return "DES"; }
BlockCipher* clone() const { return new DES; }
DES() : BlockCipher(8, 8) {}
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
SecureBuffer<u32bit, 32> round_key;
};
/*
* Triple DES
*/
class BOTAN_DLL TripleDES : public BlockCipher
{
public:
void clear() throw() { round_key.clear(); }
std::string name() const { return "TripleDES"; }
BlockCipher* clone() const { return new TripleDES; }
TripleDES() : BlockCipher(8, 16, 24, 8) {}
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
SecureBuffer<u32bit, 96> round_key;
};
/*
* DES Tables
*/
extern const u32bit DES_SPBOX1[256];
extern const u32bit DES_SPBOX2[256];
extern const u32bit DES_SPBOX3[256];
extern const u32bit DES_SPBOX4[256];
extern const u32bit DES_SPBOX5[256];
extern const u32bit DES_SPBOX6[256];
extern const u32bit DES_SPBOX7[256];
extern const u32bit DES_SPBOX8[256];
extern const u64bit DES_IPTAB1[256];
extern const u64bit DES_IPTAB2[256];
extern const u64bit DES_FPTAB1[256];
extern const u64bit DES_FPTAB2[256];
}
#endif

View File

@@ -1,35 +0,0 @@
/*
* DESX
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DESX_H__
#define BOTAN_DESX_H__
#include <botan/des.h>
namespace Botan {
/*
* DESX
*/
class BOTAN_DLL DESX : public BlockCipher
{
public:
void clear() throw() { des.clear(); K1.clear(); K2.clear(); }
std::string name() const { return "DESX"; }
BlockCipher* clone() const { return new DESX; }
DESX() : BlockCipher(8, 24) {}
private:
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key_schedule(const byte[], u32bit);
SecureBuffer<byte, 8> K1, K2;
DES des;
};
}
#endif

View File

@@ -1,80 +0,0 @@
/*
* Diffie-Hellman
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DIFFIE_HELLMAN_H__
#define BOTAN_DIFFIE_HELLMAN_H__
#include <botan/dl_algo.h>
#include <botan/dh_core.h>
namespace Botan {
/**
* This class represents Diffie-Hellman public keys.
*/
class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey
{
public:
std::string algo_name() const { return "DH"; }
MemoryVector<byte> public_value() const;
u32bit max_input_bits() const;
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; }
/**
* Construct an uninitialized key. Use this constructor if you wish
* to decode an encoded key into the new instance.
*/
DH_PublicKey() {}
/**
* Construct a public key with the specified parameters.
* @param grp the DL group to use in the key
* @param y the public value y
*/
DH_PublicKey(const DL_Group& grp, const BigInt& y);
private:
void X509_load_hook();
};
/**
* This class represents Diffie-Hellman private keys.
*/
class BOTAN_DLL DH_PrivateKey : public DH_PublicKey,
public PK_Key_Agreement_Key,
public virtual DL_Scheme_PrivateKey
{
public:
SecureVector<byte> derive_key(const byte other[], u32bit length) const;
SecureVector<byte> derive_key(const DH_PublicKey& other) const;
SecureVector<byte> derive_key(const BigInt& other) const;
MemoryVector<byte> public_value() const;
/**
* Construct an uninitialized key. Use this constructor if you wish
* to decode an encoded key into the new instance.
*/
DH_PrivateKey() {}
/**
* Construct a private key with predetermined value.
* @param rng random number generator to use
* @param grp the group to be used in the key
* @param x the key's secret value (or if zero, generate a new key)
*/
DH_PrivateKey(RandomNumberGenerator& rng, const DL_Group& grp,
const BigInt& x = 0);
private:
void PKCS8_load_hook(RandomNumberGenerator& rng, bool = false);
DH_Core core;
};
}
#endif

View File

@@ -1,38 +0,0 @@
/*
* DH Core
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DH_CORE_H__
#define BOTAN_DH_CORE_H__
#include <botan/dh_op.h>
#include <botan/blinding.h>
namespace Botan {
/*
* DH Core
*/
class BOTAN_DLL DH_Core
{
public:
BigInt agree(const BigInt&) const;
DH_Core& operator=(const DH_Core&);
DH_Core() { op = 0; }
DH_Core(const DH_Core&);
DH_Core(RandomNumberGenerator& rng,
const DL_Group&, const BigInt&);
~DH_Core() { delete op; }
private:
DH_Operation* op;
Blinder blinder;
};
}
#endif

View File

@@ -1,45 +0,0 @@
/*
* DH Operations
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DH_OPS_H__
#define BOTAN_DH_OPS_H__
#include <botan/dl_group.h>
#include <botan/reducer.h>
#include <botan/pow_mod.h>
namespace Botan {
/*
* DH Operation Interface
*/
class BOTAN_DLL DH_Operation
{
public:
virtual BigInt agree(const BigInt&) const = 0;
virtual DH_Operation* clone() const = 0;
virtual ~DH_Operation() {}
};
/*
* Botan's Default DH Operation
*/
class BOTAN_DLL Default_DH_Op : public DH_Operation
{
public:
BigInt agree(const BigInt& i) const { return powermod_x_p(i); }
DH_Operation* clone() const { return new Default_DH_Op(*this); }
Default_DH_Op(const DL_Group& group, const BigInt& x) :
powermod_x_p(x, group.get_p()) {}
private:
Fixed_Exponent_Power_Mod powermod_x_p;
};
}
#endif

View File

@@ -1,19 +0,0 @@
/*
* Division
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DIVISON_ALGORITHM_H__
#define BOTAN_DIVISON_ALGORITHM_H__
#include <botan/bigint.h>
namespace Botan {
void BOTAN_DLL divide(const BigInt&, const BigInt&, BigInt&, BigInt&);
}
#endif

View File

@@ -1,116 +0,0 @@
/*
* DL Scheme
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DL_ALGO_H__
#define BOTAN_DL_ALGO_H__
#include <botan/dl_group.h>
#include <botan/x509_key.h>
#include <botan/pkcs8.h>
#include <botan/rng.h>
namespace Botan {
/**
* This class represents discrete logarithm (DL) public keys.
*/
class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
{
public:
bool check_key(RandomNumberGenerator& rng, bool) const;
/**
* Get the DL domain parameters of this key.
* @return the DL domain parameters of this key
*/
const DL_Group& get_domain() const { return group; }
/**
* Get the public value y with y = g^x mod p where x is the secret key.
*/
const BigInt& get_y() const { return y; }
/**
* Get the prime p of the underlying DL group.
* @return the prime p
*/
const BigInt& group_p() const { return group.get_p(); }
/**
* Get the prime q of the underlying DL group.
* @return the prime q
*/
const BigInt& group_q() const { return group.get_q(); }
/**
* Get the generator g of the underlying DL group.
* @return the generator g
*/
const BigInt& group_g() const { return group.get_g(); }
/**
* Get the underlying groups encoding format.
* @return the encoding format
*/
virtual DL_Group::Format group_format() const = 0;
/**
* Get an X509 encoder for this key.
* @return an encoder usable to encode this key.
*/
X509_Encoder* x509_encoder() const;
/**
* Get an X509 decoder for this key.
* @return an decoder usable to decode a DL key and store the
* values in this instance.
*/
X509_Decoder* x509_decoder();
protected:
BigInt y;
DL_Group group;
private:
virtual void X509_load_hook() {}
};
/**
* This class represents discrete logarithm (DL) private keys.
*/
class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
public virtual Private_Key
{
public:
bool check_key(RandomNumberGenerator& rng, bool) const;
/**
* Get the secret key x.
* @return the secret key
*/
const BigInt& get_x() const { return x; }
/**
* Get an PKCS#8 encoder for this key.
* @return an encoder usable to encode this key.
*/
PKCS8_Encoder* pkcs8_encoder() const;
/**
* Get an PKCS#8 decoder for this key.
* @param rng the rng to use
* @return an decoder usable to decode a DL key and store the
* values in this instance.
*/
PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator& rng);
protected:
BigInt x;
private:
virtual void PKCS8_load_hook(RandomNumberGenerator&, bool = false) {}
};
}
#endif

View File

@@ -1,162 +0,0 @@
/*
* Discrete Logarithm Group
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DL_PARAM_H__
#define BOTAN_DL_PARAM_H__
#include <botan/bigint.h>
#include <botan/data_src.h>
namespace Botan {
/**
* This class represents discrete logarithm groups. It holds a prime p,
* a prime q = (p-1)/2 and g = x^((p-1)/q) mod p.
*/
class BOTAN_DLL DL_Group
{
public:
/**
* Get the prime p.
* @return the prime p
*/
const BigInt& get_p() const;
/**
* Get the prime q.
* @return the prime q
*/
const BigInt& get_q() const;
/**
* Get the base g.
* @return the base g
*/
const BigInt& get_g() const;
/**
* The DL group encoding format variants.
*/
enum Format {
ANSI_X9_42,
ANSI_X9_57,
PKCS_3,
DSA_PARAMETERS = ANSI_X9_57,
DH_PARAMETERS = ANSI_X9_42,
X942_DH_PARAMETERS = ANSI_X9_42,
PKCS3_DH_PARAMETERS = PKCS_3
};
/**
* Determine the prime creation for DL groups.
*/
enum PrimeType { Strong, Prime_Subgroup, DSA_Kosherizer };
/**
* Perform validity checks on the group.
* @param rng the rng to use
* @param strong whether to perform stronger by lengthier tests
* @return true if the object is consistent, false otherwise
*/
bool verify_group(RandomNumberGenerator& rng, bool strong) const;
/**
* Encode this group into a string using PEM encoding.
* @param format the encoding format
* @return the string holding the PEM encoded group
*/
std::string PEM_encode(Format format) const;
/**
* Encode this group into a string using DER encoding.
* @param format the encoding format
* @return the string holding the DER encoded group
*/
SecureVector<byte> DER_encode(Format format) const;
/**
* Decode a DER/BER encoded group into this instance.
* @param src a DataSource providing the encoded group
* @param format the format of the encoded group
*/
void BER_decode(DataSource& src, Format format);
/**
* Decode a PEM encoded group into this instance.
* @param src a DataSource providing the encoded group
*/
void PEM_decode(DataSource& src);
/**
* Construct a DL group with uninitialized internal value.
* Use this constructor is you wish to set the groups values
* from a DER or PEM encoded group.
*/
DL_Group();
/**
* Construct a DL group that is registered in the configuration.
* @param name the name that is configured in the global configuration
* for the desired group. If no configuration file is specified,
* the default values from the file policy.cpp will be used. For instance,
* use "modp/ietf/768" as name.
*/
DL_Group(const std::string& name);
/**
* Create a new group randomly.
* @param rng the random number generator to use
* @param type specifies how the creation of primes p and q shall
* be performed. If type=Strong, then p will be determined as a
* safe prime, and q will be chosen as (p-1)/2. If
* type=Prime_Subgroup and qbits = 0, then the size of q will be
* determined according to the estimated difficulty of the DL
* problem. If type=DSA_Kosherizer, DSA primes will be created.
* @param pbits the number of bits of p
* @param qbits the number of bits of q. Leave it as 0 to have
* the value determined according to pbits.
*/
DL_Group(RandomNumberGenerator& rng, PrimeType type,
u32bit pbits, u32bit qbits = 0);
/**
* Create a DSA group with a given seed.
* @param rng the random number generator to use
* @param seed the seed to use to create the random primes
* @param pbits the desired bit size of the prime p
* @param qbits the desired bit size of the prime q.
*/
DL_Group(RandomNumberGenerator& rng, const MemoryRegion<byte>& seed,
u32bit pbits = 1024, u32bit qbits = 0);
/**
* Create a DL group. The prime q will be determined according to p.
* @param p the prime p
* @param g the base g
*/
DL_Group(const BigInt& p, const BigInt& g);
/**
* Create a DL group.
* @param p the prime p
* @param q the prime q
* @param g the base g
*/
DL_Group(const BigInt& p, const BigInt& q, const BigInt& g);
private:
static BigInt make_dsa_generator(const BigInt&, const BigInt&);
void init_check() const;
void initialize(const BigInt&, const BigInt&, const BigInt&);
bool initialized;
BigInt p, q, g;
};
}
#endif

View File

@@ -1,69 +0,0 @@
/*
* DLIES
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DLIES_H__
#define BOTAN_DLIES_H__
#include <botan/pubkey.h>
#include <botan/mac.h>
#include <botan/kdf.h>
namespace Botan {
/*
* DLIES Encryption
*/
class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
{
public:
DLIES_Encryptor(const PK_Key_Agreement_Key&,
KDF* kdf,
MessageAuthenticationCode* mac,
u32bit mac_key_len = 20);
~DLIES_Encryptor();
void set_other_key(const MemoryRegion<byte>&);
private:
SecureVector<byte> enc(const byte[], u32bit,
RandomNumberGenerator&) const;
u32bit maximum_input_size() const;
const PK_Key_Agreement_Key& key;
SecureVector<byte> other_key;
KDF* kdf;
MessageAuthenticationCode* mac;
u32bit mac_keylen;
};
/*
* DLIES Decryption
*/
class BOTAN_DLL DLIES_Decryptor : public PK_Decryptor
{
public:
DLIES_Decryptor(const PK_Key_Agreement_Key&,
KDF* kdf,
MessageAuthenticationCode* mac,
u32bit mac_key_len = 20);
~DLIES_Decryptor();
private:
SecureVector<byte> dec(const byte[], u32bit) const;
const PK_Key_Agreement_Key& key;
KDF* kdf;
MessageAuthenticationCode* mac;
u32bit mac_keylen;
};
}
#endif

View File

@@ -1,62 +0,0 @@
/*
* DSA
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DSA_H__
#define BOTAN_DSA_H__
#include <botan/dl_algo.h>
#include <botan/dsa_core.h>
namespace Botan {
/*
* DSA Public Key
*/
class BOTAN_DLL DSA_PublicKey : public PK_Verifying_wo_MR_Key,
public virtual DL_Scheme_PublicKey
{
public:
std::string algo_name() const { return "DSA"; }
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; }
u32bit message_parts() const { return 2; }
u32bit message_part_size() const;
bool verify(const byte[], u32bit, const byte[], u32bit) const;
u32bit max_input_bits() const;
DSA_PublicKey() {}
DSA_PublicKey(const DL_Group&, const BigInt&);
protected:
DSA_Core core;
private:
void X509_load_hook();
};
/*
* DSA Private Key
*/
class BOTAN_DLL DSA_PrivateKey : public DSA_PublicKey,
public PK_Signing_Key,
public virtual DL_Scheme_PrivateKey
{
public:
SecureVector<byte> sign(const byte[], u32bit,
RandomNumberGenerator& rng) const;
bool check_key(RandomNumberGenerator& rng, bool) const;
DSA_PrivateKey() {}
DSA_PrivateKey(RandomNumberGenerator&, const DL_Group&,
const BigInt& = 0);
private:
void PKCS8_load_hook(RandomNumberGenerator& rng, bool = false);
};
}
#endif

View File

@@ -1,37 +0,0 @@
/*
* DSA Core
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DSA_CORE_H__
#define BOTAN_DSA_CORE_H__
#include <botan/dsa_op.h>
#include <botan/dl_group.h>
namespace Botan {
/*
* DSA Core
*/
class BOTAN_DLL DSA_Core
{
public:
SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const;
bool verify(const byte[], u32bit, const byte[], u32bit) const;
DSA_Core& operator=(const DSA_Core&);
DSA_Core() { op = 0; }
DSA_Core(const DSA_Core&);
DSA_Core(const DL_Group&, const BigInt&, const BigInt& = 0);
~DSA_Core() { delete op; }
private:
DSA_Operation* op;
};
}
#endif

View File

@@ -1,53 +0,0 @@
/*
* DSA Operations
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_DSA_OPS_H__
#define BOTAN_DSA_OPS_H__
#include <botan/numthry.h>
#include <botan/pow_mod.h>
#include <botan/reducer.h>
#include <botan/dl_group.h>
namespace Botan {
/*
* DSA Operation
*/
class BOTAN_DLL DSA_Operation
{
public:
virtual bool verify(const byte[], u32bit,
const byte[], u32bit) const = 0;
virtual SecureVector<byte> sign(const byte[], u32bit,
const BigInt&) const = 0;
virtual DSA_Operation* clone() const = 0;
virtual ~DSA_Operation() {}
};
/*
* Botan's Default DSA Operation
*/
class BOTAN_DLL Default_DSA_Op : public DSA_Operation
{
public:
bool verify(const byte[], u32bit, const byte[], u32bit) const;
SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const;
DSA_Operation* clone() const { return new Default_DSA_Op(*this); }
Default_DSA_Op(const DL_Group&, const BigInt&, const BigInt&);
private:
const BigInt x, y;
const DL_Group group;
Fixed_Base_Power_Mod powermod_g_p, powermod_y_p;
Modular_Reducer mod_p, mod_q;
};
}
#endif

View File

@@ -1,244 +0,0 @@
/*
* EAC ASN.1 Objects
* (C) 2007-2008 FlexSecure GmbH
* 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAC_ASN1_OBJ_H__
#define BOTAN_EAC_ASN1_OBJ_H__
#include <botan/asn1_obj.h>
#include <vector>
#include <map>
namespace Botan {
/**
* This class represents CVC EAC Time objects.
* It only models year, month and day. Only limited sanity checks of
* the inputted date value are performed.
*/
class BOTAN_DLL EAC_Time : public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
/**
* Get a this objects value as a string.
* @return the date string
*/
std::string as_string() const;
/**
* Get a this objects value as a readable formatted string.
* @return the date string
*/
std::string readable_string() const;
/**
* Find out whether this object's values have been set.
* @return true if this object's internal values are set
*/
bool time_is_set() const;
/**
* Compare this to another EAC_Time object.
* @return -1 if this object's date is earlier than
* other, +1 in the opposite case, and 0 if both dates are
* equal.
*/
s32bit cmp(const EAC_Time& other) const;
/**
* Set this' value by a string value.
* @param str a string in the format "yyyy mm dd",
* e.g. "2007 08 01"
*/
void set_to(const std::string& str);
//void set_to(const std::string&, ASN1_Tag);
/**
* Add the specified number of years to this.
* @param years the number of years to add
*/
void add_years(u32bit years);
/**
* Add the specified number of months to this.
* @param months the number of months to add
*/
void add_months(u32bit months);
/**
* Get the year value of this objects.
* @return the year value
*/
u32bit get_year() const;
/**
* Get the month value of this objects.
* @return the month value
*/
u32bit get_month() const;
/**
* Get the day value of this objects.
* @return the day value
*/
u32bit get_day() const;
EAC_Time(u64bit, ASN1_Tag t = ASN1_Tag(0));
//EAC_Time(const std::string& = "");
EAC_Time(const std::string&, ASN1_Tag = ASN1_Tag(0));
EAC_Time(u32bit year, u32bit month, u32bit day, ASN1_Tag = ASN1_Tag(0));
virtual ~EAC_Time() {}
private:
SecureVector<byte> encoded_eac_time() const;
bool passes_sanity_check() const;
u32bit year, month, day;
ASN1_Tag tag;
};
/**
* This class represents CVC CEDs. Only limited sanity checks of
* the inputted date value are performed.
*/
class BOTAN_DLL ASN1_Ced : public EAC_Time
{
public:
/**
* Construct a CED from a string value.
* @param str a string in the format "yyyy mm dd",
* e.g. "2007 08 01"
*/
ASN1_Ced(std::string const& str = std::string());
/**
* Construct a CED from a timer value.
* @param time the number of seconds elapsed midnight, 1st
* January 1970 GMT (or 7pm, 31st December 1969 EST) up to the
* desired date
*/
ASN1_Ced(u64bit time);
/**
* Copy constructor (for general EAC_Time objects).
* @param other the object to copy from
*/
ASN1_Ced(EAC_Time const& other);
//ASN1_Ced(ASN1_Cex const& cex);
};
/**
* This class represents CVC CEXs. Only limited sanity checks of
* the inputted date value are performed.
*/
class BOTAN_DLL ASN1_Cex : public EAC_Time
{
public:
/**
* Construct a CED from a string value.
* @param str a string in the format "yyyy mm dd",
* e.g. "2007 08 01"
*/
ASN1_Cex(std::string const& str=std::string());
/**
* Construct a CED from a timer value.
* @param time the number of seconds elapsed
* midnight, 1st
* January 1970 GMT (or 7pm, 31st December 1969 EST)
* up to the desired date
*/
ASN1_Cex(u64bit time);
/**
* Copy constructor (for general EAC_Time objects).
* @param other the object to copy from
*/
ASN1_Cex(EAC_Time const& other);
//ASN1_Cex(ASN1_Ced const& ced);
};
/**
* Base class for car/chr of cv certificates.
*/
class BOTAN_DLL ASN1_EAC_String: public ASN1_Object
{
public:
void encode_into(class DER_Encoder&) const;
void decode_from(class BER_Decoder&);
/**
* Get this objects string value.
* @return the string value
*/
std::string value() const;
/**
* Get this objects string value.
* @return the string value in iso8859 encoding
*/
std::string iso_8859() const;
ASN1_Tag tagging() const;
ASN1_EAC_String(const std::string& str, ASN1_Tag the_tag);
virtual ~ASN1_EAC_String() {}
protected:
bool sanity_check() const;
private:
std::string iso_8859_str;
ASN1_Tag tag;
};
/**
* This class represents CARs of CVCs. (String tagged with 2)
*/
class BOTAN_DLL ASN1_Car : public ASN1_EAC_String
{
public:
/**
* Create a CAR with the specified content.
* @param str the CAR value
*/
ASN1_Car(std::string const& str = std::string());
};
/**
* This class represents CHRs of CVCs (tag 32)
*/
class BOTAN_DLL ASN1_Chr : public ASN1_EAC_String
{
public:
/**
* Create a CHR with the specified content.
* @param str the CHR value
*/
ASN1_Chr(std::string const& str = std::string());
};
/*
* Comparison Operations
*/
bool operator==(const EAC_Time&, const EAC_Time&);
bool operator!=(const EAC_Time&, const EAC_Time&);
bool operator<=(const EAC_Time&, const EAC_Time&);
bool operator>=(const EAC_Time&, const EAC_Time&);
bool operator>(const EAC_Time&, const EAC_Time&);
bool operator<(const EAC_Time&, const EAC_Time&);
bool operator==(const ASN1_EAC_String&, const ASN1_EAC_String&);
inline bool operator!=(const ASN1_EAC_String& lhs, const ASN1_EAC_String& rhs)
{
return !(lhs == rhs);
}
}
#endif

View File

@@ -1,131 +0,0 @@
/*
* EAC1_1 objects
* (C) 2008 Falko Strenzke
* strenzke@flexsecure.de
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAC_OBJ_H__
#define BOTAN_EAC_OBJ_H__
#include <botan/pubkey.h>
#include <botan/x509_key.h>
#include <botan/signed_obj.h>
#include <botan/pubkey_enums.h>
#include <botan/pubkey.h>
#include <botan/parsing.h>
#include <botan/pem.h>
#include <botan/oids.h>
#include <botan/look_pk.h>
#include <botan/ecdsa_sig.h>
#include <string>
namespace Botan {
const std::string eac_cvc_emsa("EMSA1_BSI");
/*
* TR03110 v1.1 EAC CV Certificate
*/
template<typename Derived> // CRTP is used enable the call sequence:
class BOTAN_DLL EAC1_1_obj : public EAC_Signed_Object
{
// data members first:
protected:
ECDSA_Signature m_sig;
// member functions here:
public:
/**
* Return the signature as a concatenation of the encoded parts.
* @result the concatenated signature
*/
SecureVector<byte> get_concat_sig() const;
/**
* Verify the signature of this objects.
* @param pub_key the public key to verify the signature with
* @result true if the verification succeeded
*/
virtual bool check_signature(Public_Key& pub_key) const;
protected:
void init(SharedPtrConverter<DataSource> in);
static SecureVector<byte> make_signature(PK_Signer* signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng);
virtual ~EAC1_1_obj<Derived>(){}
};
template<typename Derived> SecureVector<byte> EAC1_1_obj<Derived>::get_concat_sig() const
{
return m_sig.get_concatenation();
}
template<typename Derived> SecureVector<byte>
EAC1_1_obj<Derived>::make_signature(PK_Signer* signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng)
{
// this is the signature as a der sequence
SecureVector<byte> seq_sig = signer->sign_message(tbs_bits, rng);
ECDSA_Signature sig(decode_seq(seq_sig));
SecureVector<byte> concat_sig(sig.get_concatenation());
return concat_sig;
}
template<typename Derived> void EAC1_1_obj<Derived>::init(SharedPtrConverter<DataSource> in)
{
try
{
Derived::decode_info(in.get_shared(), tbs_bits, m_sig);
}
catch(Decoding_Error)
{
throw Decoding_Error(PEM_label_pref + " decoding failed");
}
}
template<typename Derived>
bool EAC1_1_obj<Derived>::check_signature(Public_Key& pub_key) const
{
try
{
std::vector<std::string> sig_info =
split_on(OIDS::lookup(sig_algo.oid), '/');
if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
{
return false;
}
std::string padding = sig_info[1];
Signature_Format format =
(pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
if(!dynamic_cast<PK_Verifying_wo_MR_Key*>(&pub_key))
return false;
std::auto_ptr<ECDSA_Signature_Encoder> enc(new ECDSA_Signature_Encoder(&m_sig));
SecureVector<byte> seq_sig = enc->signature_bits();
SecureVector<byte> to_sign = tbs_data();
PK_Verifying_wo_MR_Key& sig_key = dynamic_cast<PK_Verifying_wo_MR_Key&>(pub_key);
std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(sig_key, padding, format));
return verifier->verify_message(to_sign, seq_sig);
}
catch(...)
{
return false;
}
}
}
#endif

View File

@@ -1,85 +0,0 @@
/*
* EAX Mode
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EAX_H__
#define BOTAN_EAX_H__
#include <botan/basefilt.h>
#include <botan/block_cipher.h>
#include <botan/mac.h>
namespace Botan {
/*
* EAX Base Class
*/
class BOTAN_DLL EAX_Base : public Keyed_Filter
{
public:
void set_key(const SymmetricKey&);
void set_iv(const InitializationVector&);
void set_header(const byte[], u32bit);
std::string name() const;
bool valid_keylength(u32bit) const;
~EAX_Base() { delete cipher; delete mac; }
protected:
EAX_Base(BlockCipher*, u32bit);
void start_msg();
void increment_counter();
const u32bit TAG_SIZE, BLOCK_SIZE;
BlockCipher* cipher;
MessageAuthenticationCode* mac;
SecureVector<byte> nonce_mac, header_mac, state, buffer;
u32bit position;
};
/*
* EAX Encryption
*/
class BOTAN_DLL EAX_Encryption : public EAX_Base
{
public:
EAX_Encryption(BlockCipher* ciph, u32bit tag_size = 0) :
EAX_Base(ciph, tag_size) {}
EAX_Encryption(BlockCipher* ciph, const SymmetricKey& key,
const InitializationVector& iv,
u32bit tag_size) : EAX_Base(ciph, tag_size)
{
set_key(key);
set_iv(iv);
}
private:
void write(const byte[], u32bit);
void end_msg();
};
/*
* EAX Decryption
*/
class BOTAN_DLL EAX_Decryption : public EAX_Base
{
public:
EAX_Decryption(BlockCipher* ciph, u32bit tag_size = 0);
EAX_Decryption(BlockCipher* ciph, const SymmetricKey& key,
const InitializationVector& iv,
u32bit tag_size = 0);
private:
void write(const byte[], u32bit);
void do_write(const byte[], u32bit);
void end_msg();
SecureVector<byte> queue;
u32bit queue_start, queue_end;
};
}
#endif

View File

@@ -1,121 +0,0 @@
/*
* ECDSA Domain Parameters
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECC_DOMAIN_PARAMETERS_H__
#define BOTAN_ECC_DOMAIN_PARAMETERS_H__
#include <botan/point_gfp.h>
#include <botan/gfp_element.h>
#include <botan/curve_gfp.h>
#include <botan/bigint.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/alg_id.h>
#include <botan/pubkey_enums.h>
namespace Botan {
/**
* This class represents elliptic curce domain parameters
*/
class BOTAN_DLL EC_Domain_Params
{
public:
/**
* Construct Domain paramers from specified parameters
* @param curve elliptic curve
* @param base_point a base point
* @param order the order of the base point
* @param cofactor the cofactor
*/
EC_Domain_Params(const CurveGFp& curve,
const PointGFp& base_point,
const BigInt& order,
const BigInt& cofactor);
/**
* Return domain parameter curve
* @result domain parameter curve
*/
const CurveGFp& get_curve() const
{
return m_curve;
}
/**
* Return domain parameter curve
* @result domain parameter curve
*/
const PointGFp& get_base_point() const
{
return m_base_point;
}
/**
* Return the order of the base point
* @result order of the base point
*/
const BigInt& get_order() const
{
return m_order;
}
/**
* Return the cofactor
* @result the cofactor
*/
const BigInt& get_cofactor() const
{
return m_cofactor;
}
/**
* Return the OID of these domain parameters
* @result the OID
*/
std::string get_oid() const { return m_oid; }
private:
friend EC_Domain_Params get_EC_Dom_Pars_by_oid(std::string oid);
CurveGFp m_curve;
PointGFp m_base_point;
BigInt m_order;
BigInt m_cofactor;
std::string m_oid;
};
bool operator==(EC_Domain_Params const& lhs, EC_Domain_Params const& rhs);
inline bool operator!=(const EC_Domain_Params& lhs,
const EC_Domain_Params& rhs)
{
return !(lhs == rhs);
}
enum EC_dompar_enc { ENC_EXPLICIT = 0, ENC_IMPLICITCA = 1, ENC_OID = 2 };
SecureVector<byte> encode_der_ec_dompar(EC_Domain_Params const& dom_pars,
EC_dompar_enc enc_type);
EC_Domain_Params decode_ber_ec_dompar(SecureVector<byte> const& encoded);
/**
* 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.
* @param oid the oid of the demanded EC domain parameters
* @result the EC domain parameters associated with the OID
*/
EC_Domain_Params get_EC_Dom_Pars_by_oid(std::string oid);
}
#endif

View File

@@ -1,73 +0,0 @@
/*
* ECB Mode
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECB_H__
#define BOTAN_ECB_H__
#include <botan/modebase.h>
#include <botan/mode_pad.h>
#include <botan/block_cipher.h>
namespace Botan {
/*
* ECB
*/
class BOTAN_DLL ECB : public BlockCipherMode
{
protected:
ECB(BlockCipher* ciph, BlockCipherModePaddingMethod* pad) :
BlockCipherMode(ciph, "ECB", 0), padder(pad) {}
~ECB() { delete padder; }
std::string name() const;
BlockCipherModePaddingMethod* padder;
private:
bool valid_iv_size(u32bit) const;
};
/*
* ECB Encryption
*/
class BOTAN_DLL ECB_Encryption : public ECB
{
public:
ECB_Encryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad) :
ECB(ciph, pad) {}
ECB_Encryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad,
const SymmetricKey& key) :
ECB(ciph, pad) { set_key(key); }
private:
void write(const byte[], u32bit);
void end_msg();
};
/*
* ECB Decryption
*/
class BOTAN_DLL ECB_Decryption : public ECB
{
public:
ECB_Decryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad) :
ECB(ciph, pad) {}
ECB_Decryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad,
const SymmetricKey& key) :
ECB(ciph, pad) { set_key(key); }
private:
void write(const byte[], u32bit);
void end_msg();
};
}
#endif

View File

@@ -1,156 +0,0 @@
/*
* ECDSA
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* Manuel Hartl, FlexSecure GmbH
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECC_PUBLIC_KEY_BASE_H__
#define BOTAN_ECC_PUBLIC_KEY_BASE_H__
#include <botan/bigint.h>
#include <botan/curve_gfp.h>
#include <botan/pk_keys.h>
#include <botan/ec_dompar.h>
#include <botan/x509_key.h>
#include <botan/pkcs8.h>
#include <memory>
namespace Botan {
/**
* This class represents abstract EC Public Keys. When encoding a key
* via an encoder that can be accessed via the corresponding member
* functions, the key will decide upon its internally stored encoding
* information whether to encode itself with or without domain
* parameters, or using the domain parameter oid. Furthermore, a public
* key without domain parameters can be decoded. In that case, it
* cannot be used for verification until its domain parameters are set
* by calling the corresponding member function.
*/
class BOTAN_DLL EC_PublicKey : public virtual Public_Key
{
public:
/**
* Tells whether this key knows his own domain parameters.
* @result true if the domain parameters are set, false otherwise
*/
bool domain_parameters_set();
/**
* Get the public point of this key.
* @throw Invalid_State is thrown if the
* domain parameters of this point are not set
* @result the public point of this key
*/
const PointGFp& public_point() const;
/**
* Get the domain parameters of this key.
* @throw Invalid_State is thrown if the
* domain parameters of this point are not set
* @result the domain parameters of this key
*/
const EC_Domain_Params& domain_parameters() const;
/**
* Set the domain parameter encoding to be used when encoding this key.
* @param enc the encoding to use
*/
void set_parameter_encoding(EC_dompar_enc enc);
/**
* Get the domain parameter encoding to be used when encoding this key.
* @result the encoding to use
*/
inline int get_parameter_encoding() const
{
return m_param_enc;
}
//ctors
EC_PublicKey()
: m_param_enc(ENC_EXPLICIT)
{
//assert(mp_dom_pars.get() == 0);
//assert(mp_public_point.get() == 0);
}
/**
* Get an x509_encoder that can be used to encode this key.
* @result an x509_encoder for this key
*/
X509_Encoder* x509_encoder() const;
/**
* Get an x509_decoder that can be used to decode a stored key into
* this key.
* @result an x509_decoder for this key
*/
X509_Decoder* x509_decoder();
/**
* Make sure that the public point and domain parameters of this key are set.
* @throw Invalid_State if either of the two data members is not set
*/
virtual void affirm_init() const;
virtual ~EC_PublicKey() {}
protected:
virtual void X509_load_hook();
SecureVector<byte> m_enc_public_point; // stores the public point
std::auto_ptr<EC_Domain_Params> mp_dom_pars;
std::auto_ptr<PointGFp> mp_public_point;
EC_dompar_enc m_param_enc;
};
/**
* This abstract class represents general EC Private Keys
*/
class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey, public virtual Private_Key
{
public:
/**
* Get an PKCS#8 encoder that can be used to encoded this key.
* @result an PKCS#8 encoder for this key
*/
PKCS8_Encoder* pkcs8_encoder() const;
/**
* Get an PKCS#8 decoder that can be used to decoded a stored key into
* this key.
* @result an PKCS#8 decoder for this key
*/
PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator&);
/**
* Get the private key value of this key object.
* @result the private key value of this key object
*/
const BigInt& private_value() const;
/**
* Make sure that the public key parts of this object are set
* (calls EC_PublicKey::affirm_init()) as well as the private key
* value.
* @throw Invalid_State if the above conditions are not satisfied
*/
virtual void affirm_init() const;
virtual ~EC_PrivateKey() {}
protected:
virtual void PKCS8_load_hook(bool = false);
void generate_private_key(RandomNumberGenerator&);
BigInt m_private_value;
};
}
#endif

View File

@@ -1,145 +0,0 @@
/*
* ECDSA
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* Manuel Hartl, FlexSecure GmbH
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECDSA_KEY_H__
#define BOTAN_ECDSA_KEY_H__
#include <botan/ecc_key.h>
#include <botan/ecdsa_core.h>
namespace Botan {
/**
* This class represents ECDSA Public Keys.
*/
class BOTAN_DLL ECDSA_PublicKey : public virtual EC_PublicKey,
public PK_Verifying_wo_MR_Key
{
public:
/**
* Get this keys algorithm name.
* @result this keys algorithm name ("ECDSA")
*/
std::string algo_name() const { return "ECDSA"; }
/**
* Get the maximum number of bits allowed to be fed to this key.
* This is the bitlength of the order of the base point.
* @result the maximum number of input bits
*/
u32bit max_input_bits() const;
/**
* Verify a message with this key.
* @param message the byte array containing the message
* @param mess_len the number of bytes in the message byte array
* @param signature the byte array containing the signature
* @param sig_len the number of bytes in the signature byte array
*/
bool verify(const byte message[], u32bit mess_len,
const byte signature[], u32bit sig_len) const;
/**
* Default constructor. Use this one if you want to later fill
* this object with data from an encoded key.
*/
ECDSA_PublicKey() {}
/**
* Construct a public key from a given public point.
* @param dom_par the domain parameters associated with this key
* @param public_point the public point defining this key
*/
ECDSA_PublicKey(const EC_Domain_Params& dom_par,
const PointGFp& public_point); // sets core
ECDSA_PublicKey const& operator=(const ECDSA_PublicKey& rhs);
ECDSA_PublicKey(const ECDSA_PublicKey& other);
/**
* Set the domain parameters of this key. This function has to be
* used when a key encoded without domain parameters was decoded into
* this key. Otherwise it will not be able to verify a signature.
* @param dom_pars the domain_parameters associated with this key
* @throw Invalid_Argument if the point was found not to be satisfying the
* curve equation of the provided domain parameters
* or if this key already has domain parameters set
* and these are differing from those given as the parameter
*/
void set_domain_parameters(const EC_Domain_Params& dom_pars);
/**
* Ensure that the public point and domain parameters of this key are set.
* @throw Invalid_State if either of the two data members is not set
*/
virtual void affirm_init() const;
protected:
void X509_load_hook();
virtual void set_all_values(const ECDSA_PublicKey& other);
ECDSA_Core m_ecdsa_core;
};
/**
* This class represents ECDSA Private Keys
*/
class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey,
public EC_PrivateKey,
public PK_Signing_Key
{
public:
//ctors
/**
* Default constructor. Use this one if you want to later fill
* this object with data from an encoded key.
*/
ECDSA_PrivateKey() {}
/**
* Generate a new private key
* @param the domain parameters to used for this key
*/
ECDSA_PrivateKey(RandomNumberGenerator& rng,
const EC_Domain_Params& domain);
ECDSA_PrivateKey(const ECDSA_PrivateKey& other);
ECDSA_PrivateKey const& operator=(const ECDSA_PrivateKey& rhs);
/**
* Sign a message with this key.
* @param message the byte array representing the message to be signed
* @param mess_len the length of the message byte array
* @result the signature
*/
SecureVector<byte> sign(const byte message[], u32bit mess_len,
RandomNumberGenerator& rng) const;
/**
* Make sure that the public key parts of this object are set
* (calls EC_PublicKey::affirm_init()) as well as the private key
* value.
* @throw Invalid_State if the above conditions are not satisfied
*/
virtual void affirm_init() const;
protected:
virtual void set_all_values(const ECDSA_PrivateKey& other);
private:
void PKCS8_load_hook(bool = false);
};
}
#endif

View File

@@ -1,47 +0,0 @@
/*
* ECDSA Core
* (C) 1999-2007 Jack Lloyd
* (C) 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECDSA_CORE_H__
#define BOTAN_ECDSA_CORE_H__
#include <botan/ecdsa_op.h>
#include <botan/blinding.h>
#include <botan/ec_dompar.h>
namespace Botan {
/*
* ECDSA Core
*/
class BOTAN_DLL ECDSA_Core
{
public:
bool verify(const byte signature[], u32bit sig_len,
const byte message[], u32bit mess_len) const;
SecureVector<byte> sign(const byte message[], u32bit mess_len,
RandomNumberGenerator& rng) const;
ECDSA_Core& operator=(const ECDSA_Core&);
ECDSA_Core() { op = 0; }
ECDSA_Core(const ECDSA_Core&);
ECDSA_Core(const EC_Domain_Params& dom_pars,
const BigInt& priv_key,
const PointGFp& pub_key);
~ECDSA_Core() { delete op; }
private:
ECDSA_Operation* op;
};
}
#endif

View File

@@ -1,64 +0,0 @@
/*
* ECDSA Operations
* (C) 1999-2008 Jack Lloyd
* (C) 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECDSA_OPERATIONS_H__
#define BOTAN_ECDSA_OPERATIONS_H__
#include <botan/ec_dompar.h>
#include <botan/rng.h>
namespace Botan {
/*
* ECDSA Operation
*/
class BOTAN_DLL ECDSA_Operation
{
public:
virtual bool verify(const byte sig[], u32bit sig_len,
const byte msg[], u32bit msg_len) const = 0;
virtual SecureVector<byte> sign(const byte message[],
u32bit mess_len,
RandomNumberGenerator&) const = 0;
virtual ECDSA_Operation* clone() const = 0;
virtual ~ECDSA_Operation() {}
};
/*
* Default ECDSA operation
*/
class BOTAN_DLL Default_ECDSA_Op : public ECDSA_Operation
{
public:
bool verify(const byte signature[], u32bit sig_len,
const byte message[], u32bit mess_len) const;
SecureVector<byte> sign(const byte message[], u32bit mess_len,
RandomNumberGenerator& rng) const;
ECDSA_Operation* clone() const
{
return new Default_ECDSA_Op(*this);
}
Default_ECDSA_Op(const EC_Domain_Params& dom_pars,
const BigInt& priv_key,
const PointGFp& pub_key);
private:
EC_Domain_Params m_dom_pars;
PointGFp m_pub_key;
BigInt m_priv_key;
};
}
#endif

View File

@@ -1,88 +0,0 @@
/*
* ECDSA
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECDSA_SIGNATURE_H__
#define BOTAN_ECDSA_SIGNATURE_H__
#include <botan/bigint.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
namespace Botan {
class BOTAN_DLL ECDSA_Signature
{
public:
friend class ECDSA_Signature_Decoder;
ECDSA_Signature() {}
ECDSA_Signature(const BigInt& r, const BigInt& s);
ECDSA_Signature(ECDSA_Signature const& other);
ECDSA_Signature const& operator=(ECDSA_Signature const& other);
const BigInt& get_r() const { return m_r; }
const BigInt& get_s() const { return m_s; }
/**
* return the r||s
*/
SecureVector<byte> const get_concatenation() const;
private:
BigInt m_r;
BigInt m_s;
};
/* Equality of ECDSA_Signature */
bool operator==(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs);
inline bool operator!=(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs)
{
return !(lhs == rhs);
}
class BOTAN_DLL ECDSA_Signature_Decoder
{
public:
void signature_bits(const MemoryRegion<byte>& bits)
{
BER_Decoder(bits)
.start_cons(SEQUENCE)
.decode(m_signature->m_r)
.decode(m_signature->m_s)
.verify_end()
.end_cons();
}
ECDSA_Signature_Decoder(ECDSA_Signature* signature) : m_signature(signature)
{}
private:
ECDSA_Signature* m_signature;
};
class BOTAN_DLL ECDSA_Signature_Encoder
{
public:
MemoryVector<byte> signature_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
.encode(m_signature->get_r())
.encode(m_signature->get_s())
.end_cons()
.get_contents();
}
ECDSA_Signature_Encoder(const ECDSA_Signature* signature) : m_signature(signature)
{}
private:
const ECDSA_Signature* m_signature;
};
ECDSA_Signature const decode_seq(MemoryRegion<byte> const& seq);
ECDSA_Signature const decode_concatenation(MemoryRegion<byte> const& concatenation);
}
#endif

View File

@@ -1,137 +0,0 @@
/*
* ECKAEG
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* Manuel Hartl, FlexSecure GmbH
* (C) 2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECKAEG_KEY_H__
#define BOTAN_ECKAEG_KEY_H__
#include <botan/ecc_key.h>
#include <botan/eckaeg_core.h>
namespace Botan {
/**
* This class represents ECKAEG Public Keys.
*/
class BOTAN_DLL ECKAEG_PublicKey : public virtual EC_PublicKey
{
public:
/**
* Default constructor. Use this one if you want to later fill
* this object with data from an encoded key.
*/
ECKAEG_PublicKey() {}
/**
* Construct a public key from a given public point.
* @param dom_par the domain parameters associated with this key
* @param public_point the public point defining this key
*/
ECKAEG_PublicKey(const EC_Domain_Params& dom_par,
const PointGFp& public_point);
/**
* Get this keys algorithm name.
* @result this keys algorithm name
*/
std::string algo_name() const { return "ECKAEG"; }
/**
* Get the maximum number of bits allowed to be fed to this key.
* This is the bitlength of the order of the base point.
* @result the maximum number of input bits
*/
u32bit max_input_bits() const
{
if(!mp_dom_pars.get())
throw Invalid_State("ECKAEG_PublicKey::max_input_bits(): domain parameters not set");
return mp_dom_pars->get_order().bits();
}
ECKAEG_PublicKey(ECKAEG_PublicKey const& other);
ECKAEG_PublicKey const& operator= (ECKAEG_PublicKey const& rhs);
/**
* Make sure that the public point and domain parameters of this
* key are set.
* @throw Invalid_State if either of the two data members is not set
*/
virtual void affirm_init() const;
protected:
void X509_load_hook();
virtual void set_all_values(const ECKAEG_PublicKey& other);
ECKAEG_Core m_eckaeg_core;
};
/**
* This class represents ECKAEG Private Keys.
*/
class BOTAN_DLL ECKAEG_PrivateKey : public ECKAEG_PublicKey,
public EC_PrivateKey,
public PK_Key_Agreement_Key
{
public:
/**
* Generate a new private key
* @param the domain parameters to used for this key
*/
ECKAEG_PrivateKey(RandomNumberGenerator& rng,
const EC_Domain_Params& dom_pars)
{
mp_dom_pars = std::auto_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_pars));
generate_private_key(rng);
mp_public_point->check_invariants();
m_eckaeg_core = ECKAEG_Core(*mp_dom_pars, m_private_value, *mp_public_point);
}
/**
* Default constructor. Use this one if you want to later fill this object with data
* from an encoded key.
*/
ECKAEG_PrivateKey() {}
ECKAEG_PrivateKey(ECKAEG_PrivateKey const& other);
ECKAEG_PrivateKey const& operator=(ECKAEG_PrivateKey const& rhs);
MemoryVector<byte> public_value() const;
void PKCS8_load_hook(bool = false);
/**
* Derive a shared key with the other partys public key.
* @param key the other partys public key
* @param key_len the other partys public key
*/
SecureVector<byte> derive_key(const byte key[], u32bit key_len) const;
/**
* Derive a shared key with the other partys public key.
* @param other the other partys public key
*/
SecureVector<byte> derive_key(const ECKAEG_PublicKey& other) const;
/**
* Make sure that the public key parts of this object are set
* (calls EC_PublicKey::affirm_init()) as well as the private key
* value.
* @throw Invalid_State if the above conditions are not satisfied
*/
virtual void affirm_init() const;
protected:
virtual void set_all_values(const ECKAEG_PrivateKey& other);
};
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* ECKAEG Core
* (C) 1999-2007 Jack Lloyd
* (C) 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECKAEG_CORE_H__
#define BOTAN_ECKAEG_CORE_H__
#include <botan/eckaeg_op.h>
#include <botan/blinding.h>
#include <botan/ec_dompar.h>
namespace Botan {
/*
* ECKAEG Core
*/
class BOTAN_DLL ECKAEG_Core
{
public:
SecureVector<byte> agree(const PointGFp&) const;
ECKAEG_Core& operator=(const ECKAEG_Core&);
ECKAEG_Core() { op = 0; }
ECKAEG_Core(const ECKAEG_Core&);
ECKAEG_Core(const EC_Domain_Params& dom_pars,
const BigInt& priv_key,
PointGFp const& pub_key);
~ECKAEG_Core() { delete op; }
private:
ECKAEG_Operation* op;
Blinder blinder;
};
}
#endif

View File

@@ -1,49 +0,0 @@
/*
* ECKAEG Operations
* (C) 1999-2008 Jack Lloyd
* 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECKAEG_OPERATIONS_H__
#define BOTAN_ECKAEG_OPERATIONS_H__
#include <botan/ec_dompar.h>
namespace Botan {
/*
* ECKAEG Operation
*/
class BOTAN_DLL ECKAEG_Operation
{
public:
virtual SecureVector<byte> agree(const PointGFp&) const = 0;
virtual ECKAEG_Operation* clone() const = 0;
virtual ~ECKAEG_Operation() {}
};
/*
* Default ECKAEG operation
*/
class BOTAN_DLL Default_ECKAEG_Op : public ECKAEG_Operation
{
public:
SecureVector<byte> agree(const PointGFp& i) const;
ECKAEG_Operation* clone() const { return new Default_ECKAEG_Op(*this); }
Default_ECKAEG_Op(const EC_Domain_Params& dom_pars,
const BigInt& priv_key,
const PointGFp& pub_key);
private:
EC_Domain_Params m_dom_pars;
PointGFp m_pub_key;
BigInt m_priv_key;
};
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* ElGamal Core
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ELGAMAL_CORE_H__
#define BOTAN_ELGAMAL_CORE_H__
#include <botan/elg_op.h>
#include <botan/blinding.h>
#include <botan/dl_group.h>
namespace Botan {
/*
* ElGamal Core
*/
class BOTAN_DLL ELG_Core
{
public:
SecureVector<byte> encrypt(const byte[], u32bit, const BigInt&) const;
SecureVector<byte> decrypt(const byte[], u32bit) const;
ELG_Core& operator=(const ELG_Core&);
ELG_Core() { op = 0; }
ELG_Core(const ELG_Core&);
ELG_Core(const DL_Group&, const BigInt&);
ELG_Core(RandomNumberGenerator&, const DL_Group&,
const BigInt&, const BigInt&);
~ELG_Core() { delete op; }
private:
ELG_Operation* op;
Blinder blinder;
u32bit p_bytes;
};
}
#endif

View File

@@ -1,52 +0,0 @@
/*
* ElGamal Operations
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ELGAMAL_OPS_H__
#define BOTAN_ELGAMAL_OPS_H__
#include <botan/pow_mod.h>
#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/dl_group.h>
namespace Botan {
/*
* ElGamal Operation
*/
class BOTAN_DLL ELG_Operation
{
public:
virtual SecureVector<byte> encrypt(const byte[], u32bit,
const BigInt&) const = 0;
virtual BigInt decrypt(const BigInt&, const BigInt&) const = 0;
virtual ELG_Operation* clone() const = 0;
virtual ~ELG_Operation() {}
};
/*
* Botan's Default ElGamal Operation
*/
class BOTAN_DLL Default_ELG_Op : public ELG_Operation
{
public:
SecureVector<byte> encrypt(const byte[], u32bit, const BigInt&) const;
BigInt decrypt(const BigInt&, const BigInt&) const;
ELG_Operation* clone() const { return new Default_ELG_Op(*this); }
Default_ELG_Op(const DL_Group&, const BigInt&, const BigInt&);
private:
const BigInt p;
Fixed_Base_Power_Mod powermod_g_p, powermod_y_p;
Fixed_Exponent_Power_Mod powermod_x_p;
Modular_Reducer mod_p;
};
}
#endif

View File

@@ -1,59 +0,0 @@
/*
* ElGamal
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ELGAMAL_H__
#define BOTAN_ELGAMAL_H__
#include <botan/dl_algo.h>
#include <botan/elg_core.h>
namespace Botan {
/*
* ElGamal Public Key
*/
class BOTAN_DLL ElGamal_PublicKey : public PK_Encrypting_Key,
public virtual DL_Scheme_PublicKey
{
public:
std::string algo_name() const { return "ElGamal"; }
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; }
SecureVector<byte> encrypt(const byte[], u32bit,
RandomNumberGenerator& rng) const;
u32bit max_input_bits() const;
ElGamal_PublicKey() {}
ElGamal_PublicKey(const DL_Group&, const BigInt&);
protected:
ELG_Core core;
private:
void X509_load_hook();
};
/*
* ElGamal Private Key
*/
class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
public PK_Decrypting_Key,
public virtual DL_Scheme_PrivateKey
{
public:
SecureVector<byte> decrypt(const byte[], u32bit) const;
bool check_key(RandomNumberGenerator& rng, bool) const;
ElGamal_PrivateKey() {}
ElGamal_PrivateKey(RandomNumberGenerator&, const DL_Group&,
const BigInt& = 0);
private:
void PKCS8_load_hook(RandomNumberGenerator&, bool = false);
};
}
#endif

View File

@@ -1,42 +0,0 @@
/*
* EME Classes
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__
#define BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__
#include <botan/secmem.h>
#include <botan/rng.h>
namespace Botan {
/*
* Encoding Method for Encryption
*/
class BOTAN_DLL EME
{
public:
virtual u32bit maximum_input_size(u32bit) const = 0;
SecureVector<byte> encode(const byte[], u32bit, u32bit,
RandomNumberGenerator&) const;
SecureVector<byte> encode(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator&) const;
SecureVector<byte> decode(const byte[], u32bit, u32bit) const;
SecureVector<byte> decode(const MemoryRegion<byte>&, u32bit) const;
virtual ~EME() {}
private:
virtual SecureVector<byte> pad(const byte[], u32bit, u32bit,
RandomNumberGenerator&) const = 0;
virtual SecureVector<byte> unpad(const byte[], u32bit, u32bit) const = 0;
};
}
#endif

View File

@@ -1,45 +0,0 @@
/*
* EME1
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EME1_H__
#define BOTAN_EME1_H__
#include <botan/eme.h>
#include <botan/kdf.h>
#include <botan/hash.h>
namespace Botan {
/*
* EME1
*/
class BOTAN_DLL EME1 : public EME
{
public:
u32bit maximum_input_size(u32bit) const;
/**
EME1 constructor. Hash will be deleted by ~EME1 (when mgf is deleted)
P is an optional label. Normally empty.
*/
EME1(HashFunction* hash, const std::string& P = "");
~EME1() { delete mgf; }
private:
SecureVector<byte> pad(const byte[], u32bit, u32bit,
RandomNumberGenerator&) const;
SecureVector<byte> unpad(const byte[], u32bit, u32bit) const;
const u32bit HASH_LENGTH;
SecureVector<byte> Phash;
MGF* mgf;
};
}
#endif

View File

@@ -1,30 +0,0 @@
/*
* EME PKCS#1 v1.5
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EME_PKCS1_H__
#define BOTAN_EME_PKCS1_H__
#include <botan/eme.h>
namespace Botan {
/*
* EME_PKCS1v15
*/
class BOTAN_DLL EME_PKCS1v15 : public EME
{
public:
u32bit maximum_input_size(u32bit) const;
private:
SecureVector<byte> pad(const byte[], u32bit, u32bit,
RandomNumberGenerator&) const;
SecureVector<byte> unpad(const byte[], u32bit, u32bit) const;
};
}
#endif

View File

@@ -1,36 +0,0 @@
/*
* EMSA Classes
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_PUBKEY_EMSA_H__
#define BOTAN_PUBKEY_EMSA_H__
#include <botan/secmem.h>
#include <botan/rng.h>
namespace Botan {
/*
* Encoding Method for Signatures, Appendix
*/
class BOTAN_DLL EMSA
{
public:
virtual void update(const byte[], u32bit) = 0;
virtual SecureVector<byte> raw_data() = 0;
virtual SecureVector<byte> encoding_of(const MemoryRegion<byte>&,
u32bit,
RandomNumberGenerator& rng) = 0;
virtual bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
u32bit) throw() = 0;
virtual ~EMSA() {}
};
}
#endif

View File

@@ -1,41 +0,0 @@
/*
* EMSA1
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EMSA1_H__
#define BOTAN_EMSA1_H__
#include <botan/emsa.h>
#include <botan/hash.h>
namespace Botan {
/*
* EMSA1
*/
class BOTAN_DLL EMSA1 : public EMSA
{
public:
EMSA1(HashFunction* h) : hash(h) {}
~EMSA1() { delete hash; }
protected:
const HashFunction* hash_ptr() const { return hash; }
private:
void update(const byte[], u32bit);
SecureVector<byte> raw_data();
SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
u32bit) throw();
HashFunction* hash;
};
}
#endif

View File

@@ -1,32 +0,0 @@
/*
* EMSA1 BSI Variant
* (C) 1999-2008 Jack Lloyd
* 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EMSA1_BSI_H__
#define BOTAN_EMSA1_BSI_H__
#include <botan/emsa1.h>
namespace Botan {
/**
EMSA1_BSI is a variant of EMSA1 specified by the BSI. It accepts only
hash values which are less or equal than the maximum key length. The
implementation comes from InSiTo
*/
class BOTAN_DLL EMSA1_BSI : public EMSA1
{
public:
EMSA1_BSI(HashFunction* hash) : EMSA1(hash) {}
private:
SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator& rng);
};
}
#endif

View File

@@ -1,41 +0,0 @@
/*
* EMSA2
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EMSA2_H__
#define BOTAN_EMSA2_H__
#include <botan/emsa.h>
#include <botan/hash.h>
namespace Botan {
/*
* EMSA2
*/
class BOTAN_DLL EMSA2 : public EMSA
{
public:
EMSA2(HashFunction* hash);
~EMSA2() { delete hash; }
private:
void update(const byte[], u32bit);
SecureVector<byte> raw_data();
SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
u32bit) throw();
SecureVector<byte> empty_hash;
HashFunction* hash;
byte hash_id;
};
}
#endif

View File

@@ -1,65 +0,0 @@
/*
* EMSA3 and EMSA3_Raw
* (C) 1999-2008 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EMSA3_H__
#define BOTAN_EMSA3_H__
#include <botan/emsa.h>
#include <botan/hash.h>
namespace Botan {
/**
* EMSA3
* aka PKCS #1 v1.5 signature padding
* aka PKCS #1 block type 1
*/
class BOTAN_DLL EMSA3 : public EMSA
{
public:
EMSA3(HashFunction*);
~EMSA3();
void update(const byte[], u32bit);
SecureVector<byte> raw_data();
SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
u32bit) throw();
private:
HashFunction* hash;
SecureVector<byte> hash_id;
};
/**
* EMSA3_Raw which is EMSA3 without a hash or digest id (which
* according to QCA docs is "identical to PKCS#11's CKM_RSA_PKCS
* mechanism", something I have not confirmed)
*/
class BOTAN_DLL EMSA3_Raw : public EMSA
{
public:
void update(const byte[], u32bit);
SecureVector<byte> raw_data();
SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
u32bit) throw();
private:
SecureVector<byte> message;
};
}
#endif

View File

@@ -1,43 +0,0 @@
/*
* EMSA4
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_EMSA4_H__
#define BOTAN_EMSA4_H__
#include <botan/emsa.h>
#include <botan/hash.h>
#include <botan/kdf.h>
namespace Botan {
/*
* EMSA4
*/
class BOTAN_DLL EMSA4 : public EMSA
{
public:
EMSA4(HashFunction*);
EMSA4(HashFunction*, u32bit);
~EMSA4() { delete hash; delete mgf; }
private:
void update(const byte[], u32bit);
SecureVector<byte> raw_data();
SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
u32bit) throw();
u32bit SALT_SIZE;
HashFunction* hash;
const MGF* mgf;
};
}
#endif

Some files were not shown because too many files have changed in this diff Show More