Created
September 13, 2022 16:49
-
-
Save atoponce/1047339f3fc6133b0f51637c05c78a1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
/***************************************************************** | |
** Skein block function constants (shared across Ref and Opt code) | |
******************************************************************/ | |
enum | |
{ | |
/* Skein_256 round rotation constants */ | |
R_256_0_0=14, R_256_0_1=16, | |
R_256_1_0=52, R_256_1_1=57, | |
R_256_2_0=23, R_256_2_1=40, | |
R_256_3_0= 5, R_256_3_1=37, | |
R_256_4_0=25, R_256_4_1=33, | |
R_256_5_0=46, R_256_5_1=12, | |
R_256_6_0=58, R_256_6_1=22, | |
R_256_7_0=32, R_256_7_1=32, | |
/* Skein_512 round rotation constants */ | |
R_512_0_0=46, R_512_0_1=36, R_512_0_2=19, R_512_0_3=37, | |
R_512_1_0=33, R_512_1_1=27, R_512_1_2=14, R_512_1_3=42, | |
R_512_2_0=17, R_512_2_1=49, R_512_2_2=36, R_512_2_3=39, | |
R_512_3_0=44, R_512_3_1= 9, R_512_3_2=54, R_512_3_3=56, | |
R_512_4_0=39, R_512_4_1=30, R_512_4_2=34, R_512_4_3=24, | |
R_512_5_0=13, R_512_5_1=50, R_512_5_2=10, R_512_5_3=17, | |
R_512_6_0=25, R_512_6_1=29, R_512_6_2=39, R_512_6_3=43, | |
R_512_7_0= 8, R_512_7_1=35, R_512_7_2=56, R_512_7_3=22, | |
/* Skein1024 round rotation constants */ | |
R1024_0_0=24, R1024_0_1=13, R1024_0_2= 8, R1024_0_3=47, R1024_0_4= 8, R1024_0_5=17, R1024_0_6=22, R1024_0_7=37, | |
R1024_1_0=38, R1024_1_1=19, R1024_1_2=10, R1024_1_3=55, R1024_1_4=49, R1024_1_5=18, R1024_1_6=23, R1024_1_7=52, | |
R1024_2_0=33, R1024_2_1= 4, R1024_2_2=51, R1024_2_3=13, R1024_2_4=34, R1024_2_5=41, R1024_2_6=59, R1024_2_7=17, | |
R1024_3_0= 5, R1024_3_1=20, R1024_3_2=48, R1024_3_3=41, R1024_3_4=47, R1024_3_5=28, R1024_3_6=16, R1024_3_7=25, | |
R1024_4_0=41, R1024_4_1= 9, R1024_4_2=37, R1024_4_3=31, R1024_4_4=12, R1024_4_5=47, R1024_4_6=44, R1024_4_7=30, | |
R1024_5_0=16, R1024_5_1=34, R1024_5_2=56, R1024_5_3=51, R1024_5_4= 4, R1024_5_5=53, R1024_5_6=42, R1024_5_7=41, | |
R1024_6_0=31, R1024_6_1=44, R1024_6_2=47, R1024_6_3=46, R1024_6_4=19, R1024_6_5=42, R1024_6_6=44, R1024_6_7=25, | |
R1024_7_0= 9, R1024_7_1=48, R1024_7_2=35, R1024_7_3=52, R1024_7_4=23, R1024_7_5=31, R1024_7_6=37, R1024_7_7=20 | |
}; | |
//... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
for (r=1;r <= SKEIN_256_ROUNDS_TOTAL/8; r++) | |
{ /* unroll 8 rounds */ | |
X[0] += X[1]; X[1] = RotL_64(X[1],R_256_0_0); X[1] ^= X[0]; | |
X[2] += X[3]; X[3] = RotL_64(X[3],R_256_0_1); X[3] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-7,X); | |
X[0] += X[3]; X[3] = RotL_64(X[3],R_256_1_0); X[3] ^= X[0]; | |
X[2] += X[1]; X[1] = RotL_64(X[1],R_256_1_1); X[1] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-6,X); | |
X[0] += X[1]; X[1] = RotL_64(X[1],R_256_2_0); X[1] ^= X[0]; | |
X[2] += X[3]; X[3] = RotL_64(X[3],R_256_2_1); X[3] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-5,X); | |
X[0] += X[3]; X[3] = RotL_64(X[3],R_256_3_0); X[3] ^= X[0]; | |
X[2] += X[1]; X[1] = RotL_64(X[1],R_256_3_1); X[1] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-4,X); | |
InjectKey(2*r-1); | |
X[0] += X[1]; X[1] = RotL_64(X[1],R_256_4_0); X[1] ^= X[0]; | |
X[2] += X[3]; X[3] = RotL_64(X[3],R_256_4_1); X[3] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-3,X); | |
X[0] += X[3]; X[3] = RotL_64(X[3],R_256_5_0); X[3] ^= X[0]; | |
X[2] += X[1]; X[1] = RotL_64(X[1],R_256_5_1); X[1] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-2,X); | |
X[0] += X[1]; X[1] = RotL_64(X[1],R_256_6_0); X[1] ^= X[0]; | |
X[2] += X[3]; X[3] = RotL_64(X[3],R_256_6_1); X[3] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r-1,X); | |
X[0] += X[3]; X[3] = RotL_64(X[3],R_256_7_0); X[3] ^= X[0]; | |
X[2] += X[1]; X[1] = RotL_64(X[1],R_256_7_1); X[1] ^= X[2]; Skein_Show_Round(BLK_BITS,&ctx->h,8*r ,X); | |
InjectKey(2*r); | |
} | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment