/** * Read a key using the current settings. * @throws IOException * @throws MalformedURLException If the key could not be read due to an error in parsing the key. * REDFLAG: May want to recover from these in future, hence the short length. */ private FreenetURI readKey(DataInputStream dis) throws IOException { // Read URL if(fullKeys) { return FreenetURI.readFullBinaryKeyWithLength(dis); } else { return ClientCHK.readRawBinaryKey(dis).getURI(); } }
public void readKeys(DataInputStream dis, boolean check) throws IOException { int count = check ? checkBlocks : dataBlocks; int offset = check ? dataBlocks : 0; if(commonDecryptKey != null) { int rkOffset = offset * NodeCHK.KEY_LENGTH; for(int i=0;i<count;i++) { dis.readFully(routingKeys, rkOffset, NodeCHK.KEY_LENGTH); rkOffset += NodeCHK.KEY_LENGTH; } } else { int rkOffset = offset * NodeCHK.KEY_LENGTH; int extraOffset = offset * EXTRA_BYTES_LENGTH; assert(NodeCHK.KEY_LENGTH == ClientCHK.CRYPTO_KEY_LENGTH); for(int i=0;i<count;i++) { ClientCHK key = ClientCHK.readRawBinaryKey(dis); byte[] r = key.getRoutingKey(); System.arraycopy(r, 0, routingKeys, rkOffset, NodeCHK.KEY_LENGTH); byte[] c = key.getCryptoKey(); System.arraycopy(c, 0, decryptKeys, rkOffset, NodeCHK.KEY_LENGTH); rkOffset += NodeCHK.KEY_LENGTH; byte[] e = key.getExtra(); System.arraycopy(e, 0, extraBytesForKeys, extraOffset, EXTRA_BYTES_LENGTH); extraOffset += EXTRA_BYTES_LENGTH; } } }