Common functions used in the analysis of TEA.  
More...
#include "common.hh"
#include "tea.hh"
|  | 
| void | tea_encrypt (uint32_t *v, uint32_t *k, int nrounds) | 
|  | 
| uint32_t | tea_f (uint32_t x, uint32_t k0, uint32_t k1, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const) | 
|  | 
| uint32_t | tea_f_i (const uint32_t mask_i, const uint32_t k0, const uint32_t k1, const uint32_t delta, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in) | 
|  | 
| void | tea_compute_delta_const (uint32_t D[TEA_NCYCLES]) | 
|  | 
| double | tea_add_diff_adjust_to_key (const uint64_t npairs, const int round_idx, const uint32_t da, const uint32_t db, const uint32_t key[4]) | 
|  | 
| double | tea_differential_thres_exper_fk (uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2]) | 
|  | 
| uint32_t | tea_add_verify_trail (uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS]) | 
|  | 
| uint32_t | tea_add_verify_differential (uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS]) | 
|  | 
| void | print_trail_latex (FILE *fp, uint32_t nrounds, uint32_t keys[4], differential_t trail[NROUNDS]) | 
|  | 
Common functions used in the analysis of TEA. 
- Author
- V.Velichkov, vesse.nosp@m.lin..nosp@m.velic.nosp@m.hkov.nosp@m.@uni..nosp@m.lu 
      
        
          | void print_trail_latex | ( | FILE * | fp, | 
        
          |  |  | uint32_t | nrounds, | 
        
          |  |  | uint32_t | keys[4], | 
        
          |  |  | differential_t | trail[NROUNDS] | 
        
          |  | ) |  |  | 
      
 
Print a differential trail in LaTeX-formatted style, suitable to add in a LaTeX document.
- Parameters
- 
  
    | fp | FILE pointer for writing; opened and closed by the calling function. |  | nrounds | number of rounds covered by the trail (NROUNDS). |  | keys | cryptographic key of TEA. |  | trail | differential trail for nrounds. |  
 
 
 
      
        
          | double tea_add_diff_adjust_to_key | ( | const uint64_t | npairs, | 
        
          |  |  | const int | round_idx, | 
        
          |  |  | const uint32_t | da, | 
        
          |  |  | const uint32_t | db, | 
        
          |  |  | const uint32_t | key[4] | 
        
          |  | ) |  |  | 
      
 
Experimentally adjust the probability of a differential for one round of TEA to a fixed key over a number of chosen plaintexts.
- Parameters
- 
  
    | npairs | number of chosen plaintext pairs (NPAIRS). |  | round_idx | index of the round. |  | da | input difference to the TEA F function. |  | db | output difference from the TEA F function. |  | key | cryptographic key of TEA. |  
 
 
 
      
        
          | uint32_t tea_add_verify_differential | ( | uint32_t | nrounds, | 
        
          |  |  | uint32_t | npairs, | 
        
          |  |  | uint32_t | key[4], | 
        
          |  |  | differential_t | trail[NROUNDS] | 
        
          |  | ) |  |  | 
      
 
Given an ADD trail for  rounds of TEA, experimentally verify the probabilities of the corresponding
 rounds of TEA, experimentally verify the probabilities of the corresponding  differentials:
 differentials: 
  - Differential for 1 round: round 0. 
  - Differential for 2 rounds: rounds \form#316. 
  - Differential for 3 rounds: rounds \form#317. 
  -  \form#318
  - Differential for \form#315 rounds: rounds \form#319. 
- Parameters
- 
  
    | nrounds | number of rounds covered by the trail (NROUNDS). |  | npairs | number of chosen plaintext pairs (NPAIRS). |  | key | cryptographic key of TEA. |  | trail | differential trail for nrounds. |  
 
 
 
      
        
          | uint32_t tea_add_verify_trail | ( | uint32_t | nrounds, | 
        
          |  |  | uint32_t | npairs, | 
        
          |  |  | uint32_t | key[4], | 
        
          |  |  | differential_t | trail[NROUNDS] | 
        
          |  | ) |  |  | 
      
 
Experimentally verify the probability of all 1-round differentials from which an N round ADD trail for TEA is composed.
- Parameters
- 
  
    | nrounds | number of rounds covered by the trail (NROUNDS). |  | npairs | number of chosen plaintext pairs (NPAIRS). |  | key | cryptographic key of TEA. |  | trail | differential trail for nrounds. |  
 
 
 
      
        
          | void tea_compute_delta_const | ( | uint32_t | D[TEA_NCYCLES] | ) |  | 
      
 
Compute all round constants of block cipher TEA.
- Parameters
- 
  
    | D | all round constants  of TEA. |  
 
 
 
      
        
          | double tea_differential_thres_exper_fk | ( | uint64_t | npairs, | 
        
          |  |  | int | r, | 
        
          |  |  | uint32_t | key[4], | 
        
          |  |  | uint32_t | da[2], | 
        
          |  |  | uint32_t | db[2] | 
        
          |  | ) |  |  | 
      
 
Experimentally verify the probability of an r round differential for TEA, for a fixed key, over a number of chosen plaintexts.
- Parameters
- 
  
    | npairs | number of chosen plaintext pairs (NPAIRS). |  | r | number of rounds (1   nrounds 64). |  | da | input state to round 1. |  | db | output state after round r. |  | key | cryptographic key of TEA. |  
 
 
 
      
        
          | void tea_encrypt | ( | uint32_t * | v, | 
        
          |  |  | uint32_t * | k, | 
        
          |  |  | int | nrounds | 
        
          |  | ) |  |  | 
      
 
 
      
        
          | uint32_t tea_f | ( | uint32_t | x, | 
        
          |  |  | uint32_t | k0, | 
        
          |  |  | uint32_t | k1, | 
        
          |  |  | uint32_t | delta, | 
        
          |  |  | uint32_t | lsh_const, | 
        
          |  |  | uint32_t | rsh_const | 
        
          |  | ) |  |  | 
      
 
 
      
        
          | uint32_t tea_f_i | ( | const uint32_t | mask_i, | 
        
          |  |  | const uint32_t | k0, | 
        
          |  |  | const uint32_t | k1, | 
        
          |  |  | const uint32_t | delta, | 
        
          |  |  | const uint32_t | lsh_const, | 
        
          |  |  | const uint32_t | rsh_const, | 
        
          |  |  | const uint32_t | x_in | 
        
          |  | ) |  |  | 
      
 
The F-function of block cipher TEA (tea_f) computed on the first i least-significant (LS) bits.
- Parameters
- 
  
    | mask_i | ibit LSB mask. |  | k0 | first round key. |  | k1 | second round key. |  | delta | round constant. |  | lsh_const | LSH constant (default is 4). |  | rsh_const | RSH constant (default is 5). |  | x_in | input to  . |  
 
- Returns
 
- Attention
- the initial value x_inmust be minimum (rsh_const+ 1) bits long so that it can be shifted right byrsh_constpositions.
- See Also
- xtea_f()