本文整理匯總了Java中org.bouncycastle.asn1.x9.X9ECParameters.getSeed方法的典型用法代碼示例。如果您正苦於以下問題:Java X9ECParameters.getSeed方法的具體用法?Java X9ECParameters.getSeed怎麽用?Java X9ECParameters.getSeed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bouncycastle.asn1.x9.X9ECParameters
的用法示例。
在下文中一共展示了X9ECParameters.getSeed方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getParameterSpec
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
/**
* return a parameter spec representing the passed in named
* curve. The routine returns null if the curve is not present.
*
* @param name the name of the curve requested
* @return a parameter spec for the curve, null if it is not available.
*/
public static ECNamedCurveParameterSpec getParameterSpec(
String name)
{
X9ECParameters ecP = X962NamedCurves.getByName(name);
if (ecP == null)
{
return null;
}
return new ECNamedCurveParameterSpec(
name,
ecP.getCurve(),
ecP.getG(),
ecP.getN(),
ecP.getH(),
ecP.getSeed());
}
示例2: getParametersForNamedCurve
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
String curveName = getNameOfNamedCurve(namedCurve);
if (curveName == null)
{
return null;
}
// Lazily created the first time a particular curve is accessed
X9ECParameters ecP = SECNamedCurves.getByName(curveName);
if (ecP == null)
{
return null;
}
// It's a bit inefficient to do this conversion every time
return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
示例3: testExportImport
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
@Test
public void testExportImport() throws GeneralSecurityException {
// Create a curve25519 parameter spec
X9ECParameters params = CustomNamedCurves.getByName("curve25519");
ECParameterSpec ecParameterSpec = new ECParameterSpec(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed());
// Create public key
KeyAgreementPeer peer = new ECDHPeer(ecParameterSpec, null, "BC");
ECPublicKey ecPublicKey = (ECPublicKey) peer.getPublicKey();
// Export public key
byte[] encoded = ecPublicKey.getQ().getEncoded(true);
System.out.println(Arrays.toString(encoded));
System.out.println("Encoded length: " + encoded.length);
// Import public key
ECPublicKey importedECPublicKey = loadPublicKey(encoded);
Assert.assertArrayEquals(ecPublicKey.getEncoded(), importedECPublicKey.getEncoded());
}
示例4: getParametersForNamedCurve
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
String curveName = getNameOfNamedCurve(namedCurve);
if (curveName == null)
{
return null;
}
// Parameters are lazily created the first time a particular curve is accessed
X9ECParameters ecP = CustomNamedCurves.getByName(curveName);
if (ecP == null)
{
ecP = ECNamedCurveTable.getByName(curveName);
if (ecP == null)
{
return null;
}
}
// It's a bit inefficient to do this conversion every time
return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
示例5: loadPublicKey
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
/**
* Loads and returns the elliptic-curve public key from the data byte array.
* @param data
* @return
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @throws InvalidKeySpecException
*/
public static ECPublicKey loadPublicKey(byte[] data) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException
{
X9ECParameters params = CustomNamedCurves.getByName("curve25519");
ECParameterSpec ecParameterSpec = new ECParameterSpec(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed());
ECPublicKeySpec publicKey = new ECPublicKeySpec(ecParameterSpec.getCurve().decodePoint(data), ecParameterSpec);
KeyFactory kf = KeyFactory.getInstance("ECDH", "BC");
return (ECPublicKey) kf.generatePublic(publicKey);
}
示例6: generateECPublicKey
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
public static AsymmetricCipherKeyPair generateECPublicKey() {
// Should we also generate random curves?
X9ECParameters ecp = SECNamedCurves.getByName(getRandomCurveName());
ECKeyPairGenerator keygen = new ECKeyPairGenerator();
ECDomainParameters domainParams = new ECDomainParameters(ecp.getCurve(), ecp.getG(), ecp.getN(), ecp.getH(),
ecp.getSeed());
keygen.init(new ECKeyGenerationParameters(domainParams, RandomHelper.getBadSecureRandom()));
return keygen.generateKeyPair();
}
示例7: testECMQVTestVector1
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
private void testECMQVTestVector1()
{
// Test Vector from GEC-2
X9ECParameters x9 = SECNamedCurves.getByName("secp160r1");
ECDomainParameters p = new ECDomainParameters(
x9.getCurve(), x9.getG(), x9.getN(), x9.getH(), x9.getSeed());
AsymmetricCipherKeyPair U1 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("0251B4496FECC406ED0E75A24A3C03206251419DC0")), p),
new ECPrivateKeyParameters(
new BigInteger("AA374FFC3CE144E6B073307972CB6D57B2A4E982", 16), p));
AsymmetricCipherKeyPair U2 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("03D99CE4D8BF52FA20BD21A962C6556B0F71F4CA1F")), p),
new ECPrivateKeyParameters(
new BigInteger("149EC7EA3A220A887619B3F9E5B4CA51C7D1779C", 16), p));
AsymmetricCipherKeyPair V1 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("0349B41E0E9C0369C2328739D90F63D56707C6E5BC")), p),
new ECPrivateKeyParameters(
new BigInteger("45FB58A92A17AD4B15101C66E74F277E2B460866", 16), p));
AsymmetricCipherKeyPair V2 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("02706E5D6E1F640C6E9C804E75DBC14521B1E5F3B5")), p),
new ECPrivateKeyParameters(
new BigInteger("18C13FCED9EADF884F7C595C8CB565DEFD0CB41E", 16), p));
BigInteger x = calculateAgreement(U1, U2, V1, V2);
if (x == null
|| !x.equals(new BigInteger("5A6955CEFDB4E43255FB7FCF718611E4DF8E05AC", 16)))
{
fail("MQV Test Vector #1 agreement failed");
}
}
示例8: testECMQVTestVector2
import org.bouncycastle.asn1.x9.X9ECParameters; //導入方法依賴的package包/類
private void testECMQVTestVector2()
{
// Test Vector from GEC-2
X9ECParameters x9 = SECNamedCurves.getByName("sect163k1");
ECDomainParameters p = new ECDomainParameters(
x9.getCurve(), x9.getG(), x9.getN(), x9.getH(), x9.getSeed());
AsymmetricCipherKeyPair U1 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("03037D529FA37E42195F10111127FFB2BB38644806BC")), p),
new ECPrivateKeyParameters(
new BigInteger("03A41434AA99C2EF40C8495B2ED9739CB2155A1E0D", 16), p));
AsymmetricCipherKeyPair U2 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("02015198E74BC2F1E5C9A62B80248DF0D62B9ADF8429")), p),
new ECPrivateKeyParameters(
new BigInteger("032FC4C61A8211E6A7C4B8B0C03CF35F7CF20DBD52", 16), p));
AsymmetricCipherKeyPair V1 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("03072783FAAB9549002B4F13140B88132D1C75B3886C")), p),
new ECPrivateKeyParameters(
new BigInteger("57E8A78E842BF4ACD5C315AA0569DB1703541D96", 16), p));
AsymmetricCipherKeyPair V2 = new AsymmetricCipherKeyPair(
new ECPublicKeyParameters(
p.getCurve().decodePoint(Hex.decode("03067E3AEA3510D69E8EDD19CB2A703DDC6CF5E56E32")), p),
new ECPrivateKeyParameters(
new BigInteger("02BD198B83A667A8D908EA1E6F90FD5C6D695DE94F", 16), p));
BigInteger x = calculateAgreement(U1, U2, V1, V2);
if (x == null
|| !x.equals(new BigInteger("038359FFD30C0D5FC1E6154F483B73D43E5CF2B503", 16)))
{
fail("MQV Test Vector #2 agreement failed");
}
}