Java 类org.bouncycastle.openpgp.operator.PGPContentSigner 实例源码

项目:CryptMeme    文件:JcaPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, PGPPrivateKey privateKey)
    throws PGPException
{
    if (privateKey instanceof JcaPGPPrivateKey)
    {
        return build(signatureType, privateKey.getKeyID(), ((JcaPGPPrivateKey)privateKey).getPrivateKey());
    }
    else
    {
        return build(signatureType, privateKey.getKeyID(), keyConverter.getPrivateKey(privateKey));
    }
}
项目:irma_future_id    文件:JcaPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, PGPPrivateKey privateKey)
    throws PGPException
{
    if (privateKey instanceof JcaPGPPrivateKey)
    {
        return build(signatureType, privateKey.getKeyID(), ((JcaPGPPrivateKey)privateKey).getPrivateKey());
    }
    else
    {
        return build(signatureType, privateKey.getKeyID(), keyConverter.getPrivateKey(privateKey));
    }
}
项目:bc-java    文件:JcaPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, PGPPrivateKey privateKey)
    throws PGPException
{
    if (privateKey instanceof JcaPGPPrivateKey)
    {
        return build(signatureType, privateKey.getKeyID(), ((JcaPGPPrivateKey)privateKey).getPrivateKey());
    }
    else
    {
        return build(signatureType, privateKey.getKeyID(), keyConverter.getPrivateKey(privateKey));
    }
}
项目:gwt-crypto    文件:BcPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, final PGPPrivateKey privateKey)
    throws PGPException
{
    final PGPDigestCalculator digestCalculator = digestCalculatorProvider.get(hashAlgorithm);
    final Signer signer = BcImplProvider.createSigner(keyAlgorithm, hashAlgorithm);

    if (random != null)
    {
        signer.init(true, new ParametersWithRandom(keyConverter.getPrivateKey(privateKey), random));
    }
    else
    {
        signer.init(true, keyConverter.getPrivateKey(privateKey));
    }

    return new PGPContentSigner()
    {
        public int getType()
        {
            return signatureType;
        }

        public int getHashAlgorithm()
        {
            return hashAlgorithm;
        }

        public int getKeyAlgorithm()
        {
            return keyAlgorithm;
        }

        public long getKeyID()
        {
            return privateKey.getKeyID();
        }

        public OutputStream getOutputStream()
        {
            return new TeeOutputStream(new SignerOutputStream(signer), digestCalculator.getOutputStream());
        }

        public byte[] getSignature()
        {
            try
            {
                return signer.generateSignature();
            }
            catch (CryptoException e)
            {    // TODO: need a specific runtime exception for PGP operators.
                throw new IllegalStateException("unable to create signature");
            }
        }

        public byte[] getDigest()
        {
            return digestCalculator.getDigest();
        }
    };
}
项目:CryptMeme    文件:BcPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, final PGPPrivateKey privateKey)
    throws PGPException
{
    final PGPDigestCalculator digestCalculator = digestCalculatorProvider.get(hashAlgorithm);
    final Signer signer = BcImplProvider.createSigner(keyAlgorithm, hashAlgorithm);

    if (random != null)
    {
        signer.init(true, new ParametersWithRandom(keyConverter.getPrivateKey(privateKey), random));
    }
    else
    {
        signer.init(true, keyConverter.getPrivateKey(privateKey));
    }

    return new PGPContentSigner()
    {
        public int getType()
        {
            return signatureType;
        }

        public int getHashAlgorithm()
        {
            return hashAlgorithm;
        }

        public int getKeyAlgorithm()
        {
            return keyAlgorithm;
        }

        public long getKeyID()
        {
            return privateKey.getKeyID();
        }

        public OutputStream getOutputStream()
        {
            return new TeeOutputStream(new SignerOutputStream(signer), digestCalculator.getOutputStream());
        }

        public byte[] getSignature()
        {
            try
            {
                return signer.generateSignature();
            }
            catch (CryptoException e)
            {    // TODO: need a specific runtime exception for PGP operators.
                throw new IllegalStateException("unable to create signature");
            }
        }

        public byte[] getDigest()
        {
            return digestCalculator.getDigest();
        }
    };
}
项目:irma_future_id    文件:BcPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, final PGPPrivateKey privateKey)
    throws PGPException
{
    final PGPDigestCalculator digestCalculator = digestCalculatorProvider.get(hashAlgorithm);
    final Signer signer = BcImplProvider.createSigner(keyAlgorithm, hashAlgorithm);

    if (random != null)
    {
        signer.init(true, new ParametersWithRandom(keyConverter.getPrivateKey(privateKey), random));
    }
    else
    {
        signer.init(true, keyConverter.getPrivateKey(privateKey));
    }

    return new PGPContentSigner()
    {
        public int getType()
        {
            return signatureType;
        }

        public int getHashAlgorithm()
        {
            return hashAlgorithm;
        }

        public int getKeyAlgorithm()
        {
            return keyAlgorithm;
        }

        public long getKeyID()
        {
            return privateKey.getKeyID();
        }

        public OutputStream getOutputStream()
        {
            return new TeeOutputStream(new SignerOutputStream(signer), digestCalculator.getOutputStream());
        }

        public byte[] getSignature()
        {
            try
            {
                return signer.generateSignature();
            }
            catch (CryptoException e)
            {    // TODO: need a specific runtime exception for PGP operators.
                throw new IllegalStateException("unable to create signature");
            }
        }

        public byte[] getDigest()
        {
            return digestCalculator.getDigest();
        }
    };
}
项目:bc-java    文件:BcPGPContentSignerBuilder.java   
public PGPContentSigner build(final int signatureType, final PGPPrivateKey privateKey)
    throws PGPException
{
    final PGPDigestCalculator digestCalculator = digestCalculatorProvider.get(hashAlgorithm);
    final Signer signer = BcImplProvider.createSigner(keyAlgorithm, hashAlgorithm);

    if (random != null)
    {
        signer.init(true, new ParametersWithRandom(keyConverter.getPrivateKey(privateKey), random));
    }
    else
    {
        signer.init(true, keyConverter.getPrivateKey(privateKey));
    }

    return new PGPContentSigner()
    {
        public int getType()
        {
            return signatureType;
        }

        public int getHashAlgorithm()
        {
            return hashAlgorithm;
        }

        public int getKeyAlgorithm()
        {
            return keyAlgorithm;
        }

        public long getKeyID()
        {
            return privateKey.getKeyID();
        }

        public OutputStream getOutputStream()
        {
            return new TeeOutputStream(new SignerOutputStream(signer), digestCalculator.getOutputStream());
        }

        public byte[] getSignature()
        {
            try
            {
                return signer.generateSignature();
            }
            catch (CryptoException e)
            {    // TODO: need a specific runtime exception for PGP operators.
                throw new IllegalStateException("unable to create signature");
            }
        }

        public byte[] getDigest()
        {
            return digestCalculator.getDigest();
        }
    };
}