VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/GostCipher.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-09-25 22:37:45 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-10-17 18:40:16 +0200
commitb65eabe23d5910a26d741439b1f5ea45ba4a0777 (patch)
treebd63c2de5b151657d294f1a56040fc4c6db4c893 /src/Crypto/GostCipher.c
parentd18ecc1a37b5f83d70b204f0bcb097fb8525314f (diff)
downloadVeraCrypt-b65eabe23d5910a26d741439b1f5ea45ba4a0777.tar.gz
VeraCrypt-b65eabe23d5910a26d741439b1f5ea45ba4a0777.zip
Add test vectors for Kuznyechik and GOST89 (the later is deprecated)
Diffstat (limited to 'src/Crypto/GostCipher.c')
-rw-r--r--src/Crypto/GostCipher.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/Crypto/GostCipher.c b/src/Crypto/GostCipher.c
index b84fd4ed..4d7e5070 100644
--- a/src/Crypto/GostCipher.c
+++ b/src/Crypto/GostCipher.c
@@ -69,7 +69,6 @@ void gost_prepare_kds(gost_kds* kds) {
}
-#ifdef GOST_DYNAMIC_SBOXES
static void xor_s_box(byte s_box[8][16], byte *seed)
{
int i;
@@ -85,38 +84,35 @@ static void xor_s_box(byte s_box[8][16], byte *seed)
s_box[7][i] ^= (seed[ (i * 4) + 3 ]>>4) & 0xF;
}
}
-#endif
-void gost_set_key(const byte *key, gost_kds *ks)
+void gost_set_key(const byte *key, gost_kds *ks, int useDynamicSbox)
{
-#ifdef GOST_DYNAMIC_SBOXES
- STREEBOG_CTX sctx;
- byte sbox_seed[64];
-#if defined (DEVICE_DRIVER) && !defined (_WIN64)
- KFLOATING_SAVE floatingPointState;
- NTSTATUS saveStatus = STATUS_SUCCESS;
- if (HasSSE2() || HasSSE41())
- saveStatus = KeSaveFloatingPointState (&floatingPointState);
-#endif
-#endif
-
memcpy(ks->key, key, GOST_KEYSIZE);
memcpy(ks->sbox, S_TC26, sizeof(ks->sbox));
-#ifdef GOST_DYNAMIC_SBOXES
- //Generate pseudorandom data based on the key
- STREEBOG_init(&sctx);
- STREEBOG_add(&sctx, key, 32);
- STREEBOG_finalize(&sctx, sbox_seed);
-
+ if (useDynamicSbox)
+ {
+ STREEBOG_CTX sctx;
+ byte sbox_seed[64];
#if defined (DEVICE_DRIVER) && !defined (_WIN64)
- if (NT_SUCCESS (saveStatus) && (HasSSE2() || HasSSE41()))
- KeRestoreFloatingPointState (&floatingPointState);
+ KFLOATING_SAVE floatingPointState;
+ NTSTATUS saveStatus = STATUS_SUCCESS;
+ if (HasSSE2() || HasSSE41())
+ saveStatus = KeSaveFloatingPointState (&floatingPointState);
#endif
+ //Generate pseudorandom data based on the key
+ STREEBOG_init(&sctx);
+ STREEBOG_add(&sctx, key, 32);
+ STREEBOG_finalize(&sctx, sbox_seed);
- xor_s_box(ks->sbox, sbox_seed);
+#if defined (DEVICE_DRIVER) && !defined (_WIN64)
+ if (NT_SUCCESS (saveStatus) && (HasSSE2() || HasSSE41()))
+ KeRestoreFloatingPointState (&floatingPointState);
#endif
+ xor_s_box(ks->sbox, sbox_seed);
+ }
+
gost_prepare_kds(ks);
}