High-Speed Implementation of PRESENT on AVR Microcontroller
Abstract
:1. Introduction
1.1. Contribution
1.1.1. Optimal Implementation of PRESENT Block Cipher on Embedded Processors
1.1.2. Pre-Computation for PRESENT with CTR
1.1.3. Open Source
2. Related Works
2.1. PRESENT Block Cipher
2.2. Target Processor
2.3. Former Implementations on Low-End Embedded Processors
3. Proposed Method
3.1. Optimization of PRESENT–ECB
Algorithm 1: Add-round-key operation in assembly language. | |
Input: Intermediate data (reg0∼7), round | 7: LD tmp, X+ |
key pointer (X). | 8: EOR reg3, tmp |
Output: Output results (reg0∼7). | 9: LD tmp, X+ |
10: EOR reg4, tmp | |
1: LD tmp, X+ | |
2: EOR reg0, tmp | 11: LD tmp, X+ |
12: EOR reg5, tmp | |
3: LD tmp, X+ | |
4: EOR reg1, tmp | 13: LD tmp, X+ |
14: EOR reg6, tmp | |
5: LD tmp, X+ | |
6: EOR reg2, tmp | 15: LD tmp, X+ |
16: EOR reg7, tmp |
Algorithm 2: Permutation () operation in assembly language. | |
Input: Intermediate data (reg0∼7). | 27: MOVW tmp0, reg2 |
28: LSR tmp1 | |
Output: Result (reg0∼7). | 29: ROR tmp0 |
30: LSR tmp1 | |
//t=(X0⊕(ROR_u16(X1,1)))&0x5555 | 31: ROR tmp0 |
1: MOVW tmp0, reg4 | 32: EOR tmp0, reg6 |
2: LSR tmp1 | 33: EOR tmp1, reg7 |
3: ROR tmp0 | |
34:ANDI tmp0, 0X33 | |
4: EOR tmp0, reg6 | 35: ANDI tmp1, 0X33 |
5: EOR tmp1, reg7 | |
//X0=X0⊕t; X2=X2⊕(ROL_u16(t, 2)); | |
6: ANDI tmp0, 0X55 | |
7: ANDI tmp1, 0X55 | 36: EOR reg6, tmp0 |
37: EOR reg7, tmp1 | |
//X0=X0⊕t; X1=X1⊕(ROL_u16(t,1)); | |
38: LSL tmp0 | |
8: EOR reg6, tmp0 | 39: ROL tmp1 |
9: EOR reg7, tmp1 | 40: LSL tmp0 |
41: ROL tmp1 | |
10: LSL tmp0 | |
11: ROL tmp1 | 42: EOR reg2, tmp0 |
43: EOR reg3, tmp1 | |
12: EOR reg4, tmp0 | |
13: EOR reg5, tmp1 | //t=(X1⊕(ROR_u16(X3, 2)))&0x3333; |
//t=(X2⊕(ROR_u16(X3, 1)))&0x5555; | 44: MOVW tmp0, reg0 |
45: LSR tmp1 | |
14: MOVW tmp0, reg0 | 46: ROR tmp0 |
15: LSR tmp1 | 47: LSR tmp1 |
16: ROR tmp0 | 48: ROR tmp0 |
17: EOR tmp0, reg2 | 49: EOR tmp0, reg4 |
18: EOR tmp1, reg3 | 50: EOR tmp1, reg5 |
19: ANDI tmp0, 0X55 | 51: ANDI tmp0, 0X33 |
20:ANDI tmp1, 0X55 | 52: ANDI tmp1, 0X33 |
//X2=X2⊕t; X3=X3⊕(ROL_u16(t, 1)); | //X1=X1⊕t; X3=X3⊕(ROL_u16(t, 2)); |
21: EOR reg2, tmp0 | 53: EOR reg4, tmp0 |
22: EOR reg3, tmp1 | 54: EOR reg5, tmp1 |
23: LSL tmp0 | 56: LSL tmp0 |
24: ROL tmp1 | 55: ROL tmp1 |
57: LSL tmp0 | |
25: EOR reg0, tmp0 | 58:ROL tmp1 |
26: EOR reg1, tmp1 | |
59: EOR reg0, tmp0 | |
//t=(X0⊕(ROR_u16(X2, 2)))&0x3333; | 60: EOR reg1, tmp1 |
Algorithm 3: Substitution operation in assembly language. | ||
Input: Intermediate data | //T2=T1&T3; | 26: COM reg0 |
(reg0∼7) | 27:COM reg1 | |
13: MOVW tmp2, tmp0 | ||
Output: Result (reg0∼7). | 14: AND tmp2, tmp4 | //T2=T2⊕x3; |
15: AND tmp3, tmp5 | ||
//T1=x2⊕x1; | 28: EOR tmp2, reg0 | |
//T1=T1⊕T5; | 29: EOR tmp3, reg1 | |
1: EOR tmp0, reg2 | ||
2: EOR tmp0, reg4 | 16: EOR tmp0, tmp7 | //x0=x2⊕T2; |
3: EOR tmp1, reg5 | 17: EOR tmp1, tmp8 | |
30: MOVW reg6, reg2 | ||
//T2=x1&T1; | //T2=T2⊕x1; | 31: EOR reg6, tmp2 |
32: EOR reg7, tmp3 | ||
4: MOVW tmp2, reg4 | 18: EOR tmp2, reg4 | |
5: AND tmp2, tmp0 | 19: EOR tmp3, reg5 | //T2=T2|T1; |
6: AND tmp3, tmp1 | ||
//T4=x3|T2; | 33: OR tmp2, tmp0 | |
//T3=x0⊕T2; | 20: MOVW tmp6, reg0 | 34: OR tmp3, tmp1 |
21: OR tmp6, tmp2 | ||
7: MOVW tmp4, reg6 | 22: OR tmp6, tmp3 | //x1=T3⊕T2; |
8: EOR tmp4, tmp2 | ||
9: EOR tmp5, tmp3 | //x2=T1⊕T4; | 35: MOVW reg4, tmp4 |
36: EOR reg4, tmp2 | ||
//T5=x3⊕T3; | 23: MOVW reg2, tmp0 | 37: EOR reg5, tmp3 |
24: EOR reg2, tmp6 | ||
10: MOVW tmp7, reg0 | 25: EOR reg3, tmp6 | //x3=T5; |
11: EOR tmp7, tmp4 | ||
12: EOR tmp8, tmp5 | //x3=x3⊕0xFFFF; | 38: MOVW reg0, tmp7 |
3.2. Optimization of PRESENT–CTR
- First add-round-key. 64-bit plaintext is XORed with 64-bit round key. Since this is a bit-wise operation, each bits do not interfere with each other;
- Permutation . The intermediate result is permuted. 16-bit counter values are distributed throughout the 64-bit intermediate result. Bits of the counter are arranged by 1 bit in the order of green, red, blue, and yellow according to a permutation rule;
- Substitution. The 4-bit input values consist of 1-bit counter-part and 3-bit nonce part. The output of substitution can be pre-computed with the counter-part;
- Permutation . The intermediate result is permuted again. After the permutation, the intermediate result is aligned by 16-bit wise;
- Second add-round-key. The intermediate result is XORed with a second 64-bit round key.
Algorithm 4: Generation of look-up tables for proposed PRESENT-CTR16 encryption. |
Input: 64-bit block of Initial Vector (16-bit counter and 48-bit nonce) B, roundkeys (). Output: Look-up tables for 16-bit counter (, , , ).
|
Algorithm 5: Proposed PRESENT-CTR16 encryption. |
Input: 64-bit plaintext B, a key K. Output: 64-bit ciphertext C.
|
- First add-round-key. Similarly to the 16-bit counter mode, the 64-bit plaintext is XORed with 64-bit round key. Since this is a bit-wise operation, bits do not interfere with each other;
- Permutation . The intermediate result is permuted. 32-bit counter values are distributed throughout 64-bit intermediate results. The 16-bit to 32-bit of 32-bit counter are arranged one by one behind each color square;
- Substitution. The 4-bit input values consist of a 2-bit counter part and 2-bit nonce part. The output of substitution can be pre-computed with the counter part;
- Permutation . The intermediate result is permuted again. After the permutation, the intermediate result is aligned by 16-bit wise;
- Second add-round-key. Similarly to the 16-bit counter mode of operation, the intermediate result is XORed with a second 64-bit round key.
Algorithm 6: Generation of look-up tables for proposed PRESENT-CTR32 encryption. |
Input: 64-bit block of Initial Vector (32-bit nonce and 32-bit counter) B, roundkeys (). Output: Look-up tables for 32-bit counter (, , , ).
|
Algorithm 7: Proposed PRESENT-CTR32 encryption. |
Input: 64-bit plaintext B, a key K. Output: 64-bit ciphertext C.
|
4. Evaluation
5. Conclusions
Author Contributions
Funding
Conflicts of Interest
References
- Engels, S.; Kavun, E.B.; Paar, C.; Yalçin, T.; Mihajloska, H. A non-linear/linear instruction set extension for lightweight ciphers. In Proceedings of the 2013 IEEE 21st Symposium on Computer Arithmetic, Austin, TX, USA, 7–10 April 2013; IEEE: Piscataway, NJ, USA, 2013; pp. 67–75. [Google Scholar]
- Bogdanov, A.; Knudsen, L.R.; Leander, G.; Paar, C.; Poschmann, A.; Robshaw, M.J.; Seurin, Y.; Vikkelsoe, C. PRESENT: An ultra-lightweight block cipher. In Proceedings of the International Workshop on Cryptographic Hardware and Embedded Systems, Vienna, Austria, 10–13 September 2007; Springer: Berlin/Heidelberg, Germany, 2007; pp. 450–466. [Google Scholar]
- Hong, D.; Lee, J.K.; Kim, D.C.; Kwon, D.; Ryu, K.H.; Lee, D.G. LEA: A 128-bit block cipher for fast encryption on common processors. In Proceedings of the International Workshop on Information Security Applications, Jeju Island, Korea, 19–21 August 2013; Springer: Berlin/Heidelberg, Germany, 2013; pp. 3–27. [Google Scholar]
- Seo, H.; Liu, Z.; Choi, J.; Park, T.; Kim, H. Compact implementations of LEA block cipher for low-end microprocessors. In Proceedings of the International Workshop on Information Security Applications, Jeju Island, Korea, 20–22 August 2015; Springer: Berlin/Heidelberg, Germany, 2015; pp. 28–40. [Google Scholar]
- Seo, H.; Jeong, I.; Lee, J.; Kim, W.H. Compact implementations of ARX-based block ciphers on IoT processors. ACM Trans. Embed. Comput. Syst. (TECS) 2018, 17, 1–16. [Google Scholar] [CrossRef]
- Seo, H.; An, K.; Kwon, H. Compact LEA and HIGHT implementations on 8-bit AVR and 16-bit MSP processors. In Proceedings of the International Workshop on Information Security Applications, Jeju Island, Korea, 23–25 August 2018; Springer: Berlin/Heidelberg, Germany, 2018; pp. 253–265. [Google Scholar]
- Kim, Y.; Kwon, H.; An, S.; Seo, H.; Seo, S.C. Efficient Implementation of ARX-Based Block Ciphers on 8-Bit AVR Microcontrollers. Mathematics 2020, 8, 1837. [Google Scholar] [CrossRef]
- Hong, D.; Sung, J.; Hong, S.; Lim, J.; Lee, S.; Koo, B.S.; Lee, C.; Chang, D.; Lee, J.; Jeong, K.; et al. HIGHT: A new block cipher suitable for low-resource device. In Proceedings of the International Workshop on Cryptographic Hardware and Embedded Systems, Yokohama, Japan, 10–13 October 2006; Springer: Berlin/Heidelberg, Germany, 2006; pp. 46–59. [Google Scholar]
- Eisenbarth, T.; Gong, Z.; Güneysu, T.; Heyse, S.; Indesteege, S.; Kerckhof, S.; Koeune, F.; Nad, T.; Plos, T.; Regazzoni, F.; et al. Compact implementation and performance evaluation of block ciphers in ATtiny devices. In Proceedings of the International Conference on Cryptology in Africa, Ifrance, Morocco, 10–12 July 2012; Springer: Berlin/Heidelberg, Germany, 2012; pp. 172–187. [Google Scholar]
- Kim, B.; Cho, J.; Choi, B.; Park, J.; Seo, H. Compact Implementations of HIGHT Block Cipher on IoT Platforms. Secur. Commun. Netw. 2019, 2019, 5323578. [Google Scholar] [CrossRef]
- Koo, B.; Roh, D.; Kim, H.; Jung, Y.; Lee, D.G.; Kwon, D. CHAM: A family of lightweight block ciphers for resource-constrained devices. In Proceedings of the International Conference on Information Security and Cryptology, Xi’an, China, 3–5 November 2017; Springer: Berlin/Heidelberg, Germany, 2017; pp. 3–25. [Google Scholar]
- Seo, H. Memory-efficient implementation of ultra-lightweight block cipher algorithm CHAM on low-end 8-bit AVR processors. J. Korea Inst. Inf. Secur. Cryptol. 2018, 28, 545–550. [Google Scholar]
- Roh, D.; Koo, B.; Jung, Y.; Jeong, I.W.; Lee, D.G.; Kwon, D.; Kim, W.H. Revised Version of Block Cipher CHAM. In Proceedings of the International Conference on Information Security and Cryptology, Seoul, Korea, 4–6 December 2019; Springer: Berlin/Heidelberg, Germany, 2019; pp. 1–19. [Google Scholar]
- Kwon, H.; Kim, H.; Choi, S.J.; Jang, K.; Park, J.; Kim, H.; Seo, H. Compact Implementation of CHAM Block Cipher on Low-End Microcontrollers. In Proceedings of the International Conference on Information Security Applications, Jeju Island, Korea, 26–28 August 2020; Springer: Berlin/Heidelberg, Germany, 2020; pp. 127–141. [Google Scholar]
- Kwon, H.; An, S.; Kim, Y.; Kim, H.; Choi, S.J.; Jang, K.; Park, J.; Kim, H.; Seo, S.C.; Seo, H. Designing a CHAM Block Cipher on Low-End Microcontrollers for Internet of Things. Electronics 2020, 9, 1548. [Google Scholar] [CrossRef]
- Beaulieu, R.; Shors, D.; Smith, J.; Treatman-Clark, S.; Weeks, B.; Wingers, L. The SIMON and SPECK Families of Lightweight Block Ciphers. IACR Cryptol. EPrint Arch. 2013, 2013, 404–449. [Google Scholar]
- Beaulieu, R.; Shors, D.; Smith, J.; Treatman-Clark, S.; Weeks, B.; Wingers, L. The SIMON and SPECK block ciphers on AVR 8-bit microcontrollers. In Proceedings of the International Workshop on Lightweight Cryptography for Security and Privacy, Istanbul, Turkey, 1–2 September 2014; Springer: Berlin/Heidelberg, Germany, 2014; pp. 3–20. [Google Scholar]
- Osvik, D.A.; Bos, J.W.; Stefan, D.; Canright, D. Fast software AES encryption. In Proceedings of the International Workshop on Fast Software Encryption, Seoul, Korea, 7–10 February 2010; Springer: Berlin/Heidelberg, Germany, 2010; pp. 75–93. [Google Scholar]
- McGrew, D.; Viega, J. The Galois/counter mode of operation (GCM). Submiss. NIST Modes Oper. Process 2004, 20, 1–27. [Google Scholar]
- Park, J.H.; Lee, D.H. FACE: Fast AES CTR mode Encryption Techniques based on the Reuse of Repetitive Data. IACR Trans. Cryptogr. Hardw. Embed. Syst. 2018, 469–499. [Google Scholar] [CrossRef]
- Kim, K.; Choi, S.; Kwon, H.; Liu, Z.; Seo, H. FACE–LIGHT: Fast AES–CTR Mode Encryption for Low-End Microcontrollers. In Proceedings of the International Conference on Information Security and Cryptology, Seoul, Korea, 4–6 December 2019; Springer: Berlin/Heidelberg, Germany, 2019; pp. 102–114. [Google Scholar]
- Kim, K.; Choi, S.; Kwon, H.; Kim, H.; Liu, Z.; Seo, H. PAGE–Practical AES-GCM Encryption for Low-End Microcontrollers. Appl. Sci. 2020, 10, 3131. [Google Scholar] [CrossRef]
- Seo, H.; Kwon, H.; Kim, H.; Park, J. ACE: ARIA-CTR Encryption for Low-End Embedded Processors. Sensors 2020, 20, 3788. [Google Scholar] [CrossRef]
- Reis, T.B.; Aranha, D.F.; López, J. PRESENT runs fast. In Proceedings of the International Conference on Cryptographic Hardware and Embedded Systems, Taipei, Taiwan, 25–28 September 2017; Springer: Berlin/Heidelberg, Germany, 2017; pp. 644–664. [Google Scholar]
- Seo, H.; Lee, G.; Park, T.; Kim, H. Compact GCM implementations on 32-bit ARMv7-A processors. In Proceedings of the 2017 International Conference on Information and Communication Technology Convergence (ICTC), Jeju, Korea, 18–20 October 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 704–707. [Google Scholar]
- Kim, Y.; Seo, S.C. An Efficient Implementation of AES on 8-Bit AVR-Based Sensor Nodes. In Proceedings of the International Conference on Information Security Applications, Jeju Island, Korea, 26–28 August 2020; Springer: Berlin/Heidelberg, Germany, 2020; pp. 276–290. [Google Scholar]
- McGrew, D.A. Counter mode security: Analysis and recommendations. Cisco Syst. Novemb. 2002, 2, 1–8. [Google Scholar]
- Dinu, D.; Biryukov, A.; Großschädl, J.; Khovratovich, D.; Le Corre, Y.; Perrin, L. FELICS–fair evaluation of lightweight cryptographic systems. In Proceedings of the NIST Workshop on Lightweight Cryptography, Gaithersburg, MD, USA, 20–21 July 2015; Volume 128. [Google Scholar]
- Kim, H.; Jeon, Y.; Kim, G.; Kim, J.; Sim, B.Y.; Han, D.G.; Seo, H.; Kim, S.; Hong, S.; Sung, J.; et al. A New Method for Designing Lightweight S-Boxes with High Differential and Linear Branch Numbers, and Its Application*. In Proceedings of the 23rd Annual International Conference on Information Security and Cryptology (ICISC 2020), Seoul, Korea, 2–4 December 2020; pp. 105–132. [Google Scholar]
- Baysal, A.; Şahin, S. RoadRunneR: A small and fast bitslice block cipher for low cost 8-bit processors. In Lightweight Cryptography for Security and Privacy; Springer: Cham, Switzerland, 2015; pp. 58–76. [Google Scholar]
- Beierle, C.; Leander, G.; Moradi, A.; Rasoolzadeh, S. CRAFT: Lightweight tweakable block cipher with efficient protection against DFA attacks. IACR Trans. Symmetric Cryptol. 2019, 2019, 5–45. [Google Scholar] [CrossRef]
Method | Security Level | Mode of Operation | Code Size | RAM | Timing |
---|---|---|---|---|---|
[28] | 80 | ECB | 760 | 281 | 930.8 |
[1] | 128 | ECB | 660 | 280 | 1349.0 |
This work | 956 | 282 | 504.2 | ||
CTR | 1150 | 420 | 488.2 | ||
CTR | 1152 | 292 | 488.7 | ||
CTR | 3072 | 292 | 491.6 |
Method | Message Size (bytes) | ||||
---|---|---|---|---|---|
4096 | 8192 | 16,384 | 32,768 | 65,536 | |
CTR | 2.0038 | 4.0037 | 8.0035 | 16.0030 | 32.0019 |
CTR | 2.0010 | 4.0038 | 8.0076 | 16.0153 | 32.0307 |
CTR | 2.0136 | 4.0273 | 8.0547 | 16.1095 | 32.2191 |
Algorithm | Plaintext | Security Level | Code Size | RAM | Timing |
---|---|---|---|---|---|
PIPO [29] | 64 | 128 | 320 | 31 | 197 |
SIMON [17] | 290 | 24 | 253 | ||
RECTANGLE [28] | 466 | 204 | 403 | ||
RoadRunneR [30] | 196 | 24 | 477 | ||
PRESENT [this work ] | 956 | 282 | 504 | ||
SKINNY [28] | 502 | 187 | 877 | ||
PRIDE [28] | 650 | 47 | 969 | ||
PRESENT [1] | 660 | 280 | 1349 | ||
CRAFT [31] | 894 | 243 | 1,504 |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Kwon, H.; Kim, Y.B.; Seo, S.C.; Seo, H. High-Speed Implementation of PRESENT on AVR Microcontroller. Mathematics 2021, 9, 374. https://doi.org/10.3390/math9040374
Kwon H, Kim YB, Seo SC, Seo H. High-Speed Implementation of PRESENT on AVR Microcontroller. Mathematics. 2021; 9(4):374. https://doi.org/10.3390/math9040374
Chicago/Turabian StyleKwon, Hyeokdong, Young Beom Kim, Seog Chung Seo, and Hwajeong Seo. 2021. "High-Speed Implementation of PRESENT on AVR Microcontroller" Mathematics 9, no. 4: 374. https://doi.org/10.3390/math9040374
APA StyleKwon, H., Kim, Y. B., Seo, S. C., & Seo, H. (2021). High-Speed Implementation of PRESENT on AVR Microcontroller. Mathematics, 9(4), 374. https://doi.org/10.3390/math9040374