public static byte[] getRawFingerprint(Digest d, byte[] buf, int offset, int len) throws Exception { if (len <= 0) { return null; } Objects.requireNonNull(d, "No digest").init(); d.update(buf, offset, len); return d.digest(); } }
public static byte[] getRawFingerprint(Digest d, byte[] buf, int offset, int len) throws Exception { if (len <= 0) { return null; } Objects.requireNonNull(d, "No digest").init(); d.update(buf, offset, len); return d.digest(); } }
/** * Method used while putting new keys into use that will resize the key used to * initialize the cipher to the needed length. * * @param e the key to resize * @param blockSize the cipher block size (in bytes) * @param hash the hash algorithm * @param k the key exchange k parameter * @param h the key exchange h parameter * @return the resized key * @throws Exception if a problem occur while resizing the key */ protected byte[] resizeKey(byte[] e, int blockSize, Digest hash, byte[] k, byte[] h) throws Exception { for (Buffer buffer = null; blockSize > e.length; buffer = BufferUtils.clear(buffer)) { if (buffer == null) { buffer = new ByteArrayBuffer(); } buffer.putMPInt(k); buffer.putRawBytes(h); buffer.putRawBytes(e); hash.update(buffer.array(), 0, buffer.available()); byte[] foo = hash.digest(); byte[] bar = new byte[e.length + foo.length]; System.arraycopy(e, 0, bar, 0, e.length); System.arraycopy(foo, 0, bar, e.length, foo.length); e = bar; } return e; }
/** * Method used while putting new keys into use that will resize the key used to * initialize the cipher to the needed length. * * @param e the key to resize * @param kdfSize the cipher key-derivation-factor (in bytes) * @param hash the hash algorithm * @param k the key exchange k parameter * @param h the key exchange h parameter * @return the resized key * @throws Exception if a problem occur while resizing the key */ protected byte[] resizeKey(byte[] e, int kdfSize, Digest hash, byte[] k, byte[] h) throws Exception { for (Buffer buffer = null; kdfSize > e.length; buffer = BufferUtils.clear(buffer)) { if (buffer == null) { buffer = new ByteArrayBuffer(); } buffer.putMPInt(k); buffer.putRawBytes(h); buffer.putRawBytes(e); hash.update(buffer.array(), 0, buffer.available()); byte[] foo = hash.digest(); byte[] bar = new byte[e.length + foo.length]; System.arraycopy(e, 0, bar, 0, e.length); System.arraycopy(foo, 0, bar, e.length, foo.length); e = bar; } return e; }
byte[] hashValue = digest.digest(); if (traceEnabled) { log.trace("doCheckFileHash({})[{}] offset={}, length={} - algo={}, hash={}", digest.update(digestBuf, 0, readLen); byte[] hashValue = digest.digest(); // NOTE: this also resets the hash for the next read if (traceEnabled) { log.trace("doCheckFileHash({})({})[{}] offset={}, length={} - algo={}, hash={}",
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest(); sig.update(h);
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest(); sig.update(h);
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest();
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest();
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest();
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest();
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest(); sig.update(h);
buffer.putMPInt(k); hash.update(buffer.array(), 0, buffer.available()); h = hash.digest(); sig.update(h);