aboutsummaryrefslogtreecommitdiffstats
path: root/src/codec/hex
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-18 20:32:36 +0000
committerlloyd <[email protected]>2012-05-18 20:32:36 +0000
commitc691561f3198f481c13457433efbccc1c9fcd898 (patch)
treea45ea2c5a30e0cb009fbcb68a61ef39332ff790c /src/codec/hex
parentd76700f01c7ecac5633edf75f8d7408b46c5dbac (diff)
Fairly huge update that replaces the old secmem types with std::vector
using a custom allocator. Currently our allocator just does new/delete with a memset before deletion, and the mmap and mlock allocators have been removed.
Diffstat (limited to 'src/codec/hex')
-rw-r--r--src/codec/hex/hex.cpp12
-rw-r--r--src/codec/hex/hex.h14
2 files changed, 12 insertions, 14 deletions
diff --git a/src/codec/hex/hex.cpp b/src/codec/hex/hex.cpp
index 41ba1298d..1fd32e2ed 100644
--- a/src/codec/hex/hex.cpp
+++ b/src/codec/hex/hex.cpp
@@ -34,12 +34,6 @@ void hex_encode(char output[],
}
}
-std::string hex_encode(const MemoryRegion<byte>& input,
- bool uppercase)
- {
- return hex_encode(&input[0], input.size(), uppercase);
- }
-
std::string hex_encode(const byte input[],
size_t input_length,
bool uppercase)
@@ -165,11 +159,11 @@ size_t hex_decode(byte output[],
return hex_decode(output, &input[0], input.length(), ignore_ws);
}
-SecureVector<byte> hex_decode(const char input[],
+secure_vector<byte> hex_decode(const char input[],
size_t input_length,
bool ignore_ws)
{
- SecureVector<byte> bin(1 + input_length / 2);
+ secure_vector<byte> bin(1 + input_length / 2);
size_t written = hex_decode(&bin[0],
input,
@@ -180,7 +174,7 @@ SecureVector<byte> hex_decode(const char input[],
return bin;
}
-SecureVector<byte> hex_decode(const std::string& input,
+secure_vector<byte> hex_decode(const std::string& input,
bool ignore_ws)
{
return hex_decode(&input[0], input.size(), ignore_ws);
diff --git a/src/codec/hex/hex.h b/src/codec/hex/hex.h
index 40930e808..bdb5e5365 100644
--- a/src/codec/hex/hex.h
+++ b/src/codec/hex/hex.h
@@ -42,8 +42,12 @@ std::string BOTAN_DLL hex_encode(const byte input[],
* @param uppercase should output be upper or lower case?
* @return hexadecimal representation of input
*/
-std::string BOTAN_DLL hex_encode(const MemoryRegion<byte>& input,
- bool uppercase = true);
+template<typename Alloc>
+std::string hex_encode(const std::vector<byte, Alloc>& input,
+ bool uppercase = true)
+ {
+ return hex_encode(&input[0], input.size(), uppercase);
+ }
/**
* Perform hex decoding
@@ -98,7 +102,7 @@ size_t BOTAN_DLL hex_decode(byte output[],
exception if whitespace is encountered
* @return decoded hex output
*/
-SecureVector<byte> BOTAN_DLL hex_decode(const char input[],
+secure_vector<byte> BOTAN_DLL hex_decode(const char input[],
size_t input_length,
bool ignore_ws = true);
@@ -109,8 +113,8 @@ SecureVector<byte> BOTAN_DLL hex_decode(const char input[],
exception if whitespace is encountered
* @return decoded hex output
*/
-SecureVector<byte> BOTAN_DLL hex_decode(const std::string& input,
- bool ignore_ws = true);
+secure_vector<byte> BOTAN_DLL hex_decode(const std::string& input,
+ bool ignore_ws = true);
}