Java 类org.bouncycastle.crypto.io.CipherInputStream 实例源码

项目:gwt-crypto    文件:BcUtil.java   
public static PGPDataDecryptor createDataDecryptor(boolean withIntegrityPacket, BlockCipher engine, byte[] key)
{
    final BufferedBlockCipher c = createStreamCipher(false, engine, withIntegrityPacket, key);

    return new PGPDataDecryptor()
    {
        public InputStream getInputStream(InputStream in)
        {
            return new CipherInputStream(in, c);
        }

        public int getBlockSize()
        {
            return c.getBlockSize();
        }

        public PGPDigestCalculator getIntegrityCalculator()
        {
            return new SHA1PGPDigestCalculator();
        }
    };
}
项目:gwt-crypto    文件:CipherStreamTest.java   
private InputStream createCipherInputStream(byte[] data, Object cipher)
{
    ByteArrayInputStream input = new ByteArrayInputStream(data);
    if (cipher instanceof BufferedBlockCipher)
    {
        return new CipherInputStream(input, (BufferedBlockCipher)cipher);
    }
    else if (cipher instanceof AEADBlockCipher)
    {
        return new CipherInputStream(input, (AEADBlockCipher)cipher);
    }
    else
    {
        return new CipherInputStream(input, (StreamCipher)cipher);
    }
}
项目:bunkr    文件:MultilayeredInputStream.java   
public MultilayeredInputStream(ArchiveInfoContext context, FileInventoryItem target)
{
    this.emptyFile = target.getActualSize() == 0;
    if (! emptyFile)
    {
        this.baseStream = new BlockReaderInputStream(context.filePath, context.getBlockSize(), target);
        this.topstream = this.baseStream;

        if (target.isEncrypted())
        {
            this.topstream = new CipherInputStream(
                    this.topstream, new BufferedBlockCipher(CipherBuilder.buildCipherForFile(target, false))
            );
        }
        this.topstream = new InflaterInputStream(this.topstream);
    }
}
项目:jCryptTool    文件:AesEncryptionService.java   
@Override
public InputStream decryptedInputStream(final Path path, final String password) throws IOException,
        DecryptionFailedException {
    try {
        InputStream in = new BufferedInputStream(Files.newInputStream(path));
        byte[] initBlock = readInitBlock(in);
        byte[] salt = extractSalt(initBlock);
        byte[] iv = extractIV(initBlock);
        byte[] key = generateKey(password, salt);

        PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESEngine()),
                new PKCS7Padding());
        KeyParameter keyParam = new KeyParameter(key);
        CipherParameters params = new ParametersWithIV(keyParam, iv);
        cipher.init(false, params);

        return new CipherInputStream(in, cipher);
    } catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
        throw new DecryptionFailedException(e);
    }
}
项目:keepassj    文件:StandardAesEngine.java   
private static InputStream CreateInputStream(InputStream s, boolean bEncrypt, byte[] pbKey, byte[] pbIV)
        {

            byte[] pbLocalIV = new byte[16];
            System.arraycopy(pbIV, 0, pbLocalIV, 0, 16);

            byte[] pbLocalKey = new byte[32];
            System.arraycopy(pbKey, 0, pbLocalKey, 0, 32);

            try {
//                Cipher r = Cipher.getInstance("AES/CBC/PKCS5Padding");
//                IvParameterSpec ivspec = new IvParameterSpec(pbLocalIV);
//                SecretKeySpec keyspec = new SecretKeySpec(pbLocalKey, "AES");
//                r.init(Cipher.DECRYPT_MODE, keyspec, ivspec);

                BlockCipher aes = AesEngines.createAesEngine();
                KeyParameter key = new KeyParameter(pbLocalKey);
                ParametersWithIV iv = new ParametersWithIV(key, pbLocalIV);
                BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(aes));
                cipher.init(false, iv);

                return new CipherInputStream(s, cipher);
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        }
项目:sambox    文件:SecurityHandler.java   
/**
 * Encrypt or decrypt data with AES256.
 *
 * @param data The data to encrypt.
 * @param output The output to write the encrypted data to.
 *
 * @throws IOException If there is an error reading the data.
 */
private void decryptDataAES256(InputStream data, OutputStream output) throws IOException
{
    byte[] iv = new byte[16];

    // read IV from stream
    int ivSize = data.read(iv);
    if (ivSize == -1)
    {
        return;
    }

    if (ivSize != iv.length)
    {
        throw new IOException("AES initialization vector not fully read: only " + ivSize
                + " bytes read instead of " + iv.length);
    }
    PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(
            new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false, new ParametersWithIV(new KeyParameter(encryptionKey), iv));
    try (CipherInputStream cis = new CipherInputStream(data, cipher))
    {
        org.apache.commons.io.IOUtils.copy(cis, output);
    }
}
项目:CryptMeme    文件:BcUtil.java   
public static PGPDataDecryptor createDataDecryptor(boolean withIntegrityPacket, BlockCipher engine, byte[] key)
{
    final BufferedBlockCipher c = createStreamCipher(false, engine, withIntegrityPacket, key);

    return new PGPDataDecryptor()
    {
        public InputStream getInputStream(InputStream in)
        {
            return new CipherInputStream(in, c);
        }

        public int getBlockSize()
        {
            return c.getBlockSize();
        }

        public PGPDigestCalculator getIntegrityCalculator()
        {
            return new SHA1PGPDigestCalculator();
        }
    };
}
项目:irma_future_id    文件:BcUtil.java   
public static PGPDataDecryptor createDataDecryptor(boolean withIntegrityPacket, BlockCipher engine, byte[] key)
{
    final BufferedBlockCipher c = createStreamCipher(false, engine, withIntegrityPacket, key);

    return new PGPDataDecryptor()
    {
        public InputStream getInputStream(InputStream in)
        {
            return new CipherInputStream(in, c);
        }

        public int getBlockSize()
        {
            return c.getBlockSize();
        }

        public PGPDigestCalculator getIntegrityCalculator()
        {
            return new SHA1PGPDigestCalculator();
        }
    };
}
项目:bc-java    文件:BcUtil.java   
public static PGPDataDecryptor createDataDecryptor(boolean withIntegrityPacket, BlockCipher engine, byte[] key)
{
    final BufferedBlockCipher c = createStreamCipher(false, engine, withIntegrityPacket, key);

    return new PGPDataDecryptor()
    {
        public InputStream getInputStream(InputStream in)
        {
            return new CipherInputStream(in, c);
        }

        public int getBlockSize()
        {
            return c.getBlockSize();
        }

        public PGPDigestCalculator getIntegrityCalculator()
        {
            return new SHA1PGPDigestCalculator();
        }
    };
}
项目:toffi    文件:BaseBlockCipherEncoder.java   
@Override
public void transform(InputStream in, OutputStream out) {
    try {
        AEADBlockCipher aeadBlockCipher = createAEADBlockCipher();

        AEADParameters aeadParameters = new AEADParameters(new KeyParameter(key.getKey()),
                Constants.GCM_MAC_SIZE, nonce, nonSecretPayload);

        aeadBlockCipher.init(true, aeadParameters);

        // Write nonce as first 4 bytes
        out.write(this.nonce);
        try (CipherInputStream cipherInputStream = new CipherInputStream(in, aeadBlockCipher)) {
            IOUtils.copy(cipherInputStream, out);
        }
    } catch (Exception ex) {
        LOG.error(ex.getMessage(), ex);
        throw new EncryptorException(ex.getMessage(), ex);
    }
}
项目:ipack    文件:BcPKCS12PBEInputDecryptorProviderBuilder.java   
public InputDecryptorProvider build(final char[] password)
{
    return new InputDecryptorProvider()
    {
        public InputDecryptor get(final AlgorithmIdentifier algorithmIdentifier)
        {
            final PaddedBufferedBlockCipher engine = PKCS12PBEUtils.getEngine(algorithmIdentifier.getAlgorithm());

            PKCS12PBEParams           pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());

            CipherParameters params = PKCS12PBEUtils.createCipherParameters(algorithmIdentifier.getAlgorithm(), digest, engine.getBlockSize(), pbeParams, password);

            engine.init(false, params);

            return new InputDecryptor()
            {
                public AlgorithmIdentifier getAlgorithmIdentifier()
                {
                    return algorithmIdentifier;
                }

                public InputStream getInputStream(InputStream input)
                {
                    return new CipherInputStream(input, engine);
                }

                public GenericKey getKey()
                {
                    return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
                }
            };
        }
    };

}
项目:ipack    文件:BcPasswordEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    KeyParameter secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, derivedKey, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataOut)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataOut, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataOut, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:ipack    文件:BcRSAKeyTransEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    CipherParameters secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataIn)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataIn, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataIn, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:gwt-crypto    文件:BcPKCS12PBEInputDecryptorProviderBuilder.java   
public InputDecryptorProvider build(final char[] password)
{
    return new InputDecryptorProvider()
    {
        public InputDecryptor get(final AlgorithmIdentifier algorithmIdentifier)
        {
            final PaddedBufferedBlockCipher engine = PKCS12PBEUtils.getEngine(algorithmIdentifier.getAlgorithm());

            PKCS12PBEParams           pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());

            CipherParameters params = PKCS12PBEUtils.createCipherParameters(algorithmIdentifier.getAlgorithm(), digest, engine.getBlockSize(), pbeParams, password);

            engine.init(false, params);

            return new InputDecryptor()
            {
                public AlgorithmIdentifier getAlgorithmIdentifier()
                {
                    return algorithmIdentifier;
                }

                public InputStream getInputStream(InputStream input)
                {
                    return new CipherInputStream(input, engine);
                }

                public GenericKey getKey()
                {
                    return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
                }
            };
        }
    };

}
项目:gwt-crypto    文件:BcPasswordEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    KeyParameter secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, derivedKey, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataOut)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataOut, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataOut, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:gwt-crypto    文件:BcRSAKeyTransEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    CipherParameters secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataIn)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataIn, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataIn, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:Aki-SSL    文件:BcPKCS12PBEInputDecryptorProviderBuilder.java   
public InputDecryptorProvider build(final char[] password)
{
    return new InputDecryptorProvider()
    {
        public InputDecryptor get(final AlgorithmIdentifier algorithmIdentifier)
        {
            final PaddedBufferedBlockCipher engine = PKCS12PBEUtils.getEngine(algorithmIdentifier.getAlgorithm());

            PKCS12PBEParams           pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());

            CipherParameters params = PKCS12PBEUtils.createCipherParameters(algorithmIdentifier.getAlgorithm(), digest, engine.getBlockSize(), pbeParams, password);

            engine.init(false, params);

            return new InputDecryptor()
            {
                public AlgorithmIdentifier getAlgorithmIdentifier()
                {
                    return algorithmIdentifier;
                }

                public InputStream getInputStream(InputStream input)
                {
                    return new CipherInputStream(input, engine);
                }

                public GenericKey getKey()
                {
                    return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
                }
            };
        }
    };

}
项目:Aki-SSL    文件:BcPasswordEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    KeyParameter secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, derivedKey, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataOut)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataOut, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataOut, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:Aki-SSL    文件:BcRSAKeyTransEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    CipherParameters secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataIn)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataIn, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataIn, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:secrete    文件:Curve25519PrivateKey.java   
public static Curve25519PrivateKey deserialize(InputStream in, char[] password) throws IOException {

        try {

            // check magic number
            byte[] mn = new byte[MagicNumbers.PRIVATE_KEY.length];
            IOUtils.readFully(in, mn, 0, mn.length);
            if (!Arrays.areEqual(mn, MagicNumbers.PRIVATE_KEY))
                throw new IllegalArgumentException("Wrong key file format");

            // read initial vector
            byte[] iv = new byte[16];
            IOUtils.readFully(in, iv, 0, iv.length);

            // read salt
            byte[] salt = new byte[64];
            IOUtils.readFully(in, salt, 0, salt.length);

            // initialize cipher
            CipherParameters params = new ParametersWithIV(new KeyParameter(deriveKey(password, salt)), iv);
            BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESEngine()), new PKCS7Padding());
            cipher.reset();
            cipher.init(false, params);

            // decrypt key
            CipherInputStream cin = new CipherInputStream(in, cipher);
            byte[] key = new byte[Curve25519.KEY_SIZE];
            IOUtils.readFully(cin, key, 0, key.length);

            // return key instance
            return new Curve25519PrivateKey(key);

        } catch (UnsupportedEncodingException ex) {

            throw new UnsupportedOperationException(ex.getMessage(), ex);
        }
    }
项目:InflatableDonkey    文件:StreamCryptor.java   
public CipherInputStream newCipherInputStream(InputStream is, byte[] password) throws IOException {
    byte[] salt = IOUtils.readFully(is, saltLength);
    byte[] nonce = IOUtils.readFully(is, nonceLength);
    byte[] dk = kdf.apply(password, salt);
    GCMBlockCipher cipher = new GCMBlockCipher(new AESEngine());
    AEADParameters parameters = new AEADParameters(new KeyParameter(dk), tagLength * 8, nonce);
    cipher.init(false, parameters);
    return new CipherInputStream(is, cipher);
}
项目:Zom-Android    文件:Downloader.java   
public static InputStream setupInputStream(InputStream is, byte[] keyAndIv) {
    if (keyAndIv != null && keyAndIv.length == 48) {
        byte[] key = new byte[32];
        byte[] iv = new byte[16];
        System.arraycopy(keyAndIv, 0, iv, 0, 16);
        System.arraycopy(keyAndIv, 16, key, 0, 32);
        AEADBlockCipher cipher = new GCMBlockCipher(new AESEngine());
        cipher.init(true, new AEADParameters(new KeyParameter(key), 128, iv));
        return new CipherInputStream(is, cipher);
    } else {
        return is;
    }
}
项目:irma_future_id    文件:BcPKCS12PBEInputDecryptorProviderBuilder.java   
public InputDecryptorProvider build(final char[] password)
{
    return new InputDecryptorProvider()
    {
        public InputDecryptor get(final AlgorithmIdentifier algorithmIdentifier)
        {
            final PaddedBufferedBlockCipher engine = PKCS12PBEUtils.getEngine(algorithmIdentifier.getAlgorithm());

            PKCS12PBEParams           pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());

            CipherParameters params = PKCS12PBEUtils.createCipherParameters(algorithmIdentifier.getAlgorithm(), digest, engine.getBlockSize(), pbeParams, password);

            engine.init(false, params);

            return new InputDecryptor()
            {
                public AlgorithmIdentifier getAlgorithmIdentifier()
                {
                    return algorithmIdentifier;
                }

                public InputStream getInputStream(InputStream input)
                {
                    return new CipherInputStream(input, engine);
                }

                public GenericKey getKey()
                {
                    return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
                }
            };
        }
    };

}
项目:irma_future_id    文件:BcPasswordEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    KeyParameter secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, derivedKey, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataOut)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataOut, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataOut, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:irma_future_id    文件:BcRSAKeyTransEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    CipherParameters secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataIn)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataIn, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataIn, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:bc-java    文件:BcPKCS12PBEInputDecryptorProviderBuilder.java   
public InputDecryptorProvider build(final char[] password)
{
    return new InputDecryptorProvider()
    {
        public InputDecryptor get(final AlgorithmIdentifier algorithmIdentifier)
        {
            final PaddedBufferedBlockCipher engine = PKCS12PBEUtils.getEngine(algorithmIdentifier.getAlgorithm());

            PKCS12PBEParams           pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());

            CipherParameters params = PKCS12PBEUtils.createCipherParameters(algorithmIdentifier.getAlgorithm(), digest, engine.getBlockSize(), pbeParams, password);

            engine.init(false, params);

            return new InputDecryptor()
            {
                public AlgorithmIdentifier getAlgorithmIdentifier()
                {
                    return algorithmIdentifier;
                }

                public InputStream getInputStream(InputStream input)
                {
                    return new CipherInputStream(input, engine);
                }

                public GenericKey getKey()
                {
                    return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
                }
            };
        }
    };

}
项目:bc-java    文件:BcPasswordEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    KeyParameter secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, derivedKey, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataOut)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataOut, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataOut, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:bc-java    文件:BcRSAKeyTransEnvelopedRecipient.java   
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    CipherParameters secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);

    final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);

    return new RecipientOperator(new InputDecryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return contentEncryptionAlgorithm;
        }

        public InputStream getInputStream(InputStream dataIn)
        {
            if (dataCipher instanceof BufferedBlockCipher)
            {
                return new CipherInputStream(dataIn, (BufferedBlockCipher)dataCipher);
            }
            else
            {
                return new CipherInputStream(dataIn, (StreamCipher)dataCipher);
            }
        }
    });
}
项目:InflatableDonkey    文件:ChunkListDecrypter.java   
CipherInputStream cipherInputStream(InputStream inputStream, byte[] key, byte[] checksum) {
    CFBBlockCipher cipher = new CFBBlockCipher(new AESFastEngine(), 128);
    KeyParameter keyParameter = new KeyParameter(key);
    cipher.init(false, keyParameter);
    return new CipherInputStream(inputStream, cipher);
}
项目:InflatableDonkey    文件:FileStreamWriter.java   
static InputStream decryptStream(InputStream in, XFileKey keyCipher) {
    BlockCipher cipher = keyCipher.ciphers().get();
    cipher.init(false, new KeyParameter(keyCipher.key()));
    return new CipherInputStream(in, new BufferedBlockCipher(cipher));
}
项目:sambox    文件:AESEngineNoPadding.java   
@Override
public InputStream encryptStream(InputStream data, byte[] key, byte[] iv)
{
    init(key, iv);
    return new CipherInputStream(data, cipher);
}
项目:sambox    文件:ARC4Engine.java   
@Override
public InputStream encryptStream(InputStream data, byte[] key)
{
    init(key);
    return new CipherInputStream(data, cipher);
}
项目:RuneCraftery    文件:CryptManager.java   
public static InputStream func_75888_a(SecretKey p_75888_0_, InputStream p_75888_1_) {
   return new CipherInputStream(p_75888_1_, func_75892_a(false, p_75888_0_));
}
项目:RuneCraftery    文件:CryptManager.java   
public static InputStream decryptInputStream(SecretKey par0SecretKey, InputStream par1InputStream)
{
    return new CipherInputStream(par1InputStream, createBufferedBlockCipher(false, par0SecretKey));
}
项目:Hakkit    文件:CryptManager.java   
public static InputStream decryptInputStream(SecretKey par0SecretKey, InputStream par1InputStream)
{
    return new CipherInputStream(par1InputStream, createBufferedBlockCipher(false, par0SecretKey));
}
项目:BetterNutritionMod    文件:CryptManager.java   
public static InputStream decryptInputStream(SecretKey par0SecretKey, InputStream par1InputStream)
{
    return new CipherInputStream(par1InputStream, createBufferedBlockCipher(false, par0SecretKey));
}
项目:DarkBot    文件:EncryptionUtil.java   
public static InputStream decryptInputStream(InputStream inputStream, SecretKey key) {
    return new CipherInputStream(inputStream, createBlockCipher(key, false));
}
项目:portalsammler    文件:CryptoHelper.java   
public static CipherInputStream createAesDecryptStream(final InputStream is, final byte[] key,
        final SecureRandom srand) {
    final PaddedBufferedBlockCipher cipher = initAes(key, srand, false);
    return new CipherInputStream(is, cipher);
}