The unified diff between revisions [fd68181d..] and [749fac9e..] is displayed below. It can also be downloaded as a raw diff.
#
#
# delete "doc/porting.txt"
#
# delete "include/es_file.h"
#
# delete "misc/botan.rc"
#
# delete "src/es_file.cpp"
#
# delete "src/inifile.cpp"
#
# add_dir "modules/es_dev"
#
# add_file "modules/es_dev/es_dev.cpp"
# content [903d37082b372d65135f66cb43f5cfe84f5a930f]
#
# add_file "modules/es_dev/es_dev.h"
# content [a733463b4efc81e44fa058cc9f496ae6235e0ad2]
#
# add_file "modules/es_dev/modinfo.txt"
# content [b25166d29b5afeb56586f6ae759ed944f6874256]
#
# patch ".mtn-ignore"
# from [e7f8cbb7659be886a26ef6621a3605f815ce1606]
# to [b2ab2a341f6e74b13af6591ca9c419592e3c1fe9]
#
# patch "checks/algos.cpp"
# from [99cdd8b6e21dbd9160fe5235e95c5a65e2c69b6b]
# to [e7835fc1b1698ad0663717e6558acfc43e0619d2]
#
# patch "checks/bench.cpp"
# from [380f38c3230ff1cc3599246b0c9152d77994f7a6]
# to [c6edf6ea5b86de31a9297b8c4a38e20b00b17569]
#
# patch "checks/check.cpp"
# from [77665d2d9e2a8b662ea028908d8f1b9a577609ff]
# to [8bfeb47c287bea56e3b4543a034b486664a0d60d]
#
# patch "checks/pk_bench.cpp"
# from [7127408e364db54d1dd15f5d911a96f6588f6cd8]
# to [7f9fc9df119702295302015c6542cbd94e44af2d]
#
# patch "configure.pl"
# from [cf36452cc084060385a8db0e376310fe3958e80b]
# to [512f2fd264bf2dc513c0a70b1413a7043c1f3dcb]
#
# patch "doc/api.tex"
# from [cb1e40121b562d97258d9aba065c5cb5f58bfb3c]
# to [2ff20035b5a43d5549e664daf89a4ad837ebef2a]
#
# patch "doc/building.tex"
# from [5ffcd552ad48605b03a6dbe526ac39d85451c6e4]
# to [93619b803ba091c08e1638e59a70bee267ecfde7]
#
# patch "doc/logs/log-17.txt"
# from [84160a4ac4d5f5263cb455fde8e8c8d562008aab]
# to [d08c4cbe679ff172e8d046a014597ed15236ce56]
#
# patch "include/allocate.h"
# from [532035d3cdec5a2c8fd3250f87a78fa7f3d77eb4]
# to [acaf4aa6a1213de0c71b128d79d4760cdb3159b3]
#
# patch "include/bit_ops.h"
# from [08ec67df33c30f4e2a9b87675d142f30afccf5f5]
# to [ace888ad7c2755ca077461722e24cb1a422a2ed5]
#
# patch "include/defalloc.h"
# from [ef3958943a473c5a5068dbf77eae02e7cafa55fa]
# to [e7507091a397628e401de0bd41be48bbbf929ff9]
#
# patch "include/idea.h"
# from [d7276b98289143c01e8cee8c693ba8f7b441f44c]
# to [6628f852d9edb773c8e06a3322a35923b09b70f4]
#
# patch "include/init.h"
# from [4e6621c7bdf9dd3e309d28456d06cafaebf16029]
# to [1844022acd8847f03728c907a4d390b7114af216]
#
# patch "misc/config/arch/alpha"
# from [eb4385b12908208ea2f42b048c8401e5a029e734]
# to [3ddceecf33d3c312c6e88ff806473f0a3312d8af]
#
# patch "misc/config/arch/ia32"
# from [9b9f5f5f014d8e983c6fec7c043d15b4f3826caf]
# to [37777964e179c7f27e0ce9f2d58284dabe5cfadf]
#
# patch "misc/config/cc/bcc"
# from [ee7774c89526db32c71edec4b46e39c618b9e636]
# to [561513b32f972726cc0e9a83213e33debef2f95f]
#
# patch "misc/config/cc/compaq"
# from [0d19d1445db032754b13b5a92aaf79f161168ed7]
# to [5b855b2566a3778a208de0f3950299bf71c60b08]
#
# patch "misc/config/cc/ekopath"
# from [54df4f6c355b56ff537db7e429024428da3a6300]
# to [5e065967f6749183e09a69826d804c12c67ce362]
#
# patch "misc/config/cc/gcc"
# from [8f5871a7933c06c3db66c6ae748acedc28de85a9]
# to [f57864620e4b61197536ad20ab5f07f44811245a]
#
# patch "misc/config/cc/hpcc"
# from [0f6eb059dec345100593082d9fb744ae42f0e9dd]
# to [fe395425b4097070162a67b827d43ecfb392287e]
#
# patch "misc/config/cc/icc"
# from [df7c425f180f6d8f159eccd5b5cda87ae79b20f4]
# to [7f8af2a729b9a249412a5f392b68708d760e15cf]
#
# patch "misc/config/cc/kai"
# from [9436c4c4dd6486c6982dd86e091830900ace9d56]
# to [61a0afad96346a53d75843a0e3c775e263365885]
#
# patch "misc/config/cc/mipspro"
# from [c568b9c5fa321db7de3045e21c86bdaaad913c8c]
# to [83a382a4c5c89c79124aaa5fea9543b9934a61e9]
#
# patch "misc/config/cc/msvc"
# from [a518e200b92423fc58f0c78eafea50e4395799e2]
# to [f0fcdde68fcd833622fcb77df697118fd84bf3ff]
#
# patch "misc/config/cc/pgi"
# from [55504c4febd8030685b52c149e4ca76cea0bb29d]
# to [35dc70b946b7aa83deb8bf26560fa8ca40680c6e]
#
# patch "misc/config/cc/sgipro64"
# from [66a21eb000bff03771e5e0b1bbf0fdc910e5b195]
# to [564ca86eb93141bee356b540e38aff20570ee977]
#
# patch "misc/config/cc/sunwspro"
# from [9720af2d645f294070c78d697d6d872135ebc71c]
# to [bdb44bb25abc0086d1c78c0b2efed958e614f8b6]
#
# patch "misc/config/os/aix"
# from [564e370d3fca850949786c8b3cd8a359c3db54cc]
# to [1ae489a4423d56d58cdfa6a2c3ec5c52a8e044f4]
#
# patch "misc/config/os/beos"
# from [a0090a5297ed96bdd71318721022e3dc9f454c6e]
# to [1bb820a522401f7aaa56bead761b6e6c29fa9626]
#
# patch "misc/config/os/cygwin"
# from [b98e7c0405f1497345e71ba2fe37dc1c596dcda6]
# to [da74ebac5f9ddd009c73255200998cb25295e830]
#
# patch "misc/config/os/freebsd"
# from [006ab197d32eea63361257fe1d9dcc639fd44313]
# to [d7d4d7710c19332222b65f041853c5fb10617259]
#
# patch "misc/config/os/hpux"
# from [49b209ede76c5c055c200c68b27ac3facd3eff31]
# to [3259c76e44c088eb2c46c104e4628fde63841e8f]
#
# patch "misc/config/os/irix"
# from [a62b658f50c62adf9830785f5443137430a4b66c]
# to [cc8d00e11363d56828dd5b1084ff3af9e9bb76fd]
#
# patch "misc/config/os/linux"
# from [ac26a526ad7af05b54d08a5383b3219e4e7d8629]
# to [566c9d6827c1ea19baabb82d547a6231d18fca45]
#
# patch "misc/config/os/netbsd"
# from [ac1a9307aec68c1ac997893105649bd7fc687eb1]
# to [c09645e6aab081667e61307d0536b0adc15186b9]
#
# patch "misc/config/os/openbsd"
# from [0d2465d745a65c18bc10321b0d74d3f3c19f2411]
# to [d1cf34508f82296b77ac1c05a2b8e4ec0e9ef8f7]
#
# patch "misc/config/os/qnx"
# from [e3aacf5eb51a9636a43d5da7e430ae88ae736fba]
# to [7a8fa58bccdf45e7aacadf9c48ba2c21c75af46e]
#
# patch "misc/config/os/solaris"
# from [25977d770ed58bd5d262aae613cca6f0aadeb419]
# to [42ccff72aea7d428a33b639eda96e613cc4c33ea]
#
# patch "misc/config/os/tru64"
# from [614b02f2934db3f90258879dcc57514f151a0e7b]
# to [c9f88ca6171640c19f649b8ce5f0b5a44c6f2a02]
#
# patch "misc/config/os/windows"
# from [de615c9122334f20e2671a5994988e33a3391d1f]
# to [e36531bad64840b7551ca36b03f8063fa24155ff]
#
# patch "modules/alg_amd64/modinfo.txt"
# from [0a765bd257f37a2959ec10d20a9299beffb737ae]
# to [52b990d379b77248d5ea65ed9b09df88ead61c54]
#
# patch "modules/alg_ia32/modinfo.txt"
# from [99d0df3d5eb6c0b2cfbc26f79da54a6c6f0ca9ab]
# to [a30d4e1a048c23d047d2d3ef64f5943d44e98c36]
#
# patch "modules/alloc_mmap/mmap_mem.cpp"
# from [19ff049ea80042cf62e1f02ede47004f3acf048a]
# to [90dffa50c3f59b20772e0379feb38610a4bd0441]
#
# patch "modules/alloc_mmap/modinfo.txt"
# from [d36d112666314144a5aa817fc24738e9aea91a8a]
# to [13c7ed238e98cfb2cee3234a0ccb669b882f998f]
#
# patch "modules/comp_bzip2/modinfo.txt"
# from [85bf9ca722bf07022effa03bfb357136e4c56cfa]
# to [2b56ddd0377539a229214eafdc69ae60b5dd6b0b]
#
# patch "modules/comp_zlib/modinfo.txt"
# from [5f5620f37503b158951092000b1b72dc1b3b7d82]
# to [104016f30a3f87aac823196c70ba7ef61b2739ca]
#
# patch "modules/comp_zlib/zlib.cpp"
# from [9d1bffb2c1a97d0a748728fc71149915b800626d]
# to [97d5fe2639e150906b8ed7beedf13174ea1be78c]
#
# patch "modules/eng_aep/modinfo.txt"
# from [c6c85c43e35cb4f019eeeeb055ddb5eb9dc83748]
# to [5c9e56bd0a4331c14d9f960fe16c33c6c4f5a141]
#
# patch "modules/eng_gmp/modinfo.txt"
# from [11311582ba7dfe4746dff64496b75b369eec97bf]
# to [fad564f7f180df6bb1f62e58a6d7d1468e27c7b0]
#
# patch "modules/eng_ossl/modinfo.txt"
# from [8f79388a72fdf29e9395edcc8e997efda201d79d]
# to [2b5cf08954ca898aab69f10d95b5ec908d3d97e8]
#
# patch "modules/es_beos/modinfo.txt"
# from [d0a5ef440b6013c1f82e6a39031c78f30e3fadd6]
# to [139290a57dfa41e67206141d01fcc3ddda29b852]
#
# patch "modules/es_capi/modinfo.txt"
# from [a467873f02e52e8e4ba8a88e67fb2c388fc4bfad]
# to [30e09336bd70f66edfc3953f72f0cae2e2d50991]
#
# patch "modules/es_egd/es_egd.cpp"
# from [7636a043d9df901b8cae558e1f1adc50255ece14]
# to [e68c9f084c8c7b175f347363a848824f718fd19e]
#
# patch "modules/es_egd/modinfo.txt"
# from [849799afc6c979db47632b1e12674feea8433633]
# to [11617d320ffae85830cfc628f3cd34be3a4d7b0a]
#
# patch "modules/es_ftw/es_ftw.cpp"
# from [6b9dc7cec896eed27ff456d7a2e4df9947eae598]
# to [459d8f0d2ed22f05bf43a2fc5071457e7621448c]
#
# patch "modules/es_ftw/modinfo.txt"
# from [e768aa15a419357a4b137e2ef3ee65b4b376efdc]
# to [6027bf33c4f6c5bcf85d3e18bb38cd00b70c4a29]
#
# patch "modules/es_unix/es_unix.cpp"
# from [77f32afff1d4a4516229483b7702c1ae1a65e3ff]
# to [c38a7e079734811eb5804cae88ce3551a60f0067]
#
# patch "modules/es_unix/modinfo.txt"
# from [fa9c67a4f4768aa0c066a9cab02c01ef02695b66]
# to [699f5e83d950612894d82a31d9440fcfd05ea41d]
#
# patch "modules/es_unix/unix_cmd.cpp"
# from [e749e0619b750a2faf429dcd44fc030f344fd280]
# to [dfc8ffbdea62adae0385bc25265132e96e865c34]
#
# patch "modules/es_win32/modinfo.txt"
# from [ab32f74ac8c68e0eba7b05565cf76ccfae391301]
# to [e04adc51c45928e40c22e2a9f696386a22aa0f17]
#
# patch "modules/fd_unix/modinfo.txt"
# from [cbc5342abbb086f96ee060c793b2aa2c26c8db88]
# to [139ba101ce429c741662e9c43545ee12cde1ec1b]
#
# patch "modules/ml_unix/modinfo.txt"
# from [bf6269c374008bd70e0e70b38e141d608a7348b1]
# to [97b3645bcf1f98fe2122cfb91357872b14890064]
#
# patch "modules/ml_win32/modinfo.txt"
# from [a587dfdb9f3e79f0a74b69278520b7c680bacf16]
# to [51cbfd07cbf5885d98ebb7a94e7d8f9f6b59b216]
#
# patch "modules/mp_amd64/modinfo.txt"
# from [707b42d89ee327711973f147e8583142ff52e873]
# to [87de4b21f1135e6abd902535db56d18747715701]
#
# patch "modules/mp_asm64/modinfo.txt"
# from [b986042b6363c26bff5f6deafdb72136771c2ad5]
# to [1388f106d1f50c1cffa8696dd0f6a70df1c10a26]
#
# patch "modules/mp_asm64/mp_asm.h"
# from [4a273756476f9e614222f5dc4c1861945fa93901]
# to [07cf111ba199cc23b30c65dd3501a7057bb74656]
#
# patch "modules/mp_ia32/modinfo.txt"
# from [d40d210e8f58f97f7f5ededc3ec2d2087d2a326a]
# to [c32d998bb81224cc6f23fbd747abc427b6f67116]
#
# patch "modules/mux_pthr/modinfo.txt"
# from [0306778b14500cd26b308c4ece786d4c090046f1]
# to [fc682dca25479dbea473bfe1c767bbd962711f68]
#
# patch "modules/mux_qt/modinfo.txt"
# from [7a2d33867e046517ab5abbac000f20112a8b9079]
# to [1ce02e3c791aac207a7c9d85c518608141e6ea04]
#
# patch "modules/mux_win32/modinfo.txt"
# from [0f8259741903003ddee76b57fa3eb910ad7cd337]
# to [02e107ddb2b2200962178661759102e32ced9e69]
#
# patch "modules/tm_hard/modinfo.txt"
# from [34ed0938a058deec122cda1dcb6011362b896f89]
# to [6fb2b3c80e52cbd5158ad153a8ba1d41137ed936]
#
# patch "modules/tm_posix/modinfo.txt"
# from [31f8fdc8ad4d300118857e941ba9e10a54847456]
# to [ed4eddd6b042f1d473fe5896e36ca6619ca46334]
#
# patch "modules/tm_posix/tm_posix.cpp"
# from [18d0dc1baba7dc1fbbbf5686a651aa123d1c8c14]
# to [c42545cf0bf6ff897e22295ea485c33e8634d075]
#
# patch "modules/tm_unix/modinfo.txt"
# from [b5b5e69895fd4a5f9f7a7ccdc1b8dc12e93c2e49]
# to [1a4d1b4ea18d427b03ea220b333aa4af33a656c1]
#
# patch "modules/tm_unix/tm_unix.cpp"
# from [005a4faecc3b417e3b79afe00b62256bc9492cf0]
# to [1d0040253a1a3ce883428ae5b7c7f474704f6e8a]
#
# patch "modules/tm_win32/modinfo.txt"
# from [1767c2035911b3d660e62b9d5d46f6a6021f7582]
# to [39ec6dc93fc111aa33b9005f3f4bd770f5811887]
#
# patch "readme.txt"
# from [3e7dc82c42649ddd1304614574f8db74df4993b4]
# to [5e6b8aa6aeb04399becb0471bd99de82affa5ef1]
#
# patch "src/bit_ops.cpp"
# from [431a6fceac64ded07ed5564ff63016ca0b6060d9]
# to [ebab53284a6ab9a749188fcbe417c8dcc73ac052]
#
# patch "src/defalloc.cpp"
# from [940db8ef03ae170341d257f9f7e4320ee3938935]
# to [e51a9fe4f6a6e191818c3e968213cc58e98cc6c2]
#
# patch "src/idea.cpp"
# from [7e5d3dac233471b90ef036c4e65632f321018df6]
# to [fc756e94b7f74c3f6acf7f776a8d3e6a0ca60637]
#
# patch "src/init_opt.cpp"
# from [b66c0ecf18aa8f66a11ffbef319395e5323c69ea]
# to [9a0e31808f088cb63f2ec8563d937a69421f795f]
#
# patch "src/libstate.cpp"
# from [5f372a92af4809198b85214da9c873e97ec3cb8c]
# to [4cc7325e854efc2351e4f1e0726092e5d8fb760f]
#
# patch "src/modules.cpp"
# from [310f410a77f14f2b559a24a0a00821880205b6c8]
# to [d5fbabe263e5a39b8a85adf8a5084ec28405ee64]
#
# patch "src/mp_mul.cpp"
# from [dafb1262e69f06c17fe781aea9c7ed04ef789829]
# to [4801f41f564dbaf9a3a0bacb03ad795f94c4a27b]
#
# patch "src/policy.cpp"
# from [d5d94c0e82c5d91e4827ccb42b55b43c178217d7]
# to [1cbaa37581f2e3a3cc3388766eb0f57f92c16a92]
#
# patch "src/randpool.cpp"
# from [279e898147d23a9134964dae4edc36e4a475eb18]
# to [cf40501448e5f6f3bcaa3d00b43dd3cc33c39170]
#
# patch "src/turing.cpp"
# from [e7d74e2e4657776508c3893aefcbee9180116384]
# to [5155dad33304df10b9b61e7103c611eba62a4c0d]
#
============================================================
--- modules/es_dev/es_dev.cpp 903d37082b372d65135f66cb43f5cfe84f5a930f
+++ modules/es_dev/es_dev.cpp 903d37082b372d65135f66cb43f5cfe84f5a930f
@@ -0,0 +1,118 @@
+/*************************************************
+* Device EntropySource Source File *
+* (C) 1999-2007 The Botan Project *
+*************************************************/
+
+#include <botan/es_dev.h>
+#include <botan/config.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+
+namespace Botan {
+
+namespace {
+
+/*************************************************
+* A class handling reading from a device *
+*************************************************/
+class Device_Reader
+ {
+ public:
+ typedef int fd_type;
+
+ Device_Reader(fd_type device_fd) : fd(device_fd) {}
+ ~Device_Reader() { ::close(fd); }
+ u32bit get(byte out[], u32bit length);
+
+ static fd_type open(const std::string& pathname);
+ private:
+ fd_type fd;
+ };
+
+/*************************************************
+* Read from a device file *
+*************************************************/
+u32bit Device_Reader::get(byte out[], u32bit length)
+ {
+ if(fd < 0)
+ return 0;
+
+ if(fd >= FD_SETSIZE)
+ return 0;
+
+ const u32bit READ_WAIT_MS = 10;
+
+ fd_set read_set;
+ FD_ZERO(&read_set);
+ FD_SET(fd, &read_set);
+
+ struct ::timeval timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = READ_WAIT_MS * 1000;
+
+ if(::select(fd + 1, &read_set, 0, 0, &timeout) < 0)
+ return 0;
+
+ if(!(FD_ISSET(fd, &read_set)))
+ return 0;
+
+ const ssize_t got = ::read(fd, out, length);
+ if(got <= 0)
+ return 0;
+
+ const u32bit ret = static_cast<u32bit>(got);
+
+ if(ret > length)
+ return 0;
+
+ return ret;
+ }
+
+/*************************************************
+* Attempt to open a device *
+*************************************************/
+int Device_Reader::open(const std::string& pathname)
+ {
+#ifndef O_NONBLOCK
+ #define O_NONBLOCK 0
+#endif
+
+#ifndef O_NOCTTY
+ #define O_NOCTTY 0
+#endif
+
+ const int flags = O_RDONLY | O_NONBLOCK | O_NOCTTY;
+ return ::open(pathname.c_str(), flags);
+ }
+
+}
+
+/*************************************************
+* Gather entropy from a RNG device *
+*************************************************/
+u32bit Device_EntropySource::slow_poll(byte output[], u32bit length)
+ {
+ std::vector<std::string> sources =
+ global_config().option_as_list("rng/es_files");
+
+ u32bit read = 0;
+
+ for(size_t j = 0; j != sources.size(); ++j)
+ {
+ const std::string source = sources[j];
+
+ Device_Reader reader(Device_Reader::open(source));
+
+ read += reader.get(output + read, length - read);
+
+ if(read == length)
+ break;
+ }
+
+ return read;
+ }
+
+}
============================================================
--- modules/es_dev/es_dev.h a733463b4efc81e44fa058cc9f496ae6235e0ad2
+++ modules/es_dev/es_dev.h a733463b4efc81e44fa058cc9f496ae6235e0ad2
@@ -0,0 +1,24 @@
+/*************************************************
+* Device EntropySource Header File *
+* (C) 1999-2007 The Botan Project *
+*************************************************/
+
+#ifndef BOTAN_ENTROPY_SRC_DEVICE_H__
+#define BOTAN_ENTROPY_SRC_DEVICE_H__
+
+#include <botan/base.h>
+
+namespace Botan {
+
+/*************************************************
+* Device Based Entropy Source *
+*************************************************/
+class Device_EntropySource : public EntropySource
+ {
+ public:
+ u32bit slow_poll(byte[], u32bit);
+ };
+
+}
+
+#endif
============================================================
--- modules/es_dev/modinfo.txt b25166d29b5afeb56586f6ae759ed944f6874256
+++ modules/es_dev/modinfo.txt b25166d29b5afeb56586f6ae759ed944f6874256
@@ -0,0 +1,11 @@
+realname "RNG Device Reader"
+
+define ENTROPY_SRC_DEVICE
+
+load_on auto
+modset unix
+
+<add>
+es_dev.h
+es_dev.cpp
+</add>
============================================================
--- .mtn-ignore e7f8cbb7659be886a26ef6621a3605f815ce1606
+++ .mtn-ignore b2ab2a341f6e74b13af6591ca9c419592e3c1fe9
@@ -1,13 +1,14 @@
-^check$
^Makefile$
^botan-config$
^build$
+^build/build\.h$
^build/checks$
+^build/checks/.*\.o$
^build/include$
^build/include/botan$
+^build/include/botan/.*\.h$
^build/lib$
^build/lib/.*\.o$
-^build/checks/.*\.o$
-^build/include/botan/.*\.h$
-^build/build\.h$
+^check$
+^doc/examples/.*\.pem$
^misc/nist_tests/x509test$
============================================================
--- checks/algos.cpp 99cdd8b6e21dbd9160fe5235e95c5a65e2c69b6b
+++ checks/algos.cpp e7835fc1b1698ad0663717e6558acfc43e0619d2
@@ -84,5 +84,8 @@ std::vector<algorithm> get_algos()
algos.push_back(algorithm("RNG", "Randpool"));
algos.push_back(algorithm("RNG", "X9.31-RNG"));
+ algos.push_back(algorithm("Codec", "Base64_Encode"));
+ algos.push_back(algorithm("Codec", "Base64_Decode"));
+
return algos;
}
============================================================
--- checks/bench.cpp 380f38c3230ff1cc3599246b0c9152d77994f7a6
+++ checks/bench.cpp c6edf6ea5b86de31a9297b8c4a38e20b00b17569
@@ -35,7 +35,7 @@ double bench_filter(std::string name, Bo
u32bit iterations = 0;
u64bit start = get_clock(), clocks_used = 0;
- u64bit go_up_to = (u64bit)(seconds * get_ticks());
+ u64bit go_up_to = static_cast<u64bit>(seconds * get_ticks());
while(clocks_used < go_up_to)
{
@@ -44,8 +44,8 @@ double bench_filter(std::string name, Bo
clocks_used = get_clock() - start;
}
- double bytes_per_sec = ((double)iterations * BUFFERSIZE) /
- ((double)clocks_used / get_ticks());
+ double bytes_per_sec = (static_cast<double>(iterations) * BUFFERSIZE) /
+ (static_cast<double>(clocks_used) / get_ticks());
double mbytes_per_sec = bytes_per_sec / (1024.0 * 1024.0);
std::cout.setf(std::ios::fixed, std::ios::floatfield);
@@ -121,7 +121,7 @@ void benchmark(const std::string& what,
if(html)
std::cout << "</TABLE>\n\n";
- double average = std::exp(sum / (double)how_many);
+ double average = std::exp(sum / static_cast<double>(how_many));
if(what == "All" && html)
std::cout << "\n<P>Overall speed average: " << average
============================================================
--- checks/check.cpp 77665d2d9e2a8b662ea028908d8f1b9a577609ff
+++ checks/check.cpp 8bfeb47c287bea56e3b4543a034b486664a0d60d
@@ -47,7 +47,7 @@ int main(int argc, char* argv[])
<< " --validate: Check test vectors\n"
<< " --benchmark: Benchmark everything\n"
<< " --bench-type={block,mode,stream,hash,mac,rng,pk}:\n"
- << " Benchmark only algorithms of a particular type\n"
+ << " Benchmark only algorithms of a particular type\n"
<< " --html: Produce HTML output for benchmarks\n"
<< " --seconds=n: Benchmark for n seconds\n"
<< " --init=<str>: Pass <str> to the library\n"
============================================================
--- checks/pk_bench.cpp 7127408e364db54d1dd15f5d911a96f6588f6cd8
+++ checks/pk_bench.cpp 7f9fc9df119702295302015c6542cbd94e44af2d
@@ -9,8 +9,6 @@
#include <botan/look_pk.h>
#include <botan/rng.h>
-#include <botan/parsing.h>
-
using namespace Botan;
#include "common.h"
@@ -55,6 +53,7 @@ void bench_pk(const std::string& algo, b
ad-hoc format (the RW algorithm has no assigned OID that I know of, so
there is no way to encode a RW key into a PKCS #8 structure).
*/
+ try {
if(algo == "All" || algo == "RSA")
{
@@ -178,11 +177,10 @@ void print_result(bool html, u32bit runs
void print_result(bool html, u32bit runs, u64bit clocks_used,
const std::string& algo_name, const std::string& op)
{
- double seconds = (double)clocks_used / get_ticks();
+ double seconds = static_cast<double>(clocks_used) / get_ticks();
double mseconds_per_run = 1000 * (seconds / runs);
double runs_per_sec = runs / seconds;
-
if(html)
{
std::cout << " <TR><TH>" << algo_name << " (" << op << ") <TH>";
============================================================
--- configure.pl cf36452cc084060385a8db0e376310fe3958e80b
+++ configure.pl 512f2fd264bf2dc513c0a70b1413a7043c1f3dcb
@@ -9,7 +9,7 @@ my $MINOR_VERSION = 7;
my $MAJOR_VERSION = 1;
my $MINOR_VERSION = 7;
-my $PATCH_VERSION = 2;
+my $PATCH_VERSION = 3;
my $VERSION_STRING = "$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION";
@@ -24,19 +24,13 @@ my @DOCS = (
'credits.txt', 'info.txt', 'license.txt', 'log.txt',
'thanks.txt', 'todo.txt', 'pgpkeys.asc');
-my %MODULE_SETS =
- (
- 'unix' => [ 'alloc_mmap', 'es_egd', 'es_ftw', 'es_unix', 'fd_unix',
- 'tm_unix' ],
- 'beos' => [ 'es_beos', 'es_unix', 'fd_unix', 'tm_unix' ],
- 'win32' => ['es_capi', 'es_win32', 'mux_win32', 'tm_win32' ],
- );
-
my $TRACING = 0;
##################################################
# Run main() and Quit #
##################################################
+my $config = {};
+
main();
exit;
@@ -44,8 +38,6 @@ sub main {
# Main Driver #
##################################################
sub main {
- my $config = {};
-
my $base_dir = where_am_i();
$$config{'base-dir'} = $base_dir;
@@ -68,7 +60,7 @@ sub main {
'version' => $VERSION_STRING,
});
- my ($target, $module_list) = get_options($config);
+ get_options($config);
my $default_value_is = sub {
my ($var, $val) = @_;
@@ -82,8 +74,10 @@ sub main {
&$default_value_is('local_config', '');
if(defined($$config{'build-dir'})) {
- $$config{'botan-config'} = File::Spec->catfile($$config{'build-dir'}, 'botan-config');
- $$config{'makefile'} = File::Spec->catfile($$config{'build-dir'}, 'Makefile');
+ $$config{'botan-config'} =
+ File::Spec->catfile($$config{'build-dir'}, 'botan-config');
+ $$config{'makefile'} =
+ File::Spec->catfile($$config{'build-dir'}, 'Makefile');
$$config{'check_prefix'} = $$config{'build-dir'};
$$config{'lib_prefix'} = $$config{'build-dir'};
}
@@ -95,7 +89,7 @@ sub main {
$$config{'lib_prefix'} = '';
}
- choose_target($config, $target);
+ choose_target($config);
my $os = $$config{'os'};
my $cc = $$config{'compiler'};
@@ -105,7 +99,7 @@ sub main {
&$default_value_is('docdir', os_info_for($os, 'doc_dir'));
&$default_value_is('make_style', $COMPILER{$cc}{'makefile_style'});
- my @modules = choose_modules($config, $module_list);
+ autoload_modules($config) if($$config{'autoconfig'});
add_to($config, {
'includedir' => os_info_for($os, 'header_dir'),
@@ -117,9 +111,8 @@ sub main {
'build_include_botan' =>
File::Spec->catdir($$config{'build-dir'}, 'include', 'botan'),
- 'modules' => [ @modules ],
- 'mp_bits' => find_mp_bits(@modules),
- 'mod_libs' => [ using_libs($os, @modules) ],
+ 'mp_bits' => find_mp_bits(sort keys %{$$config{'modules'}}),
+ 'mod_libs' => [ using_libs($os, sort keys %{$$config{'modules'}}) ],
'sources' => {
map_to($$config{'src-dir'}, dir_list($$config{'src-dir'}))
@@ -138,10 +131,12 @@ sub main {
load_modules($config);
- mkdirs($$config{'build-dir'},
- $$config{'build_include'}, $$config{'build_include_botan'},
- $$config{'build_lib'}, $$config{'build_check'});
+ my @dirs = mkdirs($$config{'build-dir'},
+ $$config{'build_include'}, $$config{'build_include_botan'},
+ $$config{'build_lib'}, $$config{'build_check'});
+ #autoconfig('Created ' . join(' ', @dirs)) if @dirs;
+
write_pkg_config($config);
process_template(File::Spec->catfile($$config{'config-dir'}, 'buildh.in'),
@@ -180,11 +175,12 @@ sub warning {
}
sub warning {
- warn with_diagnostic('note', @_);
+ warn with_diagnostic('warning', @_);
}
sub autoconfig {
- print with_diagnostic('autoconfig', @_);
+ print with_diagnostic('autoconfig', @_)
+ if($$config{'verbose'});
}
sub emit_help {
@@ -207,74 +203,113 @@ sub display_help {
# Display Help and Quit #
##################################################
sub display_help {
- my $sets = join('|', sort keys %MODULE_SETS);
+ sub module_sets {
+ my %modsets;
+ for my $name (sort keys %MODULES) {
+ my %info = %{$MODULES{$name}};
+ next unless (defined($info{'modset'}));
- my $helptxt = <<ENDOFHELP;
-Usage: $0 [options] CC-OS-CPU
+ for my $s (split(/,/, $info{'modset'})) {
+ $modsets{$s} = undef;
+ }
+ }
-See doc/building.pdf for more information about this program.
+ return sort keys %modsets;
+ }
-Options:
+ my $sets = join(' ', module_sets());
+
+ my $listing = sub {
+ my (@list) = @_;
+
+ return '' if (@list == 0);
+
+ my ($output, $len) = ('', 0);
+
+ my $append = sub {
+ my ($to_append) = @_;
+ $output .= $to_append;
+ $len += length $to_append;
+ };
+
+ foreach my $name (sort @list) {
+ next if $name eq 'defaults';
+ if($len > 65) {
+ $output .= "\n ";
+ $len = 8;
+ }
+ &$append($name . ' ');
+ }
+ chop $output;
+ return $output;
+ };
+
+ my $modules = &$listing(keys %MODULES);
+ my $compilers = &$listing(keys %COMPILER);
+ my $oses = &$listing(keys %OPERATING_SYSTEM);
+ my $cpus = &$listing(keys %CPU);
+
+ my $helptxt = <<ENDOFHELP;
+
+Usage for $0 (Botan $VERSION_STRING):
+
+ --help display this help
+ --version display the version of Botan
+ --quiet display only warnings and errors
+ --trace enable tracing
+
+ To change where the library is installed:
+
--prefix=PATH: set the base installation directory
--libdir=PATH: install library files in \${prefix}/\${libdir}
--docdir=PATH: install documentation in \${prefix}/\${docdir}
+
+ To change build options:
+
--build-dir=DIR: setup the build in DIR
--local-config=FILE: include the contents of FILE into build.h
- --modules=MODS: add module(s) MODS to the library.
- --module-set=SET: add a pre-specified set of modules ($sets)
- --module-info: display some information about known modules
-
--debug: set compiler flags for debugging
- --disable-shared: disable building shared libararies
- --noauto: disable autoconfiguration
+ --no-asm: disable all modules that contain assembly code
+ --no-shared: don't build shared libararies
--make-style=STYLE: override the guess as to what type of makefile to use
-You may use 'generic' for OS or CPU (useful if your OS or CPU isn't listed).
+ To change what modules to use:
-CPU can be a generic family name or a specific model name. Common aliases are
-supported but not listed. Choosing a specific submodel will usually result in
-code that will not run on earlier versions of that architecture.
+ --modules=
+ [$modules]
-ENDOFHELP
+ To add a set of modules:
+ --module-set=[$sets]
- my $listing = sub {
- my ($header, @list) = @_;
+ --module-info: display more information about modules
+ --noauto: don't enable any modules unless specifically named
- return '' if (@list == 0);
+ Normally $0 will guess the right compiler, OS, and CPU.
+ To override it:
- my ($output, $len) = ('', 0);
+ --cc=[$compilers]
+ --os=[$oses generic]
+ --cpu=[$cpus generic]
- my $append = sub {
- my ($to_append) = @_;
- $output .= $to_append;
- $len += length $to_append;
- };
+ --endian=[little big none]
+ --unaligned-mem=[yes no]
- &$append($header . ': ');
+ For more information about support CPUs, use --arch-info:
- foreach my $name (sort @list) {
- next if $name eq 'defaults';
- if($len > 71) {
- $output .= "\n ";
- $len = 3;
- }
- &$append($name . ' ');
- }
- return $output . "\n";
- };
+ --arch-info=[$cpus]
- emit_help($helptxt,
- &$listing('CC', keys %COMPILER),
- &$listing('OS', keys %OPERATING_SYSTEM),
- &$listing('CPU', keys %CPU),
- &$listing('Modules', keys %MODULES));
+See doc/building.pdf for more information about this program.
+
+ENDOFHELP
+
+ emit_help($helptxt);
}
##################################################
# Display Further Information about Modules #
##################################################
-sub display_module_info {
+sub module_info {
my $info = '';
foreach my $mod (sort keys %MODULES) {
@@ -284,24 +319,26 @@ sub display_module_info {
while(length($mod) < 10) { $mod .= ' '; }
$info .= "$mod - $fullname\n";
}
- emit_help($info);
+
+ return $info;
}
##################################################
#
##################################################
sub choose_target {
- my ($config, $target) = @_;
+ my ($config) = @_;
- if($target eq '' and $$config{'autoconfig'}) {
- $target = guess_triple();
- autoconfig("Guessing your system config is $target");
- }
+ my $cc = $$config{'compiler'};
+ my $os = $$config{'os'};
+ my $cpu = $$config{'cpu'};
- my ($cc,$os,$submodel) = split(/-/,$target,3);
+ $cpu = guess_cpu() if not defined($cpu);
+ $cc = guess_compiler() if not defined($cc);
+ $os = guess_os() if not defined($os);
display_help()
- unless(defined($cc) and defined($os) and defined($submodel));
+ unless(defined($cc) and defined($os) and defined($cpu));
croak("Compiler $cc isn't known (try --help)")
unless defined($COMPILER{$cc});
@@ -312,20 +349,8 @@ sub choose_target {
croak("OS $os isn't known (try --help)") unless
($os eq 'generic' or defined($OPERATING_SYSTEM{$os}));
- my $arch = undef;
- ($arch, $submodel) = figure_out_arch($submodel);
+ my ($arch, $submodel) = figure_out_arch($cpu);
- croak(realname($os), " doesn't run on $arch ($submodel)")
- unless($arch eq 'generic' or $os eq 'generic' or
- in_array($arch, $OPERATING_SYSTEM{$os}{'arch'}));
-
- croak(realname($cc), " doesn't run on $arch ($submodel)")
- unless($arch eq 'generic' or
- (in_array($arch, $ccinfo{'arch'})));
-
- croak(realname($cc), " doesn't run on ", realname($os))
- unless($os eq 'generic' or (in_array($os, $ccinfo{'os'})));
-
# hacks
if($cc eq 'gcc') {
$ccinfo{'binary_name'} = 'c++' if($os eq 'darwin');
@@ -337,30 +362,29 @@ sub choose_target {
$gcc_version = '' if not defined $gcc_version;
- # Some versions of GCC are a little buggy dealing with
- # long long in C++. The last check is because on Cygwin
- # (at least for me) gcc_version doesn't get the output,
- # maybe something to do with the stderr redirection? If
- # it's Cygwin and we didn't get output, assume it's a
- # buggy GCC. There is no reduction in code quality so even
- # if we're wrong it's OK.
+ my $has_ll_bug = 0;
+ $has_ll_bug = 1 if($gcc_version =~ /4\.[0123]/);
+ $has_ll_bug = 1 if($gcc_version =~ /3\.[34]/);
+ $has_ll_bug = 1 if($gcc_version =~ /2\.25\.[0-4]/);
+ $has_ll_bug = 1 if($gcc_version eq '');
- if(($gcc_version =~ /4\.[01]/) || ($gcc_version =~ /3\.[34]/) ||
- ($gcc_version =~ /2\.95\.[0-4]/) ||
- ($gcc_version eq '' && $^O eq 'cygwin'))
+ $has_ll_bug = 0 if($arch eq 'alpha' or $arch =~ /.*64$/);
+
+ if($has_ll_bug)
{
warning('Enabling -fpermissive to work around ',
'possible GCC bug');
$$config{'gcc_bug'} = 1;
}
- if($gcc_version =~ /2\.95\.[0-4]/)
- {
- warning('GCC 2.95.x issues many spurious warnings');
- }
+
+ warning('GCC 2.95.x issues many spurious warnings')
+ if($gcc_version =~ /2\.95\.[0-4]/);
}
}
+ trace("using $cc $os $arch $submodel");
+
add_to($config, {
'compiler' => $cc,
'os' => $os,
@@ -369,31 +393,60 @@ sub choose_target {
});
}
-sub choose_modules {
- my ($config, $mod_str) = @_;
+# Add modules that we think would work (unless autoconfig is off)
+# to $$config{'modules'}
+sub autoload_modules {
+ my ($config) = @_;
- my @modules = grep { $_ ne '' } split(/,/, $mod_str);
+ my $cc = $$config{'compiler'};
+ my $os = $$config{'os'};
+ my $arch = $$config{'arch'};
+ my $submodel = $$config{'submodel'};
- if($$config{'autoconfig'})
- {
- foreach my $mod (guess_mods($config)) {
+ my $asm_ok = $$config{'asm_ok'};
- autoconfig("Enabling module $mod")
- unless in_array($mod, \@modules);
+ foreach my $mod (sort keys %MODULES) {
+ my %modinfo = %{ $MODULES{$mod} };
- push @modules, $mod;
+ if(defined($$config{'modules'}{$mod})) {
+ autoconfig("Module $mod - loading by user request");
+ next;
}
- }
- # Uniqify @modules
- my %uniqed_mods = map_to(undef, @modules);
- @modules = sort keys %uniqed_mods;
+ my @arch_list = @{ $modinfo{'arch'} };
+ if(scalar @arch_list > 0 &&
+ !in_array($arch, \@arch_list) &&
+ !in_array($submodel, \@arch_list)) {
+ autoconfig("Module $mod - won't use, " .
+ "doesn't run on CPU $arch/$submodel");
+ next;
+ }
- foreach (@modules) {
- croak("Module '$_' isn't known (try --help)")
- unless defined $MODULES{$_};
+ my @os_list = @{ $modinfo{'os'} };
+ if(scalar @os_list > 0 && !in_array($os, \@os_list)) {
+ autoconfig("Module $mod - won't use, not compatible with OS $os");
+ next;
+ }
+
+ my @cc_list = @{ $modinfo{'cc'} };
+ if(scalar @cc_list > 0 && !in_array($cc, \@cc_list)) {
+ autoconfig("Module $mod - won't use, not compatbile with CC $cc");
+ next;
+ }
+
+ if(!$asm_ok and $modinfo{'load_on'} eq 'asm_ok') {
+ autoconfig("Module $mod - won't use; avoiding due to use of --no-asm");
+ next;
+ }
+
+ if($modinfo{'load_on'} eq 'request') {
+ autoconfig("Module $mod - won't use, loaded by request only");
+ next;
+ }
+
+ autoconfig("Module $mod - autoloading");
+ $$config{'modules'}{$mod} = 1;
}
- return @modules;
}
sub get_options {
@@ -405,13 +458,88 @@ sub get_options {
$$config{$opt} = $val;
};
- my $module_set = '';
- my @modules;
+ $$config{'verbose'} = 1;
+ $$config{'asm_ok'} = 1;
+ $$config{'modules'} = {};
+
+ sub arch_info {
+ my $arg = $_[0];
+
+ my $arch = find_arch($arg);
+
+ unless(defined($arch) and defined($CPU{$arch})) {
+ warning("Unknown arch name '$arg' passed to --arch-info (try --help)");
+ return '';
+ }
+
+ my %info = %{ $CPU{$arch} };
+
+ my $out = "Information for $arg ($arch)\n--------\n";
+
+ if(@{$info{'aliases'}}) {
+ $out .= 'Aliases: ' . join(' ', @{$info{'aliases'}}) . "\n";
+ }
+
+ if(@{$info{'submodels'}}) {
+ $out .= 'Submodels: ' . join(' ', @{$info{'submodels'}}) . "\n";
+ }
+
+ foreach my $k (keys %{$info{'submodel_aliases'}}) {
+ $out .= "Alias '$k' -> '" . $info{'submodel_aliases'}{$k} . "'\n";
+ }
+
+ if(defined($info{'endian'})) {
+ $out .= 'Default endian: ' . $info{'endian'} . "\n";
+ }
+
+ if(defined($info{'unaligned'})) {
+ $out .= 'Unaligned memory access: ' . $info{'unaligned'} . "\n";
+ }
+
+ return $out;
+ }
+
+ sub add_modules {
+ my ($config,$mods) = @_;
+
+ foreach my $mod (split(/,/, $mods)) {
+ $$config{'modules'}{$mod} = 1;
+ }
+ }
+
+ sub add_module_sets {
+ my ($config,$sets) = @_;
+
+ foreach my $set (split(/,/, $sets)) {
+ for my $name (sort keys %MODULES) {
+ my %info = %{$MODULES{$name}};
+
+ next unless (defined($info{'modset'}));
+
+ for my $s (split(/,/, $info{'modset'})) {
+ if($s eq $set) {
+ $$config{'modules'}{$name} = 1;
+ }
+ }
+ }
+ }
+ }
+
exit 1 unless GetOptions(
'help' => sub { display_help(); },
- 'module-info' => sub { display_module_info(); },
+ 'module-info' => sub { emit_help(module_info()); },
'version' => sub { emit_help("Botan $VERSION_STRING\n") },
+ 'quiet' => sub { $$config{'verbose'} = 0; },
+
+ 'cc=s' => sub { &$save_option('compiler', $_[1]) },
+ 'os=s' => sub { &$save_option(@_) },
+ 'cpu=s' => sub { &$save_option(@_) },
+ 'endian=s' => sub { &$save_option(@_); },
+ 'unaligned-mem=s' => sub { &$save_option(@_); },
+
+ 'arch-info=s' => sub { emit_help(arch_info($_[1])); },
+
'prefix=s' => sub { &$save_option(@_); },
'docdir=s' => sub { &$save_option(@_); },
'libdir=s' => sub { &$save_option(@_); },
@@ -421,34 +549,50 @@ sub get_options {
'make-style=s' => sub { &$save_option(@_); },
- 'modules=s' => \@modules,
- 'module-set=s' => \$module_set,
+ 'module=s' => sub { add_modules($config, $_[1]); },
+ 'modules=s' => sub { add_modules($config, $_[1]); },
+ 'module-set=s' => sub { add_module_sets($config, $_[1]); },
+ 'module-sets=s' => sub { add_module_sets($config, $_[1]); },
'trace' => sub { $TRACING = 1; },
'debug' => sub { &$save_option($_[0], 1); },
- 'disable-shared' => sub { $$config{'shared'} = 'no'; },
+ 'no-shared' => sub { $$config{'shared'} = 'no'; },
+ 'no-asm' => sub { $$config{'asm_ok'} = 0; },
'noauto' => sub { $$config{'autoconfig'} = 0; },
'dumb-gcc|gcc295x' => sub { $$config{'gcc_bug'} = 1; }
);
- croak("Module set $module_set isn't known (try --help)")
- if($module_set && !defined($MODULE_SETS{$module_set}));
-
- if($module_set) {
- foreach (@{ $MODULE_SETS{$module_set} }) { push @modules,$_; }
- }
-
- my $mod_str = join(',', @modules);
-
- return ('', $mod_str) if($#ARGV == -1);
- return ($ARGV[0], $mod_str) if($#ARGV == 0);
- display_help();
+ # All arguments should now be consumed
+ croak("Unknown option $ARGV[0] (try --help)") unless($#ARGV == -1);
}
##################################################
# Functions to search the info tables #
##################################################
+sub find_arch {
+ my $name = $_[0];
+
+ foreach my $arch (keys %CPU) {
+ my %info = %{$CPU{$arch}};
+
+ return $arch if($name eq $arch);
+
+ foreach my $alias (@{$info{'aliases'}}) {
+ return $arch if($name eq $alias);
+ }
+
+ foreach my $submodel (@{$info{'submodels'}}) {
+ return $arch if($name eq $submodel);
+ }
+
+ foreach my $submodel (keys %{$info{'submodel_aliases'}}) {
+ return $arch if($name eq $submodel);
+ }
+ }
+ return undef;
+};
+
sub figure_out_arch {
my ($name) = @_;
@@ -473,30 +617,7 @@ sub figure_out_arch {
return '';
};
- my $find_arch = sub {
- my $name = $_[0];
-
- foreach my $arch (keys %CPU) {
- my %info = %{$CPU{$arch}};
-
- return $arch if($name eq $arch);
-
- foreach my $alias (@{$info{'aliases'}}) {
- return $arch if($name eq $alias);
- }
-
- foreach my $submodel (@{$info{'submodels'}}) {
- return $arch if($name eq $submodel);
- }
-
- foreach my $submodel (keys %{$info{'submodel_aliases'}}) {
- return $arch if($name eq $submodel);
- }
- }
- return undef;
- };
-
- my $arch = &$find_arch($name);
+ my $arch = find_arch($name);
croak("Arch type $name isn't known (try --help)") unless defined $arch;
trace("mapped name '$name' to arch '$arch'");
@@ -507,7 +628,7 @@ sub figure_out_arch {
if($submodel eq '') {
$submodel = $archinfo{'default_submodel'};
- warning("Using $submodel as default type for family ", realname($arch))
+ autoconfig("Using $submodel as default type for family ", realname($arch))
if($submodel ne $arch);
}
@@ -537,6 +658,8 @@ sub os_info_for {
sub os_info_for {
my ($os,$what) = @_;
+ die unless defined($os);
+
croak('os_info_for called with an os of defaults (internal problem)')
if($os eq 'defaults');
@@ -708,11 +831,15 @@ sub mkdirs {
sub mkdirs {
my (@dirs) = @_;
+
+ my @created;
foreach my $dir (@dirs) {
next if( -e $dir and -d $dir ); # skip it if it's already there
mkdir($dir, 0777) or
croak("Could not create directory $dir ($!)");
+ push @created, $dir;
}
+ return @created;
}
sub slurp_file {
@@ -813,9 +940,7 @@ sub load_modules {
sub load_modules {
my ($config) = @_;
- my @modules = @{$$config{'modules'}};
-
- foreach my $mod (@modules) {
+ foreach my $mod (sort keys %{$$config{'modules'}}) {
load_module($config, $mod);
}
@@ -828,9 +953,16 @@ sub load_modules {
my %cpu_info = %{$CPU{$arch}};
my $endian = $cpu_info{'endian'};
- $arch = uc $arch;
- $defines .= "#define BOTAN_TARGET_ARCH_IS_$arch\n";
+ if(defined($$config{'endian'})) {
+ $endian = $$config{'endian'};
+ $endian = undef unless($endian eq 'little' || $endian eq 'big');
+ }
+ elsif(defined($endian)) {
+ autoconfig("Since arch is $arch, assuming $endian endian mode");
+ }
+ $defines .= "#define BOTAN_TARGET_ARCH_IS_" . (uc $arch) . "\n";
+
my $submodel = $$config{'submodel'};
if($arch ne $submodel) {
$submodel = uc $submodel;
@@ -844,9 +976,25 @@ sub load_modules {
$endian = uc $endian;
$defines .= "#define BOTAN_TARGET_CPU_IS_${endian}_ENDIAN\n";
- if(defined($cpu_info{'unaligned'})
- and $cpu_info{'unaligned'} eq 'ok')
+ if(defined($$config{'unaligned_mem'})) {
+ my $spec = $$config{'unaligned_mem'};
+
+ if($spec eq 'yes') {
+ $unaligned_ok = 1;
+ }
+ elsif($spec eq 'no') {
+ $unaligned_ok = 0;
+ }
+ else {
+ warning("Unknown arg to --unaligned-mem '$spec', will ignore");
+ $unaligned_ok = 0;
+ }
+ }
+ elsif(defined($cpu_info{'unaligned'}) and
+ $cpu_info{'unaligned'} eq 'ok')
{
+ autoconfig("Since arch is $arch, " .
+ "assuming unaligned memory access is OK");
$unaligned_ok = 1;
}
}
@@ -856,7 +1004,7 @@ sub load_modules {
}
my @defarray;
- foreach my $mod (@modules) {
+ foreach my $mod (sort keys %{$$config{'modules'}}) {
my $defs = $MODULES{$mod}{'define'};
next unless $defs;
@@ -1134,21 +1282,20 @@ sub read_module_files {
##################################################
# #
##################################################
+
sub get_module_info {
my ($name, $file) = @_;
my $reader = make_reader($file);
my %info;
$info{'name'} = $name;
- $info{'load_on'} = 'requeste'; # default unless specified
+ $info{'load_on'} = 'request'; # default unless specified
$info{'libs'} = {};
while($_ = &$reader()) {
match_any_of($_, \%info, 'quoted', 'realname:note');
- match_any_of($_, \%info, 'unquoted', 'define:mp_bits');
+ match_any_of($_, \%info, 'unquoted', 'define:mp_bits:modset:load_on');
- $info{'load_on'} = $1 if(/^load_on: (.*)$/);
-
read_list($_, $reader, 'arch', list_push(\@{$info{'arch'}}));
read_list($_, $reader, 'cc', list_push(\@{$info{'cc'}}));
read_list($_, $reader, 'os', list_push(\@{$info{'os'}}));
@@ -1233,7 +1380,6 @@ sub get_os_info {
'install_cmd_data:install_cmd_exec');
read_list($_, $reader, 'aliases', list_push(\@{$info{'aliases'}}));
- read_list($_, $reader, 'arch', list_push(\@{$info{'arch'}}));
read_list($_, $reader, 'supports_shared',
list_push(\@{$info{'supports_shared'}}));
@@ -1262,9 +1408,6 @@ sub get_cc_info {
match_any_of($_, \%info, 'unquoted', 'makefile_style');
- read_list($_, $reader, 'os', list_push(\@{$info{'os'}}));
- read_list($_, $reader, 'arch', list_push(\@{$info{'arch'}}));
-
sub quoted_mapping {
my $hashref = $_[0];
return sub {
@@ -1291,40 +1434,6 @@ sub get_cc_info {
return %info;
}
-sub guess_mods {
- my ($config) = @_;
-
- my $cc = $$config{'compiler'};
- my $os = $$config{'os'};
- my $arch = $$config{'arch'};
- my $submodel = $$config{'submodel'};
-
- my $asm_ok = ($$config{'debug'} == 0);
-
- my @usable_modules;
-
- foreach my $mod (sort keys %MODULES) {
- my %modinfo = %{ $MODULES{$mod} };
-
- next if($modinfo{'load_on'} eq 'request');
- next if(!$asm_ok and $modinfo{'load_on'} eq 'asm_ok');
-
- my @cc_list = @{ $modinfo{'cc'} };
- next if(scalar @cc_list > 0 && !in_array($cc, \@cc_list));
-
- my @os_list = @{ $modinfo{'os'} };
- next if(scalar @os_list > 0 && !in_array($os, \@os_list));
-
- my @arch_list = @{ $modinfo{'arch'} };
- next if(scalar @arch_list > 0 &&
- !in_array($arch, \@arch_list) &&
- !in_array($submodel, \@arch_list));
-
- push @usable_modules, $mod;
- }
- return @usable_modules;
-}
-
##################################################
# #
##################################################
@@ -1605,6 +1714,8 @@ sub generate_makefile {
trace("'$make_style' -> '$template'");
process_template($template, $$config{'makefile'}, $config);
+
+ #autoconfig('Created ' . $$config{'makefile'});
}
##################################################
@@ -1661,131 +1772,122 @@ sub guess_cpu_from_this
# Do some WAGing and see if we can figure out what system we are. Think about
# this as a really moronic config.guess
-sub guess_triple
+sub guess_compiler
{
- # /bin/sh, good bet we're on something Unix-y (at least it'll have uname)
- if(-f '/bin/sh')
+ my @CCS = ('gcc', 'msvc', 'icc', 'compaq', 'kai');
+
+ # First try the CC enviornmental variable, if it's set
+ if(defined($ENV{CC}))
{
- my $os = lc `uname -s 2>/dev/null`; chomp $os;
+ my @new_CCS = ($ENV{CC});
+ foreach my $cc (@CCS) { push @new_CCS, $cc; }
+ @CCS = @new_CCS;
+ }
- # Let the crappy hacks commence!
+ foreach (@CCS)
+ {
+ my $bin_name = $COMPILER{$_}{'binary_name'};
+ autoconfig("Guessing you want to use $_ as the compiler");
+ return $_ if(which($bin_name) ne '');
+ }
- # Cygwin's uname -s is cygwin_<windows version>
- $os = 'cygwin' if($os =~ /^cygwin/);
- $os = os_alias($os);
+ croak(
+ "Can't find a usable C++ compiler, is your PATH right?\n" .
+ "You might need to run with explicit compiler/system flags;\n" .
+ " run '$0 --help' for more information\n");
+}
- if(!defined $OPERATING_SYSTEM{$os})
- {
- warning("Unknown uname -s output: $os, falling back to 'generic'");
- $os = 'generic';
- }
+sub guess_os
+{
+ sub recognize_os
+ {
+ my $os = os_alias($_[0]);
+ if(defined($OPERATING_SYSTEM{$os})) {
+ autoconfig("Guessing your operating system is $os");
+ return $os;
+ }
+ return undef;
+ }
- my $cpu = '';
+ my $guess = recognize_os($^O);
+ return $guess if $guess;
- # If we have /proc/cpuinfo, try to get nice specific information about
- # what kind of CPU we're running on.
- my $cpuinfo = '/proc/cpuinfo';
+ trace("Can't guess os from $^O");
- if(-e $cpuinfo and -r $cpuinfo)
- {
- $cpu = guess_cpu_from_this(slurp_file($cpuinfo));
- }
+ my $uname = `uname -s 2>/dev/null`;
+ chomp $uname;
+ $uname = lc $uname;
- # `umame -p` is sometimes something stupid like unknown, but in some
- # cases it can be more specific (useful) than `uname -m`
- if($cpu eq '') # no guess so far
- {
- my $uname_p = `uname -p 2>/dev/null`;
- chomp $uname_p;
- $cpu = guess_cpu_from_this($uname_p);
+ $guess = recognize_os($uname);
+ return $guess if $guess;
- # If guess_cpu_from_this didn't figure it out, try it plain
- if($cpu eq '') { $cpu = lc $uname_p; }
+ trace("Can't guess os from $uname");
- sub known_arch {
- my ($name) = @_;
+ warning("Unknown OS ('$^O', '$uname'), falling back to generic code");
+ return 'generic';
+}
- foreach my $arch (keys %CPU) {
- my %info = %{$CPU{$arch}};
+sub guess_cpu
+{
+ # If we have /proc/cpuinfo, try to get nice specific information about
+ # what kind of CPU we're running on.
+ my $cpuinfo = '/proc/cpuinfo';
- return 1 if $name eq $info{'name'};
- foreach my $submodel (@{$info{'submodels'}}) {
- return 1 if $name eq $submodel;
- }
+ if(-e $cpuinfo and -r $cpuinfo)
+ {
+ my $cpu = guess_cpu_from_this(slurp_file($cpuinfo));
+ if($cpu) {
+ autoconfig("Guessing (based on $cpuinfo) that your CPU is a $cpu");
+ return $cpu;
+ }
+ }
- foreach my $alias (@{$info{'aliases'}}) {
- return 1 if $name eq $alias;
- }
+ # `umame -p` is sometimes something stupid like unknown, but in some
+ # cases it can be more specific (useful) than `uname -m`
+ my $uname_p = `uname -p 2>/dev/null`;
+ chomp $uname_p;
+ my $cpu = guess_cpu_from_this($uname_p);
- if(defined($info{'submodel_aliases'})) {
- my %submodel_aliases = %{$info{'submodel_aliases'}};
- foreach my $sm_alias (keys %submodel_aliases) {
- return 1 if $name eq $sm_alias;
- }
- }
- }
- return 0;
+ # If guess_cpu_from_this didn't figure it out, try it as is
+ if($cpu eq '') { $cpu = lc $uname_p; }
+
+ sub known_arch {
+ my ($name) = @_;
+
+ foreach my $arch (keys %CPU) {
+ my %info = %{$CPU{$arch}};
+
+ return 1 if $name eq $info{'name'};
+ foreach my $submodel (@{$info{'submodels'}}) {
+ return 1 if $name eq $submodel;
}
- if(!known_arch($cpu))
- {
- # Nope, couldn't figure out uname -p
- $cpu = lc `uname -m 2>/dev/null`;
- chomp $cpu;
+ foreach my $alias (@{$info{'aliases'}}) {
+ return 1 if $name eq $alias;
+ }
- if(!known_arch($cpu))
- {
- $cpu = 'generic';
+ if(defined($info{'submodel_aliases'})) {
+ my %submodel_aliases = %{$info{'submodel_aliases'}};
+ foreach my $sm_alias (keys %submodel_aliases) {
+ return 1 if $name eq $sm_alias;
}
}
}
+ return 0;
+ }
- my @CCS = ('gcc', 'icc', 'compaq', 'kai'); # Skips several, oh well...
+ if(!known_arch($cpu))
+ {
+ # Nope, couldn't figure out uname -p
+ $cpu = lc `uname -m 2>/dev/null`;
+ chomp $cpu;
- # First try the CC enviornmental variable, if it's set
- if(defined($ENV{CC}))
+ if(!known_arch($cpu))
{
- my @new_CCS = ($ENV{CC});
- foreach my $cc (@CCS) { push @new_CCS, $cc; }
- @CCS = @new_CCS;
+ $cpu = 'generic';
}
-
- my $cc = '';
- foreach (@CCS)
- {
- my $bin_name = $COMPILER{$_}{'binary_name'};
- $cc = $_ if(which($bin_name) ne '');
- last if($cc ne '');
- }
-
- if($cc eq '') {
- my $msg =
- "Can't find a usable C++ compiler, is your PATH right?\n" .
- "You might need to run with explicit compiler/system flags;\n" .
- " run '$0 --help' for more information\n";
- croak($msg);
- }
-
- return "$cc-$os-$cpu";
}
- elsif($^O eq 'MSWin32' or $^O eq 'dos')
- {
- my $os = 'windows'; # obviously
- # Suggestions on this? The Win32 'shell' env is not so hot. We could
- # try using cpuinfo, except that will crash hard on NT/Alpha (like what
- # we're doing now won't!). In my defense of choosing i686:
- # a) There are maybe a few hundred Alpha/MIPS boxes running NT4 today
- # b) Anyone running Windows on < Pentium Pro deserves to lose.
- my $cpu = 'i686';
-
- # No /bin/sh, so not cygwin. Assume VC++; again, this could be much
- # smarter
- my $cc = 'msvc';
- return "$cc-$os-$cpu";
- }
- else
- {
- croak('Autoconfiguration failed (try --help)');
- }
+ autoconfig("Guessing (based on uname -p) your CPU is a $cpu");
+ return $cpu;
}
============================================================
--- doc/api.tex cb1e40121b562d97258d9aba065c5cb5f58bfb3c
+++ doc/api.tex 2ff20035b5a43d5549e664daf89a4ad837ebef2a
@@ -212,12 +212,6 @@ \subsection{Initializing the Library}
On systems that don't (currently) have any specialized allocators, like
MS Windows, this option is ignored.
-\option{config=/path/to/configfile}: Process the specified
-configuration file. Configuration files can specify things like the
-various options, new aliases, and new OIDs for algorithms. An example
-can be found in \filename{doc/botan.rc}. Currently only one config=
-argument will be processed, the rest will be ignored.
-
\option{use\_engines}: Use any available ``engine'' modules to speed
up processing. Currently Botan has support for engines based on the
AEP1000/AEP2000 crypto hardware cards, GNU MP, and OpenSSL's BN
@@ -2762,105 +2756,6 @@ \subsection{Available Options}
and much less commonly used.
\end{list}
-\subsection{Configuration Files}
-
-Botan has a number of options, which can be configured by calling the
-appropriate functions, documented earlier in this section. But this is somewhat
-inconvenient for the users of applications which use Botan. So Botan also
-supports reading options from a file which looks rather like Windows .INI files
-or OpenSSL configurations. You can find an example config (which simply matches
-the compiled-in defaults) in \filename{doc/botan.rc}
-
-Each set of options is part of a 'section', for example, ``base'', ``rng'', or
-``x509''. These names are essentially arbitrary, and are (in theory) chosen on
-the basis of what the options pertain to. To set the option
-``x509/ca/default\_expire'' (which tells \type{X509\_CA} how long newly minted
-X.509 certificates should be valid for), you could use either of the following
-methods:
-
-\begin{verbatim}
-[x509/ca] # section is x509/ca
-default_expire = 1y # x509/ca + default_expire -> x509/ca/default_expire
-
-# same as above
-[x509] # section is x509
-# other x509/ options in here...
-ca/default_expire = 1y # x509 + ca/default_expire -> x509/ca/default_expire
-\end{verbatim}
-
-There are also two special sections, ``oids'' and ``aliases''. The aliases
-section is easier to understand, and probably more useful for the average user.
-By adding a new line in an alias section, \verb|alias = officialname|, you can
-create a new way to reference a particular algorithm (in those cases when you
-ask for an algorithm object with a string specifying its type). For example, if
-the line \verb|MyAlgo = Blowfish| was included in an aliases section, then one
-could do this:
-
-\begin{verbatim}
-Pipe pipe(get_cipher(``MyAlgo/CBC/PKCS7'', key, iv, ENCRYPTION));
-\end{verbatim}
-
-and get a Blowfish CBC encryptor. Initially this was implemented due to the
-number of algorithms with multiple names (such as ``SHA1'', ``SHA-1'', and
-``SHA-160''), but might also be useful in other, more interesting, contexts.
-
-The OIDs section gives a mapping between ASN.1 OIDs and the algorithm or object
-it represents, in the form \verb|name = oid|, where oid is the usual
-decimal-dotted representation. For readability and easy of extension in
-configuration files, a simple variable interpolation scheme is also
-available. Consider the following:
-
-\begin{verbatim}
-[oids]
-ISO_MEMBER = 1.2
-US_BODY = ISO_MEMBER.840 # US_BODY = 1.2.840
-RSA_DSI = US_BODY.113549 # RSA_DSI = 1.2.840.113549
-\end{verbatim}
-
-This only works when the variable name is at the start of the string; since the
-primary reason for its inclusion is for with OIDs, this is acceptable. In some
-cases, adding a new OID in is sufficient for code to work with new algorithms
-(though not always). For example, by setting the proper OIDs, you can make it
-possible to import, export, create, and process X.509 certificates that use
-Rabin-Williams.
-
-\subsubsection{Syntax}
-
-Each line is either a comment, blank, a section name, or a name/value pair
-separated by a '='. Comments start with the '\#' character and continue to the
-end of line. The reader allows escaping, so if you wanted to include an actual
-\# sign you could use \verb|\#|, or include it in a string ('\#' or ``\#''). A
-section name is specified by \verb|[somename]|; a section name must have at
-least one character, and a section must appear before any name/value pairs. A
-name must be alphanumeric, but a value can contain spaces or other strange
-things (you must either enclose the argument in quotes or escape each space
-with a backslash). An example showing some of the trickier parts of how input
-is interpreted follows (but the reader is cautioned that relying on this
-behavior is not a good idea):
-
-\begin{verbatim}
-[examples]
-foo1 = a b c # stored as abc (not quoted, ws removed)
-foo2 = 'a b c' # stored as a b c (quoted, keep ws)
-foo3 = "a b c" # stored as a b c (quoted, keep ws)
-tricky = "Jack \"I like pie\" Lloyd" # stored as Jack "I like pie" Lloyd
-simpler = "Jack 'I like pie' Lloyd" # no escapes needed
-
-hashmark = "#" # set to a hash
-hashmark2 = \# # also set to a hash
-
-[oids]
-RW = 1.2.3.4.5.6 # Now RW keys can be imported/exported!
-NR = 1.2.3.4.5.7 # Now NR can be imported/exported too.
- # Note these OIDs are *not* allocated for RW/NR, in fact I have no idea who
- # owns that section of the OID space, but it's certainly not me. Someone will
- # have to allocate OIDs for RW/NR before this is 'legal'
-
-some_thing = 1.2.3 # some OID
-another_thing = some_thing.4.5 # another_thing = 1.2.3.4.5
-\end{verbatim}
-
-
\pagebreak
\section{Botan's Modules}
============================================================
--- doc/building.tex 5ffcd552ad48605b03a6dbe526ac39d85451c6e4
+++ doc/building.tex 93619b803ba091c08e1638e59a70bee267ecfde7
@@ -55,41 +55,27 @@ \section{For the Impatient}
spot, you might need to prefix the \texttt{configure.pl} command with
\texttt{perl} or \texttt{/path/to/perl}.
-The autoconfiguaration abilities of \filename{configure.pl} were only recently
-added, so they may break if you run it on something unusual. In addition, you
-are certain to get more features, and possibly better optimization, by
-explicitly specifying how you want to library configured. How to do this is
-detailed below. Also, if you don't want to use the default compiler (typically
-either GNU C++ or Visual C++, depending on the platform), you will need to
-specify one.
-
\section{Building the Library}
-The first step is to run \filename{configure.pl}, which is a Perl script that
-creates various directories, config files, and a Makefile for building
-everything. It is run as \verb|./configure.pl CC-OS-CPU <extra args>|. The
-script requires at least Perl 5.6; any later version should also work.
+The first step is to run \filename{configure.pl}, which is a Perl
+script that creates various directories, config files, and a Makefile
+for building everything. The script requires at least Perl 5.6; any
+later version should also work.
-The tuple CC-OS-CPU specifies what system Botan is being built for, in terms of
-the C++ compiler, the operating system, and the CPU model. For example, to use
-GNU C++ on a FreeBSD box that has an Alpha EV6 CPU, one would use
-``gcc-freebsd-alphaev6'', and for Visual C++ on Windows with a Pentium II,
-``msvc-windows-pentium2''. To get the list of values for \verb|CC|, \verb|OS|,
-and \verb|CPU| that \filename{configure.pl} supports, run it with the
-``\verb|--help|'' option.
+The script will attempt to guess what kind of system you are trying
+to compile for (and will print messages telling you what it guessed).
+You can override this process by passing the options \verb|--cc|,
+\verb|--os|, and \verb|--arch| -- acceptable values are printed if
+you run \verb|configure.pl| with \verb|--help|.
-You can put basically anything reasonable for CPU: the script knows
-about a large number of different architectures, their sub-models, and
-common aliases for them. The script does not display all the
-possibilities in its help message because there are simply too many
-entries. You should only select the 64-bit version of a CPU (such as
-``sparc64'' or ``mips64'') if your operating system knows how to
+You can pass basically anything reasonable with \verb|--cpu|: the
+script knows about a large number of different architectures, their
+sub-models, and common aliases for them. The script does not display
+all the possibilities in its help message because there are simply too
+many entries. You should only select the 64-bit version of a CPU (such
+as ``sparc64'' or ``mips64'') if your operating system knows how to
handle 64-bit object code -- a 32-bit kernel on a 64-bit CPU will
-generally not like 64-bit code. For example, gcc-solaris-sparc64 will
-not work unless you're running a 64-bit Solaris kernel (for 32-bit
-Solaris running on an UltraSPARC system, you want
-gcc-solaris-sparc32-v9). You may or may not have to install 64-bit
-versions of libc and related system libraries as well.
+generally not like 64-bit code.
The script also knows about the various extension modules
available. You can enable one or more with the option
@@ -128,13 +114,16 @@ \subsection{POSIX / Unix}
The basic build procedure on Unix and Unix-like systems is:
\begin{verbatim}
- $ ./configure.pl CC-OS-CPU --module-set=[unix|beos] --modules=<other mods>
+ $ ./configure.pl --module-set=[unix|beos] --modules=<other mods>
$ make
# You may need to set your LD_LIBRARY_PATH or equivalent for ./check to run
$ make check # optional, but a good idea
$ make install
\end{verbatim}
+This will probably default to using GCC, depending on what can be
+found within your PATH.
+
The 'unix' module set should work on most POSIX/Unix systems out there
(including MacOS X), while the 'beos' module is specific to BeOS. While the two
sets share a number of modules, some normal Unix ones don't work on BeOS (in
@@ -142,9 +131,9 @@ \subsection{POSIX / Unix}
a few extras just for it. The library will pick a default module set for you
based on the value of OS, so there is rarely a reason to specify that.
-The \verb|make install| target has a default directory in which it will install
-Botan (on everything that's a real Unix, it's \verb|/usr/local|). You can
-override this by using the \texttt{--prefix} argument to
+The \verb|make install| target has a default directory in which it
+will install Botan (typically \verb|/usr/local|). You can override
+this by using the \texttt{--prefix} argument to
\filename{configure.pl}, like so:
\verb|./configure.pl --prefix=/opt <other arguments>|
@@ -173,15 +162,16 @@ \subsection{MS Windows}
have a copy of Perl installed, and have both Perl and Visual C++ in your path.
\begin{verbatim}
- > perl configure.pl msvc-windows-<CPU> --module-set=win32
+ > perl configure.pl --cc=msvc --os=windows [--cpu=CPU] --module-set=win32
> nmake
> nmake check # optional, but recommended
\end{verbatim}
-By default, the configure script will include the 'win32' module set for you.
-This includes a pair of entropy sources for use on Windows; at some point in
-the future it will also add support for high-resolution timers, mutexes for
-thread safety, and other useful things.
+The configure script will include the 'win32' module set by default if
+you pass \verb|--os=windows|. This module set includes a pair of
+entropy sources for use on Windows; at some point in the future it
+will also add support for high-resolution timers, mutexes for thread
+safety, and other useful things.
For Win95 pre OSR2, the \verb|es_capi| module will not work, because
CryptoAPI didn't exist. All versions of NT4 lack the ToolHelp32
============================================================
--- doc/logs/log-17.txt 84160a4ac4d5f5263cb455fde8e8c8d562008aab
+++ doc/logs/log-17.txt d08c4cbe679ff172e8d046a014597ed15236ce56
@@ -1,5 +1,14 @@
-* 1.7.2, Oct 13, 2007
+* 1.7.3, November 4, 2007
+ - New invocation syntax for configure.pl with several new options
+ - Support for IPv4 addresses in a subject alternative name
+ - New fast poll for the generic Unix entropy source (es_unix)
+ - The malloc allocator does not inherit from Pooling_Allocator anymore
+ - The dirs that es_unix will search in are now fully user-configurable
+ - Truncate X9.42 PRF output rather than allow counter overflow
+ - PowerPC is now assumed to be big-endian
+
+* 1.7.2, October 13, 2007
- Initialize the global library state lazily
- Add plain CBC-MAC for backwards compatability with old systems
- Clean up some of the self test code
============================================================
--- include/allocate.h 532035d3cdec5a2c8fd3250f87a78fa7f3d77eb4
+++ include/allocate.h acaf4aa6a1213de0c71b128d79d4760cdb3159b3
@@ -12,7 +12,7 @@ namespace Botan {
namespace Botan {
/*************************************************
-* Allocator *
+* Allocator Interface *
*************************************************/
class Allocator
{
@@ -30,10 +30,6 @@ class Allocator
virtual ~Allocator() {}
};
-/*************************************************
-* Get an allocator *
-*************************************************/
-
}
#endif
============================================================
--- include/bit_ops.h 08ec67df33c30f4e2a9b87675d142f30afccf5f5
+++ include/bit_ops.h ace888ad7c2755ca077461722e24cb1a422a2ed5
@@ -26,26 +26,10 @@ template<typename T> inline T rotate_rig
/*************************************************
* Byteswap *
*************************************************/
-inline u16bit reverse_bytes(u16bit input)
- {
- return rotate_left(input, 8);
- }
+u16bit reverse_bytes(u16bit);
+u32bit reverse_bytes(u32bit);
+u64bit reverse_bytes(u64bit);
-inline u32bit reverse_bytes(u32bit input)
- {
- input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8);
- return rotate_left(input, 16);
- }
-
-inline u64bit reverse_bytes(u64bit input)
- {
- input = ((input & 0xFF00FF00FF00FF00) >> 8) |
- ((input & 0x00FF00FF00FF00FF) << 8);
- input = ((input & 0xFFFF0000FFFF0000) >> 16) |
- ((input & 0x0000FFFF0000FFFF) << 16);
- return rotate_left(input, 32);
- }
-
/*************************************************
* Array XOR *
*************************************************/
============================================================
--- include/defalloc.h ef3958943a473c5a5068dbf77eae02e7cafa55fa
+++ include/defalloc.h e7507091a397628e401de0bd41be48bbbf929ff9
@@ -13,14 +13,13 @@ namespace Botan {
/*************************************************
* Malloc Allocator *
*************************************************/
-class Malloc_Allocator : public Pooling_Allocator
+class Malloc_Allocator : public Allocator
{
public:
- Malloc_Allocator() : Pooling_Allocator(64*1024, false) {}
+ void* allocate(u32bit);
+ void deallocate(void*, u32bit);
+
std::string type() const { return "malloc"; }
- private:
- void* alloc_block(u32bit);
- void dealloc_block(void*, u32bit);
};
/*************************************************
============================================================
--- include/idea.h d7276b98289143c01e8cee8c693ba8f7b441f44c
+++ include/idea.h 6628f852d9edb773c8e06a3322a35923b09b70f4
@@ -24,7 +24,6 @@ class IDEA : public BlockCipher
void enc(const byte[], byte[]) const;
void dec(const byte[], byte[]) const;
void key(const byte[], u32bit);
- static u16bit mul_inv(u16bit);
SecureBuffer<u16bit, 52> EK, DK;
};
============================================================
--- include/init.h 4e6621c7bdf9dd3e309d28456d06cafaebf16029
+++ include/init.h 1844022acd8847f03728c907a4d390b7114af216
@@ -24,8 +24,6 @@ class InitializerOptions
bool fips_mode() const;
bool self_test() const;
- std::string config_file() const;
-
InitializerOptions(const std::string&);
private:
std::map<std::string, std::string> args;
============================================================
--- misc/config/arch/alpha eb4385b12908208ea2f42b048c8401e5a029e734
+++ misc/config/arch/alpha 3ddceecf33d3c312c6e88ff806473f0a3312d8af
@@ -1,6 +1,7 @@ default_submodel alpha-ev5
realname "DEC Alpha"
default_submodel alpha-ev5
+endian little
<aliases>
axp
============================================================
--- misc/config/arch/ia32 9b9f5f5f014d8e983c6fec7c043d15b4f3826caf
+++ misc/config/arch/ia32 37777964e179c7f27e0ce9f2d58284dabe5cfadf
@@ -1,6 +1,6 @@ realname "IA-32"
realname "IA-32"
-default_submodel i586
+default_submodel i686
endian little
unaligned ok
============================================================
--- misc/config/cc/bcc ee7774c89526db32c71edec4b46e39c618b9e636
+++ misc/config/cc/bcc 561513b32f972726cc0e9a83213e33debef2f95f
@@ -26,11 +26,3 @@ pentium4 -> "/G6"
athlon -> "/G6"
pentium4 -> "/G6"
</mach_opt>
-
-<arch>
-ia32
-</arch>
-
-<os>
-windows
-</os>
============================================================
--- misc/config/cc/compaq 0d19d1445db032754b13b5a92aaf79f161168ed7
+++ misc/config/cc/compaq 5b855b2566a3778a208de0f3950299bf71c60b08
@@ -24,12 +24,3 @@ alpha -> "-arch=SUBMODEL" alpha-
<mach_opt>
alpha -> "-arch=SUBMODEL" alpha-
</mach_opt>
-
-<arch>
-alpha
-</arch>
-
-<os>
-tru64
-linux
-</os>
============================================================
--- misc/config/cc/ekopath 54df4f6c355b56ff537db7e429024428da3a6300
+++ misc/config/cc/ekopath 5e065967f6749183e09a69826d804c12c67ce362
@@ -35,12 +35,3 @@ amd64 -> "-mcpu=athlon64"
ia32 -> "-mcpu=anyx86"
amd64 -> "-mcpu=athlon64"
</mach_opt>
-
-<os>
-linux
-</os>
-
-<arch>
-ia32
-amd64
-</arch>
============================================================
--- misc/config/cc/gcc 8f5871a7933c06c3db66c6ae748acedc28de85a9
+++ misc/config/cc/gcc f57864620e4b61197536ad20ab5f07f44811245a
@@ -81,39 +81,3 @@ qnx -> "-fexceptions -D_QNX_SOURCE"
netbsd -> "-pthread"
qnx -> "-fexceptions -D_QNX_SOURCE"
</mach_abi_linking>
-
-<os>
-aix
-beos
-cygwin
-darwin
-freebsd
-hpux
-irix
-linux
-netbsd
-openbsd
-qnx
-solaris
-tru64
-windows
-</os>
-
-<arch>
-alpha
-amd64
-arm
-hppa
-ia32
-ia64
-m68k
-mips32
-mips64
-ppc
-ppc64
-s390
-s390x
-sh
-sparc32
-sparc64
-</arch>
============================================================
--- misc/config/cc/hpcc 0f6eb059dec345100593082d9fb744ae42f0e9dd
+++ misc/config/cc/hpcc fe395425b4097070162a67b827d43ecfb392287e
@@ -27,11 +27,3 @@ default -> "$(CXX) +Z -b -Wl,+h,$(SONAME
<so_link_flags>
default -> "$(CXX) +Z -b -Wl,+h,$(SONAME)" # Documented in cc(1), but not CC(1) (?)
</so_link_flags>
-
-<arch>
-hppa
-</arch>
-
-<os>
-hpux
-</os>
============================================================
--- misc/config/cc/icc df7c425f180f6d8f159eccd5b5cda87ae79b20f4
+++ misc/config/cc/icc 7f8af2a729b9a249412a5f392b68708d760e15cf
@@ -1,6 +1,6 @@ realname "Intel C++"
realname "Intel C++"
-binary_name "icc"
+binary_name "icpc"
compile_option "-c "
output_to_option "-o "
@@ -11,30 +11,20 @@ debug_flags "-g"
lib_opt_flags "-O3 -ip -unroll"
check_opt_flags "-O2"
debug_flags "-g"
-no_debug_flags ""
+no_debug_flags "-fomit-frame-pointer"
lang_flags ""
warning_flags "-w1"
-so_obj_flags "-KPIC"
+so_obj_flags "-fPIC"
makefile_style unix
<mach_opt>
-i586 -> "-tpp5"
-i686 -> "-tpp6 -xiM"
-athlon -> "-tpp6 -xiM"
-pentium4 -> "-tpp7 -xiMW"
+i686 -> "-march=pentium3"
+athlon -> "-march=pentium3"
+pentium4 -> "-march=pentium4"
+core2duo -> "-msse3"
</mach_opt>
<so_link_flags>
-default -> "$(CXX) -KPIC -shared"
+default -> "$(CXX) -fPIC -shared"
</so_link_flags>
-
-<arch>
-amd64
-ia32
-ia64
-</arch>
-
-<os>
-linux
-</os>
============================================================
--- misc/config/cc/kai 9436c4c4dd6486c6982dd86e091830900ace9d56
+++ misc/config/cc/kai 61a0afad96346a53d75843a0e3c775e263365885
@@ -25,22 +25,3 @@ all -> "--one_per"
<mach_abi_linking>
all -> "--one_per"
</mach_abi_linking>
-
-<arch>
-alpha
-hppa
-ia32
-mips32
-mips64
-sparc32
-sparc64
-</arch>
-
-<os>
-hpux
-irix
-linux
-solaris
-tru64
-</os>
-
============================================================
--- misc/config/cc/mipspro c568b9c5fa321db7de3045e21c86bdaaad913c8c
+++ misc/config/cc/mipspro 83a382a4c5c89c79124aaa5fea9543b9934a61e9
@@ -37,12 +37,3 @@ mips64 -> "-64"
mips32 -> "-n32"
mips64 -> "-64"
</mach_abi_linking>
-
-<arch>
-mips32
-mips64
-</arch>
-
-<os>
-irix
-</os>
============================================================
--- misc/config/cc/msvc a518e200b92423fc58f0c78eafea50e4395799e2
+++ misc/config/cc/msvc f0fcdde68fcd833622fcb77df697118fd84bf3ff
@@ -10,7 +10,7 @@ check_opt_flags "/O2"
lib_opt_flags "/O2 /Ob2"
check_opt_flags "/O2"
-debug_flags ""
+debug_flags "/Zi"
no_debug_flags ""
lang_flags "/EHsc /GR /D_CONSOLE"
warning_flags ""
@@ -18,11 +18,3 @@ makefile_style nmake
ar_command "link /lib"
makefile_style nmake
-
-<arch>
-ia32
-</arch>
-
-<os>
-windows
-</os>
============================================================
--- misc/config/cc/pgi 55504c4febd8030685b52c149e4ca76cea0bb29d
+++ misc/config/cc/pgi 35dc70b946b7aa83deb8bf26560fa8ca40680c6e
@@ -26,12 +26,3 @@ ia32 -> "-tp px"
pentium4 -> "-tp p6"
ia32 -> "-tp px"
</mach_opt>
-
-<arch>
-ia32
-</arch>
-
-<os>
-linux
-solaris
-</os>
============================================================
--- misc/config/cc/sgipro64 66a21eb000bff03771e5e0b1bbf0fdc910e5b195
+++ misc/config/cc/sgipro64 564ca86eb93141bee356b540e38aff20570ee977
@@ -25,11 +25,3 @@ default -> "$(CXX) -shared -Wl,-soname,$
<mach_opt>
</mach_opt>
-
-<arch>
-ia64
-</arch>
-
-<os>
-linux
-</os>
============================================================
--- misc/config/cc/sunwspro 9720af2d645f294070c78d697d6d872135ebc71c
+++ misc/config/cc/sunwspro bdb44bb25abc0086d1c78c0b2efed958e614f8b6
@@ -41,13 +41,3 @@ sparc64 -> "-xarch=v9"
<mach_abi_linking>
sparc64 -> "-xarch=v9"
</mach_abi_linking>
-
-<arch>
-ia32
-sparc32
-sparc64
-</arch>
-
-<os>
-solaris
-</os>
============================================================
--- misc/config/os/aix 564e370d3fca850949786c8b3cd8a359c3db54cc
+++ misc/config/os/aix 1ae489a4423d56d58cdfa6a2c3ec5c52a8e044f4
@@ -5,9 +5,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-ia64
-ppc
-ppc64
-</arch>
============================================================
--- misc/config/os/beos a0090a5297ed96bdd71318721022e3dc9f454c6e
+++ misc/config/os/beos 1bb820a522401f7aaa56bead761b6e6c29fa9626
@@ -11,11 +11,6 @@ all
all
</supports_shared>
-<arch>
-ia32
-ppc
-</arch>
-
<aliases>
haiku
</aliases>
============================================================
--- misc/config/os/cygwin b98e7c0405f1497345e71ba2fe37dc1c596dcda6
+++ misc/config/os/cygwin da74ebac5f9ddd009c73255200998cb25295e830
@@ -11,9 +11,3 @@ doc_dir docs
<supports_shared>
#all
</supports_shared>
-
-<arch>
-ia32
-amd64 # in theory
-ia64 # in theory
-</arch>
============================================================
--- misc/config/os/freebsd 006ab197d32eea63361257fe1d9dcc639fd44313
+++ misc/config/os/freebsd d7d4d7710c19332222b65f041853c5fb10617259
@@ -7,12 +7,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-alpha
-amd64
-ia32
-ia64
-powerpc
-sparc64
-</arch>
============================================================
--- misc/config/os/hpux 49b209ede76c5c055c200c68b27ac3facd3eff31
+++ misc/config/os/hpux 3259c76e44c088eb2c46c104e4628fde63841e8f
@@ -8,11 +8,6 @@ all
all
</supports_shared>
-<arch>
-hppa
-ia64
-</arch>
-
<aliases>
hp-ux
</aliases>
============================================================
--- misc/config/os/irix a62b658f50c62adf9830785f5443137430a4b66c
+++ misc/config/os/irix cc8d00e11363d56828dd5b1084ff3af9e9bb76fd
@@ -5,9 +5,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-mips32
-mips64
-</arch>
-
============================================================
--- misc/config/os/linux ac26a526ad7af05b54d08a5383b3219e4e7d8629
+++ misc/config/os/linux 566c9d6827c1ea19baabb82d547a6231d18fca45
@@ -6,22 +6,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-alpha
-amd64
-arm
-hppa
-ia32
-ia64
-m68k
-mips32
-mips64
-ppc
-ppc64
-sh
-sparc32
-sparc64
-s390
-s390x
-</arch>
============================================================
--- misc/config/os/netbsd ac1a9307aec68c1ac997893105649bd7fc687eb1
+++ misc/config/os/netbsd c09645e6aab081667e61307d0536b0adc15186b9
@@ -7,17 +7,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-alpha
-amd64
-arm
-hppa
-ia32
-ia64
-m68k
-mips32
-mips64
-ppc
-sparc32
-</arch>
============================================================
--- misc/config/os/openbsd 0d2465d745a65c18bc10321b0d74d3f3c19f2411
+++ misc/config/os/openbsd d1cf34508f82296b77ac1c05a2b8e4ec0e9ef8f7
@@ -7,13 +7,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-alpha
-ia32
-m68k
-mips32
-ppc
-sparc32
-sparc64
-</arch>
============================================================
--- misc/config/os/qnx e3aacf5eb51a9636a43d5da7e430ae88ae736fba
+++ misc/config/os/qnx 7a8fa58bccdf45e7aacadf9c48ba2c21c75af46e
@@ -5,11 +5,3 @@ all
<supports_shared>
all
</supports_shared>
-
-<arch>
-arm
-ia32
-mips32
-ppc
-sh
-</arch>
============================================================
--- misc/config/os/solaris 25977d770ed58bd5d262aae613cca6f0aadeb419
+++ misc/config/os/solaris 42ccff72aea7d428a33b639eda96e613cc4c33ea
@@ -9,12 +9,6 @@ all
all
</supports_shared>
-<arch>
-ia32
-sparc32
-sparc64
-</arch>
-
<aliases>
sunos
</aliases>
============================================================
--- misc/config/os/tru64 614b02f2934db3f90258879dcc57514f151a0e7b
+++ misc/config/os/tru64 c9f88ca6171640c19f649b8ce5f0b5a44c6f2a02
@@ -6,10 +6,6 @@ all
all
</supports_shared>
-<arch>
-alpha
-</arch>
-
<aliases>
osf1
</aliases>
============================================================
--- misc/config/os/windows de615c9122334f20e2671a5994988e33a3391d1f
+++ misc/config/os/windows e36531bad64840b7551ca36b03f8063fa24155ff
@@ -19,12 +19,7 @@ install_group <nil>
#all
</supports_shared>
-<arch>
-ia32
-amd64 # in theory
-ia64 # in theory
-</arch>
-
<aliases>
win32
+mswin32
</aliases>
============================================================
--- modules/alg_amd64/modinfo.txt 0a765bd257f37a2959ec10d20a9299beffb737ae
+++ modules/alg_amd64/modinfo.txt 52b990d379b77248d5ea65ed9b09df88ead61c54
@@ -2,7 +2,7 @@
mp_bits 64
-load_on: asm_ok
+load_on asm_ok
<replace>
sha160.cpp
============================================================
--- modules/alg_ia32/modinfo.txt 99d0df3d5eb6c0b2cfbc26f79da54a6c6f0ca9ab
+++ modules/alg_ia32/modinfo.txt a30d4e1a048c23d047d2d3ef64f5943d44e98c36
@@ -2,7 +2,7 @@
mp_bits 32
-load_on: asm_ok
+load_on asm_ok
<replace>
md4.cpp
============================================================
--- modules/alloc_mmap/mmap_mem.cpp 19ff049ea80042cf62e1f02ede47004f3acf048a
+++ modules/alloc_mmap/mmap_mem.cpp 90dffa50c3f59b20772e0379feb38610a4bd0441
@@ -59,15 +59,15 @@ void* MemoryMapping_Allocator::alloc_blo
filepath = new char[path.length() + 1];
std::strcpy(filepath, path.c_str());
- mode_t old_umask = umask(077);
- fd = mkstemp(filepath);
- umask(old_umask);
+ mode_t old_umask = ::umask(077);
+ fd = ::mkstemp(filepath);
+ ::umask(old_umask);
}
~TemporaryFile()
{
delete[] filepath;
- if(fd != -1 && close(fd) == -1)
+ if(fd != -1 && ::close(fd) == -1)
throw MemoryMapping_Failed("Could not close file");
}
private:
@@ -80,15 +80,15 @@ void* MemoryMapping_Allocator::alloc_blo
if(file.get_fd() == -1)
throw MemoryMapping_Failed("Could not create file");
- if(unlink(file.path().c_str()))
- throw MemoryMapping_Failed("Could not unlink file " + file.path());
+ if(::unlink(file.path().c_str()))
+ throw MemoryMapping_Failed("Could not unlink file '" + file.path() + "'");
- lseek(file.get_fd(), n-1, SEEK_SET);
- if(write(file.get_fd(), "\0", 1) != 1)
+ ::lseek(file.get_fd(), n-1, SEEK_SET);
+ if(::write(file.get_fd(), "\0", 1) != 1)
throw MemoryMapping_Failed("Could not write to file");
- void* ptr = mmap(0, n, PROT_READ | PROT_WRITE, MAP_SHARED,
- file.get_fd(), 0);
+ void* ptr = ::mmap(0, n, PROT_READ | PROT_WRITE, MAP_SHARED,
+ file.get_fd(), 0);
if(ptr == static_cast<void*>(MAP_FAILED))
throw MemoryMapping_Failed("Could not map file");
@@ -101,23 +101,21 @@ void MemoryMapping_Allocator::dealloc_bl
*************************************************/
void MemoryMapping_Allocator::dealloc_block(void* ptr, u32bit n)
{
- if(ptr == 0) return;
+ if(ptr == 0)
+ return;
- const u32bit OVERWRITE_PASSES = 12;
const byte PATTERNS[] = { 0x00, 0xFF, 0xAA, 0x55, 0x73, 0x8C, 0x5F, 0xA0,
- 0x6E, 0x91, 0x30, 0xCF, 0xD3, 0x2C, 0xAC, 0x53 };
+ 0x6E, 0x91, 0x30, 0xCF, 0xD3, 0x2C, 0xAC, 0x00 };
- for(u32bit j = 0; j != OVERWRITE_PASSES; j++)
+ for(u32bit j = 0; j != sizeof(PATTERNS); j++)
{
- std::memset(ptr, PATTERNS[j % sizeof(PATTERNS)], n);
- if(msync(ptr, n, MS_SYNC))
+ std::memset(ptr, PATTERNS[j], n);
+
+ if(::msync(ptr, n, MS_SYNC))
throw MemoryMapping_Failed("Sync operation failed");
}
- std::memset(ptr, 0, n);
- if(msync(ptr, n, MS_SYNC))
- throw MemoryMapping_Failed("Sync operation failed");
- if(munmap(ptr, n))
+ if(::munmap(ptr, n))
throw MemoryMapping_Failed("Could not unmap file");
}
============================================================
--- modules/alloc_mmap/modinfo.txt d36d112666314144a5aa817fc24738e9aea91a8a
+++ modules/alloc_mmap/modinfo.txt 13c7ed238e98cfb2cee3234a0ccb669b882f998f
@@ -1,8 +1,9 @@
realname "Disk Based Allocation System"
define ALLOC_MMAP
+modset unix
-load_on: auto
+load_on auto
<add>
mmap_mem.cpp
============================================================
--- modules/comp_bzip2/modinfo.txt 85bf9ca722bf07022effa03bfb357136e4c56cfa
+++ modules/comp_bzip2/modinfo.txt 2b56ddd0377539a229214eafdc69ae60b5dd6b0b
@@ -3,8 +3,9 @@
realname "Bzip2 Compressor"
define COMPRESSOR_BZIP2
+modset compression
-load_on: request
+load_on request
<add>
bzip2.h
============================================================
--- modules/comp_zlib/modinfo.txt 5f5620f37503b158951092000b1b72dc1b3b7d82
+++ modules/comp_zlib/modinfo.txt 104016f30a3f87aac823196c70ba7ef61b2739ca
@@ -4,7 +4,8 @@
define COMPRESSOR_ZLIB
#define COMPRESSOR_ZLIB,COMPRESSOR_GZIP
-load_on: request
+load_on request
+modset compression
<add>
zlib.h
============================================================
--- modules/comp_zlib/zlib.cpp 9d1bffb2c1a97d0a748728fc71149915b800626d
+++ modules/comp_zlib/zlib.cpp 97d5fe2639e150906b8ed7beedf13174ea1be78c
@@ -97,12 +97,12 @@ void Zlib_Compression::write(const byte
*************************************************/
void Zlib_Compression::write(const byte input[], u32bit length)
{
- zlib->stream.next_in = (Bytef*)input;
+ zlib->stream.next_in = static_cast<Bytef*>(input);
zlib->stream.avail_in = length;
while(zlib->stream.avail_in != 0)
{
- zlib->stream.next_out = (Bytef*)buffer.begin();
+ zlib->stream.next_out = static_cast<Bytef*>(buffer.begin());
zlib->stream.avail_out = buffer.size();
deflate(&(zlib->stream), Z_NO_FLUSH);
send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
@@ -120,7 +120,7 @@ void Zlib_Compression::end_msg()
int rc = Z_OK;
while(rc != Z_STREAM_END)
{
- zlib->stream.next_out = (Bytef*)buffer.begin();
+ zlib->stream.next_out = static_cast<Bytef*>(buffer.begin());
zlib->stream.avail_out = buffer.size();
rc = deflate(&(zlib->stream), Z_FINISH);
send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
@@ -138,7 +138,7 @@ void Zlib_Compression::flush()
while(true)
{
- zlib->stream.next_out = (Bytef*)buffer.begin();
+ zlib->stream.next_out = static_cast<Bytef*>(buffer.begin());
zlib->stream.avail_out = buffer.size();
deflate(&(zlib->stream), Z_FULL_FLUSH);
send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
@@ -188,12 +188,12 @@ void Zlib_Decompression::write(const byt
{
if(length) no_writes = false;
- zlib->stream.next_in = (Bytef*)input;
+ zlib->stream.next_in = static_cast<Bytef*>(input;
zlib->stream.avail_in = length;
while(zlib->stream.avail_in != 0)
{
- zlib->stream.next_out = (Bytef*)buffer.begin();
+ zlib->stream.next_out = static_cast<Bytef*>(buffer.begin();
zlib->stream.avail_out = buffer.size();
int rc = inflate(&(zlib->stream), Z_SYNC_FLUSH);
@@ -213,7 +213,7 @@ void Zlib_Decompression::write(const byt
{
u32bit read_from_block = length - zlib->stream.avail_in;
start_msg();
- zlib->stream.next_in = (Bytef*)input + read_from_block;
+ zlib->stream.next_in = static_cast<Bytef*>(input + read_from_block;
zlib->stream.avail_in = length - read_from_block;
input += read_from_block;
length -= read_from_block;
@@ -233,7 +233,7 @@ void Zlib_Decompression::end_msg()
int rc = Z_OK;
while(rc != Z_STREAM_END)
{
- zlib->stream.next_out = (Bytef*)buffer.begin();
+ zlib->stream.next_out = static_cast<Bytef*>(buffer.begin();
zlib->stream.avail_out = buffer.size();
rc = inflate(&(zlib->stream), Z_SYNC_FLUSH);
if(rc != Z_OK && rc != Z_STREAM_END)
============================================================
--- modules/eng_aep/modinfo.txt c6c85c43e35cb4f019eeeeb055ddb5eb9dc83748
+++ modules/eng_aep/modinfo.txt 5c9e56bd0a4331c14d9f960fe16c33c6c4f5a141
@@ -2,7 +2,7 @@
define ENGINE_AEP,ENTROPY_SRC_AEP
-load_on: request
+load_on request
<add>
eng_aep.cpp
============================================================
--- modules/eng_gmp/modinfo.txt 11311582ba7dfe4746dff64496b75b369eec97bf
+++ modules/eng_gmp/modinfo.txt fad564f7f180df6bb1f62e58a6d7d1468e27c7b0
@@ -2,7 +2,7 @@
define ENGINE_GNU_MP
-load_on: request
+load_on request
<add>
eng_gmp.cpp
============================================================
--- modules/eng_ossl/modinfo.txt 8f79388a72fdf29e9395edcc8e997efda201d79d
+++ modules/eng_ossl/modinfo.txt 2b5cf08954ca898aab69f10d95b5ec908d3d97e8
@@ -2,7 +2,7 @@
define ENGINE_OPENSSL
-load_on: request
+load_on request
<add>
eng_ossl.cpp
============================================================
--- modules/es_beos/modinfo.txt d0a5ef440b6013c1f82e6a39031c78f30e3fadd6
+++ modules/es_beos/modinfo.txt 139290a57dfa41e67206141d01fcc3ddda29b852
@@ -1,8 +1,9 @@
realname "BeOS Entropy Source"
define ENTROPY_SRC_BEOS
+modset beos
-load_on: auto
+load_on auto
<add>
es_beos.h
============================================================
--- modules/es_capi/modinfo.txt a467873f02e52e8e4ba8a88e67fb2c388fc4bfad
+++ modules/es_capi/modinfo.txt 30e09336bd70f66edfc3953f72f0cae2e2d50991
@@ -1,9 +1,9 @@
realname "Win32 CryptoAPI Entropy Source"
define ENTROPY_SRC_CAPI
+load_on auto
+modset win32
-load_on: auto
-
<add>
es_capi.h
es_capi.cpp
============================================================
--- modules/es_egd/es_egd.cpp 7636a043d9df901b8cae558e1f1adc50255ece14
+++ modules/es_egd/es_egd.cpp e68c9f084c8c7b175f347363a848824f718fd19e
@@ -52,25 +52,25 @@ u32bit EGD_EntropySource::do_poll(byte o
throw Exception("EGD_EntropySource: Socket path is too long");
std::strcpy(addr.sun_path, path.c_str());
- int fd = socket(addr.sun_family, SOCK_STREAM, 0);
+ int fd = ::socket(addr.sun_family, SOCK_STREAM, 0);
if(fd == -1) return 0;
int len = sizeof(addr.sun_family) + std::strlen(addr.sun_path) + 1;
- if(connect(fd, reinterpret_cast<struct sockaddr*>(&addr), len))
- { close(fd); return 0; }
+ if(::connect(fd, reinterpret_cast<struct ::sockaddr*>(&addr), len))
+ { ::close(fd); return 0; }
byte buffer[2];
buffer[0] = 1;
buffer[1] = static_cast<byte>(length);
- if(write(fd, buffer, 2) != 2) { close(fd); return 0; }
- if(read(fd, buffer, 1) != 1) { close(fd); return 0; }
+ if(::write(fd, buffer, 2) != 2) { ::close(fd); return 0; }
+ if(::read(fd, buffer, 1) != 1) { ::close(fd); return 0; }
- ssize_t count = read(fd, output, buffer[0]);
+ ssize_t count = ::read(fd, output, buffer[0]);
if(count == -1) { close(fd); return 0; }
- close(fd);
+ ::close(fd);
return count;
}
============================================================
--- modules/es_egd/modinfo.txt 849799afc6c979db47632b1e12674feea8433633
+++ modules/es_egd/modinfo.txt 11617d320ffae85830cfc628f3cd34be3a4d7b0a
@@ -2,7 +2,8 @@
define ENTROPY_SRC_EGD
-load_on: auto
+load_on auto
+modset unix
<add>
es_egd.h
============================================================
--- modules/es_ftw/es_ftw.cpp 6b9dc7cec896eed27ff456d7a2e4df9947eae598
+++ modules/es_ftw/es_ftw.cpp 459d8f0d2ed22f05bf43a2fc5071457e7621448c
@@ -56,32 +56,32 @@ void FTW_EntropySource::gather_from_dir(
if(dirname == "" || files_read >= max_read)
return;
- DIR* dir = opendir(dirname.c_str());
+ DIR* dir = ::opendir(dirname.c_str());
if(dir == 0)
return;
std::vector<std::string> subdirs;
- dirent* entry = readdir(dir);
+ dirent* entry = ::readdir(dir);
while(entry && (files_read < max_read))
{
if((std::strcmp(entry->d_name, ".") == 0) ||
(std::strcmp(entry->d_name, "..") == 0))
- { entry = readdir(dir); continue; }
+ { entry = ::readdir(dir); continue; }
const std::string filename = dirname + '/' + entry->d_name;
- struct stat stat_buf;
- if(lstat(filename.c_str(), &stat_buf) == -1)
- { entry = readdir(dir); continue; }
+ struct ::stat stat_buf;
+ if(::lstat(filename.c_str(), &stat_buf) == -1)
+ { entry = ::readdir(dir); continue; }
if(S_ISREG(stat_buf.st_mode))
gather_from_file(filename);
else if(S_ISDIR(stat_buf.st_mode))
subdirs.push_back(filename);
- entry = readdir(dir);
+ entry = ::readdir(dir);
}
- closedir(dir);
+ ::closedir(dir);
for(u32bit j = 0; j != subdirs.size(); j++)
gather_from_dir(subdirs[j]);
@@ -98,7 +98,7 @@ void FTW_EntropySource::gather_from_file
SecureVector<byte> read_buf(1024);
ssize_t got = ::read(fd, read_buf.begin(), read_buf.size());
- close(fd);
+ ::close(fd);
if(got > 0)
{
============================================================
--- modules/es_ftw/modinfo.txt e768aa15a419357a4b137e2ef3ee65b4b376efdc
+++ modules/es_ftw/modinfo.txt 6027bf33c4f6c5bcf85d3e18bb38cd00b70c4a29
@@ -2,7 +2,8 @@
define ENTROPY_SRC_FTW
-load_on: auto
+load_on auto
+modset unix
<add>
es_ftw.h
============================================================
--- modules/es_unix/es_unix.cpp 77f32afff1d4a4516229483b7702c1ae1a65e3ff
+++ modules/es_unix/es_unix.cpp c38a7e079734811eb5804cae88ce3551a60f0067
@@ -51,30 +51,30 @@ void Unix_EntropySource::do_fast_poll()
for(u32bit j = 0; STAT_TARGETS[j]; j++)
{
- struct stat statbuf;
+ struct ::stat statbuf;
clear_mem(&statbuf, 1);
- stat(STAT_TARGETS[j], &statbuf);
+ ::stat(STAT_TARGETS[j], &statbuf);
add_bytes(&statbuf, sizeof(statbuf));
}
- add_bytes(getpid());
- add_bytes(getppid());
+ add_bytes(::getpid());
+ add_bytes(::getppid());
- add_bytes(getuid());
- add_bytes(getgid());
- add_bytes(geteuid());
- add_bytes(getegid());
+ add_bytes(::getuid());
+ add_bytes(::getgid());
+ add_bytes(::geteuid());
+ add_bytes(::getegid());
- add_bytes(getpgrp());
- add_bytes(getsid(0));
+ add_bytes(::getpgrp());
+ add_bytes(::getsid(0));
- struct rusage usage;
+ struct ::rusage usage;
clear_mem(&usage, 1);
- getrusage(RUSAGE_SELF, &usage);
+ ::getrusage(RUSAGE_SELF, &usage);
add_bytes(&usage, sizeof(usage));
- getrusage(RUSAGE_CHILDREN, &usage);
+ ::getrusage(RUSAGE_CHILDREN, &usage);
add_bytes(&usage, sizeof(usage));
}
============================================================
--- modules/es_unix/modinfo.txt fa9c67a4f4768aa0c066a9cab02c01ef02695b66
+++ modules/es_unix/modinfo.txt 699f5e83d950612894d82a31d9440fcfd05ea41d
@@ -1,8 +1,9 @@
realname "Generic Unix Entropy Source"
define ENTROPY_SRC_UNIX
+modset unix,beos
-load_on: auto
+load_on auto
<add>
es_unix.cpp
============================================================
--- modules/es_unix/unix_cmd.cpp e749e0619b750a2faf429dcd44fc030f344fd280
+++ modules/es_unix/unix_cmd.cpp dfc8ffbdea62adae0385bc25265132e96e865c34
@@ -41,7 +41,7 @@ void do_exec(const std::vector<std::stri
{
const std::string full_path = paths[j] + "/" + arg_list[0];
const char* fsname = full_path.c_str();
- execl(fsname, fsname, arg1, arg2, arg3, arg4, 0);
+ ::execl(fsname, fsname, arg1, arg2, arg3, arg4, 0);
}
}
@@ -69,12 +69,12 @@ u32bit DataSource_Command::read(byte buf
FD_ZERO(&set);
FD_SET(pipe->fd, &set);
- struct timeval tv;
+ struct ::timeval tv;
tv.tv_sec = 0;
tv.tv_usec = MAX_BLOCK_USECS;
ssize_t got = 0;
- if(select(pipe->fd + 1, &set, 0, 0, &tv) == 1)
+ if(::select(pipe->fd + 1, &set, 0, 0, &tv) == 1)
{
if(FD_ISSET(pipe->fd, &set))
got = ::read(pipe->fd, buf, length);
@@ -136,7 +136,7 @@ void DataSource_Command::create_pipe(con
for(u32bit j = 0; j != paths.size(); j++)
{
const std::string full_path = paths[j] + "/" + arg_list[0];
- if(access(full_path.c_str(), X_OK) == 0)
+ if(::access(full_path.c_str(), X_OK) == 0)
{
found_something = true;
break;
@@ -149,31 +149,31 @@ void DataSource_Command::create_pipe(con
if(::pipe(pipe_fd) != 0)
return;
- pid_t pid = fork();
+ pid_t pid = ::fork();
if(pid == -1)
{
- close(pipe_fd[0]);
- close(pipe_fd[1]);
+ ::close(pipe_fd[0]);
+ ::close(pipe_fd[1]);
}
else if(pid > 0)
{
pipe = new pipe_wrapper;
pipe->fd = pipe_fd[0];
pipe->pid = pid;
- close(pipe_fd[1]);
+ ::close(pipe_fd[1]);
}
else
{
if(dup2(pipe_fd[1], STDOUT_FILENO) == -1)
- exit(127);
+ ::exit(127);
if(close(pipe_fd[0]) != 0 || close(pipe_fd[1]) != 0)
- exit(127);
+ ::exit(127);
if(close(STDERR_FILENO) != 0)
- exit(127);
+ ::exit(127);
do_exec(arg_list, paths);
- exit(127);
+ ::exit(127);
}
}
@@ -190,23 +190,23 @@ void DataSource_Command::shutdown_pipe()
{
kill(pipe->pid, SIGTERM);
- struct timeval tv;
+ struct ::timeval tv;
tv.tv_sec = 0;
tv.tv_usec = KILL_WAIT;
select(0, 0, 0, 0, &tv);
- reaped = waitpid(pipe->pid, 0, WNOHANG);
+ reaped = ::waitpid(pipe->pid, 0, WNOHANG);
if(reaped == 0)
{
- kill(pipe->pid, SIGKILL);
+ ::kill(pipe->pid, SIGKILL);
do
- reaped = waitpid(pipe->pid, 0, 0);
+ reaped = ::waitpid(pipe->pid, 0, 0);
while(reaped == -1);
}
}
- close(pipe->fd);
+ ::close(pipe->fd);
delete pipe;
pipe = 0;
}
============================================================
--- modules/es_win32/modinfo.txt ab32f74ac8c68e0eba7b05565cf76ccfae391301
+++ modules/es_win32/modinfo.txt e04adc51c45928e40c22e2a9f696386a22aa0f17
@@ -4,8 +4,9 @@
#note "This module will not run under NT4"
define ENTROPY_SRC_WIN32
+modset win32
-load_on: auto
+load_on auto
<add>
es_win32.h
============================================================
--- modules/fd_unix/modinfo.txt cbc5342abbb086f96ee060c793b2aa2c26c8db88
+++ modules/fd_unix/modinfo.txt 139ba101ce429c741662e9c43545ee12cde1ec1b
@@ -1,8 +1,9 @@
realname "Unix I/O support for Pipe"
define PIPE_UNIXFD_IO
+modset unix,beos
-load_on: auto
+load_on auto
<add>
fd_unix.h
============================================================
--- modules/ml_unix/modinfo.txt bf6269c374008bd70e0e70b38e141d608a7348b1
+++ modules/ml_unix/modinfo.txt 97b3645bcf1f98fe2122cfb91357872b14890064
@@ -1,6 +1,6 @@
realname "Memory Locking for Unix"
-load_on: auto
+load_on auto
<replace>
mlock.cpp
============================================================
--- modules/ml_win32/modinfo.txt a587dfdb9f3e79f0a74b69278520b7c680bacf16
+++ modules/ml_win32/modinfo.txt 51cbfd07cbf5885d98ebb7a94e7d8f9f6b59b216
@@ -1,6 +1,6 @@
realname "Memory Locking for Win32"
-load_on: auto
+load_on auto
<replace>
mlock.cpp
============================================================
--- modules/mp_amd64/modinfo.txt 707b42d89ee327711973f147e8583142ff52e873
+++ modules/mp_amd64/modinfo.txt 87de4b21f1135e6abd902535db56d18747715701
@@ -2,7 +2,7 @@
mp_bits 64
-load_on: asm_ok
+load_on asm_ok
<replace>
mp_asm.h
============================================================
--- modules/mp_asm64/modinfo.txt b986042b6363c26bff5f6deafdb72136771c2ad5
+++ modules/mp_asm64/modinfo.txt 1388f106d1f50c1cffa8696dd0f6a70df1c10a26
@@ -2,16 +2,14 @@
mp_bits 64
-load_on: asm_ok
+load_on asm_ok
<replace>
mp_asm.h
</replace>
-# Disable amd64 since (nominally) the mp_amd64 module has that covered
<arch>
alpha
-# amd64
ia64
mips64
ppc64
============================================================
--- modules/mp_asm64/mp_asm.h 4a273756476f9e614222f5dc4c1861945fa93901
+++ modules/mp_asm64/mp_asm.h 07cf111ba199cc23b30c65dd3501a7057bb74656
@@ -12,15 +12,8 @@
#error The mp_asm64 module requires that BOTAN_MP_WORD_BITS == 64
#endif
-#if defined(BOTAN_TARGET_ARCH_IS_AMD64)
+#if defined(BOTAN_TARGET_ARCH_IS_ALPHA)
-#define BOTAN_WORD_MUL(a,b,z1,z0) do { \
- asm("mulq %3" : "=d" (z0), "=a" (z1) : \
- "a" (a), "rm" (b) : "cc"); \
-} while(0);
-
-#elif defined(BOTAN_TARGET_ARCH_IS_ALPHA)
-
#define BOTAN_WORD_MUL(a,b,z1,z0) do { \
asm("umulh %1,%2,%0" : "=r" (z0) : "r" (a), "r" (b)); \
z1 = a * b; \
============================================================
--- modules/mp_ia32/modinfo.txt d40d210e8f58f97f7f5ededc3ec2d2087d2a326a
+++ modules/mp_ia32/modinfo.txt c32d998bb81224cc6f23fbd747abc427b6f67116
@@ -2,7 +2,7 @@
mp_bits 32
-load_on: asm_ok
+load_on asm_ok
<replace>
mp_asm.h
============================================================
--- modules/mux_pthr/modinfo.txt 0306778b14500cd26b308c4ece786d4c090046f1
+++ modules/mux_pthr/modinfo.txt fc682dca25479dbea473bfe1c767bbd962711f68
@@ -2,7 +2,7 @@
define MUTEX_PTHREAD
-load_on: auto
+load_on auto
<add>
mux_pthr.cpp
============================================================
--- modules/mux_qt/modinfo.txt 7a2d33867e046517ab5abbac000f20112a8b9079
+++ modules/mux_qt/modinfo.txt 1ce02e3c791aac207a7c9d85c518608141e6ea04
@@ -4,7 +4,7 @@
note "You'll probably have to add -I/-L flags to the Makefile to find Qt"
-load_on: request
+load_on request
<add>
mux_qt.cpp
============================================================
--- modules/mux_win32/modinfo.txt 0f8259741903003ddee76b57fa3eb910ad7cd337
+++ modules/mux_win32/modinfo.txt 02e107ddb2b2200962178661759102e32ced9e69
@@ -1,8 +1,9 @@
realname "Win32 Mutex"
define MUTEX_WIN32
+modset win32
-load_on: auto
+load_on auto
<add>
mux_win32.cpp
============================================================
--- modules/tm_hard/modinfo.txt 34ed0938a058deec122cda1dcb6011362b896f89
+++ modules/tm_hard/modinfo.txt 6fb2b3c80e52cbd5158ad153a8ba1d41137ed936
@@ -2,7 +2,7 @@
define TIMER_HARDWARE
-load_on: asm_ok
+load_on asm_ok
<add>
tm_hard.cpp
============================================================
--- modules/tm_posix/modinfo.txt 31f8fdc8ad4d300118857e941ba9e10a54847456
+++ modules/tm_posix/modinfo.txt ed4eddd6b042f1d473fe5896e36ca6619ca46334
@@ -2,7 +2,7 @@
define TIMER_POSIX
-load_on: auto
+load_on auto
<add>
tm_posix.cpp
============================================================
--- modules/tm_posix/tm_posix.cpp 18d0dc1baba7dc1fbbbf5686a651aa123d1c8c14
+++ modules/tm_posix/tm_posix.cpp c42545cf0bf6ff897e22295ea485c33e8634d075
@@ -23,8 +23,8 @@ u64bit POSIX_Timer::clock() const
*************************************************/
u64bit POSIX_Timer::clock() const
{
- struct timespec tv;
- clock_gettime(CLOCK_REALTIME, &tv);
+ struct ::timespec tv;
+ ::clock_gettime(CLOCK_REALTIME, &tv);
return combine_timers(tv.tv_sec, tv.tv_nsec, 1000000000);
}
============================================================
--- modules/tm_unix/modinfo.txt b5b5e69895fd4a5f9f7a7ccdc1b8dc12e93c2e49
+++ modules/tm_unix/modinfo.txt 1a4d1b4ea18d427b03ea220b333aa4af33a656c1
@@ -2,7 +2,8 @@
define TIMER_UNIX
-load_on: auto
+load_on auto
+modset unix,beos
<add>
tm_unix.cpp
============================================================
--- modules/tm_unix/tm_unix.cpp 005a4faecc3b417e3b79afe00b62256bc9492cf0
+++ modules/tm_unix/tm_unix.cpp 1d0040253a1a3ce883428ae5b7c7f474704f6e8a
@@ -14,8 +14,8 @@ u64bit Unix_Timer::clock() const
*************************************************/
u64bit Unix_Timer::clock() const
{
- struct timeval tv;
- gettimeofday(&tv, 0);
+ struct ::timeval tv;
+ ::gettimeofday(&tv, 0);
return combine_timers(tv.tv_sec, tv.tv_usec, 1000000);
}
============================================================
--- modules/tm_win32/modinfo.txt 1767c2035911b3d660e62b9d5d46f6a6021f7582
+++ modules/tm_win32/modinfo.txt 39ec6dc93fc111aa33b9005f3f4bd770f5811887
@@ -1,8 +1,9 @@
realname "Win32 Timer"
define TIMER_WIN32
+modset win32
-load_on: auto
+load_on auto
<add>
tm_win32.cpp
============================================================
--- readme.txt 3e7dc82c42649ddd1304614574f8db74df4993b4
+++ readme.txt 5e6b8aa6aeb04399becb0471bd99de82affa5ef1
@@ -1,4 +1,4 @@
-Botan 1.7.2 (prerelease)
+Botan 1.7.3 (prerelease)
Please note that this is an experimental / development version of
Botan. Don't be surprised by bugs. No, the documentation hasn't been
============================================================
--- src/bit_ops.cpp 431a6fceac64ded07ed5564ff63016ca0b6060d9
+++ src/bit_ops.cpp ebab53284a6ab9a749188fcbe417c8dcc73ac052
@@ -3,6 +3,7 @@
* (C) 1999-2007 The Botan Project *
*************************************************/
+#include <botan/bit_ops.h>
#include <botan/loadstor.h>
namespace Botan {
@@ -42,6 +43,35 @@ void xor_buf(byte out[], const byte in[]
}
/*************************************************
+* Reverse bytes *
+*************************************************/
+u16bit reverse_bytes(u16bit input)
+ {
+ return rotate_left(input, 8);
+ }
+
+/*************************************************
+* Reverse bytes *
+*************************************************/
+u32bit reverse_bytes(u32bit input)
+ {
+ input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8);
+ return rotate_left(input, 16);
+ }
+
+/*************************************************
+* Reverse bytes *
+*************************************************/
+u64bit reverse_bytes(u64bit input)
+ {
+ input = ((input & 0xFF00FF00FF00FF00) >> 8) |
+ ((input & 0x00FF00FF00FF00FF) << 8);
+ input = ((input & 0xFFFF0000FFFF0000) >> 16) |
+ ((input & 0x0000FFFF0000FFFF) << 16);
+ return rotate_left(input, 32);
+ }
+
+/*************************************************
* Return true iff arg is 2**n for some n > 0 *
*************************************************/
bool power_of_2(u64bit arg)
============================================================
--- src/defalloc.cpp 940db8ef03ae170341d257f9f7e4320ee3938935
+++ src/defalloc.cpp e51a9fe4f6a6e191818c3e968213cc58e98cc6c2
@@ -50,7 +50,7 @@ void do_free(void* ptr, u32bit n, bool d
/*************************************************
* Malloc_Allocator's Allocation *
*************************************************/
-void* Malloc_Allocator::alloc_block(u32bit n)
+void* Malloc_Allocator::allocate(u32bit n)
{
return do_malloc(n, false);
}
@@ -58,7 +58,7 @@ void* Malloc_Allocator::alloc_block(u32b
/*************************************************
* Malloc_Allocator's Deallocation *
*************************************************/
-void Malloc_Allocator::dealloc_block(void* ptr, u32bit n)
+void Malloc_Allocator::deallocate(void* ptr, u32bit n)
{
do_free(ptr, n, false);
}
============================================================
--- src/idea.cpp 7e5d3dac233471b90ef036c4e65632f321018df6
+++ src/idea.cpp fc756e94b7f74c3f6acf7f776a8d3e6a0ca60637
@@ -13,19 +13,46 @@ namespace {
/*************************************************
* Multiplication modulo 65537 *
*************************************************/
-inline void mul(u16bit& a, u16bit b)
+inline u16bit mul(u16bit x, u16bit y)
{
- if(a && b)
+ if(x && y)
{
- u32bit temp = static_cast<u32bit>(a) * b;
- a = static_cast<u16bit>(temp >> 16);
- b = static_cast<u16bit>(temp & 0xFFFF);
- a = static_cast<u16bit>(b - a + ((b < a) ? 1 : 0));
+ u32bit T = static_cast<u32bit>(x) * y;
+ x = static_cast<u16bit>(T >> 16);
+ y = static_cast<u16bit>(T & 0xFFFF);
+ return static_cast<u16bit>(y - x + ((y < x) ? 1 : 0));
}
else
- a = static_cast<u16bit>(1 - a - b);
+ return static_cast<u16bit>(1 - x - y);
}
+/*************************************************
+* Find multiplicative inverses modulo 65537 *
+*************************************************/
+u16bit mul_inv(u16bit x)
+ {
+ if(x <= 1)
+ return x;
+
+ u16bit t0 = static_cast<u16bit>(65537 / x), t1 = 1;
+ u16bit y = static_cast<u16bit>(65537 % x);
+
+ while(y != 1)
+ {
+ u16bit q = x / y;
+ x %= y;
+ t1 += q * t0;
+
+ if(x == 1)
+ return t1;
+
+ q = y / x;
+ y %= x;
+ t0 += q * t1;
+ }
+ return (1 - t0);
+ }
+
}
/*************************************************
@@ -40,24 +67,28 @@ void IDEA::enc(const byte in[], byte out
for(u32bit j = 0; j != 8; ++j)
{
- mul(X1, EK[6*j+0]);
+ X1 = mul(X1, EK[6*j+0]);
X2 += EK[6*j+1];
X3 += EK[6*j+2];
- mul(X4, EK[6*j+3]);
+ X4 = mul(X4, EK[6*j+3]);
+
u16bit T0 = X3;
- X3 ^= X1;
- mul(X3, EK[6*j+4]);
+ X3 = mul(X3 ^ X1, EK[6*j+4]);
+
u16bit T1 = X2;
- X2 = static_cast<u16bit>((X2 ^ X4) + X3);
- mul(X2, EK[6*j+5]);
+ X2 = mul((X2 ^ X4) + X3, EK[6*j+5]);
X3 += X2;
+
X1 ^= X2;
X4 ^= X3;
X2 ^= T0;
X3 ^= T1;
}
- mul(X1, EK[48]); X2 += EK[50]; X3 += EK[49]; mul(X4, EK[51]);
+ X1 = mul(X1, EK[48]);
+ X2 += EK[50];
+ X3 += EK[49];
+ X4 = mul(X4, EK[51]);
store_be(out, X1, X3, X2, X4);
}
@@ -74,54 +105,33 @@ void IDEA::dec(const byte in[], byte out
for(u32bit j = 0; j != 8; ++j)
{
- mul(X1, DK[6*j+0]);
+ X1 = mul(X1, DK[6*j+0]);
X2 += DK[6*j+1];
X3 += DK[6*j+2];
- mul(X4, DK[6*j+3]);
+ X4 = mul(X4, DK[6*j+3]);
+
u16bit T0 = X3;
- X3 ^= X1;
- mul(X3, DK[6*j+4]);
+ X3 = mul(X3 ^ X1, DK[6*j+4]);
+
u16bit T1 = X2;
- X2 = static_cast<u16bit>((X2 ^ X4) + X3);
- mul(X2, DK[6*j+5]);
+ X2 = mul((X2 ^ X4) + X3, DK[6*j+5]);
X3 += X2;
+
X1 ^= X2;
X4 ^= X3;
X2 ^= T0;
X3 ^= T1;
}
- mul(X1, DK[48]); X2 += DK[50]; X3 += DK[49]; mul(X4, DK[51]);
+ X1 = mul(X1, DK[48]);
+ X2 += DK[50];
+ X3 += DK[49];
+ X4 = mul(X4, DK[51]);
store_be(out, X1, X3, X2, X4);
}
/*************************************************
-* Find multiplicative inverses modulo 65537 *
-*************************************************/
-u16bit IDEA::mul_inv(u16bit x)
- {
- if(x <= 1)
- return x;
-
- u16bit t0 = static_cast<u16bit>(65537 / x), t1 = 1;
- u16bit y = static_cast<u16bit>(65537 % x);
-
- while(y != 1)
- {
- u16bit q = static_cast<u16bit>(x / y);
- x %= y;
- t1 += static_cast<u16bit>(q * t0);
- if(x == 1)
- return t1;
- q = static_cast<u16bit>(y / x);
- y %= x;
- t0 += static_cast<u16bit>(q * t1);
- }
- return static_cast<u16bit>(1 - t0);
- }
-
-/*************************************************
* IDEA Key Schedule *
*************************************************/
void IDEA::key(const byte key[], u32bit)
============================================================
--- src/init_opt.cpp b66c0ecf18aa8f66a11ffbef319395e5323c69ea
+++ src/init_opt.cpp 9a0e31808f088cb63f2ec8563d937a69421f795f
@@ -86,15 +86,6 @@ bool InitializerOptions::self_test() con
}
/*************************************************
-* Return the config file to load, if any *
-*************************************************/
-std::string InitializerOptions::config_file() const
- {
- std::map<std::string, std::string>::const_iterator i = args.find("config");
- return (i != args.end()) ? i->second : "";
- }
-
-/*************************************************
* Setup an InitializerOptions *
*************************************************/
InitializerOptions::InitializerOptions(const std::string& arg_string)
============================================================
--- src/libstate.cpp 5f372a92af4809198b85214da9c873e97ec3cb8c
+++ src/libstate.cpp 4cc7325e854efc2351e4f1e0726092e5d8fb760f
@@ -340,9 +340,6 @@ void Library_State::initialize(const Ini
timer = modules.timer();
transcoder = modules.transcoder();
- if(args.config_file() != "")
- config().load_inifile(args.config_file());
-
locks["settings"] = get_mutex();
locks["allocator"] = get_mutex();
locks["rng"] = get_mutex();
============================================================
--- src/modules.cpp 310f410a77f14f2b559a24a0a00821880205b6c8
+++ src/modules.cpp d5fbabe263e5a39b8a85adf8a5084ec28405ee64
@@ -7,7 +7,6 @@
#include <botan/defalloc.h>
#include <botan/def_char.h>
#include <botan/eng_def.h>
-#include <botan/es_file.h>
#include <botan/timers.h>
#if defined(BOTAN_EXT_MUTEX_PTHREAD)
@@ -48,6 +47,10 @@
#include <botan/es_aep.h>
#endif
+#if defined(BOTAN_EXT_ENTROPY_SRC_DEVICE)
+ #include <botan/es_dev.h>
+#endif
+
#if defined(BOTAN_EXT_ENTROPY_SRC_EGD)
#include <botan/es_egd.h>
#endif
@@ -149,8 +152,6 @@ std::vector<EntropySource*> Builtin_Modu
{
std::vector<EntropySource*> sources;
- sources.push_back(new File_EntropySource);
-
#if defined(BOTAN_EXT_ENTROPY_SRC_AEP)
sources.push_back(new AEP_EntropySource);
#endif
@@ -159,6 +160,10 @@ std::vector<EntropySource*> Builtin_Modu
sources.push_back(new EGD_EntropySource);
#endif
+#if defined(BOTAN_EXT_ENTROPY_SRC_DEVICE)
+ sources.push_back(new Device_EntropySource);
+#endif
+
#if defined(BOTAN_EXT_ENTROPY_SRC_CAPI)
sources.push_back(new Win32_CAPI_EntropySource);
#endif
============================================================
--- src/mp_mul.cpp dafb1262e69f06c17fe781aea9c7ed04ef789829
+++ src/mp_mul.cpp 4801f41f564dbaf9a3a0bacb03ad795f94c4a27b
@@ -95,8 +95,8 @@ u32bit karatsuba_size(u32bit z_size,
((y_size == y_sw) && (y_size % 2)))
return 0;
- u32bit start = (x_sw > y_sw) ? x_sw : y_sw;
- u32bit end = (x_size < y_size) ? x_size : y_size;
+ const u32bit start = (x_sw > y_sw) ? x_sw : y_sw;
+ const u32bit end = (x_size < y_size) ? x_size : y_size;
if(start == end)
{
============================================================
--- src/policy.cpp d5d94c0e82c5d91e4827ccb42b55b43c178217d7
+++ src/policy.cpp 1cbaa37581f2e3a3cc3388766eb0f57f92c16a92
@@ -229,7 +229,7 @@ void set_default_config(Config& config)
config.set_option("rng/ms_capi_prov_type", "INTEL_SEC:RSA_FULL");
config.set_option("rng/unix_path", "/bin:/sbin:/usr/bin:/usr/sbin");
- config.set_option("rng/es_files", "/dev/urandom:/dev/random");
+ config.set_option("rng/es_files", "/dev/random:/dev/srandom:/dev/urandom");
config.set_option("rng/egd_path",
"/var/run/egd-pool:/dev/egd-pool");
config.set_option("rng/slow_poll_request", "256");
============================================================
--- src/randpool.cpp 279e898147d23a9134964dae4edc36e4a475eb18
+++ src/randpool.cpp cf40501448e5f6f3bcaa3d00b43dd3cc33c39170
@@ -10,8 +10,6 @@
#include <botan/util.h>
#include <algorithm>
-#include <assert.h>
-
namespace Botan {
namespace {
============================================================
--- src/turing.cpp e7d74e2e4657776508c3893aefcbee9180116384
+++ src/turing.cpp 5155dad33304df10b9b61e7103c611eba62a4c0d
@@ -170,7 +170,7 @@ void Turing::generate()
}
/*************************************************
-*
+* Turing's byte mixing step *
*************************************************/
u32bit Turing::fixedS(u32bit W)
{