aboutsummaryrefslogtreecommitdiffstats
path: root/src/constructs/cryptobox
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-08-10 13:44:07 +0000
committerlloyd <[email protected]>2010-08-10 13:44:07 +0000
commit98264c3142e83d47a7e44a619c48e46a518b2f2d (patch)
tree3872c47b007c0599f0fd7dd436a44ecefea99eaf /src/constructs/cryptobox
parent8b8b3f783d6106485e979a73b95ece07365703a0 (diff)
In 1.9.9 I moved the cryptobox functions out of the CryptoBox
namespace, but this causes backwards compat problems, since cryptobox is already in 1.8, and also it's likely that other functions along these lines will be useful at some point (eg using RSA encryption instead of a passphrase for the key transfer).
Diffstat (limited to 'src/constructs/cryptobox')
-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);
+
+}
}