]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - USAGE.blockciphers
forgotten uart files
[avr-crypto-lib.git] / USAGE.blockciphers
index f0bc9d823392b17ed5cfae86623b3f7ea0f20757..227ec3566f4a240897cc971a9dd25ff50eaab89c 100644 (file)
@@ -8,15 +8,15 @@ email:  daniel.otte@rub.de
  
 0. Foreword
  This file will describe how to use the blockcipher implementations provided by
- this library. It will not only show how to call the cryptographic functions but
- also discuss a little how to build security mechanisms from that.
+ this library. It will not only show how to call the cryptographic functions 
but also discuss a little how to build security mechanisms from that.
  So you will also be introduced to the basic "modes of operation".
 
 1. What a blockcipher does
- A blockcipher is a algorithm which turn an input of fixed length into an output
- of the same length (enciphering or encrypting). The transformation is specified
- by a key which has to be of a fixed length, or a length of a given set or 
- range.
+ A blockcipher is a algorithm which turn an input of fixed length into an 
+ output of the same length (enciphering or encrypting). The transformation is 
+ specified by a key which has to be of a fixed length, or a length of a given 
set or range.
  Generally there is also an algorithm which turns the output back to the 
  previous input (deciphering or decrypting) when supplied with te same key.
  
@@ -30,7 +30,7 @@ email:  daniel.otte@rub.de
   * decryption algorithm
   * mostly a set of subkeys
   * mostly a keyschedule which generates the subkeys from the supplied key.
- As we can see here a blockcipher normally has an algortihm besides the 
+ As we can see here a blockcipher normally has an algorithm besides the 
  encryption and decryption algorithm, which we call keyschedule.
  Mostly the encryption and decryption algorithm consist of multiple rounds,
  where each round (and sometimes between rounds) subkeys are needed to modify
@@ -50,32 +50,32 @@ email:  daniel.otte@rub.de
  *_enc  function, which implements the encryption algorithm
  *_dec  function, which implements the decryption algorithm
  *_free function, which frees memory allocated for the keyschedule
- *_ctx_t context type, which can contain a keyschdule and other information
+ *_ctx_t context type, which can contain a keyschedule and other information
  
 3.1 look at the prototypes
  Generally the prototypes (defined in the *.h files) will tell you what 
  parameter means what. 
   
 3.1.2 sizes in bits and bytes
- Working with cryptographical functions involves working with different lengths.
- Some times you want to know it in bits and sometimes in bytes. To reduce
- frustration and to avoid bugs we suffix a length parameter with either _b or _B
- depending on the meaning. _b means in bits and _B means in bytes 
+ Working with cryptographical functions involves working with different
+ lengths. Some times you want to know it in bits and sometimes in bytes. To 
+ reduce frustration and to avoid bugs we suffix a length parameter with either
_b or _B depending on the meaning. _b means in bits and _B means in bytes 
  (big b big word).
 
 3.2. *_init function
  The *_init function generally takes a pointer to the key as first parameter.
  For ciphers where the keysize is not fixed the second parameter gives the 
- keysize (in bits regularly) and the last parameter points to a context variable
- to fill.
- For some ciphers there are additonal parameters like the number of rounds, 
+ keysize (in bits regularly) and the last parameter points to the context
variable to fill.
+ For some ciphers there are additional parameters like the number of rounds, 
  these parameters generally occur before the context pointer.
  
 3.3. *_enc and *_dec functions
  The encryption and decryption function of a specific algorithm normally do not
  differ in their parameters. Generally these functions take a pointer to the 
  block to operate on. Some ciphers allow to specify two blocks, where the first
- one will be written to and the scound will contain the source block. The two 
+ one will be written to and the second will contain the source block. The two 
  blocks may overlap or be the same. The last parameter specifies either the key 
  direct (with a pointer to it) or is a pointer to a context created with the 
  *_init function.
@@ -86,19 +86,19 @@ email:  daniel.otte@rub.de
  
 4. modes of operation
  The usage of cryptographic algorithms is usually motivated by the intend to
- fight potential threads. Blockciphers are generally good building blocks. There
- are different attacks to the cipher itself, but this is work to be done by
- cryptographers, but what stays up to you is using this building blocks in a
- secure maner.
+ fight potential threads. Blockciphers are generally good building blocks. 
+ There are different attacks to the cipher itself, but this is work to be done 
by cryptographers, but what stays up to you is using this building blocks in a
+ secure manner.
  You may read http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation to
  learn more.
  
 4.1. ECB (electronic codebook mode)
  Electronic codebook mode is the simplest mode of operation and its usages is
  generally not suggested. In ECB-mode a message which is to encrypt is simply
- split up in blocks and each block gets indipendently encrypted. The problem 
+ split up in blocks and each block gets independently encrypted. The problem 
  with this mode is that, for example same data produces the same ciphertext, 
- which may also allows an attacke to inject selected data.
+ which may also allows an attack to inject selected data.
  
     +----+   +----+   +----+           +----+   +----+   +----+
     | P1 |   | P2 |   | P3 |           | C1 |   | C2 |   | C3 |
@@ -115,17 +115,17 @@ email:  daniel.otte@rub.de
     +----+   +----+   +----+           +----+   +----+   +----+
 
 4.2. CBC (chipher-block-chaining mode)
- CBC-mode is a more advanced mode of opration. It solves most problems of 
- ECB-mode. It again works by spliting up the message into blocks and intoducing
- a initialisation vector (IV) at the beginning. The IV should be randomly 
- generated and is not required to be kept secret. The plaintext of each block
- is XORed with the ciphertext of the previous block (the first block is XORed
- with the IV) and then gets encrypted producing the ciphertext block.
+ CBC-mode is a more advanced mode of operation. It solves most problems of 
+ ECB-mode. It again works by split ing up the message into blocks and 
+ introducing a initialization vector (IV) at the beginning. The IV should be 
+ randomly generated and is not required to be kept secret. The plaintext of 
+ each block is XORed with the ciphertext of the previous block (the first block
is XORed with the IV) and then gets encrypted producing the ciphertext block.
  For decryption of a block simply decrypt the block an XOR it with the previous
  ciphertext block (or the IV in the case of the first block).
- CBC-mode has some properties which make it quite useles for some application.
+ CBC-mode has some properties which make it quite useless for some application.
  For example if you want to store a large amount of data, and you want to make
- a change in one block you would have to decrypt and reencrypt all follwing
+ a change in one block you would have to decrypt and re-encrypt all following
  blocks. If you have such a case read more about block cipher modes.
  The wikipedia article http://en.wikipedia.org/wiki/Block_cipher_modes_of_
  operation#Other_modes_and_other_cryptographic_primitives would make a good 
@@ -156,10 +156,10 @@ email:  daniel.otte@rub.de
  
 4.3.1. CTR (counter mode)
  This is quite simple. You use a counter which gets encrypted to produce a
- key stream. This key stream may be used to encrypt data by XORing the plaintext
- with the key stream. Decrypting is exactly the same then encrypting BE WARNED, 
- an attacker might flip a bit in the ciphertext and the corresponding bit in 
the plaintext gets fliped. 
+ key stream. This key stream may be used to encrypt data by XOR-ing the
+ plaintext with the key stream. Decrypting is exactly the same then encrypting
+ BE WARNED, an attacker might flip a bit in the ciphertext and the 
corresponding bit in the plaintext gets flipped. 
 
  +---------+ o--o  +---------+ o--o  +---------+ o--o  +---------+
  | counter |-|+1|->| counter |-|+1|->| counter |-|+1|->| counter |
@@ -178,7 +178,7 @@ email:  daniel.otte@rub.de
  
 4.3.2 OFB (output-feedback mode) 
  OFB-mode is much like CTR-mode. In fact the only difference is that you do not
- increment a counter, but use the output of the encrytption operation before as
+ increment a counter, but use the output of the encryption operation before as
  input.
  
  +-------+         +-------+         +-------+
@@ -203,11 +203,11 @@ email:  daniel.otte@rub.de
 
 4.3.2 CFB (cipher-feedback mode) 
  CFB-mode looks much like OFB-mode, but it has a lot of different properties.
- Instead of using the previous output block as input the resultig ciphertext is
used as input. Due to the fact that not the entire outputblock needs to be 
+ Instead of using the previous output block as input the resulting ciphertext 
is used as input. Due to the fact that not the entire output-block needs to be 
  used, the ciphertext does not form the entire input block for the next 
  operation but it is shifted in the input block.
- The resulting cipher is something known as self synchonising stream cipher.
+ The resulting cipher is something known as self synchronizing stream cipher.
  This means that a manipulation of a single bit in the ciphertext will result
  in this bit flipped in the corresponding plaintext but the following blocks 
  will be "destroyed" until the cipher "heald" itself, meaning the manipulated