use of com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
if (!initialised) {
throw new IllegalStateException("EC Key Pair Generator not initialised");
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
ECPublicKeyParameters pub = (ECPublicKeyParameters) pair.getPublic();
ECPrivateKeyParameters priv = (ECPrivateKeyParameters) pair.getPrivate();
if (ecParams instanceof ECParameterSpec) {
ECParameterSpec p = (ECParameterSpec) ecParams;
BCECGOST3410PublicKey pubKey = new BCECGOST3410PublicKey(algorithm, pub, p);
return new KeyPair(pubKey, new BCECGOST3410PrivateKey(algorithm, priv, pubKey, p));
} else if (ecParams == null) {
return new KeyPair(new BCECGOST3410PublicKey(algorithm, pub), new BCECGOST3410PrivateKey(algorithm, priv));
} else {
java.security.spec.ECParameterSpec p = (java.security.spec.ECParameterSpec) ecParams;
BCECGOST3410PublicKey pubKey = new BCECGOST3410PublicKey(algorithm, pub, p);
return new KeyPair(pubKey, new BCECGOST3410PrivateKey(algorithm, priv, pubKey, p));
}
}
use of com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
if (!initialised) {
throw new IllegalStateException("EC Key Pair Generator not initialised");
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
ECPublicKeyParameters pub = (ECPublicKeyParameters) pair.getPublic();
ECPrivateKeyParameters priv = (ECPrivateKeyParameters) pair.getPrivate();
if (ecParams instanceof ECParameterSpec) {
ECParameterSpec p = (ECParameterSpec) ecParams;
BCECGOST3410_2012PublicKey pubKey = new BCECGOST3410_2012PublicKey(algorithm, pub, p);
return new KeyPair(pubKey, new BCECGOST3410_2012PrivateKey(algorithm, priv, pubKey, p));
} else if (ecParams == null) {
return new KeyPair(new BCECGOST3410_2012PublicKey(algorithm, pub), new BCECGOST3410_2012PrivateKey(algorithm, priv));
} else {
java.security.spec.ECParameterSpec p = (java.security.spec.ECParameterSpec) ecParams;
BCECGOST3410_2012PublicKey pubKey = new BCECGOST3410_2012PublicKey(algorithm, pub, p);
return new KeyPair(pubKey, new BCECGOST3410_2012PrivateKey(algorithm, priv, pubKey, p));
}
}
use of com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
if (!initialised) {
init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), CryptoServicesRegistrar.getSecureRandom());
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
GOST3410PublicKeyParameters pub = (GOST3410PublicKeyParameters) pair.getPublic();
GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters) pair.getPrivate();
return new KeyPair(new BCGOST3410PublicKey(pub, gost3410Params), new BCGOST3410PrivateKey(priv, gost3410Params));
}
use of com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair in project LinLong-Java by zhenwei1108.
the class KeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
RSAKeyParameters pub = (RSAKeyParameters) pair.getPublic();
RSAPrivateCrtKeyParameters priv = (RSAPrivateCrtKeyParameters) pair.getPrivate();
return new KeyPair(new BCRSAPublicKey(algId, pub), new BCRSAPrivateCrtKey(algId, priv));
}
use of com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair in project LinLong-Java by zhenwei1108.
the class XMSSKeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
if (!initialised) {
param = new XMSSKeyGenerationParameters(new XMSSParameters(10, new SHA512Digest()), random);
engine.init(param);
initialised = true;
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
XMSSPublicKeyParameters pub = (XMSSPublicKeyParameters) pair.getPublic();
XMSSPrivateKeyParameters priv = (XMSSPrivateKeyParameters) pair.getPrivate();
return new KeyPair(new BCXMSSPublicKey(treeDigest, pub), new BCXMSSPrivateKey(treeDigest, priv));
}
Aggregations