aboutsummaryrefslogtreecommitdiff
path: root/gost_keywrap.c
diff options
context:
space:
mode:
authorNikolay Morozov <nmorozoff77@yandex.ru>2020-02-26 12:38:27 +0300
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>2020-02-27 00:14:48 +0300
commit0906436e33bdd8dabf07d494e3d6d5184cc02246 (patch)
treeec09bd8099b325e525132588d9f16c4310e0d575 /gost_keywrap.c
parent2883c9c20b26688f648fc14db1637890f96cab35 (diff)
downloadgost-engine-0906436e33bdd8dabf07d494e3d6d5184cc02246.zip
gost-engine-0906436e33bdd8dabf07d494e3d6d5184cc02246.tar.gz
gost-engine-0906436e33bdd8dabf07d494e3d6d5184cc02246.tar.bz2
cppcheck: The scope of the variable can be reduced.
Diffstat (limited to 'gost_keywrap.c')
-rw-r--r--gost_keywrap.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gost_keywrap.c b/gost_keywrap.c
index 502a83c..a2134c2 100644
--- a/gost_keywrap.c
+++ b/gost_keywrap.c
@@ -23,16 +23,17 @@
void keyDiversifyCryptoPro(gost_ctx * ctx, const unsigned char *inputKey,
const unsigned char *ukm, unsigned char *outputKey)
{
-
- u4 k, s1, s2;
- int i, j, mask;
- unsigned char S[8];
+ int i;
memcpy(outputKey, inputKey, 32);
for (i = 0; i < 8; i++) {
+ u4 s1 = 0;
+ u4 s2 = 0;
+ int j, mask;
+ unsigned char S[8];
/* Make array of integers from key */
/* Compute IV S */
- s1 = 0, s2 = 0;
for (j = 0, mask = 1; j < 8; j++, mask <<= 1) {
+ u4 k;
k = ((u4) outputKey[4 * j]) | (outputKey[4 * j + 1] << 8) |
(outputKey[4 * j + 2] << 16) | (outputKey[4 * j + 3] << 24);
if (mask & ukm[i]) {