aboutsummaryrefslogtreecommitdiffstats
path: root/src/block
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-21 14:31:08 +0000
committerlloyd <[email protected]>2010-06-21 14:31:08 +0000
commitb4fe5806546639fb78e630bdc5b323bf7988e9a1 (patch)
tree233dd4a61c587cb186d5dc5877dbfac53149897a /src/block
parent928760016bae3887dedf1344d4b3d2e70155ef63 (diff)
In IDEA, Noekeon, Serpent, XTEA, provide and use ro accessor functions
for getting access to the key schedule, instead of giving the key schedule protected status, which is much harder tu audit.
Diffstat (limited to 'src/block')
-rw-r--r--src/block/idea/idea.h13
-rw-r--r--src/block/idea_sse2/idea_sse2.cpp4
-rw-r--r--src/block/noekeon/noekeon.h17
-rw-r--r--src/block/noekeon_simd/noekeon_simd.cpp4
-rw-r--r--src/block/serpent_ia32/serp_ia32.cpp6
-rw-r--r--src/block/serpent_simd/serp_simd.cpp4
-rw-r--r--src/block/xtea/xtea.h6
-rw-r--r--src/block/xtea_simd/xtea_simd.cpp4
8 files changed, 43 insertions, 15 deletions
diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h
index e9ccf366d..aed3be3ea 100644
--- a/src/block/idea/idea.h
+++ b/src/block/idea/idea.h
@@ -26,10 +26,19 @@ class BOTAN_DLL IDEA : public BlockCipher
BlockCipher* clone() const { return new IDEA; }
IDEA() : BlockCipher(8, 16) {}
+ protected:
+ /**
+ * @return const reference to encryption subkeys
+ */
+ const SecureVector<u16bit, 52>& get_EK() const { return EK; }
+
+ /**
+ * @return const reference to decryption subkeys
+ */
+ const SecureVector<u16bit, 52>& get_DK() const { return DK; }
+
private:
void key_schedule(const byte[], u32bit);
-
- protected: // for IDEA_SSE2
SecureVector<u16bit, 52> EK, DK;
};
diff --git a/src/block/idea_sse2/idea_sse2.cpp b/src/block/idea_sse2/idea_sse2.cpp
index 0fe35112d..0948bf46a 100644
--- a/src/block/idea_sse2/idea_sse2.cpp
+++ b/src/block/idea_sse2/idea_sse2.cpp
@@ -198,7 +198,7 @@ void IDEA_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const
{
while(blocks >= 8)
{
- idea_op_8(in, out, this->EK);
+ idea_op_8(in, out, this->get_EK());
in += 8 * BLOCK_SIZE;
out += 8 * BLOCK_SIZE;
blocks -= 8;
@@ -214,7 +214,7 @@ void IDEA_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const
{
while(blocks >= 8)
{
- idea_op_8(in, out, this->DK);
+ idea_op_8(in, out, this->get_DK());
in += 8 * BLOCK_SIZE;
out += 8 * BLOCK_SIZE;
blocks -= 8;
diff --git a/src/block/noekeon/noekeon.h b/src/block/noekeon/noekeon.h
index 018c1d1fd..2e524f8b8 100644
--- a/src/block/noekeon/noekeon.h
+++ b/src/block/noekeon/noekeon.h
@@ -26,15 +26,24 @@ class BOTAN_DLL Noekeon : public BlockCipher
BlockCipher* clone() const { return new Noekeon; }
Noekeon() : BlockCipher(16, 16) {}
- private:
- void key_schedule(const byte[], u32bit);
- protected: // for access by SIMD subclass
-
+ protected:
/**
* The Noekeon round constants
*/
static const byte RC[17];
+ /**
+ * @return const reference to encryption subkeys
+ */
+ const SecureVector<u32bit, 4>& get_EK() const { return EK; }
+
+ /**
+ * @return const reference to decryption subkeys
+ */
+ const SecureVector<u32bit, 4>& get_DK() const { return DK; }
+
+ private:
+ void key_schedule(const byte[], u32bit);
SecureVector<u32bit, 4> EK, DK;
};
diff --git a/src/block/noekeon_simd/noekeon_simd.cpp b/src/block/noekeon_simd/noekeon_simd.cpp
index f44104901..c36f269a4 100644
--- a/src/block/noekeon_simd/noekeon_simd.cpp
+++ b/src/block/noekeon_simd/noekeon_simd.cpp
@@ -55,6 +55,8 @@ namespace Botan {
*/
void Noekeon_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
{
+ const SecureVector<u32bit, 4>& EK = this->get_EK();
+
SIMD_32 K0 = SIMD_32(EK[0]);
SIMD_32 K1 = SIMD_32(EK[1]);
SIMD_32 K2 = SIMD_32(EK[2]);
@@ -109,6 +111,8 @@ void Noekeon_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void Noekeon_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
{
+ const SecureVector<u32bit, 4>& DK = this->get_DK();
+
SIMD_32 K0 = SIMD_32(DK[0]);
SIMD_32 K1 = SIMD_32(DK[1]);
SIMD_32 K2 = SIMD_32(DK[2]);
diff --git a/src/block/serpent_ia32/serp_ia32.cpp b/src/block/serpent_ia32/serp_ia32.cpp
index ff454ab4c..70f4b4cf3 100644
--- a/src/block/serpent_ia32/serp_ia32.cpp
+++ b/src/block/serpent_ia32/serp_ia32.cpp
@@ -25,7 +25,7 @@ void Serpent_IA32::encrypt_n(const byte in[], byte out[], u32bit blocks) const
{
for(u32bit i = 0; i != blocks; ++i)
{
- botan_serpent_ia32_encrypt(in, out, round_key);
+ botan_serpent_ia32_encrypt(in, out, this->get_round_keys());
in += BLOCK_SIZE;
out += BLOCK_SIZE;
}
@@ -38,7 +38,7 @@ void Serpent_IA32::decrypt_n(const byte in[], byte out[], u32bit blocks) const
{
for(u32bit i = 0; i != blocks; ++i)
{
- botan_serpent_ia32_decrypt(in, out, round_key);
+ botan_serpent_ia32_decrypt(in, out, this->get_round_keys());
in += BLOCK_SIZE;
out += BLOCK_SIZE;
}
@@ -55,7 +55,7 @@ void Serpent_IA32::key_schedule(const byte key[], u32bit length)
W[length / 4] |= u32bit(1) << ((length%4)*8);
botan_serpent_ia32_key_schedule(W);
- round_key.copy(W + 8, 132);
+ this->set_round_keys(W + 8);
}
}
diff --git a/src/block/serpent_simd/serp_simd.cpp b/src/block/serpent_simd/serp_simd.cpp
index 0a535c9a0..ba587e93d 100644
--- a/src/block/serpent_simd/serp_simd.cpp
+++ b/src/block/serpent_simd/serp_simd.cpp
@@ -182,7 +182,7 @@ void Serpent_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
{
while(blocks >= 4)
{
- serpent_encrypt_4(in, out, this->round_key);
+ serpent_encrypt_4(in, out, this->get_round_keys());
in += 4 * BLOCK_SIZE;
out += 4 * BLOCK_SIZE;
blocks -= 4;
@@ -198,7 +198,7 @@ void Serpent_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
{
while(blocks >= 4)
{
- serpent_decrypt_4(in, out, this->round_key);
+ serpent_decrypt_4(in, out, this->get_round_keys());
in += 4 * BLOCK_SIZE;
out += 4 * BLOCK_SIZE;
blocks -= 4;
diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h
index b16cdf555..d15108939 100644
--- a/src/block/xtea/xtea.h
+++ b/src/block/xtea/xtea.h
@@ -27,6 +27,12 @@ class BOTAN_DLL XTEA : public BlockCipher
XTEA() : BlockCipher(8, 16) {}
protected:
+ /**
+ * @return const reference to the key schedule
+ */
+ const SecureVector<u32bit, 64>& get_EK() const { return EK; }
+
+ private:
void key_schedule(const byte[], u32bit);
SecureVector<u32bit, 64> EK;
};
diff --git a/src/block/xtea_simd/xtea_simd.cpp b/src/block/xtea_simd/xtea_simd.cpp
index 264d4f949..44a4e81b6 100644
--- a/src/block/xtea_simd/xtea_simd.cpp
+++ b/src/block/xtea_simd/xtea_simd.cpp
@@ -96,7 +96,7 @@ void XTEA_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const
{
while(blocks >= 8)
{
- xtea_encrypt_8(in, out, this->EK);
+ xtea_encrypt_8(in, out, this->get_EK());
in += 8 * BLOCK_SIZE;
out += 8 * BLOCK_SIZE;
blocks -= 8;
@@ -112,7 +112,7 @@ void XTEA_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const
{
while(blocks >= 8)
{
- xtea_decrypt_8(in, out, this->EK);
+ xtea_decrypt_8(in, out, this->get_EK());
in += 8 * BLOCK_SIZE;
out += 8 * BLOCK_SIZE;
blocks -= 8;