public ClientCHK getKey(int x, boolean[] ignoreSlots, boolean copy) { if(ignoreSlots != null) { if(ignoreSlots[x]) return null; } return getKey(x, copy); }
public synchronized ClientCHK getKey(int blockNum) { SplitFileSegmentKeys keys; try { keys = getSegmentKeys(); } catch (IOException e) { return null; } if(keys == null) return null; return keys.getKey(blockNum, null, false); }
public ClientKey getKey(MyKey key) { try { return segments[key.segmentNumber].getSegmentKeys().getKey(key.blockNumber, null, false); } catch (IOException e) { this.failOnDiskError(e); return null; } }
private void queueHeal(int blockNumber, byte[] data) throws IOException { byte[] cryptoKey; byte cryptoAlgorithm; if(parent.splitfileSingleCryptoKey != null) { cryptoKey = parent.splitfileSingleCryptoKey; cryptoAlgorithm = parent.splitfileSingleCryptoAlgorithm; } else { ClientCHK key = getSegmentKeys().getKey(blockNumber, null, false); cryptoKey = key.getCryptoKey(); cryptoAlgorithm = key.getCryptoAlgorithm(); } parent.fetcher.queueHeal(data, cryptoKey, cryptoAlgorithm); }
SplitFileSegmentKeys keys = segment.readSegmentKeys(); for(int j=0;j<keys.totalKeys();j++) { keyListener.addKey(keys.getKey(j, null, false).getNodeKey(false), i, salt);
if(tryDecode) return false; decodeKey = keys.getKey(blockNumber, null, false);
private boolean checkEncodedDataBlocks(byte[][] checkBlocks, boolean[] checkBlocksPresent, SplitFileSegmentKeys keys, boolean capturingBinaryBlob) { for(int i=0;i<checkBlocks.length;i++) { if(checkBlocksPresent[i]) continue; ClientCHK decodeKey = keys.getKey(i+blocksForDecode(), null, false); // Encode it to check whether the key is the same. ClientCHKBlock block; try { block = ClientCHKBlock.encodeSplitfileBlock(checkBlocks[i], decodeKey.getCryptoKey(), decodeKey.getCryptoAlgorithm()); ClientCHK actualKey = block.getClientKey(); if(!actualKey.equals(decodeKey)) { Logger.error(this, "Splitfile check block "+i+" does not encode to expected key for "+this+" for "+parent); return false; } if(capturingBinaryBlob) parent.fetcher.maybeAddToBinaryBlob(block); } catch (CHKEncodeException e) { // Impossible! parent.fail(new FetchException(FetchExceptionMode.INTERNAL_ERROR, "Decoded block could not be encoded")); Logger.error(this, "Impossible: Decoded block could not be encoded"); return false; } } return true; }
for(int i=0;i<dataBlocks.length;i++) { if(dataBlocksPresent[i]) continue; ClientCHK decodeKey = keys.getKey(i, null, false);
crossCheckBlocks, maxRetries != -1, checksumLength, persistent); for(int j=0;j<(dataBlocks+crossCheckBlocks+checkBlocks);j++) { keyListener.addKey(keys.getKey(j, null, false).getNodeKey(false), i, salt);
int blockNumber = test.blockNumber; byte[] buf = test.buf; ClientCHK decodeKey = blockNumber == -1 ? null : keys.getKey(blockNumber, null, false);