private int[] generateWorkingKey( byte[] userKey) { if (userKey.length != 32) { throw new IllegalArgumentException("Key length invalid. Key needs to be 32 byte - 256 bit!!!"); } int key[] = new int[8]; for(int i=0; i!=8; i++) { key[i] = bytesToint(userKey,i*4); } return key; }
private int[] generateWorkingKey( byte[] userKey) { if (userKey.length != 32) { throw new IllegalArgumentException("Key length invalid. Key needs to be 32 byte - 256 bit!!!"); } int key[] = new int[8]; for(int i=0; i!=8; i++) { key[i] = bytesToint(userKey,i*4); } return key; }
private void gost28147MacFunc( int[] workingKey, byte[] in, int inOff, byte[] out, int outOff) { int N1, N2, tmp; //tmp -> for saving N1 N1 = bytesToint(in, inOff); N2 = bytesToint(in, inOff + 4); for(int k = 0; k < 2; k++) // 1-16 steps { for(int j = 0; j < 8; j++) { tmp = N1; N1 = N2 ^ gost28147_mainStep(N1, workingKey[j]); // CM2 N2 = tmp; } } intTobytes(N1, out, outOff); intTobytes(N2, out, outOff + 4); }
private void gost28147MacFunc( int[] workingKey, byte[] in, int inOff, byte[] out, int outOff) { int N1, N2, tmp; //tmp -> for saving N1 N1 = bytesToint(in, inOff); N2 = bytesToint(in, inOff + 4); for(int k = 0; k < 2; k++) // 1-16 steps { for(int j = 0; j < 8; j++) { tmp = N1; N1 = N2 ^ gost28147_mainStep(N1, workingKey[j]); // CM2 N2 = tmp; } } intTobytes(N1, out, outOff); intTobytes(N2, out, outOff + 4); }