本文整理汇总了Java中javax.crypto.KeyAgreementSpi类的典型用法代码示例。如果您正苦于以下问题:Java KeyAgreementSpi类的具体用法?Java KeyAgreementSpi怎么用?Java KeyAgreementSpi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyAgreementSpi类属于javax.crypto包,在下文中一共展示了KeyAgreementSpi类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testKeyAgreement
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
/**
* Test for <code>KeyAgreement</code> constructor Assertion: returns
* KeyAgreement object
*/
public void testKeyAgreement() throws NoSuchAlgorithmException,
InvalidKeyException, IllegalStateException {
if (!DEFSupported) {
fail(NotSupportMsg);
return;
}
KeyAgreementSpi spi = new MyKeyAgreementSpi();
KeyAgreement keyA = new myKeyAgreement(spi, defaultProvider,
defaultAlgorithm);
assertEquals("Incorrect algorithm", keyA.getAlgorithm(),
defaultAlgorithm);
assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider);
assertNull("Incorrect result", keyA.doPhase(null, true));
assertEquals("Incorrect result", keyA.generateSecret().length, 0);
keyA = new myKeyAgreement(null, null, null);
assertNull("Algorithm must be null", keyA.getAlgorithm());
assertNull("Provider must be null", keyA.getProvider());
try {
keyA.doPhase(null, true);
fail("NullPointerException must be thrown");
} catch (NullPointerException e) {
}
}
示例2: test_constructor
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "KeyAgreement",
args = {javax.crypto.KeyAgreementSpi.class, java.security.Provider.class, java.lang.String.class}
)
public void test_constructor() {
assertNotNull(new Mock_KeyAgreement(null, null, null));
}
示例3: KeyAgreement
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
/** @ar.org.fitc.spec_ref */
protected KeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider,
String algorithm) {
this.keyAgreementSpi = keyAgreeSpi;
this.provider = provider;
this.algorithm = algorithm;
}
示例4: testGenerateSecret03
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
/**
* Test for the methods: <code>init(Key key)</code>
* <code>generateSecret()</code>
* <code>generateSecret(byte[] sharedsecret, int offset)</code>
* <code>generateSecret(String algorithm)</code>
* Assertions: initializes KeyAgreement; returns sharedSecret; puts
* sharedsecret in buffer and return numbers of bytes; returns SecretKey
* object
*/
@TestTargets({
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
method = "init",
args = {java.security.Key.class}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
method = "generateSecret",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
method = "generateSecret",
args = {byte[].class, int.class}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
method = "generateSecret",
args = {java.lang.String.class}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
clazz = KeyAgreementSpi.class,
method = "engineGenerateSecret",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
clazz = KeyAgreementSpi.class,
method = "engineGenerateSecret",
args = {byte[].class, int.class}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Checks functionality only.",
clazz = KeyAgreementSpi.class,
method = "engineGenerateSecret",
args = {java.lang.String.class}
)
})
public void testGenerateSecret03() throws Exception {
if (!DEFSupported) {
fail(NotSupportMsg);
return;
}
createKeys();
KeyAgreement[] kAgs = createKAs();
byte[] bb;
byte[] bb1 = new byte[10];
for (int i = 0; i < kAgs.length; i++) {
kAgs[i].init(privKey);
kAgs[i].doPhase(publKey, true);
bb = kAgs[i].generateSecret();
kAgs[i].init(privKey);
kAgs[i].doPhase(publKey, true);
bb1 = new byte[bb.length + 10];
kAgs[i].generateSecret(bb1, 9);
kAgs[i].init(privKey);
kAgs[i].doPhase(publKey, true);
kAgs[i].generateSecret("DES");
}
}
示例5: Mock_KeyAgreement
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
protected Mock_KeyAgreement(KeyAgreementSpi arg0, Provider arg1, String arg2) {
super(arg0, arg1, arg2);
}
示例6: myKeyAgreement
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
public myKeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider,
String algorithm) {
super(keyAgreeSpi, provider, algorithm);
}
示例7: newInstance
import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
/**
* It's used as a factory method
*
* @param algorithm
* the algorithm
* @param provider
* the provider
* @return a new KeyAgreement object
* @throws NoSuchAlgorithmException
* if the specified algorithm is not available in the default
* package or any of the others providers that were searched
*/
private static final KeyAgreement newInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
Service service = Util.getService(Types.KEY_AGREEMENT, algorithm,
provider);
if (service == null) {
throw new NoSuchAlgorithmException("No such algorithm: "
+ algorithm);
}
return new KeyAgreement((KeyAgreementSpi) service.newInstance(null),
service.getProvider(), algorithm);
}