本文整理汇总了Java中org.spongycastle.jce.ECNamedCurveTable类的典型用法代码示例。如果您正苦于以下问题:Java ECNamedCurveTable类的具体用法?Java ECNamedCurveTable怎么用?Java ECNamedCurveTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ECNamedCurveTable类属于org.spongycastle.jce包,在下文中一共展示了ECNamedCurveTable类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadEcPublicKey
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
private static Key loadEcPublicKey(final byte [] pubKey,
final EcCurve curveName) throws NoSuchAlgorithmException,
InvalidKeySpecException {
final ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(curveName.toString());
KeyFactory kf;
try {
kf = KeyFactory.getInstance(ECDH, BouncyCastleProvider.PROVIDER_NAME);
}
catch (final NoSuchProviderException e) {
kf = KeyFactory.getInstance(ECDH);
}
final ECNamedCurveSpec params = new ECNamedCurveSpec(curveName.toString(), spec.getCurve(), spec.getG(), spec.getN());
final ECPoint point = ECPointUtil.decodePoint(params.getCurve(), pubKey);
final java.security.spec.ECPublicKeySpec pubKeySpec = new java.security.spec.ECPublicKeySpec(point, params);
return kf.generatePublic(pubKeySpec);
}
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:17,代码来源:JseCryptoHelper.java
示例2: getEcPoint
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
@Override
public AlgorithmParameterSpec getEcPoint(final byte[] nonceS, final byte[] sharedSecretH, final EcCurve curveName) {
final AlgorithmParameterSpec ecParams = ECNamedCurveTable.getParameterSpec(curveName.toString());
final BigInteger affineX = os2i(sharedSecretH);
final BigInteger affineY = computeAffineY(affineX, (ECParameterSpec) ecParams);
final ECPoint sharedSecretPointH = new ECPoint(affineX, affineY);
return mapNonceGMWithECDH(os2i(nonceS), sharedSecretPointH, (ECParameterSpec) ecParams);
}
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:9,代码来源:JseCryptoHelper.java
示例3: getParameterSpec
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的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
示例4: generate
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的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
示例5: getPubKeyFromCurve
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
/**
* Decode based on X, Y 32 byte integers
* @param pubKey
* @param curveName - Example secp256r1
* @return
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
*/
public static PublicKey getPubKeyFromCurve (byte[] pubKey, String curveName) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(curveName);
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec(curveName, spec.getCurve(), spec.getG(), spec.getN());
ECPoint point = ECPointUtil.decodePoint(params.getCurve(), pubKey);
ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params);
ECPublicKey pk = (ECPublicKey) kf.generatePublic(pubKeySpec);
return pk;
}
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:20,代码来源:KeyCodec.java
示例6: getPrivKeyFromCurve
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
/**
* Decode based on d - 32 byte integer
* @param privKey
* @param curveName - Example secp256r1
* @return
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
*/
public static PrivateKey getPrivKeyFromCurve (byte[] privKey, String curveName) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(curveName);
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec(curveName, spec.getCurve(), spec.getG(), spec.getN());
ECPrivateKeySpec priKey = new ECPrivateKeySpec(
new BigInteger(privKey), // d
params);
return kf.generatePrivate(priKey);
}
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:20,代码来源:KeyCodec.java
示例7: generate
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的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
示例8: getPubKeyFromCurve
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
/**
* Decode based on X, Y 32 byte integers
*
* @param pubKey
* @param curveName - Example secp256r1
* @return
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
*/
public static PublicKey getPubKeyFromCurve(byte[] pubKey, String curveName) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(curveName);
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec(curveName, spec.getCurve(), spec.getG(), spec.getN());
ECPoint point = ECPointUtil.decodePoint(params.getCurve(), pubKey);
ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params);
ECPublicKey pk = (ECPublicKey) kf.generatePublic(pubKeySpec);
return pk;
}
开发者ID:eBay,项目名称:UAF,代码行数:21,代码来源:KeyCodec.java
示例9: getPrivKeyFromCurve
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
/**
* Decode based on d - 32 byte integer
*
* @param privKey
* @param curveName - Example secp256r1
* @return
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
*/
public static PrivateKey getPrivKeyFromCurve(byte[] privKey, String curveName) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(curveName);
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec(curveName, spec.getCurve(), spec.getG(), spec.getN());
ECPrivateKeySpec priKey = new ECPrivateKeySpec(
new BigInteger(privKey), // d
params);
return kf.generatePrivate(priKey);
}
开发者ID:eBay,项目名称:UAF,代码行数:21,代码来源:KeyCodec.java
示例10: generateNewKey
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的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
示例11: createECCKeys
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的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
示例12: generateKeyPair
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的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
示例13: decodeNISTP256PublicKeyFromBytes
import org.spongycastle.jce.ECNamedCurveTable; //导入依赖的package包/类
/**
* <p>
* Get an EC public key from a byte array suitable for use with ssh
* operations</p>
*
* <p>
* Note: This is not a Bitcoin EC public key</p>
*
* @param pubKey The ecdsa-sha2-nistp256 EC public key encoded as bytes
*
* @return An EC public key
*
* @throws NoSuchAlgorithmException If ECDSA is not available
* @throws InvalidKeySpecException If the key is invalid
*/
public static ECPublicKey decodeNISTP256PublicKeyFromBytes(byte[] pubKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("P-256");
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec("P-256", spec.getCurve(), spec.getG(), spec.getN());
ECPoint point = ECPointUtil.decodePoint(params.getCurve(), pubKey);
ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params);
ECPublicKey pk = (ECPublicKey) kf.generatePublic(pubKeySpec);
return pk;
}
开发者ID:martin-lizner,项目名称:trezor-ssh-agent,代码行数:27,代码来源:IdentityUtils.java
注:本文中的org.spongycastle.jce.ECNamedCurveTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论