22#include "anch-crypto-export.hpp"
24#include "crypto/cipher/blockCipher.hpp"
29#ifdef ANCH_CPU_DETECTION
30#include "device/cpu.hpp"
39# if defined (__GNUC__)
40# define ALIGN16 __attribute__ ( (aligned (16)))
42# define ALIGN16 __declspec (align (16))
50 template<std::
size_t S>
52 ALIGN16 __m128i cipherKey[S];
53 ALIGN16 __m128i decipherKey[S];
67 template<std::
size_t K, std::
size_t R>
71#if defined ANCH_CPU_DETECTION || !defined(ANCH_CPU_AES)
78#ifdef ANCH_CPU_DETECTION
79 uint32_t swKey[4 * (R + 1)];
80 anch::crypto::AesniKey<R + 1> hwKey;
82 anch::crypto::AesniKey<R + 1> hwKey;
84 uint32_t swKey[4 * (R + 1)];
98 AES(
const uint8_t key[4*K]);
126 void cipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output);
134 void decipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output);
144 void aesniCipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output);
152 void aesniDecipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output);
162 __m128i aes128assist(__m128i& temp1, __m128i& temp2);
169 void aesni128ExpandKey(uint8_t key[4 * K]);
178 void aes192assist(__m128i& temp1, __m128i& temp2, __m128i& temp3);
185 void aesni192ExpandKey(uint8_t key[4 * K]);
193 void aes256assist1(__m128i& temp1, __m128i& temp2);
201 void aes256assist2(__m128i& temp1, __m128i& temp3);
208 void aesni256ExpandKey(uint8_t key[4 * K]);
215 void aesniExpandKey(uint8_t key[4 * K]);
218#if defined ANCH_CPU_DETECTION || !defined(ANCH_CPU_AES)
225 void swCipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output);
233 void swDecipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output);
240 void expandKey(
const uint8_t key[4 * K]);
250 uint32_t subWord(
const uint32_t& word);
259 uint32_t rotateWord(
const uint32_t& word);
265 void cipherSubBytes();
271 void decipherSubBytes();
276 void cipherShiftRows();
281 void decipherShiftRows();
286 void cipherMixColumns();
291 void decipherMixColumns();
298 void addRoundKey(
const uint32_t& round);
305 template<std::
size_t K, std::
size_t R>
307#ifdef ANCH_CPU_DETECTION
310 uint8_t aesKey[(4*K + 15) / 16 * 16] = {};
311 std::memcpy(aesKey, key, 4*K);
312 aesniExpandKey(aesKey);
317 uint8_t aesKey[(4*K + 15) / 16 * 16] = {};
318 std::memcpy(aesKey, key, 4*K);
319 aesniExpandKey(aesKey);
325 template<std::
size_t K, std::
size_t R>
327#ifdef ANCH_CPU_DETECTION
329 std::memcpy(_expKey.hwKey.cipherKey, other._expKey.hwKey.cipherKey, (R + 1) *
sizeof(__m128i));
330 std::memcpy(_expKey.hwKey.decipherKey, other._expKey.hwKey.decipherKey, (R + 1) *
sizeof(__m128i));
332 std::memcpy(_expKey.swKey, other._expKey.swKey, 4 * (R + 1) *
sizeof(uint32_t));
335 std::memcpy(_expKey.hwKey.cipherKey, other._expKey.hwKey.cipherKey, (R + 1) *
sizeof(__m128i));
336 std::memcpy(_expKey.hwKey.decipherKey, other._expKey.hwKey.decipherKey, (R + 1) *
sizeof(__m128i));
338 std::memcpy(_expKey.swKey, other._expKey.swKey, 4 * (R + 1) *
sizeof(uint32_t));
345 template<std::
size_t K, std::
size_t R>
353 template<std::
size_t K, std::
size_t R>
356#ifdef ANCH_CPU_DETECTION
358 aesniCipher(input, output);
360 swCipher(input, output);
363 aesniCipher(input, output);
365 swCipher(input, output);
369 template<std::
size_t K, std::
size_t R>
372#ifdef ANCH_CPU_DETECTION
374 aesniDecipher(input, output);
376 swDecipher(input, output);
379 aesniDecipher(input, output);
381 swDecipher(input, output);
386 template<std::
size_t K, std::
size_t R>
391 ALIGN16 uint8_t in[16];
392 std::memcpy(in, input.data(), 16);
403 tmp = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(in));
404 tmp = _mm_xor_si128(tmp, _expKey.hwKey.cipherKey[0]);
405 for(j = 1 ; j < R ; ++j) {
406 tmp = _mm_aesenc_si128(tmp, _expKey.hwKey.cipherKey[j]);
408 tmp = _mm_aesenclast_si128(tmp, _expKey.hwKey.cipherKey[j]);
409 _mm_storeu_si128(&out, tmp);
410 std::memcpy(output.data(),
reinterpret_cast<uint8_t*
>(&out), 16);
413 template<std::
size_t K, std::
size_t R>
415 AES<K,R>::aesniDecipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output) {
418 ALIGN16 uint8_t in[16];
419 std::memcpy(in, input.data(), 16);
430 tmp = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(in));
431 tmp = _mm_xor_si128(tmp, _expKey.hwKey.decipherKey[0]);
432 for(j = 1 ; j < R ; ++j) {
433 tmp = _mm_aesdec_si128(tmp, _expKey.hwKey.decipherKey[j]);
435 tmp = _mm_aesdeclast_si128(tmp, _expKey.hwKey.decipherKey[j]);
436 _mm_storeu_si128(&out, tmp);
437 std::memcpy(output.data(),
reinterpret_cast<uint8_t*
>(&out), 16);
440 template<std::
size_t K, std::
size_t R>
444 temp2 = _mm_shuffle_epi32(temp2 ,0xff);
445 temp3 = _mm_slli_si128(temp1, 0x4);
446 temp1 = _mm_xor_si128(temp1, temp3);
447 temp3 = _mm_slli_si128(temp3, 0x4);
448 temp1 = _mm_xor_si128(temp1, temp3);
449 temp3 = _mm_slli_si128(temp3, 0x4);
450 temp1 = _mm_xor_si128(temp1, temp3);
451 temp1 = _mm_xor_si128(temp1, temp2);
455 template<std::
size_t K, std::
size_t R>
458 if constexpr (K == 4) {
459 __m128i temp1, temp2;
460 temp1 = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(key));
461 _expKey.hwKey.cipherKey[0] = temp1;
462 temp2 = _mm_aeskeygenassist_si128(temp1, 0x1);
463 temp1 = aes128assist(temp1, temp2);
464 _expKey.hwKey.cipherKey[1] = temp1;
465 temp2 = _mm_aeskeygenassist_si128(temp1, 0x2);
466 temp1 = aes128assist(temp1, temp2);
467 _expKey.hwKey.cipherKey[2] = temp1;
468 temp2 = _mm_aeskeygenassist_si128(temp1, 0x4);
469 temp1 = aes128assist(temp1, temp2);
470 _expKey.hwKey.cipherKey[3] = temp1;
471 temp2 = _mm_aeskeygenassist_si128(temp1, 0x8);
472 temp1 = aes128assist(temp1, temp2);
473 _expKey.hwKey.cipherKey[4] = temp1;
474 temp2 = _mm_aeskeygenassist_si128(temp1, 0x10);
475 temp1 = aes128assist(temp1, temp2);
476 _expKey.hwKey.cipherKey[5] = temp1;
477 temp2 = _mm_aeskeygenassist_si128(temp1, 0x20);
478 temp1 = aes128assist(temp1, temp2);
479 _expKey.hwKey.cipherKey[6] = temp1;
480 temp2 = _mm_aeskeygenassist_si128(temp1, 0x40);
481 temp1 = aes128assist(temp1, temp2);
482 _expKey.hwKey.cipherKey[7] = temp1;
483 temp2 = _mm_aeskeygenassist_si128(temp1, 0x80);
484 temp1 = aes128assist(temp1, temp2);
485 _expKey.hwKey.cipherKey[8] = temp1;
486 temp2 = _mm_aeskeygenassist_si128(temp1, 0x1b);
487 temp1 = aes128assist(temp1, temp2);
488 _expKey.hwKey.cipherKey[9] = temp1;
489 temp2 = _mm_aeskeygenassist_si128(temp1, 0x36);
490 temp1 = aes128assist(temp1, temp2);
491 _expKey.hwKey.cipherKey[10] = temp1;
495 template<std::
size_t K, std::
size_t R>
499 temp2 = _mm_shuffle_epi32(temp2, 0x55);
500 temp4 = _mm_slli_si128(temp1, 0x4);
501 temp1 = _mm_xor_si128(temp1, temp4);
502 temp4 = _mm_slli_si128(temp4, 0x4);
503 temp1 = _mm_xor_si128(temp1, temp4);
504 temp4 = _mm_slli_si128(temp4, 0x4);
505 temp1 = _mm_xor_si128(temp1, temp4);
506 temp1 = _mm_xor_si128(temp1, temp2);
507 temp2 = _mm_shuffle_epi32(temp1, 0xff);
508 temp4 = _mm_slli_si128(temp3, 0x4);
509 temp3 = _mm_xor_si128(temp3, temp4);
510 temp3 = _mm_xor_si128(temp3, temp2);
513 template<std::
size_t K, std::
size_t R>
516 if constexpr (K == 6) {
517 __m128i temp1, temp2, temp3;
518 temp1 = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(key));
519 temp3 = _mm_loadu_si128(
reinterpret_cast<__m128i*
>((key + 16)));
520 _expKey.hwKey.cipherKey[0] = temp1;
521 _expKey.hwKey.cipherKey[1] = temp3;
522 temp2 = _mm_aeskeygenassist_si128(temp3, 0x1);
523 aes192assist(temp1, temp2, temp3);
524 _expKey.hwKey.cipherKey[1] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(_expKey.hwKey.cipherKey[1]),
525 reinterpret_cast<__m128d
>(temp1), 0));
526 _expKey.hwKey.cipherKey[2] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(temp1),
527 reinterpret_cast<__m128d
>(temp3), 1));
528 temp2 = _mm_aeskeygenassist_si128(temp3, 0x2);
529 aes192assist(temp1, temp2, temp3);
530 _expKey.hwKey.cipherKey[3] = temp1;
531 _expKey.hwKey.cipherKey[4] = temp3;
532 temp2 = _mm_aeskeygenassist_si128(temp3, 0x4);
533 aes192assist(temp1, temp2, temp3);
534 _expKey.hwKey.cipherKey[4] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(_expKey.hwKey.cipherKey[4]),
535 reinterpret_cast<__m128d
>(temp1), 0));
536 _expKey.hwKey.cipherKey[5] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(temp1),
537 reinterpret_cast<__m128d
>(temp3), 1));
538 temp2 = _mm_aeskeygenassist_si128(temp3, 0x8);
539 aes192assist(temp1, temp2, temp3);
540 _expKey.hwKey.cipherKey[6] = temp1;
541 _expKey.hwKey.cipherKey[7] = temp3;
542 temp2 = _mm_aeskeygenassist_si128(temp3, 0x10);
543 aes192assist(temp1, temp2, temp3);
544 _expKey.hwKey.cipherKey[7] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(_expKey.hwKey.cipherKey[7]),
545 reinterpret_cast<__m128d
>(temp1), 0));
546 _expKey.hwKey.cipherKey[8] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(temp1),
547 reinterpret_cast<__m128d
>(temp3), 1));
548 temp2 = _mm_aeskeygenassist_si128 (temp3, 0x20);
549 aes192assist(temp1, temp2, temp3);
550 _expKey.hwKey.cipherKey[9] = temp1;
551 _expKey.hwKey.cipherKey[10] = temp3;
552 temp2 = _mm_aeskeygenassist_si128(temp3, 0x40);
553 aes192assist(temp1, temp2, temp3);
554 _expKey.hwKey.cipherKey[10] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(_expKey.hwKey.cipherKey[10]),
555 reinterpret_cast<__m128d
>(temp1), 0));
556 _expKey.hwKey.cipherKey[11] =
reinterpret_cast<__m128i
>(_mm_shuffle_pd(
reinterpret_cast<__m128d
>(temp1),
557 reinterpret_cast<__m128d
>(temp3), 1));
558 temp2 = _mm_aeskeygenassist_si128(temp3, 0x80);
559 aes192assist(temp1, temp2, temp3);
560 _expKey.hwKey.cipherKey[12] = temp1;
564 template<std::
size_t K, std::
size_t R>
568 temp2 = _mm_shuffle_epi32(temp2, 0xff);
569 temp4 = _mm_slli_si128(temp1, 0x4);
570 temp1 = _mm_xor_si128(temp1, temp4);
571 temp4 = _mm_slli_si128(temp4, 0x4);
572 temp1 = _mm_xor_si128(temp1, temp4);
573 temp4 = _mm_slli_si128(temp4, 0x4);
574 temp1 = _mm_xor_si128(temp1, temp4);
575 temp1 = _mm_xor_si128(temp1, temp2);
578 template<std::
size_t K, std::
size_t R>
582 temp4 = _mm_aeskeygenassist_si128(temp1, 0x0);
583 temp2 = _mm_shuffle_epi32(temp4, 0xaa);
584 temp4 = _mm_slli_si128(temp3, 0x4);
585 temp3 = _mm_xor_si128(temp3, temp4);
586 temp4 = _mm_slli_si128(temp4, 0x4);
587 temp3 = _mm_xor_si128(temp3, temp4);
588 temp4 = _mm_slli_si128(temp4, 0x4);
589 temp3 = _mm_xor_si128(temp3, temp4);
590 temp3 = _mm_xor_si128(temp3, temp2);
593 template<std::
size_t K, std::
size_t R>
596 if constexpr (K == 8) {
597 __m128i temp1, temp2, temp3;
598 temp1 = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(key));
599 temp3 = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(key + 16));
600 _expKey.hwKey.cipherKey[0] = temp1;
601 _expKey.hwKey.cipherKey[1] = temp3;
602 temp2 = _mm_aeskeygenassist_si128(temp3, 0x01);
603 aes256assist1(temp1, temp2);
604 _expKey.hwKey.cipherKey[2] = temp1;
605 aes256assist2(temp1, temp3);
606 _expKey.hwKey.cipherKey[3] = temp3;
607 temp2 = _mm_aeskeygenassist_si128(temp3, 0x02);
608 aes256assist1(temp1, temp2);
609 _expKey.hwKey.cipherKey[4] = temp1;
610 aes256assist2(temp1, temp3);
611 _expKey.hwKey.cipherKey[5] = temp3;
612 temp2 = _mm_aeskeygenassist_si128(temp3, 0x04);
613 aes256assist1(temp1, temp2);
614 _expKey.hwKey.cipherKey[6] = temp1;
615 aes256assist2(temp1, temp3);
616 _expKey.hwKey.cipherKey[7] = temp3;
617 temp2 = _mm_aeskeygenassist_si128(temp3, 0x08);
618 aes256assist1(temp1, temp2);
619 _expKey.hwKey.cipherKey[8] = temp1;
620 aes256assist2(temp1, temp3);
621 _expKey.hwKey.cipherKey[9] = temp3;
622 temp2 = _mm_aeskeygenassist_si128(temp3, 0x10);
623 aes256assist1(temp1, temp2);
624 _expKey.hwKey.cipherKey[10] = temp1;
625 aes256assist2(temp1, temp3);
626 _expKey.hwKey.cipherKey[11] = temp3;
627 temp2 = _mm_aeskeygenassist_si128(temp3, 0x20);
628 aes256assist1(temp1, temp2);
629 _expKey.hwKey.cipherKey[12] = temp1;
630 aes256assist2(temp1, temp3);
631 _expKey.hwKey.cipherKey[13] = temp3;
632 temp2 = _mm_aeskeygenassist_si128(temp3, 0x40);
633 aes256assist1(temp1, temp2);
634 _expKey.hwKey.cipherKey[14] = temp1;
638 template<std::
size_t K, std::
size_t R>
642 aesni128ExpandKey(key);
643 aesni192ExpandKey(key);
644 aesni256ExpandKey(key);
648 _expKey.hwKey.decipherKey[R] = _expKey.hwKey.cipherKey[0];
649 _expKey.hwKey.decipherKey[R - 1] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[1]);
650 _expKey.hwKey.decipherKey[R - 2] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[2]);
651 _expKey.hwKey.decipherKey[R - 3] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[3]);
652 _expKey.hwKey.decipherKey[R - 4] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[4]);
653 _expKey.hwKey.decipherKey[R - 5] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[5]);
654 _expKey.hwKey.decipherKey[R - 6] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[6]);
655 _expKey.hwKey.decipherKey[R - 7] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[7]);
656 _expKey.hwKey.decipherKey[R - 8] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[8]);
657 _expKey.hwKey.decipherKey[R - 9] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[9]);
658 if constexpr (R > 10) {
659 _expKey.hwKey.decipherKey[R - 10] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[10]);
660 _expKey.hwKey.decipherKey[R - 11] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[11]);
662 if constexpr (R > 12) {
663 _expKey.hwKey.decipherKey[R - 12] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[12]);
664 _expKey.hwKey.decipherKey[R - 13] = _mm_aesimc_si128(_expKey.hwKey.cipherKey[13]);
666 _expKey.hwKey.decipherKey[0] = _expKey.hwKey.cipherKey[R];
671#if defined ANCH_CPU_DETECTION || !defined(ANCH_CPU_AES)
681 template<std::
size_t K, std::
size_t R>
683 AES<K,R>::swCipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output) {
684 std::memcpy(&_state, input.data(), 16);
685 unsigned int round = 0;
692 for(round = 1 ; round < R ; ++round) {
706 std::memcpy(output.data(), &_state, 16);
709 template<std::
size_t K, std::
size_t R>
711 AES<K,R>::swDecipher(
const std::array<uint8_t,16>& input, std::array<uint8_t,16>& output) {
712 std::memcpy(&_state, input.data(), 16);
713 unsigned int round = R;
722 for(round = R - 1 ; round > 0 ; --round) {
724 decipherMixColumns();
734 std::memcpy(output.data(), &_state, 16);
737 template<std::
size_t K, std::
size_t R>
739 AES<K,R>::expandKey(
const uint8_t key[4 * K]) {
740 std::memcpy(_expKey.swKey, key, 4 * K);
741 for(std::size_t i = K ; i < 4 * (R + 1) ; ++i) {
742 uint32_t mod =
static_cast<uint32_t
>(i % K);
744 _expKey.swKey[i] = _expKey.swKey[i - K] ^ (subWord(rotateWord(_expKey.swKey[i - 1])) ^
ANCH_AES_RCON[i / K]);
745 }
else if(K > 6 && mod == 4) {
746 _expKey.swKey[i] = _expKey.swKey[i - K] ^ subWord(_expKey.swKey[i - 1]);
748 _expKey.swKey[i] = _expKey.swKey[i - K] ^ _expKey.swKey[i - 1];
753 template<std::
size_t K, std::
size_t R>
755 AES<K,R>::subWord(
const uint32_t& word) {
757 uint8_t* resBytes =
reinterpret_cast<uint8_t*
>(&res);
758 const uint8_t*
const bytes =
reinterpret_cast<const uint8_t* const
>(&word);
766 template<std::
size_t K, std::
size_t R>
768 AES<K,R>::rotateWord(
const uint32_t& word) {
769 return ((word << 24) | (word >> 8));
772 template<std::
size_t K, std::
size_t R>
774 AES<K,R>::cipherSubBytes() {
793 template<std::
size_t K, std::
size_t R>
795 AES<K,R>::decipherSubBytes() {
814 template<std::
size_t K, std::
size_t R>
816 AES<K,R>::cipherShiftRows() {
817 uint8_t tmp = _state[0][1];
818 _state[0][1] = _state[1][1];
819 _state[1][1] = _state[2][1];
820 _state[2][1] = _state[3][1];
823 _state[1][2] = _state[3][2];
826 _state[2][2] = _state[0][2];
829 _state[3][3] = _state[2][3];
830 _state[2][3] = _state[1][3];
831 _state[1][3] = _state[0][3];
835 template<std::
size_t K, std::
size_t R>
837 AES<K,R>::decipherShiftRows() {
838 uint8_t tmp = _state[3][1];
839 _state[3][1] = _state[2][1];
840 _state[2][1] = _state[1][1];
841 _state[1][1] = _state[0][1];
844 _state[1][2] = _state[3][2];
847 _state[2][2] = _state[0][2];
850 _state[0][3] = _state[1][3];
851 _state[1][3] = _state[2][3];
852 _state[2][3] = _state[3][3];
856 template<std::
size_t K, std::
size_t R>
858 AES<K,R>::cipherMixColumns() {
861 state[0] = _state[0][0];
862 state[1] = _state[0][1];
863 state[2] = _state[0][2];
864 state[3] = _state[0][3];
870 state[0] = _state[1][0];
871 state[1] = _state[1][1];
872 state[2] = _state[1][2];
873 state[3] = _state[1][3];
879 state[0] = _state[2][0];
880 state[1] = _state[2][1];
881 state[2] = _state[2][2];
882 state[3] = _state[2][3];
888 state[0] = _state[3][0];
889 state[1] = _state[3][1];
890 state[2] = _state[3][2];
891 state[3] = _state[3][3];
898 template<std::
size_t K, std::
size_t R>
900 AES<K,R>::decipherMixColumns() {
903 state[0] = _state[0][0];
904 state[1] = _state[0][1];
905 state[2] = _state[0][2];
906 state[3] = _state[0][3];
912 state[0] = _state[1][0];
913 state[1] = _state[1][1];
914 state[2] = _state[1][2];
915 state[3] = _state[1][3];
921 state[0] = _state[2][0];
922 state[1] = _state[2][1];
923 state[2] = _state[2][2];
924 state[3] = _state[2][3];
930 state[0] = _state[3][0];
931 state[1] = _state[3][1];
932 state[2] = _state[3][2];
933 state[3] = _state[3][3];
940 template<std::
size_t K, std::
size_t R>
942 AES<K,R>::addRoundKey(
const uint32_t& round) {
943 const uint32_t* key = _expKey.swKey + 4 * round;
946 std::memcpy(state, _state,
sizeof(state));
951 std::memcpy(_state, state,
sizeof(state));
static CPU & getInstance()
AES block cipher algorithm implementation.
Definition aes.hpp:68
AES(const AES &other)
Definition aes.hpp:326
void cipher(const std::array< uint8_t, 16 > &input, std::array< uint8_t, 16 > &output)
Definition aes.hpp:355
virtual ~AES()
Definition aes.hpp:346
void decipher(const std::array< uint8_t, 16 > &input, std::array< uint8_t, 16 > &output)
Definition aes.hpp:371
AES(const uint8_t key[4 *K])
Definition aes.hpp:306
Block cipher interface.
Definition blockCipher.hpp:59
Cryptography namespace.
Definition base64.hpp:30
const uint8_t ANCH_AES_CIPHER_SBOX[256]
const uint8_t ANCH_GALOIS_MULT11[256]
const uint8_t ANCH_GALOIS_MULT9[256]
const uint32_t ANCH_AES_RCON[11]
const uint8_t ANCH_AES_DECIPHER_SBOX[256]
const uint8_t ANCH_GALOIS_MULT3[256]
const uint8_t ANCH_GALOIS_MULT14[256]
const uint8_t ANCH_GALOIS_MULT13[256]
const uint8_t ANCH_GALOIS_MULT2[256]