public RawDataCryptAESCBCPKCS5Stage(GraphManager graphManager, byte[] pass, boolean encrypt, Pipe<RawDataSchema> input, Pipe<RawDataSchema> output, //both decrypt and encrypt instances must point to same file Pipe<BlockStorageReceiveSchema> finalInput, Pipe<BlockStorageXmitSchema> finalOutput ) { super(graphManager, join(input, finalInput), join(output, finalOutput)); if (pass.length!=passSize) { throw new UnsupportedOperationException("pass must be "+passSize+" bytes"); } this.encrypt = encrypt; this.pass = pass; this.input = input; this.output = output; this.finalInput = finalInput; this.finalOutput = finalOutput; }
@Override public void useSerialStores(int instances, int largestBlock, byte[] passphrase) { SecureRandom sr = new SecureRandom(passphrase); NoiseProducer noiseProducer = new NoiseProducer(sr); serialStoreReleaseAck = new Pipe[instances]; serialStoreReplay = new Pipe[instances]; serialStoreWriteAck = new Pipe[instances]; serialStoreRequestReplay = new Pipe[instances]; serialStoreWrite = new Pipe[instances]; for(int j=0; j<instances; j++) { buildSerialStore(j, noiseProducer, largestBlock, SequentialReplayerImpl.File); } }
if (encrypt) { hashInputData(availBacking, availPos, Integer.MAX_VALUE, avail); hashInputData(targetBacking, targetPos, targetMask, result); publishDoFinal();
int blockLen = processBlock(finalLen, 0, finalData, targetPos, targetBuffer, targetMask); int finalLen2 = doFinalIntoRing(targetBuffer, targetPos+blockLen, targetMask); hashInputData(targetBuffer, targetPos+blockLen, targetMask, finalLen2); int targetLen = blockLen + finalLen2; publishBockOut(targetPos, targetLen); resetToBeginning();
requestShutdown(); processFinalInputResponse(); while (processAvail()) {} while (processAvail()){} resetToBeginning(); Pipe.readNextWithoutReleasingReadLock(input); while (processAvail()){}
byte[] cypherBlock = noiseProducer.nextCypherBlock(); RawDataCryptAESCBCPKCS5Stage crypt1 = new RawDataCryptAESCBCPKCS5Stage(gm, cypherBlock, true, cypherDataToSave[i], fileDataToSave[i], doFinalReceive1, doFinalXmit1); RawDataCryptAESCBCPKCS5Stage crypt2 = new RawDataCryptAESCBCPKCS5Stage(gm, cypherBlock, false, fileDataToLoad[i], cypherDataToLoad[i], doFinalReceive2, doFinalXmit2);
private ConsoleJSONDumpStage buildGraph2(String blockFilePath, File tempFile, StringBuilder results, GraphManager gm2) { Pipe<RawDataSchema> encryptedDataPipe2 = RawDataSchema.instance.newPipe(10, 1000); Pipe<RawDataSchema> resultDataPipe2 = RawDataSchema.instance.newPipe(10, 1000); Pipe<BlockStorageReceiveSchema> doFinalInput3 = BlockStorageReceiveSchema.instance.newPipe(10, 1000); Pipe<BlockStorageXmitSchema> doFinalOutput3 = BlockStorageXmitSchema.instance.newPipe(10, 1000); BlockStorageStage.newInstance(gm2, blockFilePath, doFinalOutput3, doFinalInput3); results.setLength(0); results.append("single large message: "); FileBlobReadStage read= new FileBlobReadStage(gm2, encryptedDataPipe2, tempFile.getAbsolutePath()); RawDataCryptAESCBCPKCS5Stage decrypt2 = new RawDataCryptAESCBCPKCS5Stage(gm2, pass, false, encryptedDataPipe2, resultDataPipe2, doFinalInput3, doFinalOutput3 ); ConsoleJSONDumpStage lastStage2 = ConsoleJSONDumpStage.newInstance(gm2, resultDataPipe2, results, true); return lastStage2; }
int finalMask = finalOutput.blobMask; int finalLength = doFinalIntoRing(blob, finalOffset, finalMask); hashInputData(targetBuffer, finalOffset, targetMask, finalLength);
runTestOfDualPath(testDataPipe, expected);
noiseProducer.writeNoise(str, blockId, str.getPipe().maxVarLen-realDataSize);
@Override public void useSerialStores(int instances, int largestBlock, String passphrase) { CharSequenceToUTF8 charSequenceToUTF8 = CharSequenceToUTF8Local.get(); SecureRandom sr = new SecureRandom(charSequenceToUTF8.convert(passphrase).asBytes()); charSequenceToUTF8.clear(); NoiseProducer noiseProducer = new NoiseProducer(sr); serialStoreReleaseAck = new Pipe[instances]; serialStoreReplay = new Pipe[instances]; serialStoreWriteAck = new Pipe[instances]; serialStoreRequestReplay = new Pipe[instances]; serialStoreWrite = new Pipe[instances]; int j = instances; while (--j>=0) { buildSerialStore(j, noiseProducer, largestBlock, SequentialReplayerImpl.File); } }
new Pipe[]{doFinalInput1,doFinalInput2}); new RawDataCryptAESCBCPKCS5Stage(gm, pass, true, testDataPipe, encryptedDataPipe, new RawDataCryptAESCBCPKCS5Stage(gm, pass, false, encryptedDataPipeB, resultDataPipe,
}; runTestOfDualPath(testDataPipe, expected);
np = new NoiseProducer(new SecureRandom("seed".getBytes()));
}; runTestOfDualPath(testDataPipe, expected);
SecureRandom sr = new SecureRandom(charSequenceToUTF8.convert(username).append(":").append(password).asBytes()); charSequenceToUTF8.clear(); noiseProducer = new NoiseProducer(sr);
}; runTestOfDualPath(testDataPipe, expected);