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