Search in sources :

Example 21 with AsymmetricCipherKeyPair

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));
    }
}
Also used : ECPrivateKeyParameters(com.github.zhenwei.core.crypto.params.ECPrivateKeyParameters) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) ECParameterSpec(com.github.zhenwei.provider.jce.spec.ECParameterSpec) ECPublicKeyParameters(com.github.zhenwei.core.crypto.params.ECPublicKeyParameters) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)

Example 22 with AsymmetricCipherKeyPair

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));
    }
}
Also used : ECPrivateKeyParameters(com.github.zhenwei.core.crypto.params.ECPrivateKeyParameters) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) ECParameterSpec(com.github.zhenwei.provider.jce.spec.ECParameterSpec) ECPublicKeyParameters(com.github.zhenwei.core.crypto.params.ECPublicKeyParameters) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)

Example 23 with AsymmetricCipherKeyPair

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));
}
Also used : KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) GOST3410PrivateKeyParameters(com.github.zhenwei.core.crypto.params.GOST3410PrivateKeyParameters) GOST3410PublicKeyParameters(com.github.zhenwei.core.crypto.params.GOST3410PublicKeyParameters) GOST3410ParameterSpec(com.github.zhenwei.provider.jce.spec.GOST3410ParameterSpec) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)

Example 24 with AsymmetricCipherKeyPair

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));
}
Also used : KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) RSAKeyParameters(com.github.zhenwei.core.crypto.params.RSAKeyParameters) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) RSAPrivateCrtKeyParameters(com.github.zhenwei.core.crypto.params.RSAPrivateCrtKeyParameters)

Example 25 with AsymmetricCipherKeyPair

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));
}
Also used : SHA512Digest(com.github.zhenwei.core.crypto.digests.SHA512Digest) XMSSParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSParameters) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) XMSSPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSPrivateKeyParameters) XMSSKeyGenerationParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSKeyGenerationParameters) XMSSPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSPublicKeyParameters) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)

Aggregations

AsymmetricCipherKeyPair (com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)41 KeyPair (java.security.KeyPair)17 BigInteger (java.math.BigInteger)9 ECPrivateKeyParameters (com.github.zhenwei.core.crypto.params.ECPrivateKeyParameters)6 ECPublicKeyParameters (com.github.zhenwei.core.crypto.params.ECPublicKeyParameters)6 DHPublicKeyParameters (com.github.zhenwei.core.crypto.params.DHPublicKeyParameters)4 DHParameters (com.github.zhenwei.core.crypto.params.DHParameters)3 DHPrivateKeyParameters (com.github.zhenwei.core.crypto.params.DHPrivateKeyParameters)3 ECParameterSpec (com.github.zhenwei.provider.jce.spec.ECParameterSpec)3 SHA512Digest (com.github.zhenwei.core.crypto.digests.SHA512Digest)2 DHKeyGenerationParameters (com.github.zhenwei.core.crypto.params.DHKeyGenerationParameters)2 DSAPrivateKeyParameters (com.github.zhenwei.core.crypto.params.DSAPrivateKeyParameters)2 DSAPublicKeyParameters (com.github.zhenwei.core.crypto.params.DSAPublicKeyParameters)2 ElGamalParameters (com.github.zhenwei.core.crypto.params.ElGamalParameters)2 ElGamalPrivateKeyParameters (com.github.zhenwei.core.crypto.params.ElGamalPrivateKeyParameters)2 ElGamalPublicKeyParameters (com.github.zhenwei.core.crypto.params.ElGamalPublicKeyParameters)2 GOST3410PrivateKeyParameters (com.github.zhenwei.core.crypto.params.GOST3410PrivateKeyParameters)2 GOST3410PublicKeyParameters (com.github.zhenwei.core.crypto.params.GOST3410PublicKeyParameters)2 RSAKeyParameters (com.github.zhenwei.core.crypto.params.RSAKeyParameters)2 RSAPrivateCrtKeyParameters (com.github.zhenwei.core.crypto.params.RSAPrivateCrtKeyParameters)2