use of com.github.zhenwei.pkix.util.oer.its.EccCurvePoint in project LinLong-Java by zhenwei1108.
the class BcITSPublicEncryptionKey method getKey.
public AsymmetricKeyParameter getKey() {
X9ECParameters params;
BasePublicEncryptionKey baseKey = encryptionKey.getBasePublicEncryptionKey();
ASN1ObjectIdentifier curveID;
switch(baseKey.getChoice()) {
case BasePublicEncryptionKey.eciesNistP256:
curveID = SECObjectIdentifiers.secp256r1;
params = NISTNamedCurves.getByOID(SECObjectIdentifiers.secp256r1);
break;
case BasePublicEncryptionKey.eciesBrainpoolP256r1:
curveID = TeleTrusTObjectIdentifiers.brainpoolP256r1;
params = TeleTrusTNamedCurves.getByOID(TeleTrusTObjectIdentifiers.brainpoolP256r1);
break;
default:
throw new IllegalStateException("unknown key type");
}
ECCurve curve = params.getCurve();
ASN1Encodable pviCurvePoint = encryptionKey.getBasePublicEncryptionKey().getValue();
final EccCurvePoint itsPoint;
if (pviCurvePoint instanceof EccCurvePoint) {
itsPoint = (EccCurvePoint) baseKey.getValue();
} else {
throw new IllegalStateException("extension to public verification key not supported");
}
byte[] key;
if (itsPoint instanceof EccP256CurvePoint) {
key = itsPoint.getEncodedPoint();
} else if (itsPoint instanceof EccP384CurvePoint) {
key = itsPoint.getEncodedPoint();
} else {
throw new IllegalStateException("unknown key type");
}
ECPoint point = curve.decodePoint(key).normalize();
return new ECPublicKeyParameters(point, new ECNamedDomainParameters(curveID, params));
}
use of com.github.zhenwei.pkix.util.oer.its.EccCurvePoint in project LinLong-Java by zhenwei1108.
the class BcITSPublicVerificationKey method getKey.
public AsymmetricKeyParameter getKey() {
X9ECParameters params;
ASN1ObjectIdentifier curveID;
switch(verificationKey.getChoice()) {
case PublicVerificationKey.ecdsaNistP256:
curveID = SECObjectIdentifiers.secp256r1;
params = NISTNamedCurves.getByOID(SECObjectIdentifiers.secp256r1);
break;
case PublicVerificationKey.ecdsaBrainpoolP256r1:
curveID = TeleTrusTObjectIdentifiers.brainpoolP256r1;
params = TeleTrusTNamedCurves.getByOID(TeleTrusTObjectIdentifiers.brainpoolP256r1);
break;
case PublicVerificationKey.ecdsaBrainpoolP384r1:
curveID = TeleTrusTObjectIdentifiers.brainpoolP384r1;
params = TeleTrusTNamedCurves.getByOID(TeleTrusTObjectIdentifiers.brainpoolP384r1);
break;
default:
throw new IllegalStateException("unknown key type");
}
ECCurve curve = params.getCurve();
ASN1Encodable pviCurvePoint = verificationKey.getCurvePoint();
final EccCurvePoint itsPoint;
if (pviCurvePoint instanceof EccCurvePoint) {
itsPoint = (EccCurvePoint) verificationKey.getCurvePoint();
} else {
throw new IllegalStateException("extension to public verification key not supported");
}
byte[] key;
if (itsPoint instanceof EccP256CurvePoint) {
key = itsPoint.getEncodedPoint();
} else if (itsPoint instanceof EccP384CurvePoint) {
key = itsPoint.getEncodedPoint();
} else {
throw new IllegalStateException("unknown key type");
}
ECPoint point = curve.decodePoint(key).normalize();
return new ECPublicKeyParameters(point, new ECNamedDomainParameters(curveID, params));
}
use of com.github.zhenwei.pkix.util.oer.its.EccCurvePoint in project LinLong-Java by zhenwei1108.
the class JcaITSPublicVerificationKey method getKey.
public PublicKey getKey() {
X9ECParameters params;
switch(verificationKey.getChoice()) {
case PublicVerificationKey.ecdsaNistP256:
params = NISTNamedCurves.getByOID(SECObjectIdentifiers.secp256r1);
break;
case PublicVerificationKey.ecdsaBrainpoolP256r1:
params = TeleTrusTNamedCurves.getByOID(TeleTrusTObjectIdentifiers.brainpoolP256r1);
break;
case PublicVerificationKey.ecdsaBrainpoolP384r1:
params = TeleTrusTNamedCurves.getByOID(TeleTrusTObjectIdentifiers.brainpoolP384r1);
break;
default:
throw new IllegalStateException("unknown key type");
}
ECCurve curve = params.getCurve();
ASN1Encodable pviCurvePoint = verificationKey.getCurvePoint();
final EccCurvePoint itsPoint;
if (pviCurvePoint instanceof EccCurvePoint) {
itsPoint = (EccCurvePoint) verificationKey.getCurvePoint();
} else {
throw new IllegalStateException("extension to public verification key not supported");
}
byte[] key;
if (itsPoint instanceof EccP256CurvePoint) {
key = itsPoint.getEncodedPoint();
} else if (itsPoint instanceof EccP384CurvePoint) {
key = itsPoint.getEncodedPoint();
} else {
throw new IllegalStateException("unknown key type");
}
ECPoint point = curve.decodePoint(key).normalize();
try {
KeyFactory keyFactory = helper.createKeyFactory("EC");
ECParameterSpec spec = EC5Util.convertToSpec(params);
java.security.spec.ECPoint jPoint = EC5Util.convertPoint(point);
return keyFactory.generatePublic(new ECPublicKeySpec(jPoint, spec));
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
use of com.github.zhenwei.pkix.util.oer.its.EccCurvePoint in project LinLong-Java by zhenwei1108.
the class JceITSPublicEncryptionKey method getKey.
public PublicKey getKey() {
BasePublicEncryptionKey baseKey = encryptionKey.getBasePublicEncryptionKey();
X9ECParameters params;
switch(baseKey.getChoice()) {
case BasePublicEncryptionKey.eciesNistP256:
params = NISTNamedCurves.getByOID(SECObjectIdentifiers.secp256r1);
break;
case BasePublicEncryptionKey.eciesBrainpoolP256r1:
params = TeleTrusTNamedCurves.getByOID(TeleTrusTObjectIdentifiers.brainpoolP256r1);
break;
default:
throw new IllegalStateException("unknown key type");
}
ASN1Encodable pviCurvePoint = encryptionKey.getBasePublicEncryptionKey().getValue();
final EccCurvePoint itsPoint;
if (pviCurvePoint instanceof EccCurvePoint) {
itsPoint = (EccCurvePoint) baseKey.getValue();
} else {
throw new IllegalStateException("extension to public verification key not supported");
}
ECCurve curve = params.getCurve();
byte[] key;
if (itsPoint instanceof EccP256CurvePoint) {
key = itsPoint.getEncodedPoint();
} else if (itsPoint instanceof EccP384CurvePoint) {
key = itsPoint.getEncodedPoint();
} else {
throw new IllegalStateException("unknown key type");
}
ECPoint point = curve.decodePoint(key).normalize();
try {
KeyFactory keyFactory = helper.createKeyFactory("EC");
ECParameterSpec spec = EC5Util.convertToSpec(params);
java.security.spec.ECPoint jPoint = EC5Util.convertPoint(point);
return keyFactory.generatePublic(new ECPublicKeySpec(jPoint, spec));
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
Aggregations