Bunny2.0
Public Types | Public Member Functions | Public Attributes
Bunny< nb_msg, nb_key, nb_sbox, nround > Class Template Reference

Bunny CLASS. More...

#include <Bunny.h>

List of all members.

Public Types

typedef bitset< nb_msg > msgType
 Is the type of a message string (e.g., bitset<128>, bitset<24>, etc..)
typedef bitset< nb_key > keyType
 Is the type of a key string (e.g., bitset<256>, bitset<128>, etc..)
typedef bitset< nb_sbox > sboxType
 Is the type of a message string which is input into the sBox (e.g., bitset<8>, bitset<6>, etc..)
typedef bitset< nb_sbox *4 > wordType
 Is the type of a word string, used in the keyschedule or in the mixing layer (e.g., bitset<128*4>, etc..)
typedef vector< keyTyperoundkeyType
 Is the type of the vector containing the round keys.

Public Member Functions

 Bunny ()
void printParameter ()
 Print to the terminal the current parameters of the block cipher.
virtual msgType encode (msgType m, keyType k)
 Encoding function for Bunny block cipher.
virtual msgType decode (msgType m, keyType k)
 Decoding function for Bunny block cipher.
virtual sboxType sbox (unsigned nbox, sboxType x)=0
virtual sboxType sboxInverse (unsigned nbox, sboxType x)=0
virtual msgType sBox (msgType m)
 Bunny S-box STEP.
virtual msgType sBoxInverse (msgType m)
 Bunny S-box Inverse STEP.
virtual msgType mixingLayer (msgType m)=0
virtual msgType mixingLayerInverse (msgType m)=0
virtual msgType addRoundKey (msgType m, msgType k)
 Add round key STEP.
virtual void keySchedule (keyType k)
 Key-Schedule STEP - Bunny's style.
sboxType extractBlock (unsigned nblk, msgType x)
 Extracts nb_sbox from a msgType x, i.e. extracts the block number nblk (block 0 is the rightmost) from x.
sboxType extractFromWordToSboxType (unsigned pos, wordType x)
 Extracts from word of type wordType nb_sbox bits and return them as an sboxType.
msgType insertBlock (msgType m, unsigned nblk, sboxType x)
 Copies the bitset x in m in the block nblk of m (to copy a string fitting the sbox size into a message).
keyType copyIntoKey (keyType m, unsigned pos, wordType x)
 Copies the bitset x in m at position pos (to copy a word into a key).
wordType copyIntoWord (wordType m, unsigned pos, sboxType x)
 Copies the bitset x in m at position pos (to copy a word into a message).
wordType extractWord (unsigned pos, keyType x)
 Extract a word of 32 bits from a keyType element.

Public Attributes

roundkeyType rk
 Contains the round keys.

Detailed Description

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
class Bunny< nb_msg, nb_key, nb_sbox, nround >

Bunny CLASS.

This class allows to instantiate a block cipher working on nb_msg bits, with a master key of nb_key bits, whose s-boxes take input of nb_sbox bits, and with nround rounds.


Constructor & Destructor Documentation

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::Bunny ( ) [inline]

Allocate the space needed to fill a vector containing all the round keys.


Member Function Documentation

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::msgType Bunny< nb_msg, nb_key, nb_sbox, nround >::addRoundKey ( msgType  m,
msgType  k 
) [inline, virtual]

Add round key STEP.

Sum with a round key k, which must be the same length of the message m.

  • INPUT: a message m of type msgType, and a round key k of type msgType (the type must be the same as the message, otherwise they can't be added together)
  • OUTPUT: the exor of m and k

Reimplemented in Bunny24m24k< nb_sbox, nround >.

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::keyType Bunny< nb_msg, nb_key, nb_sbox, nround >::copyIntoKey ( keyType  m,
unsigned  pos,
wordType  x 
) [inline]

Copies the bitset x in m at position pos (to copy a word into a key).

  • INPUT: a key m of type keyType, the position pos where to start the copy, the part x of the message to be copied of type wordType.
  • OUTPUT: the new copy of m.
template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::wordType Bunny< nb_msg, nb_key, nb_sbox, nround >::copyIntoWord ( wordType  m,
unsigned  pos,
sboxType  x 
) [inline]

Copies the bitset x in m at position pos (to copy a word into a message).

  • INPUT: a message m of type msgType, the position pos where to start the copy, the part x of the message to be copied of type wordType.
  • OUTPUT: the new copy of m.
template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::msgType Bunny< nb_msg, nb_key, nb_sbox, nround >::decode ( msgType  m,
keyType  k 
) [inline, virtual]

Decoding function for Bunny block cipher.

  • INPUT: a message m of type msgType (a bitset of dimension N) and a key k of type keyType (a bitset of dimension M).
  • OUTPUT: an (decrypted) message c of the same type as m.

Reimplemented in Bunny24m24k< nb_sbox, nround >, and BunnyAES< nb_key, nround >.

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::msgType Bunny< nb_msg, nb_key, nb_sbox, nround >::encode ( msgType  m,
keyType  k 
) [inline, virtual]

Encoding function for Bunny block cipher.

  • INPUT: a message m of type msgType (a bitset of dimension N) and a key k of type keyType (a bitset of dimension M).
  • OUTPUT: an (encrypted) message c of the same type as m.

Reimplemented in Bunny24m24k< nb_sbox, nround >, and BunnyAES< nb_key, nround >.

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::sboxType Bunny< nb_msg, nb_key, nb_sbox, nround >::extractBlock ( unsigned  nblk,
msgType  x 
) [inline]

Extracts nb_sbox from a msgType x, i.e. extracts the block number nblk (block 0 is the rightmost) from x.

Extracts nb_sbox bits in position [nblk*nb_sbox..nblk*nb_sbox + nb_sbox-1] from a string of type msgType and insert them in a string of type sboxType.

Exits from program if the position pos is negative or greater then the size of msgType minus the size of sboxType.

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::wordType Bunny< nb_msg, nb_key, nb_sbox, nround >::extractWord ( unsigned  pos,
keyType  x 
) [inline]

Extract a word of 32 bits from a keyType element.

  • INPUT: a key x, and the position pos which indicates where the extraction has to be made.
  • OUTPUT: a string y of 32 bits.
template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::msgType Bunny< nb_msg, nb_key, nb_sbox, nround >::insertBlock ( msgType  m,
unsigned  nblk,
sboxType  x 
) [inline]

Copies the bitset x in m in the block nblk of m (to copy a string fitting the sbox size into a message).

  • INPUT: a message m of type msgType, the position pos where to start the copy, the part x of the message to be copied of type sboxType.
  • OUTPUT: the new copy of m.
template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
void Bunny< nb_msg, nb_key, nb_sbox, nround >::keySchedule ( keyType  k) [inline, virtual]

Key-Schedule STEP - Bunny's style.

  • INPUT: a master key k of type keyType.
  • OUTPUT: return a pointer to a vector of msgType (this elements are the round key, which must be the same length/type as the message).

Reimplemented in Bunny24m24k< nb_sbox, nround >, and BunnyAES< nb_key, nround >.

template<unsigned nb_msg, unsigned nb_key, unsigned nb_sbox, unsigned nround>
Bunny< nb_msg, nb_key, nb_sbox, nround >::msgType Bunny< nb_msg, nb_key, nb_sbox, nround >::sBox ( msgType  m) [inline, virtual]

Bunny S-box STEP.

This function receives a message and applies the sboxes as many times as needed (using four different sbox tables):

m = (m_1, m_2, ..., m_3) ===> (sbox_1(m_1), sbox_2(m_2), ..., sbox_r(m_r))

  • INPUT: a message m of type msgType.
  • OUTPUT: the message m elaborated by the sbox.

Reimplemented in BunnyAES< nb_key, nround >.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs