aboutsummaryrefslogtreecommitdiffstats
path: root/src/constructs/cryptobox
diff options
context:
space:
mode:
Diffstat (limited to 'src/constructs/cryptobox')
-rw-r--r--src/constructs/cryptobox/cryptobox.cpp16
-rw-r--r--src/constructs/cryptobox/cryptobox.h14
2 files changed, 11 insertions, 19 deletions
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);
}