diff options
author | lloyd <[email protected]> | 2010-06-16 01:21:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-06-16 01:21:33 +0000 |
commit | a87419f1304aa63b0b4e17f750f5dd2097cb8bf4 (patch) | |
tree | ae6c8b89d432394877e657b27b5b55fe8ef0cb4f | |
parent | ecb574d32f4382326e94ad19e9d5baecc84a3c29 (diff) |
Remove some of the more extraneous namespaces
-rw-r--r-- | src/codec/openpgp/openpgp.cpp | 26 | ||||
-rw-r--r-- | src/codec/openpgp/openpgp.h | 53 | ||||
-rw-r--r-- | src/constructs/aont/package.cpp | 18 | ||||
-rw-r--r-- | src/constructs/aont/package.h | 18 | ||||
-rw-r--r-- | src/constructs/cryptobox/cryptobox.cpp | 16 | ||||
-rw-r--r-- | src/constructs/cryptobox/cryptobox.h | 14 | ||||
-rw-r--r-- | src/utils/prefetch.h | 8 |
7 files changed, 79 insertions, 74 deletions
diff --git a/src/codec/openpgp/openpgp.cpp b/src/codec/openpgp/openpgp.cpp index f55caf1c8..ca1ea6d9c 100644 --- a/src/codec/openpgp/openpgp.cpp +++ b/src/codec/openpgp/openpgp.cpp @@ -13,14 +13,13 @@ namespace Botan { -namespace OpenPGP { - /* * OpenPGP Base64 encoding */ -std::string encode(const byte input[], u32bit length, - const std::string& label, - const std::map<std::string, std::string>& headers) +std::string PGP_encode( + const byte input[], u32bit length, + const std::string& label, + const std::map<std::string, std::string>& headers) { const std::string PGP_HEADER = "-----BEGIN PGP " + label + "-----\n"; const std::string PGP_TRAILER = "-----END PGP " + label + "-----\n"; @@ -58,18 +57,19 @@ std::string encode(const byte input[], u32bit length, /* * OpenPGP Base64 encoding */ -std::string encode(const byte input[], u32bit length, - const std::string& type) +std::string PGP_encode(const byte input[], u32bit length, + const std::string& type) { std::map<std::string, std::string> empty; - return encode(input, length, type, empty); + return PGP_encode(input, length, type, empty); } /* * OpenPGP Base64 decoding */ -SecureVector<byte> decode(DataSource& source, std::string& label, - std::map<std::string, std::string>& headers) +SecureVector<byte> PGP_decode(DataSource& source, + std::string& label, + std::map<std::string, std::string>& headers) { const u32bit RANDOM_CHAR_LIMIT = 5; @@ -186,13 +186,11 @@ SecureVector<byte> decode(DataSource& source, std::string& label, /* * OpenPGP Base64 decoding */ -SecureVector<byte> decode(DataSource& source, std::string& label) +SecureVector<byte> PGP_decode(DataSource& source, std::string& label) { std::map<std::string, std::string> ignored; - return decode(source, label, ignored); + return PGP_decode(source, label, ignored); } } -} - diff --git a/src/codec/openpgp/openpgp.h b/src/codec/openpgp/openpgp.h index 7021d5675..1e2cf10f0 100644 --- a/src/codec/openpgp/openpgp.h +++ b/src/codec/openpgp/openpgp.h @@ -14,20 +14,47 @@ namespace Botan { -namespace OpenPGP { - -/* -* OpenPGP Base64 encoding/decoding +/** +* @param input the input data +* @param length length of input in bytes +* @param label the human-readable label +* @param headers a set of key/value pairs included in the header */ -BOTAN_DLL std::string encode(const byte[], u32bit, const std::string&, - const std::map<std::string, std::string>&); -BOTAN_DLL SecureVector<byte> decode(DataSource&, std::string&, - std::map<std::string, std::string>&); - -BOTAN_DLL std::string encode(const byte[], u32bit, const std::string&); -BOTAN_DLL SecureVector<byte> decode(DataSource&, std::string&); - -} +BOTAN_DLL std::string PGP_encode( + const byte input[], + u32bit length, + const std::string& label, + const std::map<std::string, std::string>& headers); + +/** +* @param input the input data +* @param length length of input in bytes +* @param label the human-readable label +*/ +BOTAN_DLL std::string PGP_encode( + const byte input[], + u32bit length, + const std::string& label); + +/** +* @param source the input source +* @param label is set to the human-readable label +* @param headers is set to any headers +* @return decoded output as raw binary +*/ +BOTAN_DLL SecureVector<byte> PGP_decode( + DataSource& source, + std::string& label, + std::map<std::string, std::string>& headers); + +/** +* @param source the input source +* @param label is set to the human-readable label +* @return decoded output as raw binary +*/ +BOTAN_DLL SecureVector<byte> PGP_decode( + DataSource& source, + std::string& label); } diff --git a/src/constructs/aont/package.cpp b/src/constructs/aont/package.cpp index 5d1e674ca..e10087060 100644 --- a/src/constructs/aont/package.cpp +++ b/src/constructs/aont/package.cpp @@ -14,12 +14,10 @@ namespace Botan { -namespace AllOrNothingTransform { - -void package(RandomNumberGenerator& rng, - BlockCipher* cipher, - const byte input[], u32bit input_len, - byte output[]) +void aont_package(RandomNumberGenerator& rng, + BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]) { if(!cipher->valid_keylength(cipher->BLOCK_SIZE)) throw Invalid_Argument("AONT::package: Invalid cipher"); @@ -66,9 +64,9 @@ void package(RandomNumberGenerator& rng, xor_buf(final_block, package_key.begin(), cipher->BLOCK_SIZE); } -void unpackage(BlockCipher* cipher, - const byte input[], u32bit input_len, - byte output[]) +void aont_unpackage(BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]) { if(!cipher->valid_keylength(cipher->BLOCK_SIZE)) throw Invalid_Argument("AONT::unpackage: Invalid cipher"); @@ -116,5 +114,3 @@ void unpackage(BlockCipher* cipher, } } - -} diff --git a/src/constructs/aont/package.h b/src/constructs/aont/package.h index 9c23d1836..211623347 100644 --- a/src/constructs/aont/package.h +++ b/src/constructs/aont/package.h @@ -14,8 +14,6 @@ namespace Botan { -namespace AllOrNothingTransform { - /** * Rivest's Package Tranform * @arg rng the random number generator to use @@ -25,10 +23,10 @@ namespace AllOrNothingTransform { * @arg output the output data buffer (must be at least * input_len + cipher->BLOCK_SIZE bytes long) */ -void BOTAN_DLL package(RandomNumberGenerator& rng, - BlockCipher* cipher, - const byte input[], u32bit input_len, - byte output[]); +void BOTAN_DLL aont_package(RandomNumberGenerator& rng, + BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]); /** * Rivest's Package Tranform (Inversion) @@ -39,11 +37,9 @@ void BOTAN_DLL package(RandomNumberGenerator& rng, * @arg output the output data buffer (must be at least * input_len - cipher->BLOCK_SIZE bytes long) */ -void BOTAN_DLL unpackage(BlockCipher* cipher, - const byte input[], u32bit input_len, - byte output[]); - -} +void BOTAN_DLL aont_unpackage(BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]); } diff --git a/src/constructs/cryptobox/cryptobox.cpp b/src/constructs/cryptobox/cryptobox.cpp index 371b52e66..7d27c0523 100644 --- a/src/constructs/cryptobox/cryptobox.cpp +++ b/src/constructs/cryptobox/cryptobox.cpp @@ -18,8 +18,6 @@ namespace Botan { -namespace CryptoBox { - namespace { /* @@ -40,9 +38,9 @@ const u32bit PBKDF_OUTPUT_LEN = CIPHER_KEY_LEN + CIPHER_IV_LEN + MAC_KEY_LEN; } -std::string encrypt(const byte input[], u32bit input_len, - const std::string& passphrase, - RandomNumberGenerator& rng) +std::string cryptobox_encrypt(const byte input[], u32bit input_len, + const std::string& passphrase, + RandomNumberGenerator& rng) { SecureVector<byte> pbkdf_salt(PBKDF_SALT_LEN); rng.randomize(pbkdf_salt.begin(), pbkdf_salt.size()); @@ -91,8 +89,8 @@ std::string encrypt(const byte input[], u32bit input_len, "BOTAN CRYPTOBOX MESSAGE"); } -std::string decrypt(const byte input[], u32bit input_len, - const std::string& passphrase) +std::string cryptobox_decrypt(const byte input[], u32bit input_len, + const std::string& passphrase) { DataSource_Memory input_src(input, input_len); SecureVector<byte> ciphertext = @@ -120,7 +118,7 @@ std::string decrypt(const byte input[], u32bit input_len, CIPHER_IV_LEN); Pipe pipe(new Fork( - get_cipher("Serpent/CTR-BE", cipher_key, iv, ENCRYPTION), + get_cipher("Serpent/CTR-BE", cipher_key, iv, DECRYPTION), new MAC_Filter(new HMAC(new SHA_512), mac_key, MAC_OUTPUT_LEN))); @@ -141,5 +139,3 @@ std::string decrypt(const byte input[], u32bit input_len, } } - -} diff --git a/src/constructs/cryptobox/cryptobox.h b/src/constructs/cryptobox/cryptobox.h index a30cb244a..3dbb894ba 100644 --- a/src/constructs/cryptobox/cryptobox.h +++ b/src/constructs/cryptobox/cryptobox.h @@ -13,8 +13,6 @@ namespace Botan { -namespace CryptoBox { - /** * Encrypt a message * @param input the input data @@ -22,9 +20,9 @@ namespace CryptoBox { * @param passphrase the passphrase used to encrypt the message * @param rng a ref to a random number generator, such as AutoSeeded_RNG */ -BOTAN_DLL std::string encrypt(const byte input[], u32bit input_len, - const std::string& passphrase, - RandomNumberGenerator& rng); +BOTAN_DLL std::string cryptobox_encrypt(const byte input[], u32bit input_len, + const std::string& passphrase, + RandomNumberGenerator& rng); /** * Decrypt a message encrypted with CryptoBox::encrypt @@ -32,10 +30,8 @@ BOTAN_DLL std::string encrypt(const byte input[], u32bit input_len, * @param input_len the length of input in bytes * @param passphrase the passphrase used to encrypt the message */ -BOTAN_DLL std::string decrypt(const byte input[], u32bit input_len, - const std::string& passphrase); - -} +BOTAN_DLL std::string cryptobox_decrypt(const byte input[], u32bit input_len, + const std::string& passphrase); } diff --git a/src/utils/prefetch.h b/src/utils/prefetch.h index ede196692..4928c44a0 100644 --- a/src/utils/prefetch.h +++ b/src/utils/prefetch.h @@ -12,10 +12,8 @@ namespace Botan { -namespace PREFETCH { - template<typename T> -inline void readonly(const T* addr, u32bit length) +inline void prefetch_readonly(const T* addr, u32bit length) { #if defined(__GNUG__) const u32bit Ts_per_cache_line = CPUID::cache_line_size() / sizeof(T); @@ -26,7 +24,7 @@ inline void readonly(const T* addr, u32bit length) } template<typename T> -inline void readwrite(const T* addr, u32bit length) +inline void prefetch_readwrite(const T* addr, u32bit length) { #if defined(__GNUG__) const u32bit Ts_per_cache_line = CPUID::cache_line_size() / sizeof(T); @@ -38,6 +36,4 @@ inline void readwrite(const T* addr, u32bit length) } -} - #endif |