خرید بک لینک

Vote count: 0

Am using the standard technique of using a RSA key/pair whose public key encrypts a 16 byte random key which encrypts my data using AES/CBC/PKCS5Padding. I am using bouncy castle for my needs to encrypt streams of usually large data (512MB+). On ruing performance tests to understand the overhead of encryption I am seeing that encryption is nearly 30-40% more expensive than un-encrypted data. Is this expected ?

Sample code

public InputStream encryptStream(InputStream streamToEncrypt, byte[] key, byte[] iv, byte[] encryptedKey // 256 bytes) {

        final Cipher cipher = getCipher(Cipher.ENCRYPT_MODE, key, iv);
        byte[] civ = cipher.getIV();
         ...
        ByteArrayInputStream ivEncryptedKeyStream = new ByteArrayInputStream(ivEncryptedKeyArray);
        CipherInputStream encrypted = new CipherInputStream(streamToEncrypt, cipher);

        retu new SequenceInputStream(ivEncryptedKeyStream, encrypted);
    }

elsewhere

 InputStream encryptedStream = ...encryptStream(plainStream, key, iv, encKey);
 IOUtils.copyLarge(encryptedStream, outputStream);

I have played around with java server args ; confirmed that the AES-NI instruction set is on etc. Just wanted to have an idea on what overhead should I be expecting with encrypting large streams ?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 2 مرداد 1395 ساعت: 19:28

صفحه بندی