aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-01-12 10:35:55 -0500
committerJack Lloyd <[email protected]>2018-01-12 11:34:29 -0500
commit2031badab44efad536509ac4c0c2f3ea1928de0a (patch)
treeeb7cc8239223d7507863000bcdad8440b8c6b32b /src/lib
parentaee4203df5d1b7437fccd0b134ce8190daea0cd0 (diff)
Make stream, block, hash and cipher mode base classes optional
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/base/info.txt4
-rw-r--r--src/lib/base/lookup.h27
-rw-r--r--src/lib/block/lion/info.txt5
-rw-r--r--src/lib/ffi/info.txt3
-rw-r--r--src/lib/filters/algo_filt.cpp11
-rw-r--r--src/lib/filters/filters.h27
-rw-r--r--src/lib/hash/checksum/info.txt4
-rw-r--r--src/lib/hash/info.txt4
-rw-r--r--src/lib/kdf/kdf1/info.txt4
-rw-r--r--src/lib/kdf/kdf1_iso18033/info.txt4
-rw-r--r--src/lib/kdf/kdf2/info.txt4
-rw-r--r--src/lib/mac/cbc_mac/info.txt4
-rw-r--r--src/lib/mac/cmac/info.txt1
-rw-r--r--src/lib/mac/gmac/info.txt2
-rw-r--r--src/lib/mac/hmac/info.txt4
-rw-r--r--src/lib/misc/nist_keywrap/info.txt4
-rw-r--r--src/lib/modes/aead/ccm/info.txt4
-rw-r--r--src/lib/modes/aead/gcm/info.txt1
-rw-r--r--src/lib/modes/aead/ocb/info.txt1
-rw-r--r--src/lib/modes/cbc/info.txt1
-rw-r--r--src/lib/modes/cfb/info.txt4
-rw-r--r--src/lib/modes/cipher_mode.cpp2
-rw-r--r--src/lib/modes/stream_mode.h9
-rw-r--r--src/lib/modes/xts/info.txt1
-rw-r--r--src/lib/stream/ctr/info.txt4
-rw-r--r--src/lib/stream/ofb/info.txt4
26 files changed, 129 insertions, 14 deletions
diff --git a/src/lib/base/info.txt b/src/lib/base/info.txt
index c5f89f470..fd3f7b890 100644
--- a/src/lib/base/info.txt
+++ b/src/lib/base/info.txt
@@ -11,11 +11,7 @@ symkey.h
</header:public>
<requires>
-block
-hash
hex
-modes
rng
-stream
utils
</requires>
diff --git a/src/lib/base/lookup.h b/src/lib/base/lookup.h
index 18c885d16..1cfa7d3c9 100644
--- a/src/lib/base/lookup.h
+++ b/src/lib/base/lookup.h
@@ -9,14 +9,23 @@
#define BOTAN_LOOKUP_H_
#include <botan/build.h>
-#include <botan/block_cipher.h>
-#include <botan/stream_cipher.h>
-#include <botan/hash.h>
#include <botan/exceptn.h>
#include <string>
#include <vector>
#include <memory>
+#if defined(BOTAN_HAS_BLOCK_CIPHER)
+ #include <botan/block_cipher.h>
+#endif
+
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+ #include <botan/stream_cipher.h>
+#endif
+
+#if defined(BOTAN_HAS_HASH)
+ #include <botan/hash.h>
+#endif
+
#if defined(BOTAN_HAS_MAC)
#include <botan/mac.h>
#endif
@@ -34,6 +43,8 @@ namespace Botan {
* caller assume ownership of them
*/
+#if defined(BOTAN_HAS_BLOCK_CIPHER)
+
/**
* Block cipher factory method.
*
@@ -61,6 +72,10 @@ inline std::vector<std::string> get_block_cipher_providers(const std::string& al
return BlockCipher::providers(algo_spec);
}
+#endif
+
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+
/**
* Stream cipher factory method.
*
@@ -88,6 +103,10 @@ inline std::vector<std::string> get_stream_cipher_providers(const std::string& a
return StreamCipher::providers(algo_spec);
}
+#endif
+
+#if defined(BOTAN_HAS_HASH)
+
/**
* Hash function factory method.
*
@@ -122,6 +141,8 @@ inline std::vector<std::string> get_hash_function_providers(const std::string& a
return HashFunction::providers(algo_spec);
}
+#endif
+
#if defined(BOTAN_HAS_MAC)
/**
* MAC factory method.
diff --git a/src/lib/block/lion/info.txt b/src/lib/block/lion/info.txt
index c818627eb..a7b93e92e 100644
--- a/src/lib/block/lion/info.txt
+++ b/src/lib/block/lion/info.txt
@@ -1,3 +1,8 @@
<defines>
LION -> 20131128
</defines>
+
+<requires>
+stream
+hash
+</requires>
diff --git a/src/lib/ffi/info.txt b/src/lib/ffi/info.txt
index d85faee0e..c02bd3a39 100644
--- a/src/lib/ffi/info.txt
+++ b/src/lib/ffi/info.txt
@@ -14,6 +14,9 @@ ffi.h
</header:public>
<requires>
+block
+stream
+hash
aead
kdf
pbkdf
diff --git a/src/lib/filters/algo_filt.cpp b/src/lib/filters/algo_filt.cpp
index 63906907c..099c413d3 100644
--- a/src/lib/filters/algo_filt.cpp
+++ b/src/lib/filters/algo_filt.cpp
@@ -10,6 +10,8 @@
namespace Botan {
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+
StreamCipher_Filter::StreamCipher_Filter(StreamCipher* cipher) :
m_buffer(DEFAULT_BUFFERSIZE),
m_cipher(cipher)
@@ -48,6 +50,10 @@ void StreamCipher_Filter::write(const uint8_t input[], size_t length)
}
}
+#endif
+
+#if defined(BOTAN_HAS_HASH)
+
Hash_Filter::Hash_Filter(const std::string& hash_name, size_t len) :
m_hash(HashFunction::create_or_throw(hash_name)),
m_out_len(len)
@@ -62,6 +68,9 @@ void Hash_Filter::end_msg()
else
send(output);
}
+#endif
+
+#if defined(BOTAN_HAS_MAC)
MAC_Filter::MAC_Filter(const std::string& mac_name, size_t len) :
m_mac(MessageAuthenticationCode::create_or_throw(mac_name)),
@@ -85,4 +94,6 @@ void MAC_Filter::end_msg()
send(output);
}
+#endif
+
}
diff --git a/src/lib/filters/filters.h b/src/lib/filters/filters.h
index af310a599..b4aee1207 100644
--- a/src/lib/filters/filters.h
+++ b/src/lib/filters/filters.h
@@ -8,14 +8,22 @@
#ifndef BOTAN_FILTERS_H_
#define BOTAN_FILTERS_H_
-#include <botan/stream_cipher.h>
-#include <botan/hash.h>
-#include <botan/mac.h>
-
-#include <botan/pipe.h>
#include <botan/basefilt.h>
#include <botan/key_filt.h>
#include <botan/data_snk.h>
+#include <botan/pipe.h>
+
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+ #include <botan/stream_cipher.h>
+#endif
+
+#if defined(BOTAN_HAS_HASH)
+ #include <botan/hash.h>
+#endif
+
+#if defined(BOTAN_HAS_MAC)
+ #include <botan/mac.h>
+#endif
#if defined(BOTAN_HAS_CODEC_FILTERS)
#include <botan/b64_filt.h>
@@ -24,6 +32,8 @@
namespace Botan {
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+
/**
* Stream Cipher Filter
*/
@@ -89,6 +99,9 @@ class BOTAN_PUBLIC_API(2,0) StreamCipher_Filter final : public Keyed_Filter
secure_vector<uint8_t> m_buffer;
std::unique_ptr<StreamCipher> m_cipher;
};
+#endif
+
+#if defined(BOTAN_HAS_HASH)
/**
* Hash Filter.
@@ -126,6 +139,9 @@ class BOTAN_PUBLIC_API(2,0) Hash_Filter final : public Filter
std::unique_ptr<HashFunction> m_hash;
const size_t m_out_len;
};
+#endif
+
+#if defined(BOTAN_HAS_MAC)
/**
* MessageAuthenticationCode Filter.
@@ -204,6 +220,7 @@ class BOTAN_PUBLIC_API(2,0) MAC_Filter final : public Keyed_Filter
std::unique_ptr<MessageAuthenticationCode> m_mac;
const size_t m_out_len;
};
+#endif
}
diff --git a/src/lib/hash/checksum/info.txt b/src/lib/hash/checksum/info.txt
new file mode 100644
index 000000000..5aab13b59
--- /dev/null
+++ b/src/lib/hash/checksum/info.txt
@@ -0,0 +1,4 @@
+
+<requires>
+hash
+</requires>
diff --git a/src/lib/hash/info.txt b/src/lib/hash/info.txt
index e71318b73..8d3817058 100644
--- a/src/lib/hash/info.txt
+++ b/src/lib/hash/info.txt
@@ -1,3 +1,7 @@
+<defines>
+HASH -> 20180112
+</defines>
+
<header:public>
hash.h
</header:public>
diff --git a/src/lib/kdf/kdf1/info.txt b/src/lib/kdf/kdf1/info.txt
index a2372c7e3..f88268f93 100644
--- a/src/lib/kdf/kdf1/info.txt
+++ b/src/lib/kdf/kdf1/info.txt
@@ -1,3 +1,7 @@
<defines>
KDF1 -> 20131128
</defines>
+
+<requires>
+hash
+</requires>
diff --git a/src/lib/kdf/kdf1_iso18033/info.txt b/src/lib/kdf/kdf1_iso18033/info.txt
index af6026836..494b8358b 100644
--- a/src/lib/kdf/kdf1_iso18033/info.txt
+++ b/src/lib/kdf/kdf1_iso18033/info.txt
@@ -1,3 +1,7 @@
<defines>
KDF1_18033 -> 20160128
</defines>
+
+<requires>
+hash
+</requires>
diff --git a/src/lib/kdf/kdf2/info.txt b/src/lib/kdf/kdf2/info.txt
index 26c824cf2..e222a4521 100644
--- a/src/lib/kdf/kdf2/info.txt
+++ b/src/lib/kdf/kdf2/info.txt
@@ -1,3 +1,7 @@
<defines>
KDF2 -> 20131128
</defines>
+
+<requires>
+hash
+</requires>
diff --git a/src/lib/mac/cbc_mac/info.txt b/src/lib/mac/cbc_mac/info.txt
index 1cf22eae0..994a63872 100644
--- a/src/lib/mac/cbc_mac/info.txt
+++ b/src/lib/mac/cbc_mac/info.txt
@@ -1,3 +1,7 @@
<defines>
CBC_MAC -> 20131128
</defines>
+
+<requires>
+block
+</requires>
diff --git a/src/lib/mac/cmac/info.txt b/src/lib/mac/cmac/info.txt
index bdddca1b2..d78b3851e 100644
--- a/src/lib/mac/cmac/info.txt
+++ b/src/lib/mac/cmac/info.txt
@@ -3,5 +3,6 @@ CMAC -> 20131128
</defines>
<requires>
+block
poly_dbl
</requires>
diff --git a/src/lib/mac/gmac/info.txt b/src/lib/mac/gmac/info.txt
index 416e914db..104e35962 100644
--- a/src/lib/mac/gmac/info.txt
+++ b/src/lib/mac/gmac/info.txt
@@ -4,5 +4,5 @@ GMAC -> 20160207
<requires>
gcm
-mac
+block
</requires>
diff --git a/src/lib/mac/hmac/info.txt b/src/lib/mac/hmac/info.txt
index cf1a288f6..50dc665dc 100644
--- a/src/lib/mac/hmac/info.txt
+++ b/src/lib/mac/hmac/info.txt
@@ -1,3 +1,7 @@
<defines>
HMAC -> 20131128
</defines>
+
+<requires>
+hash
+</requires>
diff --git a/src/lib/misc/nist_keywrap/info.txt b/src/lib/misc/nist_keywrap/info.txt
index 3fb3639f0..b48e84c11 100644
--- a/src/lib/misc/nist_keywrap/info.txt
+++ b/src/lib/misc/nist_keywrap/info.txt
@@ -1,3 +1,7 @@
<defines>
NIST_KEYWRAP -> 20171119
</defines>
+
+<requires>
+block
+</requires>
diff --git a/src/lib/modes/aead/ccm/info.txt b/src/lib/modes/aead/ccm/info.txt
index b12a43b03..9341cea7f 100644
--- a/src/lib/modes/aead/ccm/info.txt
+++ b/src/lib/modes/aead/ccm/info.txt
@@ -1,3 +1,7 @@
<defines>
AEAD_CCM -> 20131128
</defines>
+
+<requires>
+block
+</requires>
diff --git a/src/lib/modes/aead/gcm/info.txt b/src/lib/modes/aead/gcm/info.txt
index 6dc5c6928..e46fa34bc 100644
--- a/src/lib/modes/aead/gcm/info.txt
+++ b/src/lib/modes/aead/gcm/info.txt
@@ -3,5 +3,6 @@ AEAD_GCM -> 20131128
</defines>
<requires>
+block
ctr
</requires>
diff --git a/src/lib/modes/aead/ocb/info.txt b/src/lib/modes/aead/ocb/info.txt
index 9af91f238..4e16e2362 100644
--- a/src/lib/modes/aead/ocb/info.txt
+++ b/src/lib/modes/aead/ocb/info.txt
@@ -3,5 +3,6 @@ AEAD_OCB -> 20131128
</defines>
<requires>
+block
poly_dbl
</requires>
diff --git a/src/lib/modes/cbc/info.txt b/src/lib/modes/cbc/info.txt
index a1e3e1dec..778ba1e25 100644
--- a/src/lib/modes/cbc/info.txt
+++ b/src/lib/modes/cbc/info.txt
@@ -3,5 +3,6 @@ MODE_CBC -> 20131128
</defines>
<requires>
+block
mode_pad
</requires>
diff --git a/src/lib/modes/cfb/info.txt b/src/lib/modes/cfb/info.txt
index 29744514f..77a6af448 100644
--- a/src/lib/modes/cfb/info.txt
+++ b/src/lib/modes/cfb/info.txt
@@ -1,3 +1,7 @@
<defines>
MODE_CFB -> 20131128
</defines>
+
+<requires>
+block
+</requires>
diff --git a/src/lib/modes/cipher_mode.cpp b/src/lib/modes/cipher_mode.cpp
index 6023102da..804713be7 100644
--- a/src/lib/modes/cipher_mode.cpp
+++ b/src/lib/modes/cipher_mode.cpp
@@ -51,10 +51,12 @@ Cipher_Mode* get_cipher_mode(const std::string& algo, Cipher_Dir direction,
}
#endif
+#if defined(BOTAN_HAS_STREAM_CIPHER)
if(auto sc = StreamCipher::create(algo))
{
return new Stream_Cipher_Mode(sc.release());
}
+#endif
#if defined(BOTAN_HAS_AEAD_MODES)
if(auto aead = get_aead(algo, direction))
diff --git a/src/lib/modes/stream_mode.h b/src/lib/modes/stream_mode.h
index 8db23d993..3bce01731 100644
--- a/src/lib/modes/stream_mode.h
+++ b/src/lib/modes/stream_mode.h
@@ -9,10 +9,15 @@
#define BOTAN_STREAM_MODE_H_
#include <botan/cipher_mode.h>
-#include <botan/stream_cipher.h>
+
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+ #include <botan/stream_cipher.h>
+#endif
namespace Botan {
+#if defined(BOTAN_HAS_STREAM_CIPHER)
+
class BOTAN_PUBLIC_API(2,0) Stream_Cipher_Mode final : public Cipher_Mode
{
public:
@@ -70,6 +75,8 @@ class BOTAN_PUBLIC_API(2,0) Stream_Cipher_Mode final : public Cipher_Mode
std::unique_ptr<StreamCipher> m_cipher;
};
+#endif
+
}
#endif
diff --git a/src/lib/modes/xts/info.txt b/src/lib/modes/xts/info.txt
index 2a41f696f..cee850be7 100644
--- a/src/lib/modes/xts/info.txt
+++ b/src/lib/modes/xts/info.txt
@@ -3,5 +3,6 @@ MODE_XTS -> 20131128
</defines>
<requires>
+block
poly_dbl
</requires>
diff --git a/src/lib/stream/ctr/info.txt b/src/lib/stream/ctr/info.txt
index 4cb30fa2f..270ceecf8 100644
--- a/src/lib/stream/ctr/info.txt
+++ b/src/lib/stream/ctr/info.txt
@@ -1,3 +1,7 @@
<defines>
CTR_BE -> 20131128
</defines>
+
+<requires>
+block
+</requires>
diff --git a/src/lib/stream/ofb/info.txt b/src/lib/stream/ofb/info.txt
index be585d0d3..2675e7857 100644
--- a/src/lib/stream/ofb/info.txt
+++ b/src/lib/stream/ofb/info.txt
@@ -1,3 +1,7 @@
<defines>
OFB -> 20131128
</defines>
+
+<requires>
+block
+</requires>