• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ECParameterSpec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: isSignatureValid

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
@Override
public boolean isSignatureValid(byte[] data, byte[] signature, Pubkey pubkey) {
    try {
        ECParameterSpec spec = new ECParameterSpec(
            EC_CURVE_PARAMETERS.getCurve(),
            EC_CURVE_PARAMETERS.getG(),
            EC_CURVE_PARAMETERS.getN(),
            EC_CURVE_PARAMETERS.getH(),
            EC_CURVE_PARAMETERS.getSeed()
        );

        ECPoint Q = keyToPoint(pubkey.getSigningKey());
        KeySpec keySpec = new ECPublicKeySpec(Q, spec);
        PublicKey publicKey = KeyFactory.getInstance(ALGORITHM_ECDSA, provider).generatePublic(keySpec);

        Signature sig = Signature.getInstance(ALGORITHM_ECDSA, provider);
        sig.initVerify(publicKey);
        sig.update(data);
        return sig.verify(signature);
    } catch (GeneralSecurityException e) {
        throw new ApplicationException(e);
    }
}
 
开发者ID:Dissem,项目名称:Jabit,代码行数:24,代码来源:SpongyCryptography.java


示例2: getSignature

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
@Override
public byte[] getSignature(byte[] data, PrivateKey privateKey) {
    try {
        ECParameterSpec spec = new ECParameterSpec(
            EC_CURVE_PARAMETERS.getCurve(),
            EC_CURVE_PARAMETERS.getG(),
            EC_CURVE_PARAMETERS.getN(),
            EC_CURVE_PARAMETERS.getH(),
            EC_CURVE_PARAMETERS.getSeed()
        );

        BigInteger d = keyToBigInt(privateKey.getPrivateSigningKey());
        KeySpec keySpec = new ECPrivateKeySpec(d, spec);
        java.security.PrivateKey privKey = KeyFactory.getInstance(ALGORITHM_ECDSA, provider)
            .generatePrivate(keySpec);

        Signature sig = Signature.getInstance(ALGORITHM_ECDSA, provider);
        sig.initSign(privKey);
        sig.update(data);
        return sig.sign();
    } catch (GeneralSecurityException e) {
        throw new ApplicationException(e);
    }
}
 
开发者ID:Dissem,项目名称:Jabit,代码行数:25,代码来源:SpongyCryptography.java


示例3: createNewKeyPair

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
/**
 * Creates a new (elliptic curve) KeyPair according to the given arguments.
 * @param curveName The given curnename
 * @param algorithm The used algorithm
 * @param provider The security provider
 * @param custom If this is a custom curve (see BouncyCastle for what custom curves are).
 * @return The generated keypair.
 */
public static KeyPair createNewKeyPair(String curveName, String algorithm, String provider, boolean custom) {
    ECParameterSpec ecSpec = getParameterSpec(curveName, custom);
    KeyPair keyPair = null;
    try {
        KeyPairGenerator g = KeyPairGenerator.getInstance(algorithm, provider);
        g.initialize(ecSpec, new SecureRandom());
        keyPair = g.generateKeyPair();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return keyPair;
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:21,代码来源:Key.java


示例4: getParameterSpec

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
/**
 * Retrieves the parameters of the given elliptic curve.
 * @param curveName The curve name
 * @param custom Custom or not?
 * @return The elliptic curve parameters.
 */
private static ECParameterSpec getParameterSpec(String curveName, boolean custom) {
    if(custom) {
        X9ECParameters ecP = CustomNamedCurves.getByName(curveName);
        return new ECParameterSpec(ecP.getCurve(), ecP.getG(),
                ecP.getN(), ecP.getH(), ecP.getSeed());

    }
    return ECNamedCurveTable.getParameterSpec(curveName);
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:16,代码来源:Key.java


示例5: generate

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
public static KeyPair generate () throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    SecureRandom random = new SecureRandom();
    ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp256r1");
    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA");
    g.initialize(ecSpec, random);
    return g.generateKeyPair();
}
 
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:8,代码来源:KeyCodec.java


示例6: generate

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
public static KeyPair generate() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    SecureRandom random = new SecureRandom();
    ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp256r1");
    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA");
    g.initialize(ecSpec, random);
    return g.generateKeyPair();
}
 
开发者ID:eBay,项目名称:UAF,代码行数:8,代码来源:KeyCodec.java


示例7: generateNewKey

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
private static KeyPair generateNewKey(String spec) {
	try {
		ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(spec);
		KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA", "SC");
		keyGen.initialize(ecSpec, new SecureRandom());
		return keyGen.generateKeyPair();
	} catch (Exception e) {
		Log.e(TAG, "error", e);
		System.exit(0);
		return null;
	}
}
 
开发者ID:jetonmemeti,项目名称:android-signature-tests,代码行数:13,代码来源:SignatureLengths.java


示例8: createECCKeys

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
private static long createECCKeys(String spec) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
	long start = System.currentTimeMillis();
	
	ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(spec);
       KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA");
       g.initialize(ecSpec, new SecureRandom());
       g.generateKeyPair();
	
	return (System.currentTimeMillis() - start);
}
 
开发者ID:jetonmemeti,项目名称:android-signature-tests,代码行数:11,代码来源:CreateKeysTest.java


示例9: generateKeyPair

import org.spongycastle.jce.spec.ECParameterSpec; //导入依赖的package包/类
public static KeyPair generateKeyPair(PKIAlgorithm algorithm) throws UnknownPKIAlgorithmException,
        NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
	if (algorithm.getCode() != PKIAlgorithm.DEFAULT.getCode())
		throw new UnknownPKIAlgorithmException();

	ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(algorithm.getKeyPairSpecification());
	KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm.getKeyPairAlgorithm(), SECURITY_PROVIDER);
	keyGen.initialize(ecSpec, new SecureRandom());
	return keyGen.generateKeyPair();
}
 
开发者ID:jetonmemeti,项目名称:SamplePaymentProject,代码行数:11,代码来源:KeyHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OAuth2Template类代码示例发布时间:2022-05-21
下一篇:
Java LexicalizedParser类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap