use of com.github.zhenwei.provider.jce.spec.GOST3410PublicKeyParameterSetSpec in project LinLong-Java by zhenwei1108.
the class GOST3410Util method generatePublicKeyParameter.
public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey key) throws InvalidKeyException {
if (key instanceof GOST3410PublicKey) {
GOST3410PublicKey k = (GOST3410PublicKey) key;
GOST3410PublicKeyParameterSetSpec p = k.getParameters().getPublicKeyParameters();
return new GOST3410PublicKeyParameters(k.getY(), new GOST3410Parameters(p.getP(), p.getQ(), p.getA()));
}
throw new InvalidKeyException("can't identify GOST3410 public key: " + key.getClass().getName());
}
use of com.github.zhenwei.provider.jce.spec.GOST3410PublicKeyParameterSetSpec in project LinLong-Java by zhenwei1108.
the class AlgorithmParameterGeneratorSpi method engineGenerateParameters.
protected AlgorithmParameters engineGenerateParameters() {
GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator();
if (random != null) {
pGen.init(strength, 2, random);
} else {
pGen.init(strength, 2, CryptoServicesRegistrar.getSecureRandom());
}
GOST3410Parameters p = pGen.generateParameters();
AlgorithmParameters params;
try {
params = createParametersInstance("GOST3410");
params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA())));
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
return params;
}
use of com.github.zhenwei.provider.jce.spec.GOST3410PublicKeyParameterSetSpec in project LinLong-Java by zhenwei1108.
the class BCGOST3410PrivateKey method readObject.
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
String publicKeyParamSetOID = (String) in.readObject();
if (publicKeyParamSetOID != null) {
this.gost3410Spec = new GOST3410ParameterSpec(publicKeyParamSetOID, (String) in.readObject(), (String) in.readObject());
} else {
this.gost3410Spec = new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec((BigInteger) in.readObject(), (BigInteger) in.readObject(), (BigInteger) in.readObject()));
in.readObject();
in.readObject();
}
this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
}
use of com.github.zhenwei.provider.jce.spec.GOST3410PublicKeyParameterSetSpec in project LinLong-Java by zhenwei1108.
the class BCGOST3410PublicKey method readObject.
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
String publicKeyParamSetOID = (String) in.readObject();
if (publicKeyParamSetOID != null) {
this.gost3410Spec = new GOST3410ParameterSpec(publicKeyParamSetOID, (String) in.readObject(), (String) in.readObject());
} else {
this.gost3410Spec = new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec((BigInteger) in.readObject(), (BigInteger) in.readObject(), (BigInteger) in.readObject()));
in.readObject();
in.readObject();
}
}
use of com.github.zhenwei.provider.jce.spec.GOST3410PublicKeyParameterSetSpec in project LinLong-Java by zhenwei1108.
the class KeyFactorySpi method engineGetKeySpec.
protected KeySpec engineGetKeySpec(Key key, Class spec) throws InvalidKeySpecException {
if (spec.isAssignableFrom(GOST3410PublicKeySpec.class) && key instanceof GOST3410PublicKey) {
GOST3410PublicKey k = (GOST3410PublicKey) key;
GOST3410PublicKeyParameterSetSpec parameters = k.getParameters().getPublicKeyParameters();
return new GOST3410PublicKeySpec(k.getY(), parameters.getP(), parameters.getQ(), parameters.getA());
} else if (spec.isAssignableFrom(GOST3410PrivateKeySpec.class) && key instanceof GOST3410PrivateKey) {
GOST3410PrivateKey k = (GOST3410PrivateKey) key;
GOST3410PublicKeyParameterSetSpec parameters = k.getParameters().getPublicKeyParameters();
return new GOST3410PrivateKeySpec(k.getX(), parameters.getP(), parameters.getQ(), parameters.getA());
}
return super.engineGetKeySpec(key, spec);
}
Aggregations