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


Java KeyGeneratorSpi类代码示例

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


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

示例1: test_Ljava_security_SecureRandom

import javax.crypto.KeyGeneratorSpi; //导入依赖的package包/类
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "init",
        args = {java.security.SecureRandom.class}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        clazz = KeyGeneratorSpi.class,
        method = "engineInit",
        args = {java.security.SecureRandom.class}
    )
})
public void test_Ljava_security_SecureRandom() throws NoSuchAlgorithmException {
    SecureRandom random = null;
    KeyGenerator kg = null;

    for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) {
        kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]);
        random = new SecureRandom();
        kg.init(random);
        assertNotNull(kg.getProvider());
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:KeyGeneratorTest.java

示例2: test_initILjava_security_SecureRandom

import javax.crypto.KeyGeneratorSpi; //导入依赖的package包/类
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "init",
        args = {int.class, java.security.SecureRandom.class}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        clazz = KeyGeneratorSpi.class,
        method = "engineInit",
        args = {int.class, java.security.SecureRandom.class}
    )
})
public void test_initILjava_security_SecureRandom() throws NoSuchAlgorithmException {
    SecureRandom random = null;
    KeyGenerator kg = null;

    for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) {
        kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]);
        random = new SecureRandom();
        kg.init(validKeySizes[i], random);
        assertNotNull(kg.getProvider());
    }

    kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[0]);

    try {
        kg.init(5, random);
        fail("InvalidParameterException expected");
    } catch (InvalidParameterException e) {
        //expected
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:36,代码来源:KeyGeneratorTest.java

示例3: testGenerateKey

import javax.crypto.KeyGeneratorSpi; //导入依赖的package包/类
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "generateKey",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        clazz = KeyGeneratorSpi.class,
        method = "engineGenerateKey",
        args = {}
    )
})
public void testGenerateKey() throws Exception {
    if (!DEFSupported) {
        fail(NotSupportMsg);
        return;
    }
    SecretKey sKey;
    String dAl = defaultAlgorithm.toUpperCase();

    KeyGenerator[] kgs = createKGs();

    for (int i = 0; i < kgs.length; i++) {
        sKey = kgs[i].generateKey();
        assertEquals("Incorrect algorithm", sKey.getAlgorithm()
                .toUpperCase(), dAl);
        kgs[i].init(new SecureRandom());
        sKey = kgs[i].generateKey();
        assertEquals("Incorrect algorithm", sKey.getAlgorithm()
                .toUpperCase(), dAl);
        kgs[i].init(defaultKeySize);
        sKey = kgs[i].generateKey();
        assertEquals("Incorrect algorithm", sKey.getAlgorithm()
                .toUpperCase(), dAl);
        kgs[i].init(defaultKeySize, new SecureRandom());
        sKey = kgs[i].generateKey();
        assertEquals("Incorrect algorithm", sKey.getAlgorithm()
                .toUpperCase(), dAl);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:44,代码来源:KeyGeneratorTest.java

示例4: myKeyGenerator

import javax.crypto.KeyGeneratorSpi; //导入依赖的package包/类
public myKeyGenerator(KeyGeneratorSpi keyAgreeSpi, Provider provider,
        String algorithm) {
    super(keyAgreeSpi, provider, algorithm);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:5,代码来源:KeyGeneratorTest.java


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