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


Java DigestFactory.isSameDigest方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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


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