Search in sources :

Example 1 with NullOutputStream

use of com.google.common.io.NullOutputStream in project conceal by facebook.

the class CipherReadBenchmark method timeBouncyCastleGCMRead.

public void timeBouncyCastleGCMRead(int reps) throws Exception {
    for (int i = 0; i < reps; ++i) {
        ByteArrayInputStream cipheredInput = new ByteArrayInputStream(mBCGCMCipheredData);
        InputStream input = mBCGCMCipher.getInputStream(cipheredInput);
        readFully(input, new NullOutputStream());
    // Not closing the bouncy castle stream on purpose because of a bug in
    // bouncycastle.
    //input.close();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) MacLayeredInputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredInputStream) InputStream(java.io.InputStream) NullOutputStream(com.google.common.io.NullOutputStream)

Example 2 with NullOutputStream

use of com.google.common.io.NullOutputStream in project conceal by facebook.

the class MacBenchmark method timeNativeMac.

public void timeNativeMac(int reps) throws Exception {
    for (int i = 0; i < reps; ++i) {
        OutputStream output = mNativeMacHelper.getOutputStream(new NullOutputStream());
        output.write(mData);
        output.close();
    }
}
Also used : OutputStream(java.io.OutputStream) MacLayeredOutputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredOutputStream) NullOutputStream(com.google.common.io.NullOutputStream) NullOutputStream(com.google.common.io.NullOutputStream)

Example 3 with NullOutputStream

use of com.google.common.io.NullOutputStream in project conceal by facebook.

the class MacBenchmark method timeJavaHmac.

public void timeJavaHmac(int reps) throws Exception {
    for (int i = 0; i < reps; ++i) {
        Mac mac = mHMAC.getMac();
        OutputStream macOutput = new MacLayeredOutputStream(mac, new NullOutputStream());
        macOutput.write(mData);
        macOutput.close();
        mac.doFinal();
    }
}
Also used : MacLayeredOutputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredOutputStream) OutputStream(java.io.OutputStream) MacLayeredOutputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredOutputStream) NullOutputStream(com.google.common.io.NullOutputStream) Mac(javax.crypto.Mac) NullOutputStream(com.google.common.io.NullOutputStream)

Example 4 with NullOutputStream

use of com.google.common.io.NullOutputStream in project conceal by facebook.

the class CipherReadBenchmark method timeNativeGCMRead.

public void timeNativeGCMRead(int reps) throws Exception {
    for (int i = 0; i < reps; ++i) {
        ByteArrayInputStream cipheredInput = new ByteArrayInputStream(mNativeGCMCipheredData);
        InputStream input = mNativeGCMCipherHelper.getInputStream(cipheredInput);
        readFully(input, new NullOutputStream());
        input.close();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) MacLayeredInputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredInputStream) InputStream(java.io.InputStream) NullOutputStream(com.google.common.io.NullOutputStream)

Example 5 with NullOutputStream

use of com.google.common.io.NullOutputStream in project conceal by facebook.

the class CipherReadBenchmark method timeAESWithHmacRead.

public void timeAESWithHmacRead(int reps) throws Exception {
    for (int i = 0; i < reps; ++i) {
        ByteArrayInputStream cipheredInput = new ByteArrayInputStream(mAESCipherText);
        Mac mac = mHMAC.getMac();
        InputStream macStream = new MacLayeredInputStream(mac, cipheredInput);
        InputStream input = mAESCipher.getInputStream(macStream);
        readFully(input, new NullOutputStream());
        mac.doFinal();
        input.close();
    }
}
Also used : MacLayeredInputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) MacLayeredInputStream(com.facebook.crypto.benchmarks.mac.streams.MacLayeredInputStream) InputStream(java.io.InputStream) Mac(javax.crypto.Mac) NullOutputStream(com.google.common.io.NullOutputStream)

Aggregations

NullOutputStream (com.google.common.io.NullOutputStream)7 MacLayeredInputStream (com.facebook.crypto.benchmarks.mac.streams.MacLayeredInputStream)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 MacLayeredOutputStream (com.facebook.crypto.benchmarks.mac.streams.MacLayeredOutputStream)2 OutputStream (java.io.OutputStream)2 Mac (javax.crypto.Mac)2 PrintStream (java.io.PrintStream)1 Random (java.util.Random)1 BouncyCastleProvider (org.spongycastle.jce.provider.BouncyCastleProvider)1