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


Java MGF1ParameterSpec类代码示例

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


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

示例1: engineGetEncoded

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

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec,
    byte[] p) throws Exception {
    OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1",
        mgfSpec, new PSource.PSpecified(p));
    cp = Security.getProvider("SunJCE");
    System.out.println("Testing provider " + cp.getName() + "...");
    AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp);

    ap.init(spec);
    byte[] encoding = ap.getEncoded();

    AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp);
    ap2.init(encoding);

    OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec
            (OAEPParameterSpec.class);
    return compareSpec(spec, spec2);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TestOAEPParameterSpec.java

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

示例4: main

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
    boolean status = true;
    byte[] p = { (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04 };
    status &= runTest("SHA-224", MGF1ParameterSpec.SHA224, p);
    status &= runTest("SHA-256", MGF1ParameterSpec.SHA256, p);
    status &= runTest("SHA-384", MGF1ParameterSpec.SHA384, p);
    status &= runTest("SHA-512", MGF1ParameterSpec.SHA512, p);
    status &= runTest("SHA", MGF1ParameterSpec.SHA1, new byte[0]);
    status &= runTest("SHA-1", MGF1ParameterSpec.SHA1, new byte[0]);
    status &= runTest("SHA1", MGF1ParameterSpec.SHA1, new byte[0]);
    if (status) {
        System.out.println("Test Passed");
    } else {
        throw new Exception("One or More Test Failed");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TestOAEPParameterSpec.java

示例5: signPSS

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

示例6: verifyPSS

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

示例7: testGetDigestAlgorithm

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
/**
 * getDigestAlgorithm() method testing.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getDigestAlgorithm",
    args = {}
)
public void testGetDigestAlgorithm() {
    String mdName = "SHA-1";
    String mgfName = "MGF1";
    AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
    PSource pSrc = PSource.PSpecified.DEFAULT;

    OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
                                                            mgfSpec, pSrc);
    assertTrue("The returned value does not equal to the "
            + "value specified in the constructor.",
            ps.getDigestAlgorithm().equals(mdName));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:OAEPParameterSpecTest.java

示例8: testGetMGFAlgorithm

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
/**
 * getMGFAlgorithm() method testing.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getMGFAlgorithm",
    args = {}
)
public void testGetMGFAlgorithm() {
    String mdName = "SHA-1";
    String mgfName = "MGF1";
    AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
    PSource pSrc = PSource.PSpecified.DEFAULT;

    OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
                                                            mgfSpec, pSrc);
    assertTrue("The returned value does not equal to the "
            + "value specified in the constructor.",
            ps.getMGFAlgorithm().equals(mgfName));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:OAEPParameterSpecTest.java

示例9: testGetMGFParameters

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
/**
 * getMGFParameters() method testing.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getMGFParameters",
    args = {}
)
public void testGetMGFParameters() {
    String mdName = "SHA-1";
    String mgfName = "MGF1";
    AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
    PSource pSrc = PSource.PSpecified.DEFAULT;

    OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
                                                            mgfSpec, pSrc);
    assertTrue("The returned value does not equal to the "
            + "value specified in the constructor.",
            ps.getMGFParameters() == mgfSpec);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:OAEPParameterSpecTest.java

示例10: testGetPSource

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
/**
 * getPSource() method testing.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getPSource",
    args = {}
)
public void testGetPSource() {
    String mdName = "SHA-1";
    String mgfName = "MGF1";
    AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
    PSource pSrc = PSource.PSpecified.DEFAULT;

    OAEPParameterSpec ps = new OAEPParameterSpec(mdName, mgfName,
                                                            mgfSpec, pSrc);
    assertTrue("The returned value does not equal to the "
            + "value specified in the constructor.",
            ps.getPSource() == pSrc);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:OAEPParameterSpecTest.java

示例11: testMGF1ParameterSpec01

import java.security.spec.MGF1ParameterSpec; //导入依赖的package包/类
/**
 * Test #1 for <code>MGF1ParameterSpec</code> constructor<br>
 * Assertion: constructs new <code>MGF1ParameterSpec</code>
 * object using valid parameter
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "MGF1ParameterSpec",
    args = {java.lang.String.class}
)
public final void testMGF1ParameterSpec01() {
    try {
        MGF1ParameterSpec pgf = new MGF1ParameterSpec(testAlgName);
        assertNotNull(pgf);
        assertTrue(pgf instanceof MGF1ParameterSpec);
    } catch (Exception e) {
        fail("Unexpected exception: " + e);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:MGF1ParameterSpecTest.java


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