mirror of
https://codeberg.org/scip/twenty4.git
synced 2025-12-17 12:00:57 +01:00
allow 256 key max
This commit is contained in:
10
README.md
10
README.md
@@ -55,10 +55,10 @@ TWENTY4 uses two S-Box arrays, one for key expansion and one for encryption.
|
||||
## Key expansion
|
||||
|
||||
The input key will be expanded into a 17 byte array. Maximum key size is
|
||||
17 bytes (136 bit).
|
||||
32 bytes (256 bit).
|
||||
|
||||
IV = KU[0]
|
||||
for ROUND in 0..16
|
||||
for ROUND in 0..31
|
||||
if KU[ROUND]
|
||||
K[ROUND] = IV xor KU[ROUND]
|
||||
else
|
||||
@@ -69,7 +69,7 @@ The input key will be expanded into a 17 byte array. Maximum key size is
|
||||
endfor
|
||||
|
||||
for KROUND in 0..31
|
||||
for ROUND in 0..17
|
||||
for ROUND in 0..31
|
||||
K[ROUND] = IV xor (rotateleft-3(K[ROUND]) xor KBOX[rcon(IV)])
|
||||
IV = K[ROUND]
|
||||
endfor
|
||||
@@ -79,7 +79,7 @@ where:
|
||||
|
||||
KU: input key
|
||||
K[17]: initial round key array
|
||||
ROUND: encryption round 1-17
|
||||
ROUND: encryption round 1-32
|
||||
KROUND: key expansion round 1-32
|
||||
KBOX[256]: pre computed S-Box for key expansion
|
||||
|
||||
@@ -98,7 +98,7 @@ where:
|
||||
endfor
|
||||
|
||||
func rotatekey(K, B)
|
||||
[rotate K[17] array elementy 1 to the right]
|
||||
[rotate K[32] array elementy 1 to the right]
|
||||
for N in 0..16:
|
||||
K[N] = KBOX[K[N] xor B]
|
||||
endfor
|
||||
|
||||
@@ -163,7 +163,7 @@ void keyhash(char *pw, byte *hash) {
|
||||
iv = kbox[(byte)pw[0]];
|
||||
|
||||
/* stretch pw */
|
||||
for(i=0; i<S_BOX_ROUNDS; i++) {
|
||||
for(i=0; i<K_HASH_ROUNDS; i++) {
|
||||
if((size_t)i < pwlen)
|
||||
hash[i] = iv ^ pw[i];
|
||||
else
|
||||
@@ -175,7 +175,7 @@ void keyhash(char *pw, byte *hash) {
|
||||
|
||||
/* diffuse and confuse hash */
|
||||
for(round=0; round<K_HASH_ROUNDS; round++) {
|
||||
for(i=0; i<S_BOX_ROUNDS; i++) {
|
||||
for(i=0; i<K_HASH_ROUNDS; i++) {
|
||||
hash[i] = iv ^ (rot8left(hash[i], 3) ^ kbox[rcon(iv)]);
|
||||
iv = hash[i];
|
||||
}
|
||||
@@ -283,7 +283,7 @@ int cbc_handleio(byte *key, int encrypt) {
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
byte key[S_BOX_ROUNDS];
|
||||
byte key[K_HASH_ROUNDS];
|
||||
int encrypt;
|
||||
|
||||
if(argc != 3) {
|
||||
|
||||
Reference in New Issue
Block a user