fix k function

This commit is contained in:
Sebastian Hugentobler 2022-03-17 12:46:28 +01:00
parent 2a35bbbfab
commit 51a4b2d9bc
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

View File

@ -1,10 +1,12 @@
package ch.fhnw.kry;
public class SPN {
private final static int ROUND_KEY_LENGTH = 16;
public int k(int key, int i) {
i *= 4;
int mask = 0xFFFF >>> i;
int mask = 0xFFFF_0000 >>> i;
return key & mask;
return key & mask >>> ROUND_KEY_LENGTH - i;
}
}