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


Java DigestFactory类代码示例

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


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

示例1: engineGetEncoded

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
/**
 * Return the PKCS#1 ASN.1 structure RSAES-OAEP-params.
 */
protected byte[] engineGetEncoded() 
{
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                                    DigestFactory.getOID(currentSpec.getDigestAlgorithm()),
                                                    DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                                    PKCSObjectIdentifiers.id_mgf1,
                                                    new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
    AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier(
                                                    PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
    RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm);
    
    try
    {
        return oaepP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding OAEPParameters");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:AlgorithmParametersSpi.java

示例2: PSSSignatureSpi

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;
    
    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:PSSSignatureSpi.java

示例3: initFromSpec

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
private void initFromSpec(
    OAEPParameterSpec pSpec)
    throws NoSuchPaddingException
{
    MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
    Digest digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
    
    if (digest == null)
    {
        throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
    }

    cipher = new OAEPEncoding(new RSABlindedEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue());
    paramSpec = pSpec;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:CipherSpi.java

示例4: initFromSpec

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
private void initFromSpec(
    OAEPParameterSpec pSpec) 
    throws NoSuchPaddingException
{
    MGF1ParameterSpec   mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
    Digest              digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
    
    if (digest == null)
    {
        throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
    }

    cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue()));        
    paramSpec = pSpec;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:CipherSpi.java

示例5: P11RSAPSSSignatureSpi

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
protected P11RSAPSSSignatureSpi(PSSParameterSpec baseParamSpec, boolean isRaw) {
    this.originalSpec = baseParamSpec;
    this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec;
    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
 
开发者ID:xipki,项目名称:xitk,代码行数:11,代码来源:P11RSAPSSSignatureSpi.java

示例6: initFromSpec

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
private void initFromSpec(OAEPParameterSpec pSpec)
    throws NoSuchPaddingException, NoSuchFieldException, IllegalAccessException
{
    MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
    Digest digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());

    if (digest == null)
    {
        throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
    }

    cipher(new OAEPEncoding(new NativeRSAEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue()));
    set( pSpec, "paramSpec" );
}
 
开发者ID:lookout,项目名称:fast-rsa-engine,代码行数:15,代码来源:FastCipherSpi.java

示例7: getDigest

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
/**
 * Finds checksum by name.
 *
 * @param digest digest name
 * @return digest instance
 */
private static Digest getDigest(final String digest) {
    try {
        return new JceDigest(digest);
    } catch (CryptoException e) {
        String noHyphen = digest.replaceFirst("-", "");
        return DigestFactory.getDigest(noHyphen);
    }
}
 
开发者ID:joyent,项目名称:java-http-signature,代码行数:15,代码来源:NativeRSAWithSHA.java

示例8: engineSetParameter

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
protected void engineSetParameter(
    AlgorithmParameterSpec params)
    throws InvalidParameterException
{
    if (params instanceof PSSParameterSpec)
    {
        PSSParameterSpec newParamSpec = (PSSParameterSpec)params;
        
        if (originalSpec != null)
        {
            if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
            {
                throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm());
            }
        }
        if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
        {
            throw new InvalidParameterException("unknown mask generation function specified");
        }
        
        if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec))
        {
            throw new InvalidParameterException("unkown MGF parameters");
        }
        
        MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)newParamSpec.getMGFParameters();
        
        if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
        {
            throw new InvalidParameterException("digest algorithm for MGF should be the same as for PSS parameters.");
        }
        
        Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
        
        if (newDigest == null)
        {
            throw new InvalidParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
        }

        this.engineParams = null;
        this.paramSpec = newParamSpec;
        this.mgfDigest = newDigest;
        this.saltLength = paramSpec.getSaltLength();
        this.trailer = getTrailer(paramSpec.getTrailerField());

        setupContentDigest();
    }
    else
    {
        throw new InvalidParameterException("Only PSSParameterSpec supported");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:53,代码来源:PSSSignatureSpi.java

示例9: engineSetParameter

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
@Override
protected void engineSetParameter(AlgorithmParameterSpec params)
        throws InvalidParameterException {
    if (params instanceof PSSParameterSpec) {
        PSSParameterSpec newParamSpec = (PSSParameterSpec) params;

        if (originalSpec != null) {
            if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(),
                    newParamSpec.getDigestAlgorithm())) {
                throw new InvalidParameterException("parameter must be using "
                        + originalSpec.getDigestAlgorithm());
            }
        }
        if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1")
                && !newParamSpec.getMGFAlgorithm().equals(
                        PKCSObjectIdentifiers.id_mgf1.getId())) {
            throw new InvalidParameterException("unknown mask generation function specified");
        }

        if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec)) {
            throw new InvalidParameterException("unkown MGF parameters");
        }

        MGF1ParameterSpec mgfParams = (MGF1ParameterSpec) newParamSpec.getMGFParameters();

        if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(),
                newParamSpec.getDigestAlgorithm())) {
            throw new InvalidParameterException(
                    "digest algorithm for MGF should be the same as for PSS parameters.");
        }

        Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());

        if (newDigest == null) {
            throw new InvalidParameterException(
                    "no match on MGF digest algorithm: " + mgfParams.getDigestAlgorithm());
        }

        this.engineParams = null;
        this.paramSpec = newParamSpec;
        this.mgfDigest = newDigest;
        this.saltLength = paramSpec.getSaltLength();
        this.trailer = getTrailer(paramSpec.getTrailerField());

        setupContentDigest();
    } else {
        throw new InvalidParameterException("only PSSParameterSpec supported");
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:50,代码来源:P11RSAPSSSignatureSpi.java

示例10: engineSetParameter

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
protected void engineSetParameter(
    AlgorithmParameterSpec params)
    throws InvalidAlgorithmParameterException
{
    if (params instanceof PSSParameterSpec)
    {
        PSSParameterSpec newParamSpec = (PSSParameterSpec)params;
        
        if (originalSpec != null)
        {
            if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
            {
                throw new InvalidAlgorithmParameterException("parameter must be using " + originalSpec.getDigestAlgorithm());
            }
        }
        if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
        {
            throw new InvalidAlgorithmParameterException("unknown mask generation function specified");
        }
        
        if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec))
        {
            throw new InvalidAlgorithmParameterException("unknown MGF parameters");
        }
        
        MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)newParamSpec.getMGFParameters();
        
        if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
        {
            throw new InvalidAlgorithmParameterException("digest algorithm for MGF should be the same as for PSS parameters.");
        }
        
        Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
        
        if (newDigest == null)
        {
            throw new InvalidAlgorithmParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
        }

        this.engineParams = null;
        this.paramSpec = newParamSpec;
        this.mgfDigest = newDigest;
        this.saltLength = paramSpec.getSaltLength();
        this.trailer = getTrailer(paramSpec.getTrailerField());

        setupContentDigest();
    }
    else
    {
        throw new InvalidAlgorithmParameterException("Only PSSParameterSpec supported");
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:53,代码来源:PSSSignatureSpi.java

示例11: getHashObjectIdentifier

import org.bouncycastle.jcajce.provider.util.DigestFactory; //导入依赖的package包/类
private ASN1ObjectIdentifier getHashObjectIdentifier(String algorithm) {
	return DigestFactory.getOID(algorithm);
}
 
开发者ID:beat2,项目名称:pdfbox-signer,代码行数:4,代码来源:TSAClient.java


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