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


Java KeyAgreementSpi类代码示例

本文整理汇总了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) {
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:KeyAgreement_Impl1Test.java

示例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));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:KeyAgreementTest.java

示例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;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:8,代码来源:KeyAgreement.java

示例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");
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:80,代码来源:KeyAgreementTest.java

示例5: Mock_KeyAgreement

import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
protected Mock_KeyAgreement(KeyAgreementSpi arg0, Provider arg1, String arg2) {
    super(arg0, arg1, arg2);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:4,代码来源:KeyAgreementTest.java

示例6: myKeyAgreement

import javax.crypto.KeyAgreementSpi; //导入依赖的package包/类
public myKeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider,
        String algorithm) {
    super(keyAgreeSpi, provider, algorithm);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:5,代码来源:KeyAgreement_Impl1Test.java

示例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);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:24,代码来源:KeyAgreement.java


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