aboutsummaryrefslogtreecommitdiffstats
path: root/src/modes
diff options
context:
space:
mode:
Diffstat (limited to 'src/modes')
-rw-r--r--src/modes/cbc/cbc.cpp70
-rw-r--r--src/modes/cbc/cbc.h22
-rw-r--r--src/modes/cfb/cfb.cpp64
-rw-r--r--src/modes/cfb/cfb.h22
-rw-r--r--src/modes/ctr/ctr.cpp34
-rw-r--r--src/modes/ctr/ctr.h16
-rw-r--r--src/modes/cts/cts.cpp46
-rw-r--r--src/modes/cts/cts.h22
-rw-r--r--src/modes/eax/eax.cpp76
-rw-r--r--src/modes/eax/eax.h28
-rw-r--r--src/modes/eax/eax_dec.cpp40
-rw-r--r--src/modes/ecb/ecb.cpp46
-rw-r--r--src/modes/ecb/ecb.h28
-rw-r--r--src/modes/mode_pad/mode_pad.cpp70
-rw-r--r--src/modes/mode_pad/mode_pad.h4
-rw-r--r--src/modes/modebase.cpp28
-rw-r--r--src/modes/modebase.h10
-rw-r--r--src/modes/ofb/ofb.cpp28
-rw-r--r--src/modes/ofb/ofb.h16
19 files changed, 354 insertions, 316 deletions
diff --git a/src/modes/cbc/cbc.cpp b/src/modes/cbc/cbc.cpp
index 2bb2320e6..f26d4d6cf 100644
--- a/src/modes/cbc/cbc.cpp
+++ b/src/modes/cbc/cbc.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CBC Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CBC Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cbc.h>
#include <botan/xor_buf.h>
@@ -9,9 +11,9 @@
namespace Botan {
-/*************************************************
-* CBC Encryption Constructor *
-*************************************************/
+/*
+* CBC Encryption Constructor
+*/
CBC_Encryption::CBC_Encryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad) :
BlockCipherMode(ciph, "CBC", ciph->BLOCK_SIZE),
@@ -21,9 +23,9 @@ CBC_Encryption::CBC_Encryption(BlockCipher* ciph,
throw Invalid_Block_Size(name(), padder->name());
}
-/*************************************************
-* CBC Encryption Constructor *
-*************************************************/
+/*
+* CBC Encryption Constructor
+*/
CBC_Encryption::CBC_Encryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad,
const SymmetricKey& key,
@@ -37,9 +39,9 @@ CBC_Encryption::CBC_Encryption(BlockCipher* ciph,
set_iv(iv);
}
-/*************************************************
-* Encrypt in CBC mode *
-*************************************************/
+/*
+* Encrypt in CBC mode
+*/
void CBC_Encryption::write(const byte input[], u32bit length)
{
while(length)
@@ -58,9 +60,9 @@ void CBC_Encryption::write(const byte input[], u32bit length)
}
}
-/*************************************************
-* Finish encrypting in CBC mode *
-*************************************************/
+/*
+* Finish encrypting in CBC mode
+*/
void CBC_Encryption::end_msg()
{
SecureVector<byte> padding(BLOCK_SIZE);
@@ -70,17 +72,17 @@ void CBC_Encryption::end_msg()
throw Exception(name() + ": Did not pad to full blocksize");
}
-/*************************************************
-* Return a CBC mode name *
-*************************************************/
+/*
+* Return a CBC mode name
+*/
std::string CBC_Encryption::name() const
{
return (cipher->name() + "/" + mode_name + "/" + padder->name());
}
-/*************************************************
-* CBC Decryption Constructor *
-*************************************************/
+/*
+* CBC Decryption Constructor
+*/
CBC_Decryption::CBC_Decryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad) :
BlockCipherMode(ciph, "CBC", ciph->BLOCK_SIZE),
@@ -91,9 +93,9 @@ CBC_Decryption::CBC_Decryption(BlockCipher* ciph,
temp.create(BLOCK_SIZE);
}
-/*************************************************
-* CBC Decryption Constructor *
-*************************************************/
+/*
+* CBC Decryption Constructor
+*/
CBC_Decryption::CBC_Decryption(BlockCipher* ciph,
BlockCipherModePaddingMethod* pad,
const SymmetricKey& key,
@@ -108,9 +110,9 @@ CBC_Decryption::CBC_Decryption(BlockCipher* ciph,
set_iv(iv);
}
-/*************************************************
-* Decrypt in CBC mode *
-*************************************************/
+/*
+* Decrypt in CBC mode
+*/
void CBC_Decryption::write(const byte input[], u32bit length)
{
while(length)
@@ -131,9 +133,9 @@ void CBC_Decryption::write(const byte input[], u32bit length)
}
}
-/*************************************************
-* Finish decrypting in CBC mode *
-*************************************************/
+/*
+* Finish decrypting in CBC mode
+*/
void CBC_Decryption::end_msg()
{
if(position != BLOCK_SIZE)
@@ -145,9 +147,9 @@ void CBC_Decryption::end_msg()
position = 0;
}
-/*************************************************
-* Return a CBC mode name *
-*************************************************/
+/*
+* Return a CBC mode name
+*/
std::string CBC_Decryption::name() const
{
return (cipher->name() + "/" + mode_name + "/" + padder->name());
diff --git a/src/modes/cbc/cbc.h b/src/modes/cbc/cbc.h
index e7b250e33..a926ac180 100644
--- a/src/modes/cbc/cbc.h
+++ b/src/modes/cbc/cbc.h
@@ -1,7 +1,9 @@
-/*************************************************
-* CBC Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CBC Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_CBC_H__
#define BOTAN_CBC_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* CBC Encryption *
-*************************************************/
+/*
+* CBC Encryption
+*/
class BOTAN_DLL CBC_Encryption : public BlockCipherMode
{
public:
@@ -29,9 +31,9 @@ class BOTAN_DLL CBC_Encryption : public BlockCipherMode
const BlockCipherModePaddingMethod* padder;
};
-/*************************************************
-* CBC Decryption *
-*************************************************/
+/*
+* CBC Decryption
+*/
class BOTAN_DLL CBC_Decryption : public BlockCipherMode
{
public:
diff --git a/src/modes/cfb/cfb.cpp b/src/modes/cfb/cfb.cpp
index f5eb4cecf..a126bd995 100644
--- a/src/modes/cfb/cfb.cpp
+++ b/src/modes/cfb/cfb.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CFB Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CFB Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cfb.h>
#include <botan/parsing.h>
@@ -12,9 +14,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Check the feedback size *
-*************************************************/
+/*
+* Check the feedback size
+*/
void check_feedback(u32bit BLOCK_SIZE, u32bit FEEDBACK_SIZE, u32bit bits,
const std::string& name)
{
@@ -25,9 +27,9 @@ void check_feedback(u32bit BLOCK_SIZE, u32bit FEEDBACK_SIZE, u32bit bits,
}
-/*************************************************
-* CFB Encryption Constructor *
-*************************************************/
+/*
+* CFB Encryption Constructor
+*/
CFB_Encryption::CFB_Encryption(BlockCipher* ciph,
u32bit fback_bits) :
BlockCipherMode(ciph, "CFB", ciph->BLOCK_SIZE, 1),
@@ -36,9 +38,9 @@ CFB_Encryption::CFB_Encryption(BlockCipher* ciph,
check_feedback(BLOCK_SIZE, FEEDBACK_SIZE, fback_bits, name());
}
-/*************************************************
-* CFB Encryption Constructor *
-*************************************************/
+/*
+* CFB Encryption Constructor
+*/
CFB_Encryption::CFB_Encryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv,
@@ -51,9 +53,9 @@ CFB_Encryption::CFB_Encryption(BlockCipher* ciph,
set_iv(iv);
}
-/*************************************************
-* Encrypt data in CFB mode *
-*************************************************/
+/*
+* Encrypt data in CFB mode
+*/
void CFB_Encryption::write(const byte input[], u32bit length)
{
while(length)
@@ -69,9 +71,9 @@ void CFB_Encryption::write(const byte input[], u32bit length)
}
}
-/*************************************************
-* Do the feedback *
-*************************************************/
+/*
+* Do the feedback
+*/
void CFB_Encryption::feedback()
{
for(u32bit j = 0; j != BLOCK_SIZE - FEEDBACK_SIZE; ++j)
@@ -81,9 +83,9 @@ void CFB_Encryption::feedback()
position = 0;
}
-/*************************************************
-* CFB Decryption Constructor *
-*************************************************/
+/*
+* CFB Decryption Constructor
+*/
CFB_Decryption::CFB_Decryption(BlockCipher* ciph,
u32bit fback_bits) :
BlockCipherMode(ciph, "CFB", ciph->BLOCK_SIZE, 1),
@@ -92,9 +94,9 @@ CFB_Decryption::CFB_Decryption(BlockCipher* ciph,
check_feedback(BLOCK_SIZE, FEEDBACK_SIZE, fback_bits, name());
}
-/*************************************************
-* CFB Decryption Constructor *
-*************************************************/
+/*
+* CFB Decryption Constructor
+*/
CFB_Decryption::CFB_Decryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv,
@@ -107,9 +109,9 @@ CFB_Decryption::CFB_Decryption(BlockCipher* ciph,
set_iv(iv);
}
-/*************************************************
-* Decrypt data in CFB mode *
-*************************************************/
+/*
+* Decrypt data in CFB mode
+*/
void CFB_Decryption::write(const byte input[], u32bit length)
{
while(length)
@@ -126,9 +128,9 @@ void CFB_Decryption::write(const byte input[], u32bit length)
}
}
-/*************************************************
-* Do the feedback *
-*************************************************/
+/*
+* Do the feedback
+*/
void CFB_Decryption::feedback()
{
for(u32bit j = 0; j != BLOCK_SIZE - FEEDBACK_SIZE; ++j)
diff --git a/src/modes/cfb/cfb.h b/src/modes/cfb/cfb.h
index dad7ece13..7810c00e4 100644
--- a/src/modes/cfb/cfb.h
+++ b/src/modes/cfb/cfb.h
@@ -1,7 +1,9 @@
-/*************************************************
-* CFB Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CFB Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_CFB_H__
#define BOTAN_CFB_H__
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* CFB Encryption *
-*************************************************/
+/*
+* CFB Encryption
+*/
class BOTAN_DLL CFB_Encryption : public BlockCipherMode
{
public:
@@ -25,9 +27,9 @@ class BOTAN_DLL CFB_Encryption : public BlockCipherMode
const u32bit FEEDBACK_SIZE;
};
-/*************************************************
-* CFB Decryption *
-*************************************************/
+/*
+* CFB Decryption
+*/
class BOTAN_DLL CFB_Decryption : public BlockCipherMode
{
public:
diff --git a/src/modes/ctr/ctr.cpp b/src/modes/ctr/ctr.cpp
index a17343df1..9eb42ec5a 100644
--- a/src/modes/ctr/ctr.cpp
+++ b/src/modes/ctr/ctr.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CTR Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CTR Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/ctr.h>
#include <botan/xor_buf.h>
@@ -9,17 +11,17 @@
namespace Botan {
-/*************************************************
-* CTR-BE Constructor *
-*************************************************/
+/*
+* CTR-BE Constructor
+*/
CTR_BE::CTR_BE(BlockCipher* ciph) :
BlockCipherMode(ciph, "CTR-BE", ciph->BLOCK_SIZE, 1)
{
}
-/*************************************************
-* CTR-BE Constructor *
-*************************************************/
+/*
+* CTR-BE Constructor
+*/
CTR_BE::CTR_BE(BlockCipher* ciph, const SymmetricKey& key,
const InitializationVector& iv) :
BlockCipherMode(ciph, "CTR-BE", ciph->BLOCK_SIZE, 1)
@@ -28,9 +30,9 @@ CTR_BE::CTR_BE(BlockCipher* ciph, const SymmetricKey& key,
set_iv(iv);
}
-/*************************************************
-* CTR-BE Encryption/Decryption *
-*************************************************/
+/*
+* CTR-BE Encryption/Decryption
+*/
void CTR_BE::write(const byte input[], u32bit length)
{
u32bit copied = std::min(BLOCK_SIZE - position, length);
@@ -58,9 +60,9 @@ void CTR_BE::write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Increment the counter and update the buffer *
-*************************************************/
+/*
+* Increment the counter and update the buffer
+*/
void CTR_BE::increment_counter()
{
for(s32bit j = BLOCK_SIZE - 1; j >= 0; --j)
diff --git a/src/modes/ctr/ctr.h b/src/modes/ctr/ctr.h
index 9fececddd..aa0db5761 100644
--- a/src/modes/ctr/ctr.h
+++ b/src/modes/ctr/ctr.h
@@ -1,7 +1,9 @@
-/*************************************************
-* CTR Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CTR Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_COUNTER_MODE_H__
#define BOTAN_COUNTER_MODE_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* CTR-BE Mode *
-*************************************************/
+/*
+* CTR-BE Mode
+*/
class BOTAN_DLL CTR_BE : public BlockCipherMode
{
public:
diff --git a/src/modes/cts/cts.cpp b/src/modes/cts/cts.cpp
index 120cf8386..99f042f61 100644
--- a/src/modes/cts/cts.cpp
+++ b/src/modes/cts/cts.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CTS Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CTS Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cts.h>
#include <botan/xor_buf.h>
@@ -9,9 +11,9 @@
namespace Botan {
-/*************************************************
-* Encrypt a block *
-*************************************************/
+/*
+* Encrypt a block
+*/
void CTS_Encryption::encrypt(const byte block[])
{
xor_buf(state, block, BLOCK_SIZE);
@@ -19,9 +21,9 @@ void CTS_Encryption::encrypt(const byte block[])
send(state, BLOCK_SIZE);
}
-/*************************************************
-* Encrypt in CTS mode *
-*************************************************/
+/*
+* Encrypt in CTS mode
+*/
void CTS_Encryption::write(const byte input[], u32bit length)
{
u32bit copied = std::min(BUFFER_SIZE - position, length);
@@ -53,9 +55,9 @@ void CTS_Encryption::write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Finish encrypting in CTS mode *
-*************************************************/
+/*
+* Finish encrypting in CTS mode
+*/
void CTS_Encryption::end_msg()
{
if(position < BLOCK_SIZE + 1)
@@ -68,9 +70,9 @@ void CTS_Encryption::end_msg()
send(cn, position - BLOCK_SIZE);
}
-/*************************************************
-* Decrypt a block *
-*************************************************/
+/*
+* Decrypt a block
+*/
void CTS_Decryption::decrypt(const byte block[])
{
cipher->decrypt(block, temp);
@@ -79,9 +81,9 @@ void CTS_Decryption::decrypt(const byte block[])
state.copy(block, BLOCK_SIZE);
}
-/*************************************************
-* Decrypt in CTS mode *
-*************************************************/
+/*
+* Decrypt in CTS mode
+*/
void CTS_Decryption::write(const byte input[], u32bit length)
{
u32bit copied = std::min(BUFFER_SIZE - position, length);
@@ -113,9 +115,9 @@ void CTS_Decryption::write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Finish decrypting in CTS mode *
-*************************************************/
+/*
+* Finish decrypting in CTS mode
+*/
void CTS_Decryption::end_msg()
{
cipher->decrypt(buffer, temp);
diff --git a/src/modes/cts/cts.h b/src/modes/cts/cts.h
index 57582d8de..9b17203f3 100644
--- a/src/modes/cts/cts.h
+++ b/src/modes/cts/cts.h
@@ -1,7 +1,9 @@
-/*************************************************
-* CTS Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CTS Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_CTS_H__
#define BOTAN_CTS_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* CTS Encryption *
-*************************************************/
+/*
+* CTS Encryption
+*/
class BOTAN_DLL CTS_Encryption : public BlockCipherMode
{
public:
@@ -31,9 +33,9 @@ class BOTAN_DLL CTS_Encryption : public BlockCipherMode
void encrypt(const byte[]);
};
-/*************************************************
-* CTS Decryption *
-*************************************************/
+/*
+* CTS Decryption
+*/
class BOTAN_DLL CTS_Decryption : public BlockCipherMode
{
public:
diff --git a/src/modes/eax/eax.cpp b/src/modes/eax/eax.cpp
index c31a823cf..67465a776 100644
--- a/src/modes/eax/eax.cpp
+++ b/src/modes/eax/eax.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* EAX Mode Encryption Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* EAX Mode Encryption
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eax.h>
#include <botan/cmac.h>
@@ -13,9 +15,9 @@ namespace Botan {
namespace {
-/*************************************************
-* EAX MAC-based PRF *
-*************************************************/
+/*
+* EAX MAC-based PRF
+*/
SecureVector<byte> eax_prf(byte tag, u32bit BLOCK_SIZE,
MessageAuthenticationCode* mac,
const byte in[], u32bit length)
@@ -29,9 +31,9 @@ SecureVector<byte> eax_prf(byte tag, u32bit BLOCK_SIZE,
}
-/*************************************************
-* EAX_Base Constructor *
-*************************************************/
+/*
+* EAX_Base Constructor
+*/
EAX_Base::EAX_Base(BlockCipher* ciph,
u32bit tag_size) :
TAG_SIZE(tag_size ? tag_size / 8 : ciph->BLOCK_SIZE),
@@ -48,9 +50,9 @@ EAX_Base::EAX_Base(BlockCipher* ciph,
position = 0;
}
-/*************************************************
-* Check if a keylength is valid for EAX *
-*************************************************/
+/*
+* Check if a keylength is valid for EAX
+*/
bool EAX_Base::valid_keylength(u32bit n) const
{
if(!cipher->valid_keylength(n))
@@ -60,9 +62,9 @@ bool EAX_Base::valid_keylength(u32bit n) const
return true;
}
-/*************************************************
-* Set the EAX key *
-*************************************************/
+/*
+* Set the EAX key
+*/
void EAX_Base::set_key(const SymmetricKey& key)
{
cipher->set_key(key);
@@ -70,9 +72,9 @@ void EAX_Base::set_key(const SymmetricKey& key)
header_mac = eax_prf(1, BLOCK_SIZE, mac, 0, 0);
}
-/*************************************************
-* Do setup at the start of each message *
-*************************************************/
+/*
+* Do setup at the start of each message
+*/
void EAX_Base::start_msg()
{
for(u32bit j = 0; j != BLOCK_SIZE - 1; ++j)
@@ -80,9 +82,9 @@ void EAX_Base::start_msg()
mac->update(2);
}
-/*************************************************
-* Set the EAX nonce *
-*************************************************/
+/*
+* Set the EAX nonce
+*/
void EAX_Base::set_iv(const InitializationVector& iv)
{
nonce_mac = eax_prf(0, BLOCK_SIZE, mac, iv.begin(), iv.length());
@@ -90,25 +92,25 @@ void EAX_Base::set_iv(const InitializationVector& iv)
cipher->encrypt(state, buffer);
}
-/*************************************************
-* Set the EAX header *
-*************************************************/
+/*
+* Set the EAX header
+*/
void EAX_Base::set_header(const byte header[], u32bit length)
{
header_mac = eax_prf(1, BLOCK_SIZE, mac, header, length);
}
-/*************************************************
-* Return the name of this cipher mode *
-*************************************************/
+/*
+* Return the name of this cipher mode
+*/
std::string EAX_Base::name() const
{
return (cipher->name() + "/EAX");
}
-/*************************************************
-* Increment the counter and update the buffer *
-*************************************************/
+/*
+* Increment the counter and update the buffer
+*/
void EAX_Base::increment_counter()
{
for(s32bit j = BLOCK_SIZE - 1; j >= 0; --j)
@@ -118,9 +120,9 @@ void EAX_Base::increment_counter()
position = 0;
}
-/*************************************************
-* Encrypt in EAX mode *
-*************************************************/
+/*
+* Encrypt in EAX mode
+*/
void EAX_Encryption::write(const byte input[], u32bit length)
{
u32bit copied = std::min(BLOCK_SIZE - position, length);
@@ -151,9 +153,9 @@ void EAX_Encryption::write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Finish encrypting in EAX mode *
-*************************************************/
+/*
+* Finish encrypting in EAX mode
+*/
void EAX_Encryption::end_msg()
{
SecureVector<byte> data_mac = mac->final();
diff --git a/src/modes/eax/eax.h b/src/modes/eax/eax.h
index 67507f776..1bb2e510d 100644
--- a/src/modes/eax/eax.h
+++ b/src/modes/eax/eax.h
@@ -1,7 +1,9 @@
-/*************************************************
-* EAX Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* EAX Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_EAX_H__
#define BOTAN_EAX_H__
@@ -12,9 +14,9 @@
namespace Botan {
-/*************************************************
-* EAX Base Class *
-*************************************************/
+/*
+* EAX Base Class
+*/
class BOTAN_DLL EAX_Base : public Keyed_Filter
{
public:
@@ -38,9 +40,9 @@ class BOTAN_DLL EAX_Base : public Keyed_Filter
u32bit position;
};
-/*************************************************
-* EAX Encryption *
-*************************************************/
+/*
+* EAX Encryption
+*/
class BOTAN_DLL EAX_Encryption : public EAX_Base
{
public:
@@ -59,9 +61,9 @@ class BOTAN_DLL EAX_Encryption : public EAX_Base
void end_msg();
};
-/*************************************************
-* EAX Decryption *
-*************************************************/
+/*
+* EAX Decryption
+*/
class BOTAN_DLL EAX_Decryption : public EAX_Base
{
public:
diff --git a/src/modes/eax/eax_dec.cpp b/src/modes/eax/eax_dec.cpp
index 1b4a05b3c..b7e5795f7 100644
--- a/src/modes/eax/eax_dec.cpp
+++ b/src/modes/eax/eax_dec.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* EAX Mode Encryption Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* EAX Mode Encryption
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eax.h>
#include <botan/xor_buf.h>
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* EAX_Decryption Constructor *
-*************************************************/
+/*
+* EAX_Decryption Constructor
+*/
EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
u32bit tag_size) :
EAX_Base(ciph, tag_size)
@@ -21,9 +23,9 @@ EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
queue_start = queue_end = 0;
}
-/*************************************************
-* EAX_Decryption Constructor *
-*************************************************/
+/*
+* EAX_Decryption Constructor
+*/
EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv,
@@ -36,9 +38,9 @@ EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
queue_start = queue_end = 0;
}
-/*************************************************
-* Decrypt in EAX mode *
-*************************************************/
+/*
+* Decrypt in EAX mode
+*/
void EAX_Decryption::write(const byte input[], u32bit length)
{
while(length)
@@ -70,9 +72,9 @@ void EAX_Decryption::write(const byte input[], u32bit length)
}
}
-/*************************************************
-* Decrypt in EAX mode *
-*************************************************/
+/*
+* Decrypt in EAX mode
+*/
void EAX_Decryption::do_write(const byte input[], u32bit length)
{
mac->update(input, length);
@@ -102,9 +104,9 @@ void EAX_Decryption::do_write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Finish decrypting in EAX mode *
-*************************************************/
+/*
+* Finish decrypting in EAX mode
+*/
void EAX_Decryption::end_msg()
{
if((queue_end - queue_start) != TAG_SIZE)
diff --git a/src/modes/ecb/ecb.cpp b/src/modes/ecb/ecb.cpp
index b76e86ad9..8da0a4802 100644
--- a/src/modes/ecb/ecb.cpp
+++ b/src/modes/ecb/ecb.cpp
@@ -1,15 +1,17 @@
-/*************************************************
-* ECB Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* ECB Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/ecb.h>
namespace Botan {
-/*************************************************
-* Verify the IV is not set *
-*************************************************/
+/*
+* Verify the IV is not set
+*/
bool ECB::valid_iv_size(u32bit iv_size) const
{
if(iv_size == 0)
@@ -17,17 +19,17 @@ bool ECB::valid_iv_size(u32bit iv_size) const
return false;
}
-/*************************************************
-* Return an ECB mode name *
-*************************************************/
+/*
+* Return an ECB mode name
+*/
std::string ECB::name() const
{
return (cipher->name() + "/" + mode_name + "/" + padder->name());
}
-/*************************************************
-* Encrypt in ECB mode *
-*************************************************/
+/*
+* Encrypt in ECB mode
+*/
void ECB_Encryption::write(const byte input[], u32bit length)
{
buffer.copy(position, input, length);
@@ -50,9 +52,9 @@ void ECB_Encryption::write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Finish encrypting in ECB mode *
-*************************************************/
+/*
+* Finish encrypting in ECB mode
+*/
void ECB_Encryption::end_msg()
{
SecureVector<byte> padding(BLOCK_SIZE);
@@ -62,9 +64,9 @@ void ECB_Encryption::end_msg()
throw Encoding_Error(name() + ": Did not pad to full blocksize");
}
-/*************************************************
-* Decrypt in ECB mode *
-*************************************************/
+/*
+* Decrypt in ECB mode
+*/
void ECB_Decryption::write(const byte input[], u32bit length)
{
buffer.copy(position, input, length);
@@ -87,9 +89,9 @@ void ECB_Decryption::write(const byte input[], u32bit length)
position += length;
}
-/*************************************************
-* Finish decrypting in ECB mode *
-*************************************************/
+/*
+* Finish decrypting in ECB mode
+*/
void ECB_Decryption::end_msg()
{
if(position != BLOCK_SIZE)
diff --git a/src/modes/ecb/ecb.h b/src/modes/ecb/ecb.h
index 81fee28d2..5230f9b14 100644
--- a/src/modes/ecb/ecb.h
+++ b/src/modes/ecb/ecb.h
@@ -1,7 +1,9 @@
-/*************************************************
-* ECB Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* ECB Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_ECB_H__
#define BOTAN_ECB_H__
@@ -12,9 +14,9 @@
namespace Botan {
-/*************************************************
-* ECB *
-*************************************************/
+/*
+* ECB
+*/
class BOTAN_DLL ECB : public BlockCipherMode
{
protected:
@@ -28,9 +30,9 @@ class BOTAN_DLL ECB : public BlockCipherMode
bool valid_iv_size(u32bit) const;
};
-/*************************************************
-* ECB Encryption *
-*************************************************/
+/*
+* ECB Encryption
+*/
class BOTAN_DLL ECB_Encryption : public ECB
{
public:
@@ -47,9 +49,9 @@ class BOTAN_DLL ECB_Encryption : public ECB
void end_msg();
};
-/*************************************************
-* ECB Decryption *
-*************************************************/
+/*
+* ECB Decryption
+*/
class BOTAN_DLL ECB_Decryption : public ECB
{
public:
diff --git a/src/modes/mode_pad/mode_pad.cpp b/src/modes/mode_pad/mode_pad.cpp
index 3944837cc..b8badd7a7 100644
--- a/src/modes/mode_pad/mode_pad.cpp
+++ b/src/modes/mode_pad/mode_pad.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CBC Padding Methods Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CBC Padding Methods
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mode_pad.h>
#include <botan/exceptn.h>
@@ -9,26 +11,26 @@
namespace Botan {
-/*************************************************
-* Default amount of padding *
-*************************************************/
+/*
+* Default amount of padding
+*/
u32bit BlockCipherModePaddingMethod::pad_bytes(u32bit bs, u32bit pos) const
{
return (bs - pos);
}
-/*************************************************
-* Pad with PKCS #7 Method *
-*************************************************/
+/*
+* Pad with PKCS #7 Method
+*/
void PKCS7_Padding::pad(byte block[], u32bit size, u32bit position) const
{
for(u32bit j = 0; j != size; ++j)
block[j] = (size-position);
}
-/*************************************************
-* Unpad with PKCS #7 Method *
-*************************************************/
+/*
+* Unpad with PKCS #7 Method
+*/
u32bit PKCS7_Padding::unpad(const byte block[], u32bit size) const
{
u32bit position = block[size-1];
@@ -40,9 +42,9 @@ u32bit PKCS7_Padding::unpad(const byte block[], u32bit size) const
return (size-position);
}
-/*************************************************
-* Query if the size is valid for this method *
-*************************************************/
+/*
+* Query if the size is valid for this method
+*/
bool PKCS7_Padding::valid_blocksize(u32bit size) const
{
if(size > 0 && size < 256)
@@ -51,9 +53,9 @@ bool PKCS7_Padding::valid_blocksize(u32bit size) const
return false;
}
-/*************************************************
-* Pad with ANSI X9.23 Method *
-*************************************************/
+/*
+* Pad with ANSI X9.23 Method
+*/
void ANSI_X923_Padding::pad(byte block[], u32bit size, u32bit position) const
{
for(u32bit j = 0; j != size-position; ++j)
@@ -61,9 +63,9 @@ void ANSI_X923_Padding::pad(byte block[], u32bit size, u32bit position) const
block[size-position-1] = (size-position);
}
-/*************************************************
-* Unpad with ANSI X9.23 Method *
-*************************************************/
+/*
+* Unpad with ANSI X9.23 Method
+*/
u32bit ANSI_X923_Padding::unpad(const byte block[], u32bit size) const
{
u32bit position = block[size-1];
@@ -75,9 +77,9 @@ u32bit ANSI_X923_Padding::unpad(const byte block[], u32bit size) const
return (size-position);
}
-/*************************************************
-* Query if the size is valid for this method *
-*************************************************/
+/*
+* Query if the size is valid for this method
+*/
bool ANSI_X923_Padding::valid_blocksize(u32bit size) const
{
if(size > 0 && size < 256)
@@ -86,9 +88,9 @@ bool ANSI_X923_Padding::valid_blocksize(u32bit size) const
return false;
}
-/*************************************************
-* Pad with One and Zeros Method *
-*************************************************/
+/*
+* Pad with One and Zeros Method
+*/
void OneAndZeros_Padding::pad(byte block[], u32bit size, u32bit) const
{
block[0] = 0x80;
@@ -96,9 +98,9 @@ void OneAndZeros_Padding::pad(byte block[], u32bit size, u32bit) const
block[j] = 0x00;
}
-/*************************************************
-* Unpad with One and Zeros Method *
-*************************************************/
+/*
+* Unpad with One and Zeros Method
+*/
u32bit OneAndZeros_Padding::unpad(const byte block[], u32bit size) const
{
while(size)
@@ -114,9 +116,9 @@ u32bit OneAndZeros_Padding::unpad(const byte block[], u32bit size) const
return (size-1);
}
-/*************************************************
-* Query if the size is valid for this method *
-*************************************************/
+/*
+* Query if the size is valid for this method
+*/
bool OneAndZeros_Padding::valid_blocksize(u32bit size) const
{
if(size) return true;
diff --git a/src/modes/mode_pad/mode_pad.h b/src/modes/mode_pad/mode_pad.h
index 5c31a4f1e..a486d3c1f 100644
--- a/src/modes/mode_pad/mode_pad.h
+++ b/src/modes/mode_pad/mode_pad.h
@@ -1,6 +1,8 @@
/**
-* CBC Padding Methods Header File
+* CBC Padding Methods
* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_CBC_PADDING_H__
diff --git a/src/modes/modebase.cpp b/src/modes/modebase.cpp
index bf3de2572..8293acc54 100644
--- a/src/modes/modebase.cpp
+++ b/src/modes/modebase.cpp
@@ -1,15 +1,17 @@
-/*************************************************
-* Block Cipher Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Block Cipher Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/modebase.h>
namespace Botan {
-/*************************************************
-* Block Cipher Mode Constructor *
-*************************************************/
+/*
+* Block Cipher Mode Constructor
+*/
BlockCipherMode::BlockCipherMode(BlockCipher* cipher_ptr,
const std::string& cipher_mode_name,
u32bit iv_size, u32bit iv_meth,
@@ -23,17 +25,17 @@ BlockCipherMode::BlockCipherMode(BlockCipher* cipher_ptr,
position = 0;
}
-/*************************************************
-* Return the name of this type *
-*************************************************/
+/*
+* Return the name of this type
+*/
std::string BlockCipherMode::name() const
{
return (cipher->name() + "/" + mode_name);
}
-/*************************************************
-* Set the IV *
-*************************************************/
+/*
+* Set the IV
+*/
void BlockCipherMode::set_iv(const InitializationVector& new_iv)
{
if(new_iv.length() != state.size())
diff --git a/src/modes/modebase.h b/src/modes/modebase.h
index 9793c23d2..173fde58c 100644
--- a/src/modes/modebase.h
+++ b/src/modes/modebase.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Block Cipher Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Block Cipher Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MODEBASE_H__
#define BOTAN_MODEBASE_H__
diff --git a/src/modes/ofb/ofb.cpp b/src/modes/ofb/ofb.cpp
index 6f88a9bfd..cb40fdeaa 100644
--- a/src/modes/ofb/ofb.cpp
+++ b/src/modes/ofb/ofb.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* OFB Mode Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* OFB Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/ofb.h>
#include <botan/xor_buf.h>
@@ -9,17 +11,17 @@
namespace Botan {
-/*************************************************
-* OFB Constructor *
-*************************************************/
+/*
+* OFB Constructor
+*/
OFB::OFB(BlockCipher* ciph) :
BlockCipherMode(ciph, "OFB", ciph->BLOCK_SIZE, 2)
{
}
-/*************************************************
-* OFB Constructor *
-*************************************************/
+/*
+* OFB Constructor
+*/
OFB::OFB(BlockCipher* ciph, const SymmetricKey& key,
const InitializationVector& iv) :
BlockCipherMode(ciph, "OFB", ciph->BLOCK_SIZE, 2)
@@ -28,9 +30,9 @@ OFB::OFB(BlockCipher* ciph, const SymmetricKey& key,
set_iv(iv);
}
-/*************************************************
-* OFB Encryption/Decryption *
-*************************************************/
+/*
+* OFB Encryption/Decryption
+*/
void OFB::write(const byte input[], u32bit length)
{
u32bit copied = std::min(BLOCK_SIZE - position, length);
diff --git a/src/modes/ofb/ofb.h b/src/modes/ofb/ofb.h
index 53ec695bf..a3aadc137 100644
--- a/src/modes/ofb/ofb.h
+++ b/src/modes/ofb/ofb.h
@@ -1,7 +1,9 @@
-/*************************************************
-* OFB Mode Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* OFB Mode
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_OUTPUT_FEEDBACK_MODE_H__
#define BOTAN_OUTPUT_FEEDBACK_MODE_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* OFB Mode *
-*************************************************/
+/*
+* OFB Mode
+*/
class BOTAN_DLL OFB : public BlockCipherMode
{
public: