aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/serpent_x86_32
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-06-12 13:48:20 +0000
committerlloyd <[email protected]>2012-06-12 13:48:20 +0000
commitaa5d1f93c077f1c80ba06c3055671136f79f74e7 (patch)
tree12a552004aecf5e77a5b5fed9d74ca4042466960 /src/block/serpent_x86_32
parent626a0afa0f232b015d5b5098d5cc7f35fa8284cf (diff)
Fixes for the change to using std::vector in x86-32 specific code
(relying on implicit pointer conversions). Also, change Serpent::set_round_keys (used by the x86-32 asm version) to assign() the values instead of copying, as we rely on the key schedule to allocate the key values now to minimize memory waste.
Diffstat (limited to 'src/block/serpent_x86_32')
-rw-r--r--src/block/serpent_x86_32/serp_x86_32.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/block/serpent_x86_32/serp_x86_32.cpp b/src/block/serpent_x86_32/serp_x86_32.cpp
index 9566ed8a6..afff5835c 100644
--- a/src/block/serpent_x86_32/serp_x86_32.cpp
+++ b/src/block/serpent_x86_32/serp_x86_32.cpp
@@ -46,9 +46,11 @@ void botan_serpent_x86_32_key_schedule(u32bit ks[140]);
*/
void Serpent_X86_32::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
+ auto keys = this->get_round_keys();
+
for(size_t i = 0; i != blocks; ++i)
{
- botan_serpent_x86_32_encrypt(in, out, this->get_round_keys());
+ botan_serpent_x86_32_encrypt(in, out, &keys[0]);
in += BLOCK_SIZE;
out += BLOCK_SIZE;
}
@@ -59,9 +61,11 @@ void Serpent_X86_32::encrypt_n(const byte in[], byte out[], size_t blocks) const
*/
void Serpent_X86_32::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
+ auto keys = this->get_round_keys();
+
for(size_t i = 0; i != blocks; ++i)
{
- botan_serpent_x86_32_decrypt(in, out, this->get_round_keys());
+ botan_serpent_x86_32_decrypt(in, out, &keys[0]);
in += BLOCK_SIZE;
out += BLOCK_SIZE;
}
@@ -77,8 +81,8 @@ void Serpent_X86_32::key_schedule(const byte key[], size_t length)
W[i] = load_le<u32bit>(key, i);
W[length / 4] |= u32bit(1) << ((length%4)*8);
- botan_serpent_x86_32_key_schedule(W);
- this->set_round_keys(W + 8);
+ botan_serpent_x86_32_key_schedule(&W[0]);
+ this->set_round_keys(&W[8]);
}
}