public synchronized NodeCHK getNodeCHK() { // This costs us more or less nothing: we have to keep the routingKey anyway. // Therefore, keeping a NodeCHK as well is a net saving, since it's frequently // asked for. (A SoftReference would cost more). if(nodeKey == null) nodeKey = new NodeCHK(routingKey, cryptoAlgorithm); return nodeKey; }
@Override public Key archivalCopy() { return new NodeCHK(this); } }
@Override public Key cloneKey() { return new NodeCHK(this); }
public static Key readCHK(DataInput raf, byte algo) throws IOException { byte[] buf = new byte[KEY_LENGTH]; raf.readFully(buf); return new NodeCHK(buf, algo); }
private NodeCHK getNodeKey(int x, boolean copy) { int xr = x * NodeCHK.KEY_LENGTH; byte[] routingKey = Arrays.copyOfRange(routingKeys, xr, xr + NodeCHK.KEY_LENGTH); byte[] extra; if(commonExtraBytes != null) { extra = commonExtraBytes; } else { int xe = x * EXTRA_BYTES_LENGTH; extra = Arrays.copyOfRange(extraBytesForKeys, xe, xe + EXTRA_BYTES_LENGTH); } byte cryptoAlgorithm = ClientCHK.getCryptoAlgorithmFromExtra(extra); return new NodeCHK(routingKey, cryptoAlgorithm); }
SHA256.returnMessageDigest(md); if(key == null) { chk = new NodeCHK(hash, cryptoAlgorithm); } else { chk = key;