aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/constructs/cryptobox/cryptobox.cpp14
-rw-r--r--src/constructs/cryptobox/cryptobox.h19
2 files changed, 22 insertions, 11 deletions
diff --git a/src/constructs/cryptobox/cryptobox.cpp b/src/constructs/cryptobox/cryptobox.cpp
index 7d27c0523..6dcca0754 100644
--- a/src/constructs/cryptobox/cryptobox.cpp
+++ b/src/constructs/cryptobox/cryptobox.cpp
@@ -18,6 +18,8 @@
namespace Botan {
+namespace CryptoBox {
+
namespace {
/*
@@ -38,9 +40,9 @@ const u32bit PBKDF_OUTPUT_LEN = CIPHER_KEY_LEN + CIPHER_IV_LEN + MAC_KEY_LEN;
}
-std::string cryptobox_encrypt(const byte input[], u32bit input_len,
- const std::string& passphrase,
- RandomNumberGenerator& rng)
+std::string 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());
@@ -89,8 +91,8 @@ std::string cryptobox_encrypt(const byte input[], u32bit input_len,
"BOTAN CRYPTOBOX MESSAGE");
}
-std::string cryptobox_decrypt(const byte input[], u32bit input_len,
- const std::string& passphrase)
+std::string decrypt(const byte input[], u32bit input_len,
+ const std::string& passphrase)
{
DataSource_Memory input_src(input, input_len);
SecureVector<byte> ciphertext =
@@ -139,3 +141,5 @@ std::string cryptobox_decrypt(const byte input[], u32bit input_len,
}
}
+
+}
diff --git a/src/constructs/cryptobox/cryptobox.h b/src/constructs/cryptobox/cryptobox.h
index 3dbb894ba..0380dcff9 100644
--- a/src/constructs/cryptobox/cryptobox.h
+++ b/src/constructs/cryptobox/cryptobox.h
@@ -14,15 +14,20 @@
namespace Botan {
/**
-* Encrypt a message
+* This namespace holds various high-level crypto functions
+*/
+namespace CryptoBox {
+
+/**
+* Encrypt a message using a passphrase
* @param input the input data
* @param input_len the length of input in bytes
* @param passphrase the passphrase used to encrypt the message
* @param rng a ref to a random number generator, such as AutoSeeded_RNG
*/
-BOTAN_DLL std::string cryptobox_encrypt(const byte input[], u32bit input_len,
- const std::string& passphrase,
- RandomNumberGenerator& rng);
+BOTAN_DLL std::string encrypt(const byte input[], u32bit input_len,
+ const std::string& passphrase,
+ RandomNumberGenerator& rng);
/**
* Decrypt a message encrypted with CryptoBox::encrypt
@@ -30,8 +35,10 @@ BOTAN_DLL std::string cryptobox_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 cryptobox_decrypt(const byte input[], u32bit input_len,
- const std::string& passphrase);
+BOTAN_DLL std::string decrypt(const byte input[], u32bit input_len,
+ const std::string& passphrase);
+
+}
}