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


Java PSSParameterSpec.getTrailerField方法代码示例

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


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

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

示例2: engineSetParameter

import java.security.spec.PSSParameterSpec; //导入方法依赖的package包/类
@Override
protected final void engineSetParameter(AlgorithmParameterSpec params)
        throws InvalidAlgorithmParameterException {
    if (!(params instanceof PSSParameterSpec)) {
        throw new InvalidAlgorithmParameterException(
                "Unsupported parameter: " + params + ". Only "
                        + PSSParameterSpec.class.getName() + " supported");
    }
    PSSParameterSpec spec = (PSSParameterSpec) params;
    String specContentDigest = EvpMdRef
            .getJcaDigestAlgorithmStandardName(spec.getDigestAlgorithm());
    if (specContentDigest == null) {
        throw new InvalidAlgorithmParameterException(
                "Unsupported content digest algorithm: " + spec.getDigestAlgorithm());
    } else if (!contentDigestAlgorithm.equalsIgnoreCase(specContentDigest)) {
        throw new InvalidAlgorithmParameterException(
                "Changing content digest algorithm not supported");
    }

    String specMgfAlgorithm = spec.getMGFAlgorithm();
    if ((!EvpMdRef.MGF1_ALGORITHM_NAME.equalsIgnoreCase(specMgfAlgorithm))
            && (!EvpMdRef.MGF1_OID.equals(specMgfAlgorithm))) {
        throw new InvalidAlgorithmParameterException(
                "Unsupported MGF algorithm: " + specMgfAlgorithm + ". Only "
                        + EvpMdRef.MGF1_ALGORITHM_NAME + " supported");
    }

    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidAlgorithmParameterException(
                "Unsupported MGF parameters: " + mgfSpec + ". Only "
                        + MGF1ParameterSpec.class.getName() + " supported");
    }
    MGF1ParameterSpec specMgf1Spec = (MGF1ParameterSpec) spec.getMGFParameters();

    String specMgf1Digest = EvpMdRef
            .getJcaDigestAlgorithmStandardName(specMgf1Spec.getDigestAlgorithm());
    if (specMgf1Digest == null) {
        throw new InvalidAlgorithmParameterException(
                "Unsupported MGF1 digest algorithm: " + specMgf1Spec.getDigestAlgorithm());
    }
    long specMgf1EvpMdRef;
    try {
        specMgf1EvpMdRef = EvpMdRef
                .getEVP_MDByJcaDigestAlgorithmStandardName(specMgf1Digest);
    } catch (NoSuchAlgorithmException e) {
        throw new ProviderException("Failed to obtain EVP_MD for " + specMgf1Digest, e);
    }

    int specSaltSizeBytes = spec.getSaltLength();
    if (specSaltSizeBytes < 0) {
        throw new InvalidAlgorithmParameterException(
                "Salt length must be non-negative: " + specSaltSizeBytes);
    }

    int specTrailer = spec.getTrailerField();
    if (specTrailer != TRAILER_FIELD_BC_ID) {
        throw new InvalidAlgorithmParameterException(
                "Unsupported trailer field: " + specTrailer + ". Only "
                        + TRAILER_FIELD_BC_ID + " supported");
    }

    this.mgf1DigestAlgorithm = specMgf1Digest;
    this.mgf1EvpMdRef = specMgf1EvpMdRef;
    this.saltSizeBytes = specSaltSizeBytes;

    long ctx = getEVP_PKEY_CTX();
    if (ctx != 0) {
        configureEVP_PKEY_CTX(ctx);
    }
}
 
开发者ID:google,项目名称:conscrypt,代码行数:72,代码来源:OpenSSLSignature.java


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