本文整理汇总了Java中org.bouncycastle.pqc.math.linearalgebra.GF2mField.mult方法的典型用法代码示例。如果您正苦于以下问题:Java GF2mField.mult方法的具体用法?Java GF2mField.mult怎么用?Java GF2mField.mult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.pqc.math.linearalgebra.GF2mField
的用法示例。
在下文中一共展示了GF2mField.mult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.bouncycastle.pqc.math.linearalgebra.GF2mField; //导入方法依赖的package包/类
/**
* Initializes AES constans (S-box, T-box, RC for key schedule).
*
* @param encrypt
*/
public void build(boolean encrypt){
field = new GF2mField(8, POLYNOMIAL);
System.out.println(field);
int i,c,cur = 1;
gInv[0] = -1;
for(i=0; i<AES_FIELD_SIZE; i++){
g[i] = cur;
gInv[cur] = i;
cur = field.mult(cur, GENERATOR);
}
// 2. compute GF(256) element inverses in terms of generator exponent
sbox[0] = -1;
for(i=1; i<AES_FIELD_SIZE; i++){
sbox[i] = 255-i;
}
GF2MatrixEx tmpM = new GF2MatrixEx(8, 1);
GF2MatrixEx afM = getDefaultAffineMatrix(true);
byte afC = getDefaultAffineConstByte(true);
// Computing whole Sboxes with inversion + affine transformation in generic AES
// Normal Sbox: S(x) = const + A(x^{-1})
// Sbox in Dual AES: G(x) = T(const) + T(A(T^{-1}(x^{-1})))
for(i=0; i<AES_FIELD_SIZE; i++){
int tmpRes;
// i is now long representation, gInv transforms it to exponent power to obtain inverse.
// Also getLong(g[gInv[i]]) == i
int transValue = i==0 ? 0 : g[255-gInv[i]];
// tmpM = col vector of transValue
NTLUtils.zero(tmpM);
NTLUtils.putByteAsColVector(tmpM, (byte)transValue, 0, 0);
// const + A(x^{-1})
GF2MatrixEx resMatrix = (GF2MatrixEx) afM.rightMultiply(tmpM);
tmpRes = (byte) field.add(NTLUtils.colBinaryVectorToByte(resMatrix, 0, 0), afC) & 0xff;
}
// generation of constant MDS matrix in case some non-suitable round key is derived
createMDS16x16();
MDS16x16Mat = new GF2mMatrixEx(field, 16, 16);
for(i=0; i<16; i++){
for(c=0; c<16; c++){
MDS16x16Mat.set(i, c, MDS16x16[i][c]);
}
}
// Round key constant RC (for key schedule) obeys this reccurence:
// RC[0] = 1
// RC[i] = '02' * RC[i-1] = x * RC[i-1] = x^{i-1} `mod` R(X)
RC[0] = g[0];
for(i=1; i<RCNUM; i++){
RC[i] = field.mult(g[25], RC[i-1]);
}
}