Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes

SAFER::Base Class Reference

Inheritance diagram for SAFER::Base:
BlockCipher SimpleKeyingInterface BlockTransformation Algorithm Clonable SAFER::Dec SAFER::Enc

List of all members.

Public Types

enum  IV_Requirement {
  UNIQUE_IV = 0, RANDOM_IV, UNPREDICTABLE_RANDOM_IV, INTERNALLY_GENERATED_IV,
  NOT_RESYNCHRONIZABLE
}
enum  {
  BT_InBlockIsCounter = 1, BT_DontIncrementInOutPointers = 2, BT_XorInput = 4, BT_ReverseDirection = 8,
  BT_AllowParallel = 16
}

Public Member Functions

unsigned int OptimalDataAlignment () const
 returns how inputs and outputs should be aligned for optimal performance
void UncheckedSetKey (const byte *userkey, unsigned int length, const NameValuePairs &params)
virtual size_t MinKeyLength () const =0
 returns smallest valid key length in bytes */
virtual size_t MaxKeyLength () const =0
 returns largest valid key length in bytes */
virtual size_t DefaultKeyLength () const =0
 returns default (recommended) key length in bytes */
virtual size_t GetValidKeyLength (size_t n) const =0
 returns the smallest valid key length in bytes that is >= min(n, GetMaxKeyLength())
virtual bool IsValidKeyLength (size_t n) const
 returns whether n is a valid key length
virtual void SetKey (const byte *key, size_t length, const NameValuePairs &params=g_nullNameValuePairs)
 set or reset the key of this object
void SetKeyWithRounds (const byte *key, size_t length, int rounds)
 calls SetKey() with an NameValuePairs object that just specifies "Rounds"
void SetKeyWithIV (const byte *key, size_t length, const byte *iv, size_t ivLength)
 calls SetKey() with an NameValuePairs object that just specifies "IV"
void SetKeyWithIV (const byte *key, size_t length, const byte *iv)
 calls SetKey() with an NameValuePairs object that just specifies "IV"
virtual IV_Requirement IVRequirement () const =0
 returns the minimal requirement for secure IVs
bool IsResynchronizable () const
 returns whether this object can be resynchronized (i.e. supports initialization vectors)
bool CanUseRandomIVs () const
 returns whether this object can use random IVs (in addition to ones returned by GetNextIV)
bool CanUsePredictableIVs () const
 returns whether this object can use random but possibly predictable IVs (in addition to ones returned by GetNextIV)
bool CanUseStructuredIVs () const
 returns whether this object can use structured IVs, for example a counter (in addition to ones returned by GetNextIV)
virtual unsigned int IVSize () const
unsigned int DefaultIVLength () const
 returns default length of IVs accepted by this object
virtual unsigned int MinIVLength () const
 returns minimal length of IVs accepted by this object
virtual unsigned int MaxIVLength () const
 returns maximal length of IVs accepted by this object
virtual void Resynchronize (const byte *iv, int ivLength=-1)
 resynchronize with an IV. ivLength=-1 means use IVSize()
virtual void GetNextIV (RandomNumberGenerator &rng, byte *IV)
 get a secure IV for the next message
virtual void ProcessAndXorBlock (const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
 encrypt or decrypt inBlock, xor with xorBlock, and write to outBlock
void ProcessBlock (const byte *inBlock, byte *outBlock) const
 encrypt or decrypt one block
void ProcessBlock (byte *inoutBlock) const
 encrypt or decrypt one block in place
virtual unsigned int BlockSize () const =0
 block size of the cipher in bytes
virtual bool IsPermutation () const
 returns true if this is a permutation (i.e. there is an inverse transformation)
virtual bool IsForwardTransformation () const =0
 returns true if this is an encryption object
virtual unsigned int OptimalNumberOfParallelBlocks () const
 return number of blocks that can be processed in parallel, for bit-slicing implementations
virtual size_t AdvancedProcessBlocks (const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
 encrypt and xor blocks according to flags (see FlagsForAdvancedProcessBlocks)
CipherDir GetCipherDirection () const
virtual std::string AlgorithmName () const
 returns name of this algorithm, not universally implemented yet
virtual ClonableClone () const
 this is not implemented by most classes yet

Public Attributes

enum BlockTransformation:: { ... }  FlagsForAdvancedProcessBlocks

Protected Member Functions

virtual bool Strengthened () const =0
const AlgorithmGetAlgorithm () const
virtual const AlgorithmGetAlgorithm () const =0
virtual void UncheckedSetKey (const byte *key, unsigned int length, const NameValuePairs &params)=0
void ThrowIfInvalidKeyLength (size_t length)
void ThrowIfResynchronizable ()
void ThrowIfInvalidIV (const byte *iv)
size_t ThrowIfInvalidIVLength (int size)
const byte * GetIVAndThrowIfInvalid (const NameValuePairs &params, size_t &size)
void AssertValidKeyLength (size_t length) const

Protected Attributes

SecByteBlock keySchedule

Static Protected Attributes

static const byte exp_tab [256]
static const byte log_tab [256]

Detailed Description

Definition at line 16 of file safer.h.


Member Function Documentation

void SimpleKeyingInterface::SetKey ( const byte *  key,
size_t  length,
const NameValuePairs params = g_nullNameValuePairs 
) [virtual, inherited]

set or reset the key of this object

Parameters:
params is used to specify Rounds, BlockSize, etc.

Definition at line 60 of file cryptlib.cpp.

Referenced by SimpleKeyingInterface::SetKeyWithIV(), and SimpleKeyingInterface::SetKeyWithRounds().

bool SimpleKeyingInterface::IsResynchronizable (  )  const [inline, inherited]

returns whether this object can be resynchronized (i.e. supports initialization vectors)

If this function returns true, and no IV is passed to SetKey() and CanUseStructuredIVs()==true, an IV of all 0's will be assumed.

Definition at line 386 of file cryptlib.h.

void SimpleKeyingInterface::GetNextIV ( RandomNumberGenerator rng,
byte *  IV 
) [virtual, inherited]

get a secure IV for the next message

This method should be called after you finish encrypting one message and are ready to start the next one. After calling it, you must call SetKey() or Resynchronize() before using this object again. This method is not implemented on decryption objects.

Definition at line 136 of file cryptlib.cpp.

References RandomNumberGenerator::GenerateBlock().

void BlockTransformation::ProcessBlock ( const byte *  inBlock,
byte *  outBlock 
) const [inline, inherited]

encrypt or decrypt one block

Precondition:
size of inBlock and outBlock == BlockSize()

Definition at line 437 of file cryptlib.h.

Referenced by BlockTransformation::AdvancedProcessBlocks(), CBC_CTS_Decryption::ProcessLastBlock(), CBC_CTS_Encryption::ProcessLastBlock(), and CMAC_Base::Update().

size_t BlockTransformation::AdvancedProcessBlocks ( const byte *  inBlocks,
const byte *  xorBlocks,
byte *  outBlocks,
size_t  length,
word32  flags 
) const [virtual, inherited]

encrypt and xor blocks according to flags (see FlagsForAdvancedProcessBlocks)

/note If BT_InBlockIsCounter is set, last byte of inBlocks may be modified.

Definition at line 141 of file cryptlib.cpp.

References BlockTransformation::BlockSize(), BlockTransformation::ProcessAndXorBlock(), and BlockTransformation::ProcessBlock().

Referenced by CBC_Decryption::ProcessData(), CBC_Encryption::ProcessData(), ECB_OneWay::ProcessData(), CMAC_Base::TruncatedFinal(), CMAC_Base::Update(), and CBC_MAC_Base::Update().


Member Data Documentation

const byte SAFER::Base::exp_tab [static, protected]
Initial value:
 
        {1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63,
        8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247,
        64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177,
        255, 167, 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131,
        241, 51, 239, 218, 44, 181, 178, 43, 136, 209, 153, 203, 140, 132, 29, 20,
        129, 151, 113, 202, 95, 163, 139, 87, 60, 130, 196, 82, 92, 28, 232, 160,
        4, 180, 133, 74, 246, 19, 84, 182, 223, 12, 26, 142, 222, 224, 57, 252,
        32, 155, 36, 78, 169, 152, 158, 171, 242, 96, 208, 108, 234, 250, 199, 217,
        0, 212, 31, 110, 67, 188, 236, 83, 137, 254, 122, 93, 73, 201, 50, 194,
        249, 154, 248, 109, 22, 219, 89, 150, 68, 233, 205, 230, 70, 66, 143, 10,
        193, 204, 185, 101, 176, 210, 198, 172, 30, 65, 98, 41, 46, 14, 116, 80,
        2, 90, 195, 37, 123, 138, 42, 91, 240, 6, 13, 71, 111, 112, 157, 126,
        16, 206, 18, 39, 213, 76, 79, 214, 121, 48, 104, 54, 117, 125, 228, 237,
        128, 106, 144, 55, 162, 94, 118, 170, 197, 127, 61, 175, 165, 229, 25, 97,
        253, 77, 124, 183, 11, 238, 173, 75, 34, 245, 231, 115, 35, 33, 200, 5,
        225, 102, 221, 179, 88, 105, 99, 86, 15, 161, 49, 149, 23, 7, 58, 40}

Definition at line 26 of file safer.h.

const byte SAFER::Base::log_tab [static, protected]
Initial value:
 
        {128, 0, 176, 9, 96, 239, 185, 253, 16, 18, 159, 228, 105, 186, 173, 248,
        192, 56, 194, 101, 79, 6, 148, 252, 25, 222, 106, 27, 93, 78, 168, 130,
        112, 237, 232, 236, 114, 179, 21, 195, 255, 171, 182, 71, 68, 1, 172, 37,
        201, 250, 142, 65, 26, 33, 203, 211, 13, 110, 254, 38, 88, 218, 50, 15,
        32, 169, 157, 132, 152, 5, 156, 187, 34, 140, 99, 231, 197, 225, 115, 198,
        175, 36, 91, 135, 102, 39, 247, 87, 244, 150, 177, 183, 92, 139, 213, 84,
        121, 223, 170, 246, 62, 163, 241, 17, 202, 245, 209, 23, 123, 147, 131, 188,
        189, 82, 30, 235, 174, 204, 214, 53, 8, 200, 138, 180, 226, 205, 191, 217,
        208, 80, 89, 63, 77, 98, 52, 10, 72, 136, 181, 86, 76, 46, 107, 158,
        210, 61, 60, 3, 19, 251, 151, 81, 117, 74, 145, 113, 35, 190, 118, 42,
        95, 249, 212, 85, 11, 220, 55, 49, 22, 116, 215, 119, 167, 230, 7, 219,
        164, 47, 70, 243, 97, 69, 103, 227, 12, 162, 59, 28, 133, 24, 4, 29,
        41, 160, 143, 178, 90, 216, 166, 126, 238, 141, 83, 75, 161, 154, 193, 14,
        122, 73, 165, 44, 129, 196, 199, 54, 43, 127, 67, 149, 51, 242, 108, 104,
        109, 240, 2, 40, 206, 221, 155, 234, 94, 153, 124, 20, 134, 207, 229, 66,
        184, 64, 120, 45, 58, 233, 100, 31, 146, 144, 125, 57, 111, 224, 137, 48}

Definition at line 27 of file safer.h.


The documentation for this class was generated from the following files: