spn decryption works

This commit is contained in:
Sebastian Hugentobler 2022-03-17 21:22:57 +01:00
parent 4c309352ed
commit 5bd4e640f2
2 changed files with 110 additions and 13 deletions

View file

@ -23,10 +23,9 @@ class SPNTest {
//given
int x = 0xEF45;
int r = 0x051C;
System.out.print(Integer.toHexString(x));
//when
int y = spn.substitution(x);
int y = spn.substitution(x, SPN.SBOX_REVERSE);
// then
assertEquals(r, y);
@ -51,5 +50,27 @@ class SPNTest {
assertEquals(r, y);
assertEquals(r, yy);
assertEquals(x, yyy);
assertEquals(0x100A, spn.swapBits(0x80A, 3, 4));
}
@Test
void permutation() {
var spn = new SPN();
int x = spn.permutation(0xEF45);
assertEquals(0xCFC5, x);
}
@Test
void sp() {
var spn = new SPN();
int x = 0x128F ;
int key = 0x11288C00;
int y = 0xAEB4;
assertEquals(y, spn.encryptBlock(key, x));
assertEquals(x, spn.decryptBlock(key, y));
}
}