|
Timing attack against DES 0.1
|
The des library, a software library dedicated to the Data Encryption Standard (DES). More...
#include <stdint.h>#include <inttypes.h>Go to the source code of this file.
Functions | |
| int | hamming_weight (uint64_t val) |
| Returns the Hamming weight of a 64 bits word. | |
| int | hamming_distance (uint64_t val1, uint64_t val2) |
| Returns the Hamming distance between two 64 bits words. | |
| uint64_t | des_ip (uint64_t val) |
| Initial permutation (64 to 64 bits). | |
| uint64_t | des_n_ip (uint64_t val) |
| Inverse of initial permutation (64 to 64 bits). | |
| uint64_t | des_fp (uint64_t val) |
| Final permutation (64 to 64 bits). | |
| uint64_t | des_n_fp (uint64_t val) |
| Inverse of final permutation (64 to 64 bits). | |
| uint64_t | des_e (uint64_t val) |
| E expansion - permutation (32 to 48 bits). | |
| uint64_t | des_n_e (uint64_t val) |
| Inverse of E expansion - permutation (48 to 32 bits). | |
| uint64_t | des_p (uint64_t val) |
| P permutation (32 to 32 bits). | |
| uint64_t | des_n_p (uint64_t val) |
| Inverse of P permutation (32 to 32 bits). | |
| uint64_t | des_pc1 (uint64_t val) |
| PC1 permutation - selection (64 to 56 bits). | |
| uint64_t | des_set_parity_bits (uint64_t val) |
| Computes the 8 parity bits of a 64 bits word. | |
| uint64_t | des_n_pc1 (uint64_t val) |
| Inverse of PC1 permutation - selection (56 to 64 bits). | |
| uint64_t | des_pc2 (uint64_t val) |
| PC2 permutation - selection (56 to 48 bits). | |
| uint64_t | des_n_pc2 (uint64_t val) |
| Inverse of PC2 permutation - selection (48 to 56 bits). | |
| uint64_t | des_sbox (int sbox, uint64_t val) |
| Single SBox computation (6 to 4 bits). | |
| uint64_t | des_sboxes (uint64_t val) |
| All SBoxes computation (48 to 32 bits). | |
| uint64_t | des_right_half (uint64_t val) |
| Returns the 32 bits right half of a 64 bits word. | |
| uint64_t | des_left_half (uint64_t val) |
| Returns the 32 bits left half of a 64 bits word. | |
| uint64_t | des_ls (uint64_t val) |
| Applies the left shift rotation of the standard (56 to 56 bits). | |
| uint64_t | des_rs (uint64_t val) |
| Applies the right shift rotation of the standard (56 to 56 bits). | |
| uint64_t | des_f (uint64_t rk, uint64_t val) |
| The F function of the standard (48+32 bits to 32 bits). | |
| void | des_ks (uint64_t *ks, uint64_t val) |
| Computes the whole key schedule from a 64 bits secret key and stores the sixteen 48 bits round keys in an array. | |
| uint64_t | des_enc (uint64_t *ks, uint64_t val) |
| Enciphers a 64 bits plaintext with a pre-computed key schedule. | |
| uint64_t | des_dec (uint64_t *ks, uint64_t val) |
| Deciphers a 64 bits plaintext with a pre-computed key schedule. | |
| int | des_check (void) |
| A functional verification of the DES implementation. | |
Variables | |
| uint8_t | left_shifts [16] |
| Number of left shifts per round. | |
The des library, a software library dedicated to the Data Encryption Standard (DES).
uint64_t. It is a 64 bits unsigned integer.uint64_t. | int hamming_weight | ( | uint64_t | val | ) |
Returns the Hamming weight of a 64 bits word.
Note: the input's width can be anything between 0 and 64, as long as the unused bits are all zeroes.
| val | The 64 bits input. |
| int hamming_distance | ( | uint64_t | val1, |
| uint64_t | val2 | ||
| ) |
Returns the Hamming distance between two 64 bits words.
Note: the width of the inputs can be anything between 0 and 64, as long as they are the same, aligned and that the unused bits are all zeroes.
| val1 | The first 64 bits input. |
| val2 | The second 64 bits input. |
| uint64_t des_ip | ( | uint64_t | val | ) |
Initial permutation (64 to 64 bits).
Same as des_n_fp().
uint64_t. | val | The 64 bits input. |
| uint64_t des_n_ip | ( | uint64_t | val | ) |
Inverse of initial permutation (64 to 64 bits).
Same as des_fp().
uint64_t. | val | 64 bits input. |
| uint64_t des_fp | ( | uint64_t | val | ) |
Final permutation (64 to 64 bits).
Inverse of initial permutation, same as des_n_ip().
uint64_t. | val | 64 bits input. |
| uint64_t des_n_fp | ( | uint64_t | val | ) |
Inverse of final permutation (64 to 64 bits).
Same as des_ip().
uint64_t. | val | 64 bits input. |
| uint64_t des_e | ( | uint64_t | val | ) |
E expansion - permutation (32 to 48 bits).
uint64_t. | val | 32 bits input. |
| uint64_t des_n_e | ( | uint64_t | val | ) |
Inverse of E expansion - permutation (48 to 32 bits).
Duplicated bits must have the same value. If they do not, an error is raised.
uint64_t. | val | 48 bits input. |
| uint64_t des_p | ( | uint64_t | val | ) |
P permutation (32 to 32 bits).
uint64_t. | val | 32 bits input. |
| uint64_t des_n_p | ( | uint64_t | val | ) |
Inverse of P permutation (32 to 32 bits).
uint64_t. | val | 32 bits input. |
| uint64_t des_pc1 | ( | uint64_t | val | ) |
PC1 permutation - selection (64 to 56 bits).
No parity check.
uint64_t. | val | 64 bits input. |
| uint64_t des_set_parity_bits | ( | uint64_t | val | ) |
Computes the 8 parity bits of a 64 bits word.
Parity bits are the rightmost bit of each byte. Once computed, the number of set bits of each byte is odd, as specified in the DES standard.
uint64_t. | val | 64 bits input. |
| uint64_t des_n_pc1 | ( | uint64_t | val | ) |
Inverse of PC1 permutation - selection (56 to 64 bits).
Parity bits are computed.
uint64_t. | val | 56 bits input. |
| uint64_t des_pc2 | ( | uint64_t | val | ) |
PC2 permutation - selection (56 to 48 bits).
uint64_t. | val | 56 bits input. |
| uint64_t des_n_pc2 | ( | uint64_t | val | ) |
Inverse of PC2 permutation - selection (48 to 56 bits).
Missing bits are set to 0.
uint64_t. | val | 48 bits input. |
| uint64_t des_sbox | ( | int | sbox, |
| uint64_t | val | ||
| ) |
Single SBox computation (6 to 4 bits).
uint64_t. | sbox | SBox number, from 1 to 8. |
| val | 6 bits input. |
| uint64_t des_sboxes | ( | uint64_t | val | ) |
All SBoxes computation (48 to 32 bits).
uint64_t. | val | 48 bits input. |
| uint64_t des_right_half | ( | uint64_t | val | ) |
Returns the 32 bits right half of a 64 bits word.
uint64_t. | val | 64 bits input. |
| uint64_t des_left_half | ( | uint64_t | val | ) |
Returns the 32 bits left half of a 64 bits word.
uint64_t. | val | 64 bits input. |
| uint64_t des_ls | ( | uint64_t | val | ) |
Applies the left shift rotation of the standard (56 to 56 bits).
uint64_t. | val | 56 bits input. |
| uint64_t des_rs | ( | uint64_t | val | ) |
Applies the right shift rotation of the standard (56 to 56 bits).
uint64_t. | val | 56 bits input. |
| uint64_t des_f | ( | uint64_t | rk, |
| uint64_t | val | ||
| ) |
The F function of the standard (48+32 bits to 32 bits).
uint64_t. | rk | 48 bits round key. |
| val | 32 bits data input. |
| void des_ks | ( | uint64_t * | ks, |
| uint64_t | val | ||
| ) |
Computes the whole key schedule from a 64 bits secret key and stores the sixteen 48 bits round keys in an array.
The sixteen 48 bits round keys are returned in the array passed as first parameter.
| ks | The array where to store the sixteen 48 bits round keys. On return ks[0] holds the first round key, ..., ks[15] holds the last round key. Must be allocated prior the call. |
| val | 64 bits key. |
| uint64_t des_enc | ( | uint64_t * | ks, |
| uint64_t | val | ||
| ) |
Enciphers a 64 bits plaintext with a pre-computed key schedule.
uint64_t. | ks | The pre-computed key schedule. |
| val | The 64 bits plaintext. |
| uint64_t des_dec | ( | uint64_t * | ks, |
| uint64_t | val | ||
| ) |
Deciphers a 64 bits plaintext with a pre-computed key schedule.
uint64_t. | ks | The pre-computed key schedule. |
| val | The 64 bits ciphertext. |
| int des_check | ( | void | ) |
A functional verification of the DES implementation.
Runs a number of encipherments with des_enc() and the corresponding decipherments with des_dec() and checks the results against pre-computed plaintext, ciphertexts and secret keys. If compiled in DEBUG mode, prints warnings on mismatches or a OK message if the tests pass.
|
extern |
Number of left shifts per round.
left_shifts[0] corresponds to round #1, ... left_shifts[15] corresponds to round #16. A value of 0 means one shift. A value of 1 means two shifts.