Skip to content

Sample code demonstrating hardware encoded AES encryption for nRF52840 devices (here specifically RAK4631 using RUI3)

License

Notifications You must be signed in to change notification settings

Kongduino/RUI3_nRFCrypto_AES

Repository files navigation

RUI3_nRFCrypto_AES

An RUI3 port of the Adafruit nRFCrypto library, and more specifically of my fork. Since RUI3 is a bare metal platform, without RTOS, the library cannot work as is, so I had to hack things apart, and put them back together. So far I have implemented nRFCrypto_Random, an existing class from the library, and nRFCrypto_AES, my own addition to the library, which provides hardware-accelerated AES encryption and decryption, ECB, CBC and CTR.

The sample code demonstrates AES encryption for nRF52840 devices (here specifically RAK4631 using RUI3), while using nRFCrypto_Random for the key and IV. I have also added nRFCrypto_Hash to the example, using the example code from Adafruit.

Added Chacha, see also the Arduino BSP library.

TODO: round it up with HMAC.

I cleaned up the code, and added a test of confirmaity for each iteration of the hash tests.

Wakeup..
Plain text:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
pKey:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|70 3b cb b2 a6 22 e6 e2 b4 94 f3 58 72 31 bb 97 | |p;...".....Xr1..|
   +------------------------------------------------+ +----------------+
ECB Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|cf df f5 74 37 da 85 58 14 c9 a9 92 07 00 6b 8d | |...t7..X......k.|
 1.|6d 5f eb 83 82 72 7f c8 ff 85 c3 ad 3c 1e 38 d0 | |m_...r�.....<.8.|
 2.|b4 04 46 7a 47 14 04 f2 98 de ba e7 85 31 14 0d | |..FzG........1..|
   +------------------------------------------------+ +----------------+
ECB Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
IV:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|c0 78 95 8c a6 a9 44 0b 51 b4 57 67 75 03 2d 0b | |.x....D.Q.Wgu.-.|
   +------------------------------------------------+ +----------------+
CBC Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4c 7b 2f 1d ca e8 84 8f fa 4d 54 e8 1e 23 77 bb | |L{/......MT..#w.|
 1.|b2 77 20 3d 17 1a 29 af 3c c4 08 6d d9 c6 40 3b | |.w =..).<..m..@;|
 2.|64 fa ba 47 03 06 13 75 3e 95 d9 be 23 81 53 8e | |d..G...u>...#.S.|
   +------------------------------------------------+ +----------------+
CBC Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
IV:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|c0 78 95 8c a6 a9 44 0b 51 b4 57 67 75 03 2d 0b | |.x....D.Q.Wgu.-.|
   +------------------------------------------------+ +----------------+
CTR Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|3b b2 2e 48 9a f5 dd 1b 8f 90 5a eb 71 f6 a1 2d | |;..H......Z.q..-|
 1.|d2 36 87 49 92 c6 5b 13 22 cf f3 2e 13 ce b3 10 | |.6.I..[.".......|
 2.|fa b6 04 3f 69 bc 6b d6 7d 96 eb ca a1 a4 ba 39 | |...?i.k.}......9|
   +------------------------------------------------+ +----------------+
CTR Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
myKey:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|f9 f8 bf dc da 2e 95 c3 87 b6 0d 12 7a 06 d9 7e | |............z..~|
 1.|9e da 0f 71 65 ef 71 40 0e 58 b0 a5 fb 2f 13 aa | |...qe.q@.X.../..|
   +------------------------------------------------+ +----------------+
Nonce:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|fe 66 c9 11 96 b8 07 5e 32 ad 84 eb             | |.f.....^2...    |
   +------------------------------------------------+ +----------------+

Original [32]:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|07 0d 81 64 db c8 fa c7 84 cf 40 f7 42 87 02 d9 | |...d......@.B...|
 1.|91 5b 58 a2 c8 3a 92 1c e0 31 fc 7e 9c de 58 a8 | |.[X..:...1.~..X.|
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 64
 * rslt = 0x00000000
Chacha Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|a6 25 d5 66 cb aa 27 97 c6 d1 3d 70 80 91 1e 4a | |.%.f..'...=p...J|
 1.|fc 57 25 3f cc f0 5c 37 2d dc 16 ab 41 fa 7e 75 | |.W%?..\7-...A.~u|
 2.|58 c4 21 39 4e c5 99 49 1e 2e 86 86 e8 c0 1a ca | |X.!9N..I........|
 3.|56 eb 9e b7 f0 71 a2 72 3b 98 8b f6 b4 7e 9c 5c | |V....q.r;....~.\|
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 64
 * rslt = 0x00000000
Chacha Decoded (only the first 32 bytes count):
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|07 0d 81 64 db c8 fa c7 84 cf 40 f7 42 87 02 d9 | |...d......@.B...|
 1.|91 5b 58 a2 c8 3a 92 1c e0 31 fc 7e 9c de 58 a8 | |.[X..:...1.~..X.|
 2.|58 c4 21 39 4e c5 99 49 1e 2e 86 86 e8 c0 1a ca | |X.!9N..I........|
 3.|56 eb 9e b7 f0 71 a2 72 3b 98 8b f6 b4 7e 9c 5c | |V....q.r;....~.\|
   +------------------------------------------------+ +----------------+
Enc/Dec roud-trip successful!

Original [93]:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|07 0d 81 64 db c8 fa c7 84 cf 40 f7 42 87 02 d9 | |...d......@.B...|
 1.|91 5b 58 a2 c8 3a 92 1c e0 31 fc 7e 9c de 58 a8 | |.[X..:...1.~..X.|
 2.|b1 76 5e e1 20 86 2a b1 d3 52 7f 9c 81 0f 6e 17 | |.v^. .*..R�...n.|
 3.|5b 26 4d c3 91 18 96 d9 00 df 3f 34 9a ba 1a c1 | |[&M.......?4....|
 4.|18 fe 55 7a b4 1e 7d 8c 0d 1d 9d 51 cc ad 6b bb | |..Uz..}....Q..k.|
 5.|84 96 bc 36 48 69 22 a3 e2 ed 07 db 48          | |...6Hi".....H   |
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 128
Extra round: 64..92 / 93
 * rslt = 0x00000000
Chacha Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|a6 25 d5 66 cb aa 27 97 c6 d1 3d 70 80 91 1e 4a | |.%.f..'...=p...J|
 1.|fc 57 25 3f cc f0 5c 37 2d dc 16 ab 41 fa 7e 75 | |.W%?..\7-...A.~u|
 2.|ae f9 95 8a bc f1 d3 c9 6c c5 83 71 3d 94 c8 e1 | |........l..q=...|
 3.|67 af 47 ed aa 88 b4 ba dc 0a 79 df fc d9 75 18 | |g.G.......y...u.|
 4.|90 46 9c df c0 e3 11 8d 4e 27 22 2f 82 67 da 87 | |.F......N'"/.g..|
 5.|cd 2a 01 fd b6 1c f6 ce 42 17 7d 77 fb          | |.*......B.}w.   |
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 128
Extra round: 64..92 / 93
 * rslt = 0x00000000
Chacha Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|07 0d 81 64 db c8 fa c7 84 cf 40 f7 42 87 02 d9 | |...d......@.B...|
 1.|91 5b 58 a2 c8 3a 92 1c e0 31 fc 7e 9c de 58 a8 | |.[X..:...1.~..X.|
 2.|b1 76 5e e1 20 86 2a b1 d3 52 7f 9c 81 0f 6e 17 | |.v^. .*..R�...n.|
 3.|5b 26 4d c3 91 18 96 d9 00 df 3f 34 9a ba 1a c1 | |[&M.......?4....|
 4.|18 fe 55 7a b4 1e 7d 8c 0d 1d 9d 51 cc ad 6b bb | |..Uz..}....Q..k.|
 5.|84 96 bc 36 48 69 22 a3 e2 ed 07 db 48          | |...6Hi".....H   |
   +------------------------------------------------+ +----------------+
Enc/Dec roud-trip successful!
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-1
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|9f 9d a1 0e c2 37 35 93 00 89 a8 f8 9b 34 f7 b5 | |.....75......4..|
 1.|d2 67 90 3e                                     | |.g.>            |
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|9f 9d a1 0e c2 37 35 93 00 89 a8 f8 9b 34 f7 b5 | |.....75......4..|
 1.|d2 67 90 3e                                     | |.g.>            |
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-224
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|68 ab e3 4d 09 a7 58 be 6b 2f b3 a7 a9 97 98 3a | |h..M..X.k/.....:|
 1.|63 96 87 09 9d 35 40 6f 92 7a 5c c5             | |c....5@o.z\.    |
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|68 ab e3 4d 09 a7 58 be 6b 2f b3 a7 a9 97 98 3a | |h..M..X.k/.....:|
 1.|63 96 87 09 9d 35 40 6f 92 7a 5c c5             | |c....5@o.z\.    |
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-256
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|75 cf b3 9b 62 c4 74 92 1e 2a ad 97 9c 21 0f 8b | |u...b.t..*...!..|
 1.|69 18 0a 9d 58 e9 f2 96 a4 b9 90 4a e6 e7 aa 40 | |i...X......J...@|
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|75 cf b3 9b 62 c4 74 92 1e 2a ad 97 9c 21 0f 8b | |u...b.t..*...!..|
 1.|69 18 0a 9d 58 e9 f2 96 a4 b9 90 4a e6 e7 aa 40 | |i...X......J...@|
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-512
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e3 97 9c 62 96 e2 82 af 04 61 99 92 f7 1a dd fe | |...b.....a......|
 1.|fd 11 8b e2 66 26 ce dd 71 5e dc ed 36 b8 70 58 | |....f&..q^..6.pX|
 2.|f8 68 b3 16 e7 25 b2 4e 1e 7f 66 1c e2 93 5e 44 | |.h...%.N.�f...^D|
 3.|ba 4d ee a6 2a fa 3e 13 18 80 71 40 3a 2f 14 63 | |.M..*.>...q@:/.c|
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e3 97 9c 62 96 e2 82 af 04 61 99 92 f7 1a dd fe | |...b.....a......|
 1.|fd 11 8b e2 66 26 ce dd 71 5e dc ed 36 b8 70 58 | |....f&..q^..6.pX|
 2.|f8 68 b3 16 e7 25 b2 4e 1e 7f 66 1c e2 93 5e 44 | |.h...%.N.�f...^D|
 3.|ba 4d ee a6 2a fa 3e 13 18 80 71 40 3a 2f 14 63 | |.M..*.>...q@:/.c|
   +------------------------------------------------+ +----------------+
Match!

Try sleep 10000 ms..Wakeup..
Plain text:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
pKey:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|5c ce e4 21 86 8f f0 05 f8 fc cf 62 a5 1d 05 10 | |\..!.......b....|
   +------------------------------------------------+ +----------------+
ECB Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|bb 23 0a 6c af 42 f8 aa 9e 98 ea e7 aa f2 e4 cd | |.#.l.B..........|
 1.|b7 9e ac cc 74 c4 62 fe da cd 38 27 8e 06 19 bb | |....t.b...8'....|
 2.|2c 3d a5 d5 b2 d7 af 53 34 7f 38 21 cb aa 40 2f | |,=.....S4�8!..@/|
   +------------------------------------------------+ +----------------+
ECB Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
IV:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6e 5a 30 f3 81 97 69 e3 53 57 cf a7 a8 b2 8d 6e | |nZ0...i.SW.....n|
   +------------------------------------------------+ +----------------+
CBC Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4a e2 1b b3 3a 9c 05 9a 9d bb dc 3d 7e e6 13 d8 | |J...:......=~...|
 1.|9c 3d d5 f2 e0 49 1d de 1b ed da 5d 7e cd 12 6f | |.=...I.....]~..o|
 2.|08 77 2e fa 18 ae a2 54 ec 53 79 81 3c a4 a0 1f | |.w.....T.Sy.<...|
   +------------------------------------------------+ +----------------+
CBC Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
IV:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6e 5a 30 f3 81 97 69 e3 53 57 cf a7 a8 b2 8d 6e | |nZ0...i.SW.....n|
   +------------------------------------------------+ +----------------+
CTR Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|8b 2a bc cf f3 0b 38 ed e2 0b 8a 42 3d 6a 77 71 | |.*....8....B=jwq|
 1.|ed 89 12 e7 0f 18 fd 4e 73 cd cb 0a 3b ea 0d 1e | |.......Ns...;...|
 2.|bf bd 11 74 03 56 28 f7 58 06 73 ab 3c 80 06 02 | |...t.V(.X.s.<...|
   +------------------------------------------------+ +----------------+
CTR Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
myKey:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|d6 18 be 00 47 91 19 0a d2 57 08 b8 de 54 3d 25 | |....G....W...T=%|
 1.|19 9b 3d 5c 72 0d 5b f3 58 7d b7 05 f4 3f 75 e3 | |..=\r.[.X}...?u.|
   +------------------------------------------------+ +----------------+
Nonce:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|2f fb 4c d0 d5 58 de cd cd cf 12 39             | |/.L..X.....9    |
   +------------------------------------------------+ +----------------+

Original [32]:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|14 e6 e1 04 98 14 41 98 80 5f 09 9a 27 5d 89 0f | |......A.._..']..|
 1.|8f 15 a5 58 2d d6 0c 24 c2 42 89 83 c6 f8 c5 4a | |...X-..$.B.....J|
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 64
 * rslt = 0x00000000
Chacha Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|8c c2 83 c0 8b 98 b2 cb 58 2b a3 15 b0 d6 84 c1 | |........X+......|
 1.|d0 eb 5b 2c 10 82 c5 8a 58 b4 65 fb 5f cd c7 b5 | |..[,....X.e._...|
 2.|b1 76 5e e1 20 86 2a b1 d3 52 7f 9c 81 0f 6e 17 | |.v^. .*..R�...n.|
 3.|5b 26 4d c3 91 18 96 d9 00 df 3f 34 9a ba 1a c1 | |[&M.......?4....|
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 64
 * rslt = 0x00000000
Chacha Decoded (only the first 32 bytes count):
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|14 e6 e1 04 98 14 41 98 80 5f 09 9a 27 5d 89 0f | |......A.._..']..|
 1.|8f 15 a5 58 2d d6 0c 24 c2 42 89 83 c6 f8 c5 4a | |...X-..$.B.....J|
 2.|b1 76 5e e1 20 86 2a b1 d3 52 7f 9c 81 0f 6e 17 | |.v^. .*..R�...n.|
 3.|5b 26 4d c3 91 18 96 d9 00 df 3f 34 9a ba 1a c1 | |[&M.......?4....|
   +------------------------------------------------+ +----------------+
Enc/Dec roud-trip successful!

Original [93]:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|14 e6 e1 04 98 14 41 98 80 5f 09 9a 27 5d 89 0f | |......A.._..']..|
 1.|8f 15 a5 58 2d d6 0c 24 c2 42 89 83 c6 f8 c5 4a | |...X-..$.B.....J|
 2.|f4 4f 8e de ca 36 20 65 ab 54 39 80 c9 a2 70 04 | |.O...6 e.T9...p.|
 3.|fa f9 e8 3c ac f8 47 50 e1 24 30 2b ac 92 b0 e9 | |...<..GP.$0+....|
 4.|fe 44 89 81 9a 3a 17 48 af 87 fd 32 18 db 8a b4 | |.D...:.H...2....|
 5.|7b a9 15 02 35 0d f7 30 d7 80 81 d3 64          | |{...5..0....d   |
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 128
Extra round: 64..92 / 93
 * rslt = 0x00000000
Chacha Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|8c c2 83 c0 8b 98 b2 cb 58 2b a3 15 b0 d6 84 c1 | |........X+......|
 1.|d0 eb 5b 2c 10 82 c5 8a 58 b4 65 fb 5f cd c7 b5 | |..[,....X.e._...|
 2.|00 cf 9e e2 16 15 ea 71 0a a3 00 b8 27 be 4e cd | |.......q....'.N.|
 3.|1b 37 03 58 82 00 9b 08 c8 b0 8e cd ac b3 0c 32 | |.7.X...........2|
 4.|59 68 7c 45 71 12 b5 fa fb 3c 36 96 53 e4 c9 d3 | |Yh|Eq....<6.S...|
 5.|02 32 4d 12 84 b0 66 65 fe 98 ef 4b b0          | |.2M...fe...K.   |
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 128
Extra round: 64..92 / 93
 * rslt = 0x00000000
Chacha Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|14 e6 e1 04 98 14 41 98 80 5f 09 9a 27 5d 89 0f | |......A.._..']..|
 1.|8f 15 a5 58 2d d6 0c 24 c2 42 89 83 c6 f8 c5 4a | |...X-..$.B.....J|
 2.|f4 4f 8e de ca 36 20 65 ab 54 39 80 c9 a2 70 04 | |.O...6 e.T9...p.|
 3.|fa f9 e8 3c ac f8 47 50 e1 24 30 2b ac 92 b0 e9 | |...<..GP.$0+....|
 4.|fe 44 89 81 9a 3a 17 48 af 87 fd 32 18 db 8a b4 | |.D...:.H...2....|
 5.|7b a9 15 02 35 0d f7 30 d7 80 81 d3 64          | |{...5..0....d   |
   +------------------------------------------------+ +----------------+
Enc/Dec roud-trip successful!
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-1
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|9f 9d a1 0e c2 37 35 93 00 89 a8 f8 9b 34 f7 b5 | |.....75......4..|
 1.|d2 67 90 3e                                     | |.g.>            |
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|9f 9d a1 0e c2 37 35 93 00 89 a8 f8 9b 34 f7 b5 | |.....75......4..|
 1.|d2 67 90 3e                                     | |.g.>            |
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-224
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|68 ab e3 4d 09 a7 58 be 6b 2f b3 a7 a9 97 98 3a | |h..M..X.k/.....:|
 1.|63 96 87 09 9d 35 40 6f 92 7a 5c c5             | |c....5@o.z\.    |
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|68 ab e3 4d 09 a7 58 be 6b 2f b3 a7 a9 97 98 3a | |h..M..X.k/.....:|
 1.|63 96 87 09 9d 35 40 6f 92 7a 5c c5             | |c....5@o.z\.    |
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-256
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|75 cf b3 9b 62 c4 74 92 1e 2a ad 97 9c 21 0f 8b | |u...b.t..*...!..|
 1.|69 18 0a 9d 58 e9 f2 96 a4 b9 90 4a e6 e7 aa 40 | |i...X......J...@|
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|75 cf b3 9b 62 c4 74 92 1e 2a ad 97 9c 21 0f 8b | |u...b.t..*...!..|
 1.|69 18 0a 9d 58 e9 f2 96 a4 b9 90 4a e6 e7 aa 40 | |i...X......J...@|
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-512
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e3 97 9c 62 96 e2 82 af 04 61 99 92 f7 1a dd fe | |...b.....a......|
 1.|fd 11 8b e2 66 26 ce dd 71 5e dc ed 36 b8 70 58 | |....f&..q^..6.pX|
 2.|f8 68 b3 16 e7 25 b2 4e 1e 7f 66 1c e2 93 5e 44 | |.h...%.N.�f...^D|
 3.|ba 4d ee a6 2a fa 3e 13 18 80 71 40 3a 2f 14 63 | |.M..*.>...q@:/.c|
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e3 97 9c 62 96 e2 82 af 04 61 99 92 f7 1a dd fe | |...b.....a......|
 1.|fd 11 8b e2 66 26 ce dd 71 5e dc ed 36 b8 70 58 | |....f&..q^..6.pX|
 2.|f8 68 b3 16 e7 25 b2 4e 1e 7f 66 1c e2 93 5e 44 | |.h...%.N.�f...^D|
 3.|ba 4d ee a6 2a fa 3e 13 18 80 71 40 3a 2f 14 63 | |.M..*.>...q@:/.c|
   +------------------------------------------------+ +----------------+
Match!

Try sleep 10000 ms..Wakeup..
Plain text:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
pKey:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|74 16 e5 68 e2 0e c1 16 35 ca 21 63 1c 29 97 f9 | |t..h....5.!c.)..|
   +------------------------------------------------+ +----------------+
ECB Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4e b0 3b b6 9e 16 41 82 da cd 24 d8 5c 46 f8 fa | |N.;...A...$.\F..|
 1.|34 a1 c9 b0 8d e1 38 ca e0 ed 00 39 ec 90 cd d4 | |4.....8....9....|
 2.|79 ad 3b 8a dd e6 46 51 58 95 04 cf 55 8c be c8 | |y.;...FQX...U...|
   +------------------------------------------------+ +----------------+
ECB Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
IV:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|18 fc e4 86 64 9e 02 6b b1 d0 79 ba c8 65 60 f9 | |....d..k..y..e`.|
   +------------------------------------------------+ +----------------+
CBC Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|1b 80 42 04 61 d6 5a 67 19 7b 1f b3 6e ea b2 6d | |..B.a.Zg.{..n..m|
 1.|13 30 b0 e0 88 5a 08 a4 2e 3b 0e 1e c7 0a 60 43 | |.0...Z...;....`C|
 2.|de 3d 38 1e 10 87 2c c8 19 72 4f c3 53 b7 9f c1 | |.=8...,..rO.S...|
   +------------------------------------------------+ +----------------+
CBC Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
IV:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|18 fc e4 86 64 9e 02 6b b1 d0 79 ba c8 65 60 f9 | |....d..k..y..e`.|
   +------------------------------------------------+ +----------------+
CTR Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e1 7d 04 a1 53 05 52 f6 5e b9 a1 72 ee aa 2f a7 | |.}..S.R.^..r../.|
 1.|45 8a 8f 22 45 db 58 69 6b 24 e0 2f 4a 23 c2 9b | |E.."E.Xik$./J#..|
 2.|a8 54 5b b9 95 fd 0e 83 d8 d5 f2 22 bf df 42 33 | |.T[........"..B3|
   +------------------------------------------------+ +----------------+
CTR Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|48 65 6c 6c 6f 20 75 73 65 72 21 20 54 68 69 73 | |Hello user! This|
 1.|20 69 73 20 61 20 70 6c 61 69 6e 20 74 65 78 74 | | is a plain text|
 2.|20 73 74 72 69 6e 67 21 20 20 20 20 20 20 20 20 | | string!        |
   +------------------------------------------------+ +----------------+
myKey:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|14 e3 ac f1 a0 69 51 d1 ac af 9c 2d 43 61 f6 30 | |.....iQ....-Ca.0|
 1.|71 55 d6 67 69 94 d7 e5 7d 7c 03 11 b6 f0 e9 34 | |qU.gi...}|.....4|
   +------------------------------------------------+ +----------------+
Nonce:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|2c 08 7c bc 5e 5f ff 54 29 7c 98 52             | |,.|.^_.T)|.R    |
   +------------------------------------------------+ +----------------+

Original [32]:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4b f0 b7 06 78 2a 32 d3 14 2c 0d da b2 a1 4f a1 | |K...x*2..,....O.|
 1.|ba ff 98 fd d0 5d 55 d8 86 ed 3b 71 dd 47 b3 bd | |.....]U...;q.G..|
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 64
 * rslt = 0x00000000
Chacha Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|f6 7d 72 9c 39 ee 76 c6 c9 87 30 85 0e 08 4b 0d | |.}r.9.v...0...K.|
 1.|d0 38 bc b1 ea 0a 40 7c d2 ca fe f3 8c 05 ad c3 | |.8....@|........|
 2.|f4 4f 8e de ca 36 20 65 ab 54 39 80 c9 a2 70 04 | |.O...6 e.T9...p.|
 3.|fa f9 e8 3c ac f8 47 50 e1 24 30 2b ac 92 b0 e9 | |...<..GP.$0+....|
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 64
 * rslt = 0x00000000
Chacha Decoded (only the first 32 bytes count):
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4b f0 b7 06 78 2a 32 d3 14 2c 0d da b2 a1 4f a1 | |K...x*2..,....O.|
 1.|ba ff 98 fd d0 5d 55 d8 86 ed 3b 71 dd 47 b3 bd | |.....]U...;q.G..|
 2.|f4 4f 8e de ca 36 20 65 ab 54 39 80 c9 a2 70 04 | |.O...6 e.T9...p.|
 3.|fa f9 e8 3c ac f8 47 50 e1 24 30 2b ac 92 b0 e9 | |...<..GP.$0+....|
   +------------------------------------------------+ +----------------+
Enc/Dec roud-trip successful!

Original [93]:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4b f0 b7 06 78 2a 32 d3 14 2c 0d da b2 a1 4f a1 | |K...x*2..,....O.|
 1.|ba ff 98 fd d0 5d 55 d8 86 ed 3b 71 dd 47 b3 bd | |.....]U...;q.G..|
 2.|c6 12 90 a8 7e b4 5b c2 c4 42 27 59 c2 cd 7b cf | |....~.[..B'Y..{.|
 3.|31 d7 d2 4e 19 47 23 68 62 cf 73 27 47 50 e5 ee | |1..N.G#hb.s'GP..|
 4.|91 f0 fb 01 b8 a0 a2 24 3c c8 cd 5d 40 0b 9d f9 | |.......$<..]@...|
 5.|9b cc 04 36 66 03 40 43 fc d4 39 cf d7          | |...6f.@C..9..   |
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 128
Extra round: 64..92 / 93
 * rslt = 0x00000000
Chacha Encoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|f6 7d 72 9c 39 ee 76 c6 c9 87 30 85 0e 08 4b 0d | |.}r.9.v...0...K.|
 1.|d0 38 bc b1 ea 0a 40 7c d2 ca fe f3 8c 05 ad c3 | |.8....@|........|
 2.|22 7b 61 37 ff de fc 9f 76 f2 ca 9b 0a 18 47 c7 | |"{a7....v.....G.|
 3.|66 90 1a 5d aa cf b1 ce 75 40 45 c8 d3 99 e2 d7 | |f..]....u@E.....|
 4.|28 b5 3e f2 92 fa 27 9c ad 83 5b 47 99 ae 4b ee | |(.>...'...[G..K.|
 5.|38 a7 08 be 9b 99 54 06 f8 64 f0 66 5a          | |8.....T..d.fZ   |
   +------------------------------------------------+ +----------------+
Round #1: 0..63 / 128
Extra round: 64..92 / 93
 * rslt = 0x00000000
Chacha Decoded:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|4b f0 b7 06 78 2a 32 d3 14 2c 0d da b2 a1 4f a1 | |K...x*2..,....O.|
 1.|ba ff 98 fd d0 5d 55 d8 86 ed 3b 71 dd 47 b3 bd | |.....]U...;q.G..|
 2.|c6 12 90 a8 7e b4 5b c2 c4 42 27 59 c2 cd 7b cf | |....~.[..B'Y..{.|
 3.|31 d7 d2 4e 19 47 23 68 62 cf 73 27 47 50 e5 ee | |1..N.G#hb.s'GP..|
 4.|91 f0 fb 01 b8 a0 a2 24 3c c8 cd 5d 40 0b 9d f9 | |.......$<..]@...|
 5.|9b cc 04 36 66 03 40 43 fc d4 39 cf d7          | |...6f.@C..9..   |
   +------------------------------------------------+ +----------------+
Enc/Dec roud-trip successful!
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-1
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|9f 9d a1 0e c2 37 35 93 00 89 a8 f8 9b 34 f7 b5 | |.....75......4..|
 1.|d2 67 90 3e                                     | |.g.>            |
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|9f 9d a1 0e c2 37 35 93 00 89 a8 f8 9b 34 f7 b5 | |.....75......4..|
 1.|d2 67 90 3e                                     | |.g.>            |
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-224
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|68 ab e3 4d 09 a7 58 be 6b 2f b3 a7 a9 97 98 3a | |h..M..X.k/.....:|
 1.|63 96 87 09 9d 35 40 6f 92 7a 5c c5             | |c....5@o.z\.    |
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|68 ab e3 4d 09 a7 58 be 6b 2f b3 a7 a9 97 98 3a | |h..M..X.k/.....:|
 1.|63 96 87 09 9d 35 40 6f 92 7a 5c c5             | |c....5@o.z\.    |
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-256
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|75 cf b3 9b 62 c4 74 92 1e 2a ad 97 9c 21 0f 8b | |u...b.t..*...!..|
 1.|69 18 0a 9d 58 e9 f2 96 a4 b9 90 4a e6 e7 aa 40 | |i...X......J...@|
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|75 cf b3 9b 62 c4 74 92 1e 2a ad 97 9c 21 0f 8b | |u...b.t..*...!..|
 1.|69 18 0a 9d 58 e9 f2 96 a4 b9 90 4a e6 e7 aa 40 | |i...X......J...@|
   +------------------------------------------------+ +----------------+
Match!

   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a | |k....@...=~.s..*|
 1.|65 a2 32 d6 bc d0 f9 39 ed 1f e1 28 c1 3b 0e 1b | |e.2....9...(.;..|
   +------------------------------------------------+ +----------------+
 SHA-512
Produced:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e3 97 9c 62 96 e2 82 af 04 61 99 92 f7 1a dd fe | |...b.....a......|
 1.|fd 11 8b e2 66 26 ce dd 71 5e dc ed 36 b8 70 58 | |....f&..q^..6.pX|
 2.|f8 68 b3 16 e7 25 b2 4e 1e 7f 66 1c e2 93 5e 44 | |.h...%.N.�f...^D|
 3.|ba 4d ee a6 2a fa 3e 13 18 80 71 40 3a 2f 14 63 | |.M..*.>...q@:/.c|
   +------------------------------------------------+ +----------------+
Expected:
   +------------------------------------------------+ +----------------+
   |.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .a .b .c .d .e .f | |      ASCII     |
   +------------------------------------------------+ +----------------+
 0.|e3 97 9c 62 96 e2 82 af 04 61 99 92 f7 1a dd fe | |...b.....a......|
 1.|fd 11 8b e2 66 26 ce dd 71 5e dc ed 36 b8 70 58 | |....f&..q^..6.pX|
 2.|f8 68 b3 16 e7 25 b2 4e 1e 7f 66 1c e2 93 5e 44 | |.h...%.N.�f...^D|
 3.|ba 4d ee a6 2a fa 3e 13 18 80 71 40 3a 2f 14 63 | |.M..*.>...q@:/.c|
   +------------------------------------------------+ +----------------+
Match!

Try sleep 10000 ms..

About

Sample code demonstrating hardware encoded AES encryption for nRF52840 devices (here specifically RAK4631 using RUI3)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published