本文整理汇总了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());
}
}
示例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
}
}
示例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);
}
}
示例4: myKeyGenerator
import javax.crypto.KeyGeneratorSpi; //导入依赖的package包/类
public myKeyGenerator(KeyGeneratorSpi keyAgreeSpi, Provider provider,
String algorithm) {
super(keyAgreeSpi, provider, algorithm);
}