public int doFinal( byte[] out, int outOff) { finish(); Pack.intToBigEndian(H1, out, outOff); Pack.intToBigEndian(H2, out, outOff + 4); Pack.intToBigEndian(H3, out, outOff + 8); Pack.intToBigEndian(H4, out, outOff + 12); Pack.intToBigEndian(H5, out, outOff + 16); Pack.intToBigEndian(H6, out, outOff + 20); Pack.intToBigEndian(H7, out, outOff + 24); Pack.intToBigEndian(H8, out, outOff + 28); reset(); return DIGEST_LENGTH; }
public int doFinal( byte[] out, int outOff) { finish(); Pack.intToBigEndian(H1, out, outOff); Pack.intToBigEndian(H2, out, outOff + 4); Pack.intToBigEndian(H3, out, outOff + 8); Pack.intToBigEndian(H4, out, outOff + 12); Pack.intToBigEndian(H5, out, outOff + 16); reset(); return DIGEST_LENGTH; }
public int generateBytes(byte[] out, int outOff, int len) throws DataLengthException, IllegalArgumentException { // TODO Create an ASN.1 class for this (RFC3278) // ECC-CMS-SharedInfo ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new AlgorithmIdentifier(algorithm, DERNull.INSTANCE)); v.add(new DERTaggedObject(true, 2, new DEROctetString(Pack.intToBigEndian(keySize)))); try { kdf.init(new KDFParameters(z, new DERSequence(v).getEncoded(ASN1Encoding.DER))); } catch (IOException e) { throw new IllegalArgumentException("unable to initialise kdf: " + e.getMessage()); } return kdf.generateBytes(out, outOff, len); }
public void init(CipherParameters params) throws IllegalArgumentException { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException("'params' must be an instance of KeyParameter"); } KeyParameter keyParameter = (KeyParameter)params; byte[] key = keyParameter.getKey(); if (key.length != 16) { throw new IllegalArgumentException("'params' must be a 128-bit key"); } this.k0 = Pack.littleEndianToLong(key, 0); this.k1 = Pack.littleEndianToLong(key, 8); reset(); }
public int doFinal( byte[] out, int outOff) { finish(); Pack.longToBigEndian(H1, out, outOff); Pack.longToBigEndian(H2, out, outOff + 8); Pack.longToBigEndian(H3, out, outOff + 16); Pack.longToBigEndian(H4, out, outOff + 24); Pack.longToBigEndian(H5, out, outOff + 32); Pack.longToBigEndian(H6, out, outOff + 40); reset(); return DIGEST_LENGTH; }
public int doFinal( byte[] out, int outOff) { finish(); Pack.longToBigEndian(H1, out, outOff); Pack.longToBigEndian(H2, out, outOff + 8); Pack.longToBigEndian(H3, out, outOff + 16); Pack.longToBigEndian(H4, out, outOff + 24); Pack.longToBigEndian(H5, out, outOff + 32); Pack.longToBigEndian(H6, out, outOff + 40); Pack.longToBigEndian(H7, out, outOff + 48); Pack.longToBigEndian(H8, out, outOff + 56); reset(); return DIGEST_LENGTH; }
public int doFinal( byte[] out, int outOff) { finish(); Pack.intToBigEndian(H1, out, outOff); Pack.intToBigEndian(H2, out, outOff + 4); Pack.intToBigEndian(H3, out, outOff + 8); Pack.intToBigEndian(H4, out, outOff + 12); Pack.intToBigEndian(H5, out, outOff + 16); Pack.intToBigEndian(H6, out, outOff + 20); Pack.intToBigEndian(H7, out, outOff + 24); reset(); return DIGEST_LENGTH; }
public void multiplyH(byte[] x) { // assert x.Length == 16; int[] z = new int[4]; for (int i = 15; i >= 0; --i) { // GCMUtil.xor(z, M[i][x[i] & 0xff]); int[] m = M[i][x[i] & 0xff]; z[0] ^= m[0]; z[1] ^= m[1]; z[2] ^= m[2]; z[3] ^= m[3]; } Pack.intToBigEndian(z, x, 0); }
public void multiplyH(byte[] x) { // assert x.Length == 16; int[] z = new int[4]; for (int i = 15; i >= 0; --i) { // GCMUtil.xor(z, M[i + i][x[i] & 0x0f]); int[] m = M[i + i][x[i] & 0x0f]; z[0] ^= m[0]; z[1] ^= m[1]; z[2] ^= m[2]; z[3] ^= m[3]; // GCMUtil.xor(z, M[i + i + 1][(x[i] & 0xf0) >>> 4]); m = M[i + i + 1][(x[i] & 0xf0) >>> 4]; z[0] ^= m[0]; z[1] ^= m[1]; z[2] ^= m[2]; z[3] ^= m[3]; } Pack.intToBigEndian(z, x, 0); }
public int doFinal(byte[] out, int outOff) { finish(); Pack.intToBigEndian(this.V[0], out, outOff + 0); Pack.intToBigEndian(this.V[1], out, outOff + 4); Pack.intToBigEndian(this.V[2], out, outOff + 8); Pack.intToBigEndian(this.V[3], out, outOff + 12); Pack.intToBigEndian(this.V[4], out, outOff + 16); Pack.intToBigEndian(this.V[5], out, outOff + 20); Pack.intToBigEndian(this.V[6], out, outOff + 24); Pack.intToBigEndian(this.V[7], out, outOff + 28); reset(); return DIGEST_LENGTH; }