Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Brian Smith
nettle
Commits
4b0b15c0
Commit
4b0b15c0
authored
Mar 12, 1999
by
J.H.M. Dassen
Committed by
Niels Möller
Mar 12, 1999
Browse files
* src/symmetric/twofish.c (twofish_selftest): Fixed. (Ray).
Rev: src/symmetric/twofish.c:1.5
parent
8ff28ed8
Changes
1
Hide whitespace changes
Inline
Side-by-side
twofish.c
View file @
4b0b15c0
...
...
@@ -267,7 +267,7 @@ static byte mds_matrix[4][4] = { { 0x01, 0xEF, 0x5B, 0x5B },
*
* k is the key size (/ 64 bits), i is the byte number (0 = LSB), x is the
* actual byte to apply the function to; l0, l1, l2, and l3 are the
* appropriate bytes from the subkey. Note that only l0..l
k
are used.
* appropriate bytes from the subkey. Note that only l0..l
(k-1)
are used.
*/
static
word
...
...
@@ -300,7 +300,7 @@ h(int k, byte x, word l0, word l1, word l2, word l3)
/*
* Sanity check using the test vectors from appendix
2
of the Twofish paper.
* Sanity check using the test vectors from appendix
A.1
of the Twofish paper.
*/
int
twofish_selftest
(
void
)
...
...
@@ -310,16 +310,15 @@ twofish_selftest(void)
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
byte
ciphertext128
[
16
]
=
{
0x5D
,
0x9D
,
0x4E
,
0xEF
,
0xFA
,
0x91
,
0x51
,
0x57
,
0x55
,
0x24
,
0xF1
,
0x15
,
0x81
,
0x5A
,
0x12
,
0xE0
};
0x9F
,
0x58
,
0x9F
,
0x5C
,
0xF6
,
0x12
,
0x2C
,
0x32
,
0xB6
,
0xBF
,
0xEC
,
0x2F
,
0x2A
,
0xE8
,
0xC3
,
0x5A
};
byte
testkey192
[
24
]
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
,
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
,
0x00
,
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
,
0x77
};
byte
ciphertext192
[
16
]
=
{
0x
E7
,
0x
54
,
0x
49
,
0x
21
,
0x
2B
,
0x
E
E
,
0x
F
9
,
0xF
4
,
0x
A3
,
0x
90
,
0x
BD
,
0x8
6
,
0x
0A
,
0x
64
,
0x
09
,
0x4
1
};
{
0x
CF
,
0x
D1
,
0x
D2
,
0x
E5
,
0x
A9
,
0x
B
E
,
0x9
C
,
0x
D
F
,
0x
50
,
0x
1F
,
0x
13
,
0x
B
8
,
0x
92
,
0x
BD
,
0x
22
,
0x4
8
};
byte
testkey256
[
32
]
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
,
...
...
@@ -327,8 +326,8 @@ twofish_selftest(void)
0x00
,
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
,
0x77
,
0x88
,
0x99
,
0xAA
,
0xBB
,
0xCC
,
0xDD
,
0xEE
,
0xFF
};
byte
ciphertext256
[
16
]
=
{
0x37
,
0x
FE
,
0x
26
,
0x
FF
,
0x
1C
,
0x
F6
,
0x
61
,
0x
75
,
0xF
5
,
0x
DD
,
0xF
4
,
0xC
3
,
0x
3B
,
0x
9
7
,
0xA
2
,
0x0
5
};
{
0x37
,
0x
52
,
0x
7B
,
0x
E0
,
0x
05
,
0x
23
,
0x
34
,
0x
B8
,
0x
9
F
,
0x
0C
,
0xF
C
,
0xC
A
,
0x
E8
,
0x7
C
,
0x
F
A
,
0x
2
0
};
TWOFISH_context
context
;
int
i
;
...
...
@@ -337,33 +336,24 @@ twofish_selftest(void)
twofish_setup
(
&
context
,
16
,
testkey128
);
memset
(
plaintext
,
0
,
16
);
for
(
i
=
0
;
i
<
50
;
i
++
)
{
twofish_encrypt
(
&
context
,
plaintext
,
ciphertext
);
memcpy
(
plaintext
,
ciphertext
,
16
);
}
if
(
!
memcmp
(
ciphertext
,
ciphertext128
,
16
))
{
twofish_encrypt
(
&
context
,
plaintext
,
ciphertext
);
if
(
memcmp
(
ciphertext
,
ciphertext128
,
16
))
{
return
0
;
}
twofish_setup
(
&
context
,
24
,
testkey192
);
memset
(
plaintext
,
0
,
16
);
for
(
i
=
0
;
i
<
50
;
i
++
)
{
twofish_encrypt
(
&
context
,
plaintext
,
ciphertext
);
memcpy
(
plaintext
,
ciphertext
,
16
);
}
if
(
!
memcmp
(
ciphertext
,
ciphertext192
,
16
))
{
twofish_encrypt
(
&
context
,
plaintext
,
ciphertext
);
if
(
memcmp
(
ciphertext
,
ciphertext192
,
16
))
{
return
0
;
}
twofish_setup
(
&
context
,
32
,
testkey256
);
memset
(
plaintext
,
0
,
16
);
for
(
i
=
0
;
i
<
50
;
i
++
)
{
twofish_encrypt
(
&
context
,
plaintext
,
ciphertext
);
memcpy
(
plaintext
,
ciphertext
,
16
);
}
if
(
!
memcmp
(
ciphertext
,
ciphertext256
,
16
))
{
twofish_encrypt
(
&
context
,
plaintext
,
ciphertext
);
if
(
memcmp
(
ciphertext
,
ciphertext256
,
16
))
{
return
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment