VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/GfMul.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/GfMul.c')
-rw-r--r--src/Common/GfMul.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/Common/GfMul.c b/src/Common/GfMul.c
index 7e170bc1..7cc36ec1 100644
--- a/src/Common/GfMul.c
+++ b/src/Common/GfMul.c
@@ -651,43 +651,6 @@ int Gf128Tab64Init (unsigned __int8 *a, GfCtx *ctx)
651 return TRUE; 651 return TRUE;
652} 652}
653 653
654int Gf64TabInit (unsigned __int8 *a, GfCtx *ctx)
655{
656 /* Deprecated/legacy */
657
658 GfCtx4k64 *ctx4k;
659 unsigned __int8 am[8];
660 int i, j;
661
662 ctx4k = (GfCtx4k64 *) TCalloc (sizeof (GfCtx4k64));
663 if (!ctx4k)
664 return FALSE;
665
666 memcpy (am, a, 8);
667 MirrorBits64 (am);
668 compile_4k_table64 (am, ctx4k);
669
670 /* Convert LSB-first table to MSB-first */
671 for (i = 0; i < 16; i++)
672 {
673 for (j = 0; j < 16; j++)
674 {
675 int jm = 0;
676 jm |= (j & 0x1) << 3;
677 jm |= (j & 0x2) << 1;
678 jm |= (j & 0x4) >> 1;
679 jm |= (j & 0x8) >> 3;
680
681 memcpy (&ctx->gf_t64[i][jm], (unsigned char *)&ctx4k->gf_t4k[15-i][j], 8);
682 MirrorBits64 ((unsigned char *)&ctx->gf_t64[i][jm]);
683 }
684 }
685
686 burn (ctx4k,sizeof (*ctx4k));
687 burn (am, sizeof (am));
688 TCfree (ctx4k);
689 return TRUE;
690}
691 654
692#define xor_8kt64(i) \ 655#define xor_8kt64(i) \
693 xor_block_aligned(r, ctx->gf_t128[i + i][a[i] & 15]); \ 656 xor_block_aligned(r, ctx->gf_t128[i + i][a[i] & 15]); \
@@ -718,36 +681,6 @@ void Gf128MulBy64Tab (unsigned __int8 a[8], unsigned __int8 p[16], GfCtx *ctx)
718 move_block_aligned(p, r); 681 move_block_aligned(p, r);
719} 682}
720 683
721#define xor_8k64(i) \
722 xor_block_aligned64(r, ctx->gf_t64[i + i][a[i] & 15]); \
723 xor_block_aligned64(r, ctx->gf_t64[i + i + 1][a[i] >> 4])
724
725/* Multiply two 64-bit numbers in the finite field GF(2^64) */
726void Gf64MulTab (unsigned char a[8], unsigned char p[8], GfCtx *ctx)
727{
728 /* Deprecated/legacy */
729
730 unsigned __int32 r[CBLK_LEN8 >> 2];
731
732 move_block_aligned64(r, ctx->gf_t64[7*2][a[7] & 15]);
733 xor_block_aligned64(r, ctx->gf_t64[7*2+1][a[7] >> 4]);
734
735 if (*(unsigned __int16 *)a)
736 {
737 xor_8k64(0);
738 xor_8k64(1);
739 }
740 if (a[2])
741 {
742 xor_8k64(2);
743 }
744 xor_8k64(3);
745 xor_8k64(4);
746 xor_8k64(5);
747 xor_8k64(6);
748
749 move_block_aligned64(p, r);
750}
751 684
752 685
753/* Basic algorithms for testing of optimized algorithms */ 686/* Basic algorithms for testing of optimized algorithms */
@@ -809,32 +742,6 @@ static void shl64 (unsigned __int8 *a)
809 } 742 }
810} 743}
811 744
812static void GfMul64Basic (unsigned __int8 *a, unsigned __int8 *b, unsigned __int8* p)
813{
814 /* Deprecated/legacy */
815
816 int i;
817 unsigned __int8 la[8];
818 memcpy (la, a, 8);
819 memset (p, 0, 8);
820
821 for (i = 0; i < 64; i++)
822 {
823 if (IsBitSet64 (i, b))
824 xor64 ((uint64 *)p, (uint64 *)la);
825
826 if (la[0] & 0x80)
827 {
828 shl64 (la);
829 la[7] ^= 0x1b;
830 }
831 else
832 {
833 shl64 (la);
834 }
835 }
836}
837
838 745
839BOOL GfMulSelfTest () 746BOOL GfMulSelfTest ()
840{ 747{
@@ -849,23 +756,6 @@ BOOL GfMulSelfTest ()
849 if (!gfCtx) 756 if (!gfCtx)
850 return FALSE; 757 return FALSE;
851 758
852 /* GF(2^64) - deprecated/legacy */
853 for (i = 0; i < 0x100; i++)
854 {
855 for (j = 0; j < 8; j++)
856 {
857 a[j] = (unsigned __int8) i;
858 b[j] = a[j] ^ 0xff;
859 }
860
861 GfMul64Basic (a, b, p1);
862
863 Gf64TabInit (a, gfCtx);
864 Gf64MulTab (b, p2, gfCtx);
865
866 if (memcmp (p1, p2, 8) != 0)
867 result = FALSE;
868 }
869 759
870 /* GF(2^128) */ 760 /* GF(2^128) */
871 for (i = 0; i < 0x100; i++) 761 for (i = 0; i < 0x100; i++)