Java 类org.bouncycastle.openpgp.operator.bc.BcPBEDataDecryptorFactory 实例源码

项目:jpgpj    文件:Decryptor.java   
/**
 * Builds a symmetric-key decryptor for the specified passphrase.
 */
protected PBEDataDecryptorFactory buildSymmetricKeyDecryptor(
String passphrase) {
    char[] chars = !Util.isEmpty(passphrase) ?
        passphrase.toCharArray() : new char[0];
    return new BcPBEDataDecryptorFactory(chars,
        new BcPGPDigestCalculatorProvider());
}
项目:gwt-crypto    文件:BcPGPPBETest.java   
/**
 * decrypt the passed in message stream
 */
private byte[] decryptMessage(
    byte[]    message,
    Date      date)
    throws Exception
{
    PGPObjectFactory         pgpF = new BcPGPObjectFactory(message);
    PGPEncryptedDataList     enc = (PGPEncryptedDataList)pgpF.nextObject();
    PGPPBEEncryptedData      pbe = (PGPPBEEncryptedData)enc.get(0);

    InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory(pass, new BcPGPDigestCalculatorProvider()));

    PGPObjectFactory         pgpFact = new BcPGPObjectFactory(clear);

    PGPLiteralData           ld = (PGPLiteralData)pgpFact.nextObject();

    ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
    if (!ld.getFileName().equals("test.txt")
        && !ld.getFileName().equals("_CONSOLE"))
    {
        fail("wrong filename in packet");
    }
    if (!ld.getModificationTime().equals(date))
    {
        fail("wrong modification time in packet: " + ld.getModificationTime().getTime() + " " + date.getTime());
    }

    InputStream              unc = ld.getInputStream();
    int                      ch;

    while ((ch = unc.read()) >= 0)
    {
        bOut.write(ch);
    }

    if (pbe.isIntegrityProtected() && !pbe.verify())
    {
        fail("integrity check failed");
    }

    return bOut.toByteArray();
}
项目:gwt-crypto    文件:BcPGPPBETest.java   
private byte[] decryptMessageBuffered(
    byte[]    message,
    Date      date)
    throws Exception
{
    PGPObjectFactory         pgpF = new PGPObjectFactory(message, new BcKeyFingerprintCalculator());
    PGPEncryptedDataList     enc = (PGPEncryptedDataList)pgpF.nextObject();
    PGPPBEEncryptedData      pbe = (PGPPBEEncryptedData)enc.get(0);

    InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory(pass, new BcPGPDigestCalculatorProvider()));

    PGPObjectFactory         pgpFact = new PGPObjectFactory(clear, new BcKeyFingerprintCalculator());

    PGPLiteralData           ld = (PGPLiteralData)pgpFact.nextObject();

    ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
    if (!ld.getFileName().equals("test.txt")
        && !ld.getFileName().equals("_CONSOLE"))
    {
        fail("wrong filename in packet");
    }
    if (!ld.getModificationTime().equals(date))
    {
        fail("wrong modification time in packet: " + ld.getModificationTime().getTime() + " " + date.getTime());
    }

    InputStream              unc = ld.getInputStream();
    byte[]                   buf = new byte[1024];
    int                      len;

    while ((len = unc.read(buf)) >= 0)
    {
        bOut.write(buf, 0, len);
    }

    if (pbe.isIntegrityProtected() && !pbe.verify())
    {
        fail("integrity check failed");
    }

    return bOut.toByteArray();
}
项目:irma_future_id    文件:BcPGPPBETest.java   
/**
 * decrypt the passed in message stream
 */
private byte[] decryptMessage(
    byte[]    message,
    Date      date)
    throws Exception
{
    PGPObjectFactory         pgpF = new PGPObjectFactory(message);
    PGPEncryptedDataList     enc = (PGPEncryptedDataList)pgpF.nextObject();
    PGPPBEEncryptedData      pbe = (PGPPBEEncryptedData)enc.get(0);

    InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory(pass, new BcPGPDigestCalculatorProvider()));

    PGPObjectFactory         pgpFact = new PGPObjectFactory(clear);

    PGPLiteralData           ld = (PGPLiteralData)pgpFact.nextObject();

    ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
    if (!ld.getFileName().equals("test.txt")
        && !ld.getFileName().equals("_CONSOLE"))
    {
        fail("wrong filename in packet");
    }
    if (!ld.getModificationTime().equals(date))
    {
        fail("wrong modification time in packet: " + ld.getModificationTime().getTime() + " " + date.getTime());
    }

    InputStream              unc = ld.getInputStream();
    int                      ch;

    while ((ch = unc.read()) >= 0)
    {
        bOut.write(ch);
    }

    if (pbe.isIntegrityProtected() && !pbe.verify())
    {
        fail("integrity check failed");
    }

    return bOut.toByteArray();
}
项目:irma_future_id    文件:BcPGPPBETest.java   
private byte[] decryptMessageBuffered(
    byte[]    message,
    Date      date)
    throws Exception
{
    PGPObjectFactory         pgpF = new PGPObjectFactory(message);
    PGPEncryptedDataList     enc = (PGPEncryptedDataList)pgpF.nextObject();
    PGPPBEEncryptedData      pbe = (PGPPBEEncryptedData)enc.get(0);

    InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory(pass, new BcPGPDigestCalculatorProvider()));

    PGPObjectFactory         pgpFact = new PGPObjectFactory(clear);;

    PGPLiteralData           ld = (PGPLiteralData)pgpFact.nextObject();

    ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
    if (!ld.getFileName().equals("test.txt")
        && !ld.getFileName().equals("_CONSOLE"))
    {
        fail("wrong filename in packet");
    }
    if (!ld.getModificationTime().equals(date))
    {
        fail("wrong modification time in packet: " + ld.getModificationTime().getTime() + " " + date.getTime());
    }

    InputStream              unc = ld.getInputStream();
    byte[]                   buf = new byte[1024];
    int                      len;

    while ((len = unc.read(buf)) >= 0)
    {
        bOut.write(buf, 0, len);
    }

    if (pbe.isIntegrityProtected() && !pbe.verify())
    {
        fail("integrity check failed");
    }

    return bOut.toByteArray();
}
项目:bc-java    文件:BcPGPPBETest.java   
/**
 * decrypt the passed in message stream
 */
private byte[] decryptMessage(
    byte[]    message,
    Date      date)
    throws Exception
{
    PGPObjectFactory         pgpF = new PGPObjectFactory(message);
    PGPEncryptedDataList     enc = (PGPEncryptedDataList)pgpF.nextObject();
    PGPPBEEncryptedData      pbe = (PGPPBEEncryptedData)enc.get(0);

    InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory(pass, new BcPGPDigestCalculatorProvider()));

    PGPObjectFactory         pgpFact = new PGPObjectFactory(clear);

    PGPLiteralData           ld = (PGPLiteralData)pgpFact.nextObject();

    ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
    if (!ld.getFileName().equals("test.txt")
        && !ld.getFileName().equals("_CONSOLE"))
    {
        fail("wrong filename in packet");
    }
    if (!ld.getModificationTime().equals(date))
    {
        fail("wrong modification time in packet: " + ld.getModificationTime().getTime() + " " + date.getTime());
    }

    InputStream              unc = ld.getInputStream();
    int                      ch;

    while ((ch = unc.read()) >= 0)
    {
        bOut.write(ch);
    }

    if (pbe.isIntegrityProtected() && !pbe.verify())
    {
        fail("integrity check failed");
    }

    return bOut.toByteArray();
}
项目:bc-java    文件:BcPGPPBETest.java   
private byte[] decryptMessageBuffered(
    byte[]    message,
    Date      date)
    throws Exception
{
    PGPObjectFactory         pgpF = new PGPObjectFactory(message);
    PGPEncryptedDataList     enc = (PGPEncryptedDataList)pgpF.nextObject();
    PGPPBEEncryptedData      pbe = (PGPPBEEncryptedData)enc.get(0);

    InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory(pass, new BcPGPDigestCalculatorProvider()));

    PGPObjectFactory         pgpFact = new PGPObjectFactory(clear);;

    PGPLiteralData           ld = (PGPLiteralData)pgpFact.nextObject();

    ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
    if (!ld.getFileName().equals("test.txt")
        && !ld.getFileName().equals("_CONSOLE"))
    {
        fail("wrong filename in packet");
    }
    if (!ld.getModificationTime().equals(date))
    {
        fail("wrong modification time in packet: " + ld.getModificationTime().getTime() + " " + date.getTime());
    }

    InputStream              unc = ld.getInputStream();
    byte[]                   buf = new byte[1024];
    int                      len;

    while ((len = unc.read(buf)) >= 0)
    {
        bOut.write(buf, 0, len);
    }

    if (pbe.isIntegrityProtected() && !pbe.verify())
    {
        fail("integrity check failed");
    }

    return bOut.toByteArray();
}