aboutsummaryrefslogtreecommitdiffstats
path: root/src/constructs
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-17 21:48:55 +0000
committerlloyd <[email protected]>2010-06-17 21:48:55 +0000
commitc06b260b3328c5ce4be44c4f1a88feb55ee3dbc4 (patch)
tree41b05df5982b5b2e8a23b55972263d2172d6a9fd /src/constructs
parent0eecae9f21172c0a74ad62acaf77148c94a25be7 (diff)
parent3dde5683f69b9cb9f558bfb18087ce35fbbec78a (diff)
propagate from branch 'net.randombit.botan' (head 294e2082ce9231d6165276e2f2a4153a0116aca3)
to branch 'net.randombit.botan.c++0x' (head 0b695fad10f924601e07b009fcd781191fafcb28)
Diffstat (limited to 'src/constructs')
-rw-r--r--src/constructs/aont/package.cpp18
-rw-r--r--src/constructs/aont/package.h18
-rw-r--r--src/constructs/cryptobox/cryptobox.cpp16
-rw-r--r--src/constructs/cryptobox/cryptobox.h14
-rw-r--r--src/constructs/passhash/passhash9.h2
-rw-r--r--src/constructs/tss/tss.h37
6 files changed, 55 insertions, 50 deletions
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/constructs/passhash/passhash9.h b/src/constructs/passhash/passhash9.h
index 6020dce42..8900d55d3 100644
--- a/src/constructs/passhash/passhash9.h
+++ b/src/constructs/passhash/passhash9.h
@@ -16,7 +16,7 @@ namespace Botan {
* Create a password hash using PBKDF2
* @param password the password
* @param rng a random number generator
-* @Param work_factor how much work to do to slow down guessing attacks
+* @param work_factor how much work to do to slow down guessing attacks
*/
std::string BOTAN_DLL generate_passhash9(const std::string& password,
RandomNumberGenerator& rng,
diff --git a/src/constructs/tss/tss.h b/src/constructs/tss/tss.h
index c8b0242d8..485e42c53 100644
--- a/src/constructs/tss/tss.h
+++ b/src/constructs/tss/tss.h
@@ -15,16 +15,19 @@
namespace Botan {
+/**
+* A split secret, using the format from draft-mcgrew-tss-03
+*/
class BOTAN_DLL RTSS_Share
{
public:
/**
- * @arg M the number of shares needed to reconstruct
- * @arg N the number of shares generated
- * @arg secret the secret to split
- * @arg secret_len the length of the secret
- * @arg identifier the 16 byte share identifier
- * @arg rng the random number generator to use
+ * @param M the number of shares needed to reconstruct
+ * @param N the number of shares generated
+ * @param secret the secret to split
+ * @param secret_len the length of the secret
+ * @param identifier the 16 byte share identifier
+ * @param rng the random number generator to use
*/
static std::vector<RTSS_Share>
split(byte M, byte N,
@@ -33,18 +36,36 @@ class BOTAN_DLL RTSS_Share
RandomNumberGenerator& rng);
/**
- * @arg shares the list of shares
+ * @param shares the list of shares
*/
static SecureVector<byte>
reconstruct(const std::vector<RTSS_Share>& shares);
RTSS_Share() {}
- RTSS_Share(const std::string&);
+ /**
+ * @param hex_input the share encoded in hexadecimal
+ */
+ RTSS_Share(const std::string& hex_input);
+
+ /**
+ * @return hex representation
+ */
std::string to_string() const;
+
+ /**
+ * @return share identifier
+ */
byte share_id() const;
+ /**
+ * @return size of this share in bytes
+ */
u32bit size() const { return contents.size(); }
+
+ /**
+ * @return if this TSS share was initialized or not
+ */
bool initialized() const { return (contents.size() > 0); }
private:
SecureVector<byte> contents;