當前位置: 首頁>>代碼示例>>Java>>正文


Java MGF1ParameterSpec.getDigestAlgorithm方法代碼示例

本文整理匯總了Java中java.security.spec.MGF1ParameterSpec.getDigestAlgorithm方法的典型用法代碼示例。如果您正苦於以下問題:Java MGF1ParameterSpec.getDigestAlgorithm方法的具體用法?Java MGF1ParameterSpec.getDigestAlgorithm怎麽用?Java MGF1ParameterSpec.getDigestAlgorithm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.spec.MGF1ParameterSpec的用法示例。


在下文中一共展示了MGF1ParameterSpec.getDigestAlgorithm方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compareMGF

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的package包/類
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    String alg1 = s1.getMGFAlgorithm();
    String alg2 = s2.getMGFAlgorithm();
    if (alg1.equals(alg2)) {
        MGF1ParameterSpec mp1 = (MGF1ParameterSpec)s1.getMGFParameters();
        MGF1ParameterSpec mp2 = (MGF1ParameterSpec)s2.getMGFParameters();
        alg1 = mp1.getDigestAlgorithm();
        alg2 = mp2.getDigestAlgorithm();
        if (alg1.equals(alg2)) {
            return true;
        } else {
            System.out.println("MGF's MD algos: " + alg1 + " vs " + alg2);
            return false;
        }
    } else {
        System.out.println("MGF algos: " + alg1 + " vs " + alg2);
        return false;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:TestOAEPParameterSpec.java

示例2: initFromSpec

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例3: initFromSpec

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例4: RsaPssSha256

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例5: RsaPssSha384

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例6: RsaPssSha512

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例7: initFromSpec

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例8: engineSetParameter

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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 java.security.spec.MGF1ParameterSpec; //導入方法依賴的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 java.security.spec.MGF1ParameterSpec; //導入方法依賴的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

示例11: engineSetParameter

import java.security.spec.MGF1ParameterSpec; //導入方法依賴的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


注:本文中的java.security.spec.MGF1ParameterSpec.getDigestAlgorithm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。