present.c
Go to the documentation of this file.
1 /**
2  * @file present.c
3  * @brief PRESENT encryption algorithm
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @section Description
26  *
27  * PRESENT is an ultra-lightweight block cipher
28  *
29  * @author Oryx Embedded SARL (www.oryx-embedded.com)
30  * @version 1.9.0
31  **/
32 
33 //Switch to the appropriate trace level
34 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
35 
36 //Dependencies
37 #include "core/crypto.h"
38 #include "cipher/present.h"
39 
40 //Check crypto library configuration
41 #if (PRESENT_SUPPORT == ENABLED)
42 
43 //S-box
44 static const uint8_t sbox[16] =
45 {
46  0x0C, 0x05, 0x06, 0x0B, 0x09, 0x00, 0x0A, 0x0D, 0x03, 0x0E, 0x0F, 0x08, 0x04, 0x07, 0x01, 0x02
47 };
48 
49 //Inverse S-box
50 static const uint8_t isbox[256] =
51 {
52  0x55, 0x5E, 0x5F, 0x58, 0x5C, 0x51, 0x52, 0x5D, 0x5B, 0x54, 0x56, 0x53, 0x50, 0x57, 0x59, 0x5A,
53  0xE5, 0xEE, 0xEF, 0xE8, 0xEC, 0xE1, 0xE2, 0xED, 0xEB, 0xE4, 0xE6, 0xE3, 0xE0, 0xE7, 0xE9, 0xEA,
54  0xF5, 0xFE, 0xFF, 0xF8, 0xFC, 0xF1, 0xF2, 0xFD, 0xFB, 0xF4, 0xF6, 0xF3, 0xF0, 0xF7, 0xF9, 0xFA,
55  0x85, 0x8E, 0x8F, 0x88, 0x8C, 0x81, 0x82, 0x8D, 0x8B, 0x84, 0x86, 0x83, 0x80, 0x87, 0x89, 0x8A,
56  0xC5, 0xCE, 0xCF, 0xC8, 0xCC, 0xC1, 0xC2, 0xCD, 0xCB, 0xC4, 0xC6, 0xC3, 0xC0, 0xC7, 0xC9, 0xCA,
57  0x15, 0x1E, 0x1F, 0x18, 0x1C, 0x11, 0x12, 0x1D, 0x1B, 0x14, 0x16, 0x13, 0x10, 0x17, 0x19, 0x1A,
58  0x25, 0x2E, 0x2F, 0x28, 0x2C, 0x21, 0x22, 0x2D, 0x2B, 0x24, 0x26, 0x23, 0x20, 0x27, 0x29, 0x2A,
59  0xD5, 0xDE, 0xDF, 0xD8, 0xDC, 0xD1, 0xD2, 0xDD, 0xDB, 0xD4, 0xD6, 0xD3, 0xD0, 0xD7, 0xD9, 0xDA,
60  0xB5, 0xBE, 0xBF, 0xB8, 0xBC, 0xB1, 0xB2, 0xBD, 0xBB, 0xB4, 0xB6, 0xB3, 0xB0, 0xB7, 0xB9, 0xBA,
61  0x45, 0x4E, 0x4F, 0x48, 0x4C, 0x41, 0x42, 0x4D, 0x4B, 0x44, 0x46, 0x43, 0x40, 0x47, 0x49, 0x4A,
62  0x65, 0x6E, 0x6F, 0x68, 0x6C, 0x61, 0x62, 0x6D, 0x6B, 0x64, 0x66, 0x63, 0x60, 0x67, 0x69, 0x6A,
63  0x35, 0x3E, 0x3F, 0x38, 0x3C, 0x31, 0x32, 0x3D, 0x3B, 0x34, 0x36, 0x33, 0x30, 0x37, 0x39, 0x3A,
64  0x05, 0x0E, 0x0F, 0x08, 0x0C, 0x01, 0x02, 0x0D, 0x0B, 0x04, 0x06, 0x03, 0x00, 0x07, 0x09, 0x0A,
65  0x75, 0x7E, 0x7F, 0x78, 0x7C, 0x71, 0x72, 0x7D, 0x7B, 0x74, 0x76, 0x73, 0x70, 0x77, 0x79, 0x7A,
66  0x95, 0x9E, 0x9F, 0x98, 0x9C, 0x91, 0x92, 0x9D, 0x9B, 0x94, 0x96, 0x93, 0x90, 0x97, 0x99, 0x9A,
67  0xA5, 0xAE, 0xAF, 0xA8, 0xAC, 0xA1, 0xA2, 0xAD, 0xAB, 0xA4, 0xA6, 0xA3, 0xA0, 0xA7, 0xA9, 0xAA,
68 };
69 
70 //Inverse bit permutation
71 static const uint32_t ipbox[256] =
72 {
73  0x00000000, 0x00000001, 0x00000010, 0x00000011, 0x00000100, 0x00000101, 0x00000110, 0x00000111,
74  0x00001000, 0x00001001, 0x00001010, 0x00001011, 0x00001100, 0x00001101, 0x00001110, 0x00001111,
75  0x00010000, 0x00010001, 0x00010010, 0x00010011, 0x00010100, 0x00010101, 0x00010110, 0x00010111,
76  0x00011000, 0x00011001, 0x00011010, 0x00011011, 0x00011100, 0x00011101, 0x00011110, 0x00011111,
77  0x00100000, 0x00100001, 0x00100010, 0x00100011, 0x00100100, 0x00100101, 0x00100110, 0x00100111,
78  0x00101000, 0x00101001, 0x00101010, 0x00101011, 0x00101100, 0x00101101, 0x00101110, 0x00101111,
79  0x00110000, 0x00110001, 0x00110010, 0x00110011, 0x00110100, 0x00110101, 0x00110110, 0x00110111,
80  0x00111000, 0x00111001, 0x00111010, 0x00111011, 0x00111100, 0x00111101, 0x00111110, 0x00111111,
81  0x01000000, 0x01000001, 0x01000010, 0x01000011, 0x01000100, 0x01000101, 0x01000110, 0x01000111,
82  0x01001000, 0x01001001, 0x01001010, 0x01001011, 0x01001100, 0x01001101, 0x01001110, 0x01001111,
83  0x01010000, 0x01010001, 0x01010010, 0x01010011, 0x01010100, 0x01010101, 0x01010110, 0x01010111,
84  0x01011000, 0x01011001, 0x01011010, 0x01011011, 0x01011100, 0x01011101, 0x01011110, 0x01011111,
85  0x01100000, 0x01100001, 0x01100010, 0x01100011, 0x01100100, 0x01100101, 0x01100110, 0x01100111,
86  0x01101000, 0x01101001, 0x01101010, 0x01101011, 0x01101100, 0x01101101, 0x01101110, 0x01101111,
87  0x01110000, 0x01110001, 0x01110010, 0x01110011, 0x01110100, 0x01110101, 0x01110110, 0x01110111,
88  0x01111000, 0x01111001, 0x01111010, 0x01111011, 0x01111100, 0x01111101, 0x01111110, 0x01111111,
89  0x10000000, 0x10000001, 0x10000010, 0x10000011, 0x10000100, 0x10000101, 0x10000110, 0x10000111,
90  0x10001000, 0x10001001, 0x10001010, 0x10001011, 0x10001100, 0x10001101, 0x10001110, 0x10001111,
91  0x10010000, 0x10010001, 0x10010010, 0x10010011, 0x10010100, 0x10010101, 0x10010110, 0x10010111,
92  0x10011000, 0x10011001, 0x10011010, 0x10011011, 0x10011100, 0x10011101, 0x10011110, 0x10011111,
93  0x10100000, 0x10100001, 0x10100010, 0x10100011, 0x10100100, 0x10100101, 0x10100110, 0x10100111,
94  0x10101000, 0x10101001, 0x10101010, 0x10101011, 0x10101100, 0x10101101, 0x10101110, 0x10101111,
95  0x10110000, 0x10110001, 0x10110010, 0x10110011, 0x10110100, 0x10110101, 0x10110110, 0x10110111,
96  0x10111000, 0x10111001, 0x10111010, 0x10111011, 0x10111100, 0x10111101, 0x10111110, 0x10111111,
97  0x11000000, 0x11000001, 0x11000010, 0x11000011, 0x11000100, 0x11000101, 0x11000110, 0x11000111,
98  0x11001000, 0x11001001, 0x11001010, 0x11001011, 0x11001100, 0x11001101, 0x11001110, 0x11001111,
99  0x11010000, 0x11010001, 0x11010010, 0x11010011, 0x11010100, 0x11010101, 0x11010110, 0x11010111,
100  0x11011000, 0x11011001, 0x11011010, 0x11011011, 0x11011100, 0x11011101, 0x11011110, 0x11011111,
101  0x11100000, 0x11100001, 0x11100010, 0x11100011, 0x11100100, 0x11100101, 0x11100110, 0x11100111,
102  0x11101000, 0x11101001, 0x11101010, 0x11101011, 0x11101100, 0x11101101, 0x11101110, 0x11101111,
103  0x11110000, 0x11110001, 0x11110010, 0x11110011, 0x11110100, 0x11110101, 0x11110110, 0x11110111,
104  0x11111000, 0x11111001, 0x11111010, 0x11111011, 0x11111100, 0x11111101, 0x11111110, 0x11111111
105 };
106 
107 //Combined S-box and bit permutation
108 static const uint64_t spbox[256] =
109 {
110  0x0003000300000000, 0x0002000300000001, 0x0002000300010000, 0x0003000200010001,
111  0x0003000200000001, 0x0002000200000000, 0x0003000200010000, 0x0003000300000001,
112  0x0002000200010001, 0x0003000300010000, 0x0003000300010001, 0x0003000200000000,
113  0x0002000300000000, 0x0002000300010001, 0x0002000200000001, 0x0002000200010000,
114  0x0001000300000002, 0x0000000300000003, 0x0000000300010002, 0x0001000200010003,
115  0x0001000200000003, 0x0000000200000002, 0x0001000200010002, 0x0001000300000003,
116  0x0000000200010003, 0x0001000300010002, 0x0001000300010003, 0x0001000200000002,
117  0x0000000300000002, 0x0000000300010003, 0x0000000200000003, 0x0000000200010002,
118  0x0001000300020000, 0x0000000300020001, 0x0000000300030000, 0x0001000200030001,
119  0x0001000200020001, 0x0000000200020000, 0x0001000200030000, 0x0001000300020001,
120  0x0000000200030001, 0x0001000300030000, 0x0001000300030001, 0x0001000200020000,
121  0x0000000300020000, 0x0000000300030001, 0x0000000200020001, 0x0000000200030000,
122  0x0003000100020002, 0x0002000100020003, 0x0002000100030002, 0x0003000000030003,
123  0x0003000000020003, 0x0002000000020002, 0x0003000000030002, 0x0003000100020003,
124  0x0002000000030003, 0x0003000100030002, 0x0003000100030003, 0x0003000000020002,
125  0x0002000100020002, 0x0002000100030003, 0x0002000000020003, 0x0002000000030002,
126  0x0003000100000002, 0x0002000100000003, 0x0002000100010002, 0x0003000000010003,
127  0x0003000000000003, 0x0002000000000002, 0x0003000000010002, 0x0003000100000003,
128  0x0002000000010003, 0x0003000100010002, 0x0003000100010003, 0x0003000000000002,
129  0x0002000100000002, 0x0002000100010003, 0x0002000000000003, 0x0002000000010002,
130  0x0001000100000000, 0x0000000100000001, 0x0000000100010000, 0x0001000000010001,
131  0x0001000000000001, 0x0000000000000000, 0x0001000000010000, 0x0001000100000001,
132  0x0000000000010001, 0x0001000100010000, 0x0001000100010001, 0x0001000000000000,
133  0x0000000100000000, 0x0000000100010001, 0x0000000000000001, 0x0000000000010000,
134  0x0003000100020000, 0x0002000100020001, 0x0002000100030000, 0x0003000000030001,
135  0x0003000000020001, 0x0002000000020000, 0x0003000000030000, 0x0003000100020001,
136  0x0002000000030001, 0x0003000100030000, 0x0003000100030001, 0x0003000000020000,
137  0x0002000100020000, 0x0002000100030001, 0x0002000000020001, 0x0002000000030000,
138  0x0003000300000002, 0x0002000300000003, 0x0002000300010002, 0x0003000200010003,
139  0x0003000200000003, 0x0002000200000002, 0x0003000200010002, 0x0003000300000003,
140  0x0002000200010003, 0x0003000300010002, 0x0003000300010003, 0x0003000200000002,
141  0x0002000300000002, 0x0002000300010003, 0x0002000200000003, 0x0002000200010002,
142  0x0001000100020002, 0x0000000100020003, 0x0000000100030002, 0x0001000000030003,
143  0x0001000000020003, 0x0000000000020002, 0x0001000000030002, 0x0001000100020003,
144  0x0000000000030003, 0x0001000100030002, 0x0001000100030003, 0x0001000000020002,
145  0x0000000100020002, 0x0000000100030003, 0x0000000000020003, 0x0000000000030002,
146  0x0003000300020000, 0x0002000300020001, 0x0002000300030000, 0x0003000200030001,
147  0x0003000200020001, 0x0002000200020000, 0x0003000200030000, 0x0003000300020001,
148  0x0002000200030001, 0x0003000300030000, 0x0003000300030001, 0x0003000200020000,
149  0x0002000300020000, 0x0002000300030001, 0x0002000200020001, 0x0002000200030000,
150  0x0003000300020002, 0x0002000300020003, 0x0002000300030002, 0x0003000200030003,
151  0x0003000200020003, 0x0002000200020002, 0x0003000200030002, 0x0003000300020003,
152  0x0002000200030003, 0x0003000300030002, 0x0003000300030003, 0x0003000200020002,
153  0x0002000300020002, 0x0002000300030003, 0x0002000200020003, 0x0002000200030002,
154  0x0003000100000000, 0x0002000100000001, 0x0002000100010000, 0x0003000000010001,
155  0x0003000000000001, 0x0002000000000000, 0x0003000000010000, 0x0003000100000001,
156  0x0002000000010001, 0x0003000100010000, 0x0003000100010001, 0x0003000000000000,
157  0x0002000100000000, 0x0002000100010001, 0x0002000000000001, 0x0002000000010000,
158  0x0001000300000000, 0x0000000300000001, 0x0000000300010000, 0x0001000200010001,
159  0x0001000200000001, 0x0000000200000000, 0x0001000200010000, 0x0001000300000001,
160  0x0000000200010001, 0x0001000300010000, 0x0001000300010001, 0x0001000200000000,
161  0x0000000300000000, 0x0000000300010001, 0x0000000200000001, 0x0000000200010000,
162  0x0001000300020002, 0x0000000300020003, 0x0000000300030002, 0x0001000200030003,
163  0x0001000200020003, 0x0000000200020002, 0x0001000200030002, 0x0001000300020003,
164  0x0000000200030003, 0x0001000300030002, 0x0001000300030003, 0x0001000200020002,
165  0x0000000300020002, 0x0000000300030003, 0x0000000200020003, 0x0000000200030002,
166  0x0001000100000002, 0x0000000100000003, 0x0000000100010002, 0x0001000000010003,
167  0x0001000000000003, 0x0000000000000002, 0x0001000000010002, 0x0001000100000003,
168  0x0000000000010003, 0x0001000100010002, 0x0001000100010003, 0x0001000000000002,
169  0x0000000100000002, 0x0000000100010003, 0x0000000000000003, 0x0000000000010002,
170  0x0001000100020000, 0x0000000100020001, 0x0000000100030000, 0x0001000000030001,
171  0x0001000000020001, 0x0000000000020000, 0x0001000000030000, 0x0001000100020001,
172  0x0000000000030001, 0x0001000100030000, 0x0001000100030001, 0x0001000000020000,
173  0x0000000100020000, 0x0000000100030001, 0x0000000000020001, 0x0000000000030000
174 };
175 
176 //Common interface for encryption algorithms
178 {
179  "PRESENT",
180  sizeof(PresentContext),
184  NULL,
185  NULL,
188 };
189 
190 
191 /**
192  * @brief Key expansion
193  * @param[in] context Pointer to the PRESENT context to initialize
194  * @param[in] key Pointer to the key
195  * @param[in] keyLen Length of the key
196  * @return Error code
197  **/
198 
199 error_t presentInit(PresentContext *context, const uint8_t *key, size_t keyLen)
200 {
201  uint_t i;
202  uint64_t t;
203  uint64_t kl;
204  uint64_t kh;
205 
206  //Check key length
207  if(keyLen != 10 && keyLen != 16)
209 
210  //PRESENT can take keys of either 80 or 128 bits
211  if(keyLen == 10)
212  {
213  //Copy the 80-bit key
214  kh = LOAD16BE(key);
215  kl = LOAD64BE(key + 2);
216 
217  //Save the 64 leftmost bits of K
218  context->ks[0] = (kh << 48) | (kl >> 16);
219 
220  //Generate round keys
221  for(i = 1; i <= 31; i++)
222  {
223  //The key register is rotated by 61 bit positions to the left
224  t = kh & 0xFFFF;
225  kh = (kl >> 3) & 0xFFFF;
226  kl = (kl << 61) | (t << 45) | (kl >> 19);
227 
228  //The left-most four bits are passed through the S-box
229  t = sbox[(kh >> 12) & 0x0F];
230  kh = (kh & 0x0FFF) | (t << 12);
231 
232  //The round counter value i is XOR-ed with bits 19, 18, 17, 16, 15 of K
233  kl ^= (uint64_t) i << 15;
234 
235  //Save the 64 leftmost bits of K
236  context->ks[i] = (kh << 48) | (kl >> 16);
237  }
238  }
239  else
240  {
241  //Copy the 128-bit key
242  kh = LOAD64BE(key);
243  kl = LOAD64BE(key + 8);
244 
245  //Save the 64 leftmost bits of K
246  context->ks[0] = kh;
247 
248  //Generate round keys
249  for(i = 1; i <= 31; i++)
250  {
251  //The key register is rotated by 61 bit positions to the left
252  t = kh;
253  kh = (t << 61) | (kl >> 3);
254  kl = (kl << 61) | (t >> 3);
255 
256  //The left-most eight bits are passed through two S-boxes
257  t = sbox[(kh >> 56) & 0x0F];
258  kh = (kh & 0xF0FFFFFFFFFFFFFF) | (t << 56);
259  t = sbox[(kh >> 60) & 0x0F];
260  kh = (kh & 0x0FFFFFFFFFFFFFFF) | (t << 60);
261 
262  //The round counter value i is XOR-ed with bits 66, 65, 64, 63, 62 of K
263  kh ^= (uint64_t) i >> 2;
264  kl ^= (uint64_t) i << 62;
265 
266  //Save the 64 leftmost bits of K
267  context->ks[i] = kh;
268  }
269  }
270 
271  //No error to report
272  return NO_ERROR;
273 }
274 
275 
276 /**
277  * @brief Encrypt a 8-byte block using PRESENT algorithm
278  * @param[in] context Pointer to the PRESENT context
279  * @param[in] input Plaintext block to encrypt
280  * @param[out] output Ciphertext block resulting from encryption
281  **/
282 
283 void presentEncryptBlock(PresentContext *context, const uint8_t *input, uint8_t *output)
284 {
285  uint_t i;
286  uint64_t s;
287  uint64_t t;
288  uint64_t state;
289 
290  //Copy the plaintext to the 64-bit state
291  state = LOAD64BE(input);
292 
293  //Initial round key addition
294  state ^= context->ks[0];
295 
296  //The encryption consists of 31 rounds
297  for(i = 1; i <= 31; i++)
298  {
299  //Apply S-box and bit permutation
300  s = spbox[state & 0xFF];
301  t = spbox[(state >> 8) & 0xFF];
302  s |= ROL64(t, 2);
303  t = spbox[(state >> 16) & 0xFF];
304  s |= ROL64(t, 4);
305  t = spbox[(state >> 24) & 0xFF];
306  s |= ROL64(t, 6);
307  t = spbox[(state >> 32) & 0xFF];
308  s |= ROL64(t, 8);
309  t = spbox[(state >> 40) & 0xFF];
310  s |= ROL64(t, 10);
311  t = spbox[(state >> 48) & 0xFF];
312  s |= ROL64(t, 12);
313  t = spbox[(state >> 56) & 0xFF];
314  s |= ROL64(t, 14);
315 
316  //Add round key
317  state = s ^ context->ks[i];
318  }
319 
320  //The final state is then copied to the output
321  STORE64BE(state, output);
322 }
323 
324 
325 /**
326  * @brief Decrypt a 8-byte block using PRESENT algorithm
327  * @param[in] context Pointer to the PRESENT context
328  * @param[in] input Ciphertext block to decrypt
329  * @param[out] output Plaintext block resulting from decryption
330  **/
331 
332 void presentDecryptBlock(PresentContext *context, const uint8_t *input, uint8_t *output)
333 {
334  uint_t i;
335  uint64_t s;
336  uint64_t t;
337  uint64_t state;
338 
339  //Copy the ciphertext to the 64-bit state
340  state = LOAD64BE(input);
341 
342  //The decryption consists of 31 rounds
343  for(i = 31; i > 0; i--)
344  {
345  //Add round key
346  state ^= context->ks[i];
347 
348  //Apply inverse bit permutation
349  s = ipbox[state & 0xFF];
350  t = ipbox[(state >> 8) & 0xFF];
351  s |= ROL64(t, 32);
352  t = ipbox[(state >> 16) & 0xFF];
353  s |= ROL64(t, 1);
354  t = ipbox[(state >> 24) & 0xFF];
355  s |= ROL64(t, 33);
356  t = ipbox[(state >> 32) & 0xFF];
357  s |= ROL64(t, 2);
358  t = ipbox[(state >> 40) & 0xFF];
359  s |= ROL64(t, 34);
360  t = ipbox[(state >> 48) & 0xFF];
361  s |= ROL64(t, 3);
362  t = ipbox[(state >> 56) & 0xFF];
363  s |= ROL64(t, 35);
364 
365  //Apply inverse S-box
366  state = isbox[s & 0xFF];
367  t = isbox[(s >> 8) & 0xFF];
368  state |= ROL64(t, 8);
369  t = isbox[(s >> 16) & 0xFF];
370  state |= ROL64(t, 16);
371  t = isbox[(s >> 24) & 0xFF];
372  state |= ROL64(t, 24);
373  t = isbox[(s >> 32) & 0xFF];
374  state |= ROL64(t, 32);
375  t = isbox[(s >> 40) & 0xFF];
376  state |= ROL64(t, 40);
377  t = isbox[(s >> 48) & 0xFF];
378  state |= ROL64(t, 48);
379  t = isbox[(s >> 56) & 0xFF];
380  state |= ROL64(t, 56);
381  }
382 
383  //Final round key addition
384  state ^= context->ks[0];
385 
386  //The final state is then copied to the output
387  STORE64BE(state, output);
388 }
389 
390 #endif
#define STORE64BE(a, p)
Definition: cpu_endian.h:304
PRESENT algorithm context.
Definition: present.h:50
void(* CipherAlgoDecryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:1030
General definitions for cryptographic algorithms.
Common interface for encryption algorithms.
Definition: crypto.h:1073
void presentEncryptBlock(PresentContext *context, const uint8_t *input, uint8_t *output)
Encrypt a 8-byte block using PRESENT algorithm.
Definition: present.c:283
error_t(* CipherAlgoInit)(void *context, const uint8_t *key, size_t keyLen)
Definition: crypto.h:1026
#define PRESENT_BLOCK_SIZE
Definition: present.h:36
PRESENT encryption algorithm.
uint64_t ks[32]
Definition: present.h:52
#define LOAD16BE(p)
Definition: cpu_endian.h:168
uint8_t s
Success.
Definition: error.h:42
#define ROL64(a, n)
Definition: crypto.h:850
#define LOAD64BE(p)
Definition: cpu_endian.h:228
error_t
Error codes.
Definition: error.h:40
unsigned int uint_t
Definition: compiler_port.h:43
void(* CipherAlgoEncryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:1029
error_t presentInit(PresentContext *context, const uint8_t *key, size_t keyLen)
Key expansion.
Definition: present.c:199
const CipherAlgo presentCipherAlgo
Definition: present.c:177
void presentDecryptBlock(PresentContext *context, const uint8_t *input, uint8_t *output)
Decrypt a 8-byte block using PRESENT algorithm.
Definition: present.c:332