/** * Add one row to another. * * @param fromRow the addend * @param toRow the row to add to */ private void addToRow(int[] fromRow, int[] toRow) { for (int i = toRow.length - 1; i >= 0; i--) { toRow[i] = field.add(fromRow[i], toRow[i]); } }
/** * Add one row to another. * * @param fromRow the addend * @param toRow the row to add to */ private void addToRow(int[] fromRow, int[] toRow) { for (int i = toRow.length - 1; i >= 0; i--) { toRow[i] = field.add(fromRow[i], toRow[i]); } }
/** * Add one row to another. * * @param fromRow the addend * @param toRow the row to add to */ private void addToRow(int[] fromRow, int[] toRow) { for (int i = toRow.length - 1; i >= 0; i--) { toRow[i] = field.add(fromRow[i], toRow[i]); } }
/** * Compute the sum of two polynomials a and b over the finite field * <tt>GF(2^m)</tt>. * * @param a the first polynomial * @param b the second polynomial * @return a + b */ private int[] add(int[] a, int[] b) { int[] result, addend; if (a.length < b.length) { result = new int[b.length]; System.arraycopy(b, 0, result, 0, b.length); addend = a; } else { result = new int[a.length]; System.arraycopy(a, 0, result, 0, a.length); addend = b; } for (int i = addend.length - 1; i >= 0; i--) { result[i] = field.add(result[i], addend[i]); } return result; }
/** * Compute the sum of two polynomials a and b over the finite field * <tt>GF(2^m)</tt>. * * @param a the first polynomial * @param b the second polynomial * @return a + b */ private int[] add(int[] a, int[] b) { int[] result, addend; if (a.length < b.length) { result = new int[b.length]; System.arraycopy(b, 0, result, 0, b.length); addend = a; } else { result = new int[a.length]; System.arraycopy(a, 0, result, 0, a.length); addend = b; } for (int i = addend.length - 1; i >= 0; i--) { result[i] = field.add(result[i], addend[i]); } return result; }
/** * Adds specified round key to state array. * @param state * @param expandedKey * @param offset */ public void AddRoundKey(State state, byte[] expandedKey, int offset){ int i,j; for(i=0; i<State.ROWS; i++){ for(j=0; j<State.COLS; j++){ state.set((byte) field.add(state.get(i, j), expandedKey[offset + j*4+i]) , i, j); } } }
resultCoeff[i] = field.add(resultCoeff[i], scalarTerm);
resultCoeff[i] = field.add(resultCoeff[i], scalarTerm);
resultCoeff[i] = field.add(resultCoeff[i], scalarTerm);
resultCoeff[i] = field.add(resultCoeff[i], scalarTerm);
public GF2mMatrixEx rightMultiply(GF2mMatrixEx a) { if (this.getNumColumns() != a.getNumRows()){ throw new IllegalArgumentException("Dimension mismatch"); } final int[][] ai = a.getMatrix(); final int columnsInA = a.getNumColumns(); GF2mMatrixEx res = new GF2mMatrixEx(this.field, this.numRows, columnsInA); final int[][] ri = res.getMatrix(); for (int i = 0; i < this.numRows; i++) { for (int j = 0; j < columnsInA; j++) { for (int k = 0; k < this.numColumns; k++) { ri[i][j] = field.add(ri[i][j], field.mult(matrix[i][k], ai[k][j])); } } } return res; }
hArray[i][j] = field.add(hArray[i][j], field.mult(yz[k][j], gp.getCoefficient(t + k - i)));
hArray[i][j] = field.add(hArray[i][j], field.mult(yz[k][j], gp.getCoefficient(t + k - i)));
tmpRes = (byte) field.add(NTLUtils.colBinaryVectorToByte(resMatrix, 0, 0), afC) & 0xff;