Bunny2.0
|
#include <Bunny.h>
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< keyType > | roundkeyType |
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. |
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.
Bunny< nb_msg, nb_key, nb_sbox, nround >::Bunny | ( | ) | [inline] |
Allocate the space needed to fill a vector containing all the round keys.
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.
Reimplemented in Bunny24m24k< nb_sbox, 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).
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).
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.
Reimplemented in Bunny24m24k< nb_sbox, nround >, and BunnyAES< nb_key, 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.
Reimplemented in Bunny24m24k< nb_sbox, nround >, and BunnyAES< nb_key, 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.
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.
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).
void Bunny< nb_msg, nb_key, nb_sbox, nround >::keySchedule | ( | keyType | k | ) | [inline, virtual] |
Key-Schedule STEP - Bunny's style.
Reimplemented in Bunny24m24k< nb_sbox, nround >, and BunnyAES< nb_key, 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))
Reimplemented in BunnyAES< nb_key, nround >.