/** * Computes a hashcode based on the contents of a three-dimensional byte * array rather than its identity. * * @param array the array to compute the hashcode of * @return the hashcode */ public static int deepHashCode(byte[][][] array) { int result = 1; for (int i = 0; i < array.length; i++) { result = 31 * result + deepHashCode(array[i]); } return result; }
/** * Compare two two-dimensional byte arrays. No null checks are performed. * * @param left the first byte array * @param right the second byte array * @return the result of the comparison */ public static boolean equals(byte[][] left, byte[][] right) { if (left.length != right.length) { return false; } boolean result = true; for (int i = left.length - 1; i >= 0; i--) { result &= ByteUtils.equals(left[i], right[i]); } return result; }
/** * Generate a subarray of a given byte array. * * @param input the input byte array * @param start the start index * @return a subarray of <tt>input</tt>, ranging from <tt>start</tt> to * the end of the array */ public static byte[] subArray(byte[] input, int start) { return subArray(input, start, input.length); }
if (c6Len > 0) byte[][] c6EncC4 = ByteUtils.split(input, c6Len); c6 = c6EncC4[0]; encC4 = c6EncC4[1]; c4 = ByteUtils.subArray(c4, 0, c4Len); byte[] c6c5c4 = ByteUtils.concatenate(c6, c5); c6c5c4 = ByteUtils.concatenate(c6c5c4, c4); byte[][] c2c1 = ByteUtils.split(c6c5c4, c2Len); byte[] c2 = c2c1[0]; byte[] c1 = c2c1[1]; byte[][] temp = ByteUtils.split(mConstPrime, c1Len - PUBLIC_CONSTANT.length); byte[] mr = temp[0]; byte[] constPrime = temp[1]; if (!ByteUtils.equals(constPrime, PUBLIC_CONSTANT))
byte[][] c1c2 = ByteUtils.split(input, c1Len); byte[] c1 = c1c2[0]; byte[] c2 = c1c2[1]; byte[] rmBytes = ByteUtils.concatenate(rBytes, mBytes); byte[] hrm = new byte[messDigest.getDigestSize()]; messDigest.update(rmBytes, 0, rmBytes.length);
byte[] c2c1 = ByteUtils.concatenate(c2, c1); return ByteUtils.concatenate(c6, encC4);
/** * @param input an int arary * @return the int array as hex string */ public static String toHexString(int[] input) { return ByteUtils.toHexString(BigEndianConversions.toByteArray(input)); }
public static ECPublicKeyParameters createECPublicKeyParameters(String xHex, String yHex, ECCurve curve, ECDomainParameters domainParameters) { return createECPublicKeyParameters(ByteUtils.fromHexString(xHex), ByteUtils.fromHexString(yHex), curve, domainParameters); }
public static byte[] generateM1( Digest digest, BigInteger N, BigInteger g, byte[] ephemeralKeyA, byte[] ephemeralKeyB, byte[] key, byte[] salt, // s byte[] identity) { // M1 = H(H(N) XOR H(g) | H(I) | s | A | B | K) int length = length(N); // hI = H(I) byte[] hI = hash(digest, identity); // tmp = H(N) XOR H(g) byte[] hNxhG = ByteUtils.xor(hash(digest, padded(N, length)), hash(digest, padded(g, length))); return hash(digest, hNxhG, hI, salt, ephemeralKeyA, ephemeralKeyB, key); }
if (c6Len > 0) byte[][] c6EncC4 = ByteUtils.split(input, c6Len); c6 = c6EncC4[0]; encC4 = c6EncC4[1]; c4 = ByteUtils.subArray(c4, 0, c4Len); byte[] c6c5c4 = ByteUtils.concatenate(c6, c5); c6c5c4 = ByteUtils.concatenate(c6c5c4, c4); byte[][] c2c1 = ByteUtils.split(c6c5c4, c2Len); byte[] c2 = c2c1[0]; byte[] c1 = c2c1[1]; byte[][] temp = ByteUtils.split(mConstPrime, c1Len - PUBLIC_CONSTANT.length); byte[] mr = temp[0]; byte[] constPrime = temp[1]; if (!ByteUtils.equals(constPrime, PUBLIC_CONSTANT))
byte[][] c1c2 = ByteUtils.split(input, c1Len); byte[] c1 = c1c2[0]; byte[] c2 = c1c2[1]; byte[] rmBytes = ByteUtils.concatenate(rBytes, mBytes); byte[] hrm = new byte[messDigest.getDigestSize()]; messDigest.update(rmBytes, 0, rmBytes.length);
byte[] c2c1 = ByteUtils.concatenate(c2, c1); return ByteUtils.concatenate(c6, encC4);
/** * @param input an int arary * @return the int array as hex string */ public static String toHexString(int[] input) { return ByteUtils.toHexString(BigEndianConversions.toByteArray(input)); }
byte[] mr = ByteUtils.concatenate(input, r); return ByteUtils.concatenate(c1, c2);
/** * Computes a hashcode based on the contents of a two-dimensional byte array * rather than its identity. * * @param array the array to compute the hashcode of * @return the hashcode */ public static int deepHashCode(byte[][] array) { int result = 1; for (int i = 0; i < array.length; i++) { result = 31 * result + deepHashCode(array[i]); } return result; }
/** * Compare two two-dimensional byte arrays. No null checks are performed. * * @param left the first byte array * @param right the second byte array * @return the result of the comparison */ public static boolean equals(byte[][] left, byte[][] right) { if (left.length != right.length) { return false; } boolean result = true; for (int i = left.length - 1; i >= 0; i--) { result &= ByteUtils.equals(left[i], right[i]); } return result; }
/** * Generate a subarray of a given byte array. * * @param input the input byte array * @param start the start index * @return a subarray of <tt>input</tt>, ranging from <tt>start</tt> to * the end of the array */ public static byte[] subArray(byte[] input, int start) { return subArray(input, start, input.length); }
byte[] rm = ByteUtils.concatenate(rBytes, input); return ByteUtils.concatenate(c1, c2);