Timing attack against DES 0.1
des.h
Go to the documentation of this file.
1// MAIN-ONLY: DO NOT MODIFY THIS FILE
2
3/*
4 * Copyright (C) Telecom Paris
5 *
6 * This file must be used under the terms of the CeCILL. This source
7 * file is licensed as described in the file COPYING, which you should
8 * have received as part of this distribution. The terms are also
9 * available at:
10 * https://cecill.info/licences/Licence_CeCILL_V2.1-en.html
11*/
12
23#ifndef DES_H
24#define DES_H
25
26#include <stdint.h>
27#include <inttypes.h>
28
32extern uint8_t left_shifts[16];
33
36int hamming_weight (uint64_t val );
37
40int hamming_distance (uint64_t val1 ,
41 uint64_t val2
43 );
44
50uint64_t des_ip (uint64_t val);
51
54uint64_t des_n_ip (uint64_t val );
55
58uint64_t des_fp (uint64_t val );
59
62uint64_t des_n_fp (uint64_t val );
63
65uint64_t des_e (uint64_t val );
66
69uint64_t des_n_e (uint64_t val );
70
72uint64_t des_p (uint64_t val );
73
75uint64_t des_n_p (uint64_t val );
76
79uint64_t des_pc1 (uint64_t val );
80
83uint64_t des_set_parity_bits (uint64_t val );
84
87uint64_t des_n_pc1 (uint64_t val );
88
91uint64_t des_pc2 (uint64_t val );
92
95uint64_t des_n_pc2 (uint64_t val );
96
99uint64_t des_sbox (int sbox ,
100 uint64_t val
102 );
103
106uint64_t des_sboxes (uint64_t val );
107
110uint64_t des_right_half (uint64_t val );
111
114uint64_t des_left_half (uint64_t val );
115
118uint64_t des_ls (uint64_t val );
119
122uint64_t des_rs (uint64_t val );
123
126uint64_t des_f (uint64_t rk ,
127 uint64_t val
129 );
130
132void des_ks (
134 uint64_t * ks, uint64_t val
136 );
137
140uint64_t des_enc (uint64_t * ks ,
141 uint64_t val
143 );
144
147uint64_t des_dec (uint64_t * ks ,
148 uint64_t val
150 );
151
154int des_check (void);
155
156#endif
int hamming_weight(uint64_t val)
Returns the Hamming weight of a 64 bits word.
uint64_t des_n_p(uint64_t val)
Inverse of P permutation (32 to 32 bits).
uint64_t des_n_pc1(uint64_t val)
Inverse of PC1 permutation - selection (56 to 64 bits).
uint8_t left_shifts[16]
Number of left shifts per round.
int hamming_distance(uint64_t val1, uint64_t val2)
Returns the Hamming distance between two 64 bits words.
uint64_t des_n_e(uint64_t val)
Inverse of E expansion - permutation (48 to 32 bits).
uint64_t des_n_fp(uint64_t val)
Inverse of final permutation (64 to 64 bits).
uint64_t des_f(uint64_t rk, uint64_t val)
The F function of the standard (48+32 bits to 32 bits).
uint64_t des_n_pc2(uint64_t val)
Inverse of PC2 permutation - selection (48 to 56 bits).
uint64_t des_enc(uint64_t *ks, uint64_t val)
Enciphers a 64 bits plaintext with a pre-computed key schedule.
uint64_t des_e(uint64_t val)
E expansion - permutation (32 to 48 bits).
uint64_t des_pc2(uint64_t val)
PC2 permutation - selection (56 to 48 bits).
uint64_t des_ip(uint64_t val)
Initial permutation (64 to 64 bits).
uint64_t des_sboxes(uint64_t val)
All SBoxes computation (48 to 32 bits).
uint64_t des_rs(uint64_t val)
Applies the right shift rotation of the standard (56 to 56 bits).
uint64_t des_pc1(uint64_t val)
PC1 permutation - selection (64 to 56 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 i...
uint64_t des_dec(uint64_t *ks, uint64_t val)
Deciphers a 64 bits plaintext with a pre-computed key schedule.
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_sbox(int sbox, uint64_t val)
Single SBox computation (6 to 4 bits).
int des_check(void)
A functional verification of the DES implementation.
uint64_t des_right_half(uint64_t val)
Returns the 32 bits right half of a 64 bits word.
uint64_t des_set_parity_bits(uint64_t val)
Computes the 8 parity bits of a 64 bits word.
uint64_t des_p(uint64_t val)
P permutation (32 to 32 bits).
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).