Search in sources :

Example 1 with ECKey

use of com.github.zhenwei.provider.jce.interfaces.ECKey in project LinLong-Java by zhenwei1108.

the class SignatureSpi method engineInitSign.

protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
    CipherParameters param;
    if (privateKey instanceof ECKey) {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
    } else {
        param = GOST3410Util.generatePrivateKeyParameter(privateKey);
    }
    digest.reset();
    if (appRandom != null) {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    } else {
        signer.init(true, param);
    }
}
Also used : CipherParameters(com.github.zhenwei.core.crypto.CipherParameters) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom) ECKey(com.github.zhenwei.provider.jce.interfaces.ECKey)

Example 2 with ECKey

use of com.github.zhenwei.provider.jce.interfaces.ECKey in project LinLong-Java by zhenwei1108.

the class ECGOST2012SignatureSpi512 method engineInitSign.

protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
    ECKeyParameters param;
    if (privateKey instanceof ECKey) {
        param = (ECKeyParameters) ECUtil.generatePrivateKeyParameter(privateKey);
    } else {
        throw new InvalidKeyException("cannot recognise key type in ECGOST-2012-512 signer");
    }
    if (param.getParameters().getN().bitLength() < 505) {
        throw new InvalidKeyException("key too weak for ECGOST-2012-512");
    }
    digest.reset();
    if (appRandom != null) {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    } else {
        signer.init(true, param);
    }
}
Also used : ECKeyParameters(com.github.zhenwei.core.crypto.params.ECKeyParameters) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom) ECKey(com.github.zhenwei.provider.jce.interfaces.ECKey) InvalidKeyException(java.security.InvalidKeyException)

Example 3 with ECKey

use of com.github.zhenwei.provider.jce.interfaces.ECKey in project LinLong-Java by zhenwei1108.

the class ECGOST2012SignatureSpi256 method engineInitSign.

protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
    ECKeyParameters param;
    if (privateKey instanceof ECKey) {
        param = (ECKeyParameters) ECUtil.generatePrivateKeyParameter(privateKey);
    } else {
        throw new InvalidKeyException("cannot recognise key type in ECGOST-2012-256 signer");
    }
    if (param.getParameters().getN().bitLength() > 256) {
        throw new InvalidKeyException("key out of range for ECGOST-2012-256");
    }
    digest.reset();
    if (appRandom != null) {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    } else {
        signer.init(true, param);
    }
}
Also used : ECKeyParameters(com.github.zhenwei.core.crypto.params.ECKeyParameters) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom) ECKey(com.github.zhenwei.provider.jce.interfaces.ECKey) InvalidKeyException(java.security.InvalidKeyException)

Example 4 with ECKey

use of com.github.zhenwei.provider.jce.interfaces.ECKey in project LinLong-Java by zhenwei1108.

the class SignatureSpi method engineInitSign.

protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
    CipherParameters param = null;
    if (privateKey instanceof BCDSTU4145PrivateKey) {
        // TODO: add parameters support.
        param = ECUtil.generatePrivateKeyParameter(privateKey);
        digest = new GOST3411Digest(expandSbox(DSTU4145Params.getDefaultDKE()));
    } else if (privateKey instanceof ECKey) {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
        digest = new GOST3411Digest(expandSbox(DSTU4145Params.getDefaultDKE()));
    }
    if (appRandom != null) {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    } else {
        signer.init(true, param);
    }
}
Also used : CipherParameters(com.github.zhenwei.core.crypto.CipherParameters) GOST3411Digest(com.github.zhenwei.core.crypto.digests.GOST3411Digest) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom) ECKey(com.github.zhenwei.provider.jce.interfaces.ECKey)

Example 5 with ECKey

use of com.github.zhenwei.provider.jce.interfaces.ECKey in project LinLong-Java by zhenwei1108.

the class SignatureSpi method engineInitSign.

protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
    CipherParameters param;
    if (privateKey instanceof ECKey) {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
    } else {
        param = GOST3410Util.generatePrivateKeyParameter(privateKey);
    }
    digest.reset();
    if (random != null) {
        signer.init(true, new ParametersWithRandom(param, random));
    } else {
        signer.init(true, param);
    }
}
Also used : CipherParameters(com.github.zhenwei.core.crypto.CipherParameters) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom) ECKey(com.github.zhenwei.provider.jce.interfaces.ECKey)

Aggregations

ParametersWithRandom (com.github.zhenwei.core.crypto.params.ParametersWithRandom)5 ECKey (com.github.zhenwei.provider.jce.interfaces.ECKey)5 CipherParameters (com.github.zhenwei.core.crypto.CipherParameters)3 ECKeyParameters (com.github.zhenwei.core.crypto.params.ECKeyParameters)2 InvalidKeyException (java.security.InvalidKeyException)2 GOST3411Digest (com.github.zhenwei.core.crypto.digests.GOST3411Digest)1