• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PSSParameterSpec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createRawSignature

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public Signature createRawSignature(AlgorithmIdentifier algorithm)
{
    Signature   sig;

    try
    {
        String algName = getSignatureName(algorithm);

        algName = "NONE" + algName.substring(algName.indexOf("WITH"));

        sig = helper.createSignature(algName);

        // RFC 4056
        // When the id-RSASSA-PSS algorithm identifier is used for a signature,
        // the AlgorithmIdentifier parameters field MUST contain RSASSA-PSS-params.
        if (algorithm.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
        {
            AlgorithmParameters params = helper.createAlgorithmParameters(algName);

            params.init(algorithm.getParameters().toASN1Primitive().getEncoded(), "ASN.1");

            PSSParameterSpec spec = (PSSParameterSpec)params.getParameterSpec(PSSParameterSpec.class);
            sig.setParameter(spec);
        }
    }
    catch (Exception e)
    {
        return null;
    }

    return sig;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:33,代码来源:OperatorHelper.java


示例2: engineGetEncoded

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));
    
    return pssP.getEncoded("DER");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:AlgorithmParametersSpi.java


示例3: PSSSignatureSpi

import java.security.spec.PSSParameterSpec; //导入依赖的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


示例4: signPSS

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public static byte[] signPSS(PrivateKey privateKey,
		byte[] signedData) throws SignatureException,
		InvalidKeyException, NoSuchAlgorithmException,
		NoSuchProviderException, InvalidAlgorithmParameterException {
	Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC);
	signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1",
			new MGF1ParameterSpec("SHA-256"), 32, 1));
	signature.initSign(privateKey);
	signature.update(signedData);
	return signature.sign();
}
 
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:12,代码来源:RSA.java


示例5: verifyPSS

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public static boolean verifyPSS(PublicKey publicKey,
		byte[] signedData, byte[] sig) throws SignatureException,
		InvalidKeyException, NoSuchAlgorithmException,
		NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeySpecException {
	Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC);
	signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1",
			new MGF1ParameterSpec("SHA-256"), 32, 1));
	signature.initVerify(publicKey);
	signature.update(signedData);
	return signature.verify(sig);
}
 
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:12,代码来源:RSA.java


示例6: engineGetParameters

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
protected AlgorithmParameters engineGetParameters()
{
    if (engineParams == null)
    {
        try
        {
            engineParams = AlgorithmParameters.getInstance("PSS", BouncyCastleProvider.PROVIDER_NAME);
            engineParams.init(new PSSParameterSpec(saltLength));
        }
        catch (Exception e)
        {
            throw new RuntimeException(e.toString());
        }
    }

    return engineParams;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:18,代码来源:PSSSignatureSpi.java


示例7: engineGetParameters

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
protected AlgorithmParameters engineGetParameters() 
{
    if (engineParams == null)
    {
        try
        {
            engineParams = AlgorithmParameters.getInstance("PSS", "BC");
            engineParams.init(new PSSParameterSpec(saltLength));
        }
        catch (Exception e)
        {
            throw new RuntimeException(e.toString());
        }
    }

    return engineParams;
}
 
开发者ID:bullda,项目名称:DroidText,代码行数:18,代码来源:JDKPSSSigner.java


示例8: engineGetEncoded

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded()
{
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DEROutputStream         dOut = new DEROutputStream(bOut);
    PSSParameterSpec    pssSpec = (PSSParameterSpec)currentSpec;
    RSASSAPSSparams     pssP = new RSASSAPSSparams(RSASSAPSSparams.DEFAULT_HASH_ALGORITHM, RSASSAPSSparams.DEFAULT_MASK_GEN_FUNCTION, new DERInteger(pssSpec.getSaltLength()), RSASSAPSSparams.DEFAULT_TRAILER_FIELD);
    try
    {
        dOut.writeObject(pssP);
        dOut.close();
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding PSSParameters");
    }

    return bOut.toByteArray();
}
 
开发者ID:bullda,项目名称:DroidText,代码行数:22,代码来源:JDKAlgorithmParameters.java


示例9: localEngineGetParameterSpec

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == PSSParameterSpec.class && currentSpec != null)
    {
        return currentSpec;
    }
    
    throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:AlgorithmParametersSpi.java


示例10: engineInit

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PSSParameterSpec))
    {
        throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
    }
    
    this.currentSpec = (PSSParameterSpec)paramSpec;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:AlgorithmParametersSpi.java


示例11: P11RSAPSSSignatureSpi

import java.security.spec.PSSParameterSpec; //导入依赖的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


示例12: getSignatureAlgorithmJcaSignatureAlgorithm

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
private static Pair<String, ? extends AlgorithmParameterSpec>
        getSignatureAlgorithmJcaSignatureAlgorithm(int sigAlgorithm) {
    switch (sigAlgorithm) {
        case SIGNATURE_RSA_PSS_WITH_SHA256:
            return Pair.create(
                    "SHA256withRSA/PSS",
                    new PSSParameterSpec(
                            "SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 256 / 8, 1));
        case SIGNATURE_RSA_PSS_WITH_SHA512:
            return Pair.create(
                    "SHA512withRSA/PSS",
                    new PSSParameterSpec(
                            "SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 512 / 8, 1));
        case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA256:
            return Pair.create("SHA256withRSA", null);
        case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA512:
            return Pair.create("SHA512withRSA", null);
        case SIGNATURE_ECDSA_WITH_SHA256:
            return Pair.create("SHA256withECDSA", null);
        case SIGNATURE_ECDSA_WITH_SHA512:
            return Pair.create("SHA512withECDSA", null);
        case SIGNATURE_DSA_WITH_SHA256:
            return Pair.create("SHA256withDSA", null);
        default:
            throw new IllegalArgumentException(
                    "Unknown signature algorithm: 0x"
                            + Long.toHexString(sigAlgorithm & 0xffffffff));
    }
}
 
开发者ID:bihe0832,项目名称:Android-GetAPKInfo,代码行数:30,代码来源:ApkSignatureSchemeV2Verifier.java


示例13: RsaPssSha256

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public RsaPssSha256()
{
    super(AlgorithmIdentifiers.RSA_PSS_USING_SHA256, "SHA256withRSAandMGF1");
    MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA256;
    PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 32, TRAILER);
    setAlgorithmParameterSpec(pssSpec);
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:8,代码来源:RsaUsingShaAlgorithm.java


示例14: RsaPssSha384

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public RsaPssSha384()
{
    super(AlgorithmIdentifiers.RSA_PSS_USING_SHA384, "SHA384withRSAandMGF1");
    MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA384;
    PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 48, TRAILER);
    setAlgorithmParameterSpec(pssSpec);
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:8,代码来源:RsaUsingShaAlgorithm.java


示例15: RsaPssSha512

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public RsaPssSha512()
{
    super(AlgorithmIdentifiers.RSA_PSS_USING_SHA512, "SHA512withRSAandMGF1");
    MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA512;
    PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 64, TRAILER);
    setAlgorithmParameterSpec(pssSpec);
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:8,代码来源:RsaUsingShaAlgorithm.java


示例16: createRawSignature

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
public Signature createRawSignature(AlgorithmIdentifier algorithm)
{
    Signature   sig;

    try
    {
        String algName = getSignatureName(algorithm);

        algName = "NONE" + algName.substring(algName.indexOf("WITH"));

        sig = helper.createSignature(algName);

        // RFC 4056
        // When the id-RSASSA-PSS algorithm identifier is used for a signature,
        // the AlgorithmIdentifier parameters field MUST contain RSASSA-PSS-params.
        if (algorithm.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
        {
            AlgorithmParameters params = helper.createAlgorithmParameters(algName);

            AlgorithmParametersUtils.loadParameters(params, algorithm.getParameters());

            PSSParameterSpec spec = (PSSParameterSpec)params.getParameterSpec(PSSParameterSpec.class);
            sig.setParameter(spec);
        }
    }
    catch (Exception e)
    {
        return null;
    }

    return sig;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:33,代码来源:OperatorHelper.java


示例17: testPSSParameterSpec0102

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
/**
 * Test #2 for <code>PSSParameterSpec(int)</code> ctor<br>
 * Assertion:
 * throws <code>IllegalArgumentException</code>
 * if <code>saltLen</code> less than 0
 */
public final void testPSSParameterSpec0102() {
    try {
        new PSSParameterSpec(-1);
        fail("Expected IAE not thrown");
    } catch (IllegalArgumentException e) {
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:14,代码来源:PSSParameterSpecTest.java


示例18: testPSSParameterSpec0101

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
/**
 * Test #1 for <code>PSSParameterSpec(int)</code> ctor<br>
 * Assertion: constructs using valid parameter
 * <code>PSSParameterSpec<code> object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies constructor with valid parameter.",
    method = "PSSParameterSpec",
    args = {int.class}
)
public final void testPSSParameterSpec0101() {
    AlgorithmParameterSpec aps = new PSSParameterSpec(20);
    assertTrue(aps instanceof PSSParameterSpec);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:PSSParameterSpecTest.java


示例19: testPSSParameterSpec0102

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
/**
 * Test #2 for <code>PSSParameterSpec(int)</code> ctor<br>
 * Assertion:
 * throws <code>IllegalArgumentException</code>
 * if <code>saltLen</code> less than 0
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies IllegalArgumentException.",
    method = "PSSParameterSpec",
    args = {int.class}
)
public final void testPSSParameterSpec0102() {
    try {
        new PSSParameterSpec(-1);
        fail("Expected IAE not thrown");
    } catch (IllegalArgumentException e) {
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:PSSParameterSpecTest.java


示例20: testPSSParameterSpec0201

import java.security.spec.PSSParameterSpec; //导入依赖的package包/类
/**
 * Test #1 for
 * <code>
 * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
 * </code> ctor<br>
 * Assertion: constructs using valid parameters
 * <code>PSSParameterSpec<code> object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies constructor with valid parameters.",
    method = "PSSParameterSpec",
    args = {java.lang.String.class, java.lang.String.class, java.security.spec.AlgorithmParameterSpec.class, int.class, int.class}
)
public final void testPSSParameterSpec0201() {
    AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1",
            MGF1ParameterSpec.SHA1, 20, 1);
    assertTrue(aps instanceof PSSParameterSpec);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:PSSParameterSpecTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AcknowledgeMode类代码示例发布时间:2022-05-21
下一篇:
Java AccessibleCodetemplatesActivator类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap