当前位置: 首页>>代码示例>>Java>>正文


Java CompressionAlgorithmTags类代码示例

本文整理汇总了Java中org.bouncycastle.bcpg.CompressionAlgorithmTags的典型用法代码示例。如果您正苦于以下问题:Java CompressionAlgorithmTags类的具体用法?Java CompressionAlgorithmTags怎么用?Java CompressionAlgorithmTags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompressionAlgorithmTags类属于org.bouncycastle.bcpg包,在下文中一共展示了CompressionAlgorithmTags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encrypt

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
public static byte[] encrypt( final byte[] message, final PGPPublicKey publicKey, boolean armored )
        throws PGPException
{
    try
    {
        final ByteArrayInputStream in = new ByteArrayInputStream( message );
        final ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        final PGPLiteralDataGenerator literal = new PGPLiteralDataGenerator();
        final PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator( CompressionAlgorithmTags.ZIP );
        final OutputStream pOut =
                literal.open( comData.open( bOut ), PGPLiteralData.BINARY, "filename", in.available(), new Date() );
        Streams.pipeAll( in, pOut );
        comData.close();
        final byte[] bytes = bOut.toByteArray();
        final PGPEncryptedDataGenerator generator = new PGPEncryptedDataGenerator(
                new JcePGPDataEncryptorBuilder( SymmetricKeyAlgorithmTags.AES_256 ).setWithIntegrityPacket( true )
                                                                                   .setSecureRandom(
                                                                                           new SecureRandom() )

                                                                                   .setProvider( provider ) );
        generator.addMethod( new JcePublicKeyKeyEncryptionMethodGenerator( publicKey ).setProvider( provider ) );
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        OutputStream theOut = armored ? new ArmoredOutputStream( out ) : out;
        OutputStream cOut = generator.open( theOut, bytes.length );
        cOut.write( bytes );
        cOut.close();
        theOut.close();
        return out.toByteArray();
    }
    catch ( Exception e )
    {
        throw new PGPException( "Error in encrypt", e );
    }
}
 
开发者ID:subutai-io,项目名称:base,代码行数:35,代码来源:PGPEncryptionUtil.java

示例2: encrypt

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
private byte[] encrypt(byte[] clearData, PGPPublicKey encKey) {
	try {
		byte[] compressedData = compress(clearData, CompressionAlgorithmTags.ZIP);
		ByteArrayOutputStream bOut = new ByteArrayOutputStream();
		OutputStream out = new ArmoredOutputStream(bOut);
		PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(
				new BcPGPDataEncryptorBuilder(PGPEncryptedDataGenerator.CAST5)
						.setSecureRandom(new SecureRandom()));
		encGen.addMethod(new BcPublicKeyKeyEncryptionMethodGenerator(encKey));
		OutputStream encOut = encGen.open(out, compressedData.length);
		encOut.write(compressedData);
		encOut.close();
		out.close();
		return bOut.toByteArray();
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:LuatixHQ,项目名称:openex-worker,代码行数:19,代码来源:EmailPgp.java

示例3: PGPCompressedDataGenerator

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
public PGPCompressedDataGenerator(
    int                    algorithm,
    int                    compression)
{
    switch (algorithm)
    {
        case CompressionAlgorithmTags.UNCOMPRESSED:
        case CompressionAlgorithmTags.ZIP:
        case CompressionAlgorithmTags.ZLIB:
        case CompressionAlgorithmTags.BZIP2:
            break;
        default:
            throw new IllegalArgumentException("unknown compression algorithm");
    }

    if (compression != Deflater.DEFAULT_COMPRESSION)
    {
        if ((compression < Deflater.NO_COMPRESSION) || (compression > Deflater.BEST_COMPRESSION))
        {
            throw new IllegalArgumentException("unknown compression level: " + compression);
        }
    }

    this.algorithm = algorithm;
    this.compression = compression;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:27,代码来源:PGPCompressedDataGenerator.java

示例4: doOpen

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
private void doOpen() throws IOException
{
    pkOut.write(algorithm);

    switch (algorithm)
    {
        case CompressionAlgorithmTags.UNCOMPRESSED:
            dOut = pkOut;
            break;
        case CompressionAlgorithmTags.ZIP:
            dOut = new SafeDeflaterOutputStream(pkOut, compression, true);
            break;
        case CompressionAlgorithmTags.ZLIB:
            dOut = new SafeDeflaterOutputStream(pkOut, compression, false);
            break;
        case CompressionAlgorithmTags.BZIP2:
            dOut = new SafeCBZip2OutputStream(pkOut);
            break;
        default:
            // Constructor should guard against this possibility
            throw new IllegalStateException();
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:24,代码来源:PGPCompressedDataGenerator.java

示例5: testExceptionDecryptorIncorrectInputFormatSymmetricEncryptedData

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
@Test
public void testExceptionDecryptorIncorrectInputFormatSymmetricEncryptedData() throws Exception {

    byte[] payload = "Not Correct Format".getBytes("UTF-8");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(new JcePGPDataEncryptorBuilder(SymmetricKeyAlgorithmTags.CAST5)
            .setSecureRandom(new SecureRandom()).setProvider(getProvider()));

    encGen.addMethod(new JcePBEKeyEncryptionMethodGenerator("pw".toCharArray()));

    OutputStream encOut = encGen.open(bos, new byte[1024]);
    PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(CompressionAlgorithmTags.ZIP);
    OutputStream comOut = new BufferedOutputStream(comData.open(encOut));
    PGPLiteralDataGenerator litData = new PGPLiteralDataGenerator();
    OutputStream litOut = litData.open(comOut, PGPLiteralData.BINARY, PGPLiteralData.CONSOLE, new Date(), new byte[1024]);
    litOut.write(payload);
    litOut.flush();
    litOut.close();
    comOut.close();
    encOut.close();
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    template.sendBody("direct:subkeyUnmarshal", bos.toByteArray());
    assertMockEndpointsSatisfied();

    checkThrownException(mock, IllegalArgumentException.class, null, "The input message body has an invalid format.");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:PGPDataFormatTest.java

示例6: getHeaders

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
protected Map<String, Object> getHeaders() {
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put(PGPKeyAccessDataFormat.KEY_USERID, "[email protected]");
    headers.put(PGPKeyAccessDataFormat.KEY_USERIDS, Collections.singletonList("second"));
    headers.put(PGPKeyAccessDataFormat.SIGNATURE_KEY_USERID, "[email protected]");
    headers.put(PGPDataFormat.KEY_PASSWORD, "sdude");
    headers.put(PGPDataFormat.SIGNATURE_KEY_PASSWORD, "sdude");
    headers.put(PGPKeyAccessDataFormat.ENCRYPTION_ALGORITHM, SymmetricKeyAlgorithmTags.AES_128);
    headers.put(PGPKeyAccessDataFormat.SIGNATURE_HASH_ALGORITHM, HashAlgorithmTags.SHA512);
    headers.put(PGPKeyAccessDataFormat.COMPRESSION_ALGORITHM, CompressionAlgorithmTags.ZLIB);
    headers.put(PGPKeyAccessDataFormat.SIGNATURE_KEY_USERIDS, Collections.singletonList("second"));
    return headers;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:PGPDataFormatDynamicTest.java

示例7: generateKeyPair

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
public SecretKey generateKeyPair(final String id, final char[] pass) throws CryptoException {
  try {

    // This object generates individual key-pairs.
    final RSAKeyPairGenerator kpg = new RSAKeyPairGenerator();
    kpg.init(new RSAKeyGenerationParameters(BigInteger.valueOf(0x10001), new SecureRandom(), 2048, 12));

    // First create the master (signing) key with the generator.
    final PGPKeyPair keyPair = new BcPGPKeyPair(PGPPublicKey.RSA_GENERAL, kpg.generateKeyPair(), new Date());

    // Add a self-signature on the id
    final PGPSignatureSubpacketGenerator signhashgen = new PGPSignatureSubpacketGenerator();
    signhashgen.setKeyFlags(true, KeyFlags.CERTIFY_OTHER | KeyFlags.SIGN_DATA | KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE);
    signhashgen.setPreferredCompressionAlgorithms(false, new int[] { CompressionAlgorithmTags.ZIP });
    signhashgen.setPreferredHashAlgorithms(false, new int[] { HashAlgorithmTags.SHA1 });
    signhashgen.setPreferredSymmetricAlgorithms(false, new int[] { SymmetricKeyAlgorithmTags.AES_256 });
    signhashgen.setFeature(false, Features.FEATURE_MODIFICATION_DETECTION);

    // Create a signature on the encryption subkey.
    final PGPSignatureSubpacketGenerator enchashgen = new PGPSignatureSubpacketGenerator();
    enchashgen.setKeyFlags(false, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE);

    // Objects used to encrypt the secret key.

    // Finally, create the keyring itself. The constructor
    // takes parameters that allow it to generate the self
    // signature.
    final PGPDigestCalculator sha1Calc = new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA1);
    final PBESecretKeyEncryptor secretKeyEncryptor = new BcPBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_128, sha1Calc).build(pass);
    final BcPGPContentSignerBuilder contentSigner = new BcPGPContentSignerBuilder(keyPair.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1);
    final PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, keyPair, id, sha1Calc,
        signhashgen.generate(), null, contentSigner, secretKeyEncryptor);

    // return new SimpleKeyPair(new BcPGPPublicKey(publicKeyRing.getPublicKey()),
    return new BcPGPSecretKey(keyRingGen.generateSecretKeyRing().getSecretKey());
  }
  catch (final Exception e) {
    throw new CryptoException(e);
  }
}
 
开发者ID:hsch,项目名称:bcpg-simple,代码行数:41,代码来源:BcPGPKeyFactory.java

示例8: encrypt

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
public static byte[] encrypt(
        final byte[] secret,
        final PGPPublicKey... keys)
        throws CryptographyException {
    final ByteArrayOutputStream out;
    try (ByteArrayInputStream in = new ByteArrayInputStream(secret);
        ByteArrayOutputStream bOut = new ByteArrayOutputStream()) {
        final PGPLiteralDataGenerator literal = new PGPLiteralDataGenerator();
        final PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(CompressionAlgorithmTags.UNCOMPRESSED);
        final OutputStream pOut = literal.open(
                comData.open(bOut),
                PGPLiteralData.BINARY,
                "filename",
                in.available(),
                new Date());
        Streams.pipeAll(in, pOut);
        comData.close();
        final byte[] bytes = bOut.toByteArray();
        final PGPEncryptedDataGenerator generator = new PGPEncryptedDataGenerator(
                new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5)
                        .setWithIntegrityPacket(true)
                        .setSecureRandom(new SecureRandom())
                    .setProvider(PROVIDER));
        for (final PGPPublicKey key : keys) {
            generator.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(key).setProvider(PROVIDER));
        }
        out = new ByteArrayOutputStream();
        final ArmoredOutputStream armor = new ArmoredOutputStream(out);
        final OutputStream cOut = generator.open(armor, bytes.length);
        cOut.write(bytes);
        cOut.close();
        armor.close();
    } catch (IOException | PGPException e) {
        throw new CryptographyException("Failed to encrypt.", e);
    }
    return out.toByteArray();
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:38,代码来源:PGP.java

示例9: signAndEncrypt

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
public static byte[] signAndEncrypt( final byte[] message, final PGPSecretKey secretKey, final String secretPwd,
                                     final PGPPublicKey publicKey, final boolean armored ) throws PGPException
{
    try
    {
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final PGPEncryptedDataGenerator encryptedDataGenerator = new PGPEncryptedDataGenerator(
                new JcePGPDataEncryptorBuilder( SymmetricKeyAlgorithmTags.AES_256 ).setWithIntegrityPacket( true )
                                                                                   .setSecureRandom(
                                                                                           new SecureRandom() )
                                                                                   .setProvider( provider ) );

        encryptedDataGenerator.addMethod(
                new JcePublicKeyKeyEncryptionMethodGenerator( publicKey ).setSecureRandom( new SecureRandom() )
                                                                         .setProvider( provider ) );

        final OutputStream theOut = armored ? new ArmoredOutputStream( out ) : out;
        final OutputStream encryptedOut = encryptedDataGenerator.open( theOut, new byte[4096] );

        final PGPCompressedDataGenerator compressedDataGenerator =
                new PGPCompressedDataGenerator( CompressionAlgorithmTags.ZIP );
        final OutputStream compressedOut = compressedDataGenerator.open( encryptedOut, new byte[4096] );
        final PGPPrivateKey privateKey = secretKey.extractPrivateKey(
                new JcePBESecretKeyDecryptorBuilder().setProvider( provider ).build( secretPwd.toCharArray() ) );
        final PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(
                new JcaPGPContentSignerBuilder( secretKey.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1 )
                        .setProvider( provider ) );
        signatureGenerator.init( PGPSignature.BINARY_DOCUMENT, privateKey );
        final Iterator<?> it = secretKey.getPublicKey().getUserIDs();
        if ( it.hasNext() )
        {
            final PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
            spGen.setSignerUserID( false, ( String ) it.next() );
            signatureGenerator.setHashedSubpackets( spGen.generate() );
        }
        signatureGenerator.generateOnePassVersion( false ).encode( compressedOut );
        final PGPLiteralDataGenerator literalDataGenerator = new PGPLiteralDataGenerator();
        final OutputStream literalOut = literalDataGenerator
                .open( compressedOut, PGPLiteralData.BINARY, "filename", new Date(), new byte[4096] );
        final InputStream in = new ByteArrayInputStream( message );
        final byte[] buf = new byte[4096];
        for ( int len; ( len = in.read( buf ) ) > 0; )
        {
            literalOut.write( buf, 0, len );
            signatureGenerator.update( buf, 0, len );
        }
        in.close();
        literalDataGenerator.close();
        signatureGenerator.generate().encode( compressedOut );
        compressedDataGenerator.close();
        encryptedDataGenerator.close();
        theOut.close();
        return out.toByteArray();
    }
    catch ( Exception e )
    {
        throw new PGPException( "Error in signAndEncrypt", e );
    }
}
 
开发者ID:subutai-io,项目名称:base,代码行数:60,代码来源:PGPEncryptionUtil.java

示例10: generateKeyRingGenerator

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
private static PGPKeyRingGenerator generateKeyRingGenerator( String id, char[] pass, int s2kcount, int keySize,
                                                             KeyPair keyPair ) throws PGPException
{
    // This object generates individual key-pairs.
    RSAKeyPairGenerator kpg = new RSAKeyPairGenerator();

    // Boilerplate RSA parameters, no need to change anything
    // except for the RSA key-size (2048). You can use whatever
    // key-size makes sense for you -- 4096, etc.
    kpg.init( new RSAKeyGenerationParameters( BigInteger.valueOf( 0x10001 ), new SecureRandom(), keySize, 12 ) );

    // First create the master (signing) key with the generator.
    PGPKeyPair rsakp_sign = new BcPGPKeyPair( PGPPublicKey.RSA_GENERAL, kpg.generateKeyPair(), new Date() );
    // Then an encryption subkey.
    PGPKeyPair rsakp_enc = new BcPGPKeyPair( PGPPublicKey.RSA_GENERAL, kpg.generateKeyPair(), new Date() );

    keyPair.setPrimaryKeyId( Long.toHexString( rsakp_sign.getKeyID() ) );
    keyPair.setPrimaryKeyFingerprint( BytesToHex( rsakp_sign.getPublicKey().getFingerprint() ) );
    keyPair.setSubKeyId( Long.toHexString( rsakp_enc.getKeyID() ) );
    keyPair.setSubKeyFingerprint( BytesToHex( rsakp_enc.getPublicKey().getFingerprint() ) );

    // Add a self-signature on the id
    PGPSignatureSubpacketGenerator signhashgen = new PGPSignatureSubpacketGenerator();

    // Add signed metadata on the signature.
    // 1) Declare its purpose
    signhashgen.setKeyFlags( false, KeyFlags.SIGN_DATA | KeyFlags.CERTIFY_OTHER );
    // 2) Set preferences for secondary crypto algorithms to use
    //    when sending messages to this key.
    signhashgen.setPreferredSymmetricAlgorithms( false, new int[] {
            SymmetricKeyAlgorithmTags.AES_256, SymmetricKeyAlgorithmTags.AES_192, SymmetricKeyAlgorithmTags.AES_128,
            SymmetricKeyAlgorithmTags.CAST5, SymmetricKeyAlgorithmTags.TRIPLE_DES
    } );
    signhashgen.setPreferredHashAlgorithms( false, new int[] {
            HashAlgorithmTags.SHA256, HashAlgorithmTags.SHA1, HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512,
            HashAlgorithmTags.SHA224,
    } );
    signhashgen.setPreferredCompressionAlgorithms( false, new int[] {
            CompressionAlgorithmTags.ZLIB, CompressionAlgorithmTags.BZIP2, CompressionAlgorithmTags.ZIP
    } );
    // 3) Request senders add additional checksums to the
    //    message (useful when verifying unsigned messages.)
    signhashgen.setFeature( false, Features.FEATURE_MODIFICATION_DETECTION );

    // Create a signature on the encryption subkey.
    PGPSignatureSubpacketGenerator enchashgen = new PGPSignatureSubpacketGenerator();
    // Add metadata to declare its purpose
    enchashgen.setKeyFlags( false, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE );

    // Objects used to encrypt the secret key.
    PGPDigestCalculator sha1Calc = new BcPGPDigestCalculatorProvider().get( HashAlgorithmTags.SHA1 );

    // bcpg 1.48 exposes this API that includes s2kcount. Earlier
    // versions use a default of 0x60.
    PBESecretKeyEncryptor pske =
            ( new BcPBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc, s2kcount ) ).build( pass );
    // Finally, create the keyring itself. The constructor
    // takes parameters that allow it to generate the self
    // signature.
    PGPKeyRingGenerator keyRingGen =
            new PGPKeyRingGenerator( PGPSignature.POSITIVE_CERTIFICATION, rsakp_sign, id, sha1Calc,
                    signhashgen.generate(), null,
                    new BcPGPContentSignerBuilder( rsakp_sign.getPublicKey().getAlgorithm(),
                            HashAlgorithmTags.SHA1 ), pske );

    // Add our encryption subkey, together with its signature.
    keyRingGen.addSubKey( rsakp_enc, enchashgen.generate(), null );
    return keyRingGen;
}
 
开发者ID:subutai-io,项目名称:base,代码行数:70,代码来源:PGPEncryptionUtil.java

示例11: compress

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
private static byte[] compress( byte data[] ) throws IOException
{
    PGPCompressedDataGenerator compressGen = new PGPCompressedDataGenerator( CompressionAlgorithmTags.ZIP );

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    OutputStream compressOut = compressGen.open( bos );

    OutputStream os =
            new PGPLiteralDataGenerator().open( compressOut, PGPLiteralData.BINARY, "", data.length, new Date() );

    os.write( data );

    os.close();

    compressGen.close();

    return bos.toByteArray();
}
 
开发者ID:subutai-io,项目名称:base,代码行数:20,代码来源:PGPEncrypt.java

示例12: getCompressionAlgorithm

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
protected int getCompressionAlgorithm() {
    return CompressionAlgorithmTags.BZIP2;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:PGPDataFormatTest.java

示例13: run

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
public void run(final char[] passphrase, final InputStream inputStream, final OutputStream outputStream) throws IOException, CryptoException {
  try {
    final OutputStream armor = new ArmoredOutputStream(outputStream);

    final PGPEncryptedDataGenerator encryptedDataGenerator = new PGPEncryptedDataGenerator(new JcePGPDataEncryptorBuilder(
        SymmetricKeyAlgorithmTags.AES_128).setWithIntegrityPacket(true).setSecureRandom(new SecureRandom()).setProvider(new BouncyCastleProvider()));
    encryptedDataGenerator.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(publicKey).setSecureRandom(new SecureRandom()).setProvider(
        new BouncyCastleProvider()));

    final OutputStream encryptedOut = encryptedDataGenerator.open(armor, new byte[4096]);

    final PGPCompressedDataGenerator compressedDataGenerator = new PGPCompressedDataGenerator(CompressionAlgorithmTags.ZIP);
    final OutputStream compressedOut = compressedDataGenerator.open(encryptedOut, new byte[4096]);

    final PGPPrivateKey privateKey = secretKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider(new BouncyCastleProvider())
        .build(passphrase));

    final PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(secretKey.getPublicKey()
        .getAlgorithm(), HashAlgorithmTags.SHA1).setProvider(new BouncyCastleProvider()));
    signatureGenerator.init(PGPSignature.BINARY_DOCUMENT, privateKey);
    final Iterator<?> it = secretKey.getPublicKey().getUserIDs();
    if (it.hasNext()) {
      final PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
      spGen.setSignerUserID(false, (String) it.next());
      signatureGenerator.setHashedSubpackets(spGen.generate());
    }
    signatureGenerator.generateOnePassVersion(false).encode(compressedOut);

    final PGPLiteralDataGenerator literalDataGenerator = new PGPLiteralDataGenerator();
    final OutputStream literalOut = literalDataGenerator.open(compressedOut, PGPLiteralData.BINARY, "", new Date(), new byte[4096]);
    final byte[] buf = new byte[4096];
    for (int len = 0; (len = inputStream.read(buf)) > 0;) {
      literalOut.write(buf, 0, len);
      signatureGenerator.update(buf, 0, len);
    }
    literalDataGenerator.close();
    signatureGenerator.generate().encode(compressedOut);
    compressedDataGenerator.close();
    encryptedDataGenerator.close();
    armor.close();
  }
  catch (final Exception e) {
    throw new CryptoException(e);
  }

}
 
开发者ID:hsch,项目名称:bcpg-simple,代码行数:47,代码来源:BcPGPSignEncryptTransform.java

示例14: noneHasTheSameValueAsTheBCTag

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
@Test
public void noneHasTheSameValueAsTheBCTag() throws Exception {
    assertThat(CompressionAlgorithm.NONE.value())
            .isEqualTo(CompressionAlgorithmTags.UNCOMPRESSED);
}
 
开发者ID:codahale,项目名称:gpgj,代码行数:6,代码来源:CompressionAlgorithmTest.java

示例15: zlibHasTheSameValueAsTheBCTag

import org.bouncycastle.bcpg.CompressionAlgorithmTags; //导入依赖的package包/类
@Test
public void zlibHasTheSameValueAsTheBCTag() throws Exception {
    assertThat(CompressionAlgorithm.ZLIB.value())
            .isEqualTo(CompressionAlgorithmTags.ZLIB);
}
 
开发者ID:codahale,项目名称:gpgj,代码行数:6,代码来源:CompressionAlgorithmTest.java


注:本文中的org.bouncycastle.bcpg.CompressionAlgorithmTags类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。