Java Code Examples for sun.security.util.ECUtil#getECParameterSpec()

The following examples show how to use sun.security.util.ECUtil#getECParameterSpec() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ECKeyPairGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
        throws InvalidAlgorithmParameterException {

    if (params instanceof ECParameterSpec) {
        this.params = ECUtil.getECParameterSpec(null,
                                                (ECParameterSpec)params);
        if (this.params == null) {
            throw new InvalidAlgorithmParameterException(
                "Unsupported curve: " + params);
        }
    } else if (params instanceof ECGenParameterSpec) {
        String name = ((ECGenParameterSpec)params).getName();
        this.params = ECUtil.getECParameterSpec(null, name);
        if (this.params == null) {
            throw new InvalidAlgorithmParameterException(
                "Unknown curve name: " + name);
        }
    } else {
        throw new InvalidAlgorithmParameterException(
            "ECParameterSpec or ECGenParameterSpec required for EC");
    }
    this.keySize =
        ((ECParameterSpec)this.params).getCurve().getField().getFieldSize();
    this.random = random;
}
 
Example 2
Source File: ECKeyPairGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
        throws InvalidAlgorithmParameterException {

    if (params instanceof ECParameterSpec) {
        this.params = ECUtil.getECParameterSpec(null,
                                                (ECParameterSpec)params);
        if (this.params == null) {
            throw new InvalidAlgorithmParameterException(
                "Unsupported curve: " + params);
        }
    } else if (params instanceof ECGenParameterSpec) {
        String name = ((ECGenParameterSpec)params).getName();
        this.params = ECUtil.getECParameterSpec(null, name);
        if (this.params == null) {
            throw new InvalidAlgorithmParameterException(
                "Unknown curve name: " + name);
        }
    } else {
        throw new InvalidAlgorithmParameterException(
            "ECParameterSpec or ECGenParameterSpec required for EC");
    }
    this.keySize =
        ((ECParameterSpec)this.params).getCurve().getField().getFieldSize();
    this.random = random;
}
 
Example 3
Source File: TestECDSA2.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private KeyPair genECKeyPair(String curvName, String privD, String pubX,
        String pubY, Provider p) throws Exception {
    ECParameterSpec ecParams = ECUtil.getECParameterSpec(p, curvName);
    ECPrivateKeySpec privKeySpec =
        new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
    ECPublicKeySpec pubKeySpec =
        new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16), new BigInteger(pubY, 16)),
                            ecParams);
    PrivateKey privKey = kf.generatePrivate(privKeySpec);
    PublicKey pubKey = kf.generatePublic(pubKeySpec);
    return new KeyPair(pubKey, privKey);
}
 
Example 4
Source File: TestECDSA2.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private KeyPair genECKeyPair(String curvName, String privD, String pubX,
        String pubY, Provider p) throws Exception {
    ECParameterSpec ecParams = ECUtil.getECParameterSpec(p, curvName);
    ECPrivateKeySpec privKeySpec =
        new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
    ECPublicKeySpec pubKeySpec =
        new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16), new BigInteger(pubY, 16)),
                            ecParams);
    PrivateKey privKey = kf.generatePrivate(privKeySpec);
    PublicKey pubKey = kf.generatePublic(pubKeySpec);
    return new KeyPair(pubKey, privKey);
}
 
Example 5
Source File: TestECDSA2.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private KeyPair genECKeyPair(String curvName, String privD, String pubX,
        String pubY, Provider p) throws Exception {
    ECParameterSpec ecParams = ECUtil.getECParameterSpec(p, curvName);
    ECPrivateKeySpec privKeySpec =
        new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
    ECPublicKeySpec pubKeySpec =
        new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16), new BigInteger(pubY, 16)),
                            ecParams);
    PrivateKey privKey = kf.generatePrivate(privKeySpec);
    PublicKey pubKey = kf.generatePublic(pubKeySpec);
    return new KeyPair(pubKey, privKey);
}
 
Example 6
Source File: TestECDH2.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private KeyPair genECKeyPair(String curvName, String privD, String pubX,
                             String pubY, Provider p) throws Exception {
    ECParameterSpec ecParams = ECUtil.getECParameterSpec(p, curvName);
    ECPrivateKeySpec privKeySpec =
        new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
    ECPublicKeySpec pubKeySpec =
        new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16),
                                        new BigInteger(pubY, 16)),
                            ecParams);
    PrivateKey privKey = kf.generatePrivate(privKeySpec);
    PublicKey pubKey = kf.generatePublic(pubKeySpec);
    return new KeyPair(pubKey, privKey);
}
 
Example 7
Source File: ECKeyPairGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initialize(int keySize, SecureRandom random) {

    checkKeySize(keySize);
    this.params = ECUtil.getECParameterSpec(null, keySize);
    if (params == null) {
        throw new InvalidParameterException(
            "No EC parameters available for key size " + keySize + " bits");
    }
    this.random = random;
}
 
Example 8
Source File: TestECDSA2.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private KeyPair genECKeyPair(String curvName, String privD, String pubX,
        String pubY, Provider p) throws Exception {
    ECParameterSpec ecParams = ECUtil.getECParameterSpec(p, curvName);
    ECPrivateKeySpec privKeySpec =
        new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
    ECPublicKeySpec pubKeySpec =
        new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16), new BigInteger(pubY, 16)),
                            ecParams);
    PrivateKey privKey = kf.generatePrivate(privKeySpec);
    PublicKey pubKey = kf.generatePublic(pubKeySpec);
    return new KeyPair(pubKey, privKey);
}
 
Example 9
Source File: P11ECKeyFactory.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(ECParameterSpec spec) {
    return ECUtil.getECParameterSpec(getSunECProvider(), spec);
}
 
Example 10
Source File: P11ECKeyFactory.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec decodeParameters(byte[] params) throws IOException {
    return ECUtil.getECParameterSpec(getSunECProvider(), params);
}
 
Example 11
Source File: P11ECKeyFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec decodeParameters(byte[] params) throws IOException {
    return ECUtil.getECParameterSpec(getSunECProvider(), params);
}
 
Example 12
Source File: P11ECKeyFactory.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec decodeParameters(byte[] params) throws IOException {
    return ECUtil.getECParameterSpec(getSunECProvider(), params);
}
 
Example 13
Source File: P11ECKeyFactory.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(ECParameterSpec spec) {
    return ECUtil.getECParameterSpec(getSunECProvider(), spec);
}
 
Example 14
Source File: P11ECKeyFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(int keySize) {
    return ECUtil.getECParameterSpec(getSunECProvider(), keySize);
}
 
Example 15
Source File: P11ECKeyFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(String name) {
    return ECUtil.getECParameterSpec(getSunECProvider(), name);
}
 
Example 16
Source File: P11ECKeyFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(String name) {
    return ECUtil.getECParameterSpec(getSunECProvider(), name);
}
 
Example 17
Source File: JsseJce.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(String namedCurveOid) {
    return ECUtil.getECParameterSpec(cryptoProvider, namedCurveOid);
}
 
Example 18
Source File: P11ECKeyFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(String name) {
    return ECUtil.getECParameterSpec(getSunECProvider(), name);
}
 
Example 19
Source File: P11ECKeyFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec getECParameterSpec(ECParameterSpec spec) {
    return ECUtil.getECParameterSpec(getSunECProvider(), spec);
}
 
Example 20
Source File: P11ECKeyFactory.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static ECParameterSpec decodeParameters(byte[] params) throws IOException {
    return ECUtil.getECParameterSpec(getSunECProvider(), params);
}