Search in sources :

Example 1 with GOST3410Key

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

the class SignatureSpi method engineInitVerify.

protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
    CipherParameters param;
    if (publicKey instanceof ECPublicKey) {
        param = ECUtil.generatePublicKeyParameter(publicKey);
    } else if (publicKey instanceof GOST3410Key) {
        param = GOST3410Util.generatePublicKeyParameter(publicKey);
    } else {
        try {
            byte[] bytes = publicKey.getEncoded();
            publicKey = WeGooProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
            if (publicKey instanceof ECPublicKey) {
                param = ECUtil.generatePublicKeyParameter(publicKey);
            } else {
                throw new InvalidKeyException("can't recognise key type in DSA based signer");
            }
        } catch (Exception e) {
            throw new InvalidKeyException("can't recognise key type in DSA based signer");
        }
    }
    digest.reset();
    signer.init(false, param);
}
Also used : CipherParameters(com.github.zhenwei.core.crypto.CipherParameters) ECPublicKey(com.github.zhenwei.provider.jce.interfaces.ECPublicKey) GOST3410Key(com.github.zhenwei.provider.jce.interfaces.GOST3410Key) InvalidKeyException(java.security.InvalidKeyException) SignatureException(java.security.SignatureException) InvalidKeyException(java.security.InvalidKeyException)

Example 2 with GOST3410Key

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

the class SignatureSpi method engineInitVerify.

protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
    CipherParameters param;
    if (publicKey instanceof ECPublicKey) {
        param = generatePublicKeyParameter(publicKey);
    } else if (publicKey instanceof GOST3410Key) {
        param = GOST3410Util.generatePublicKeyParameter(publicKey);
    } else {
        try {
            byte[] bytes = publicKey.getEncoded();
            publicKey = WeGooProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
            param = ECUtil.generatePublicKeyParameter(publicKey);
        } catch (Exception e) {
            throw new InvalidKeyException("can't recognise key type in DSA based signer");
        }
    }
    digest.reset();
    signer.init(false, param);
}
Also used : CipherParameters(com.github.zhenwei.core.crypto.CipherParameters) ECPublicKey(com.github.zhenwei.provider.jce.interfaces.ECPublicKey) GOST3410Key(com.github.zhenwei.provider.jce.interfaces.GOST3410Key) InvalidKeyException(java.security.InvalidKeyException) SignatureException(java.security.SignatureException) InvalidKeyException(java.security.InvalidKeyException)

Aggregations

CipherParameters (com.github.zhenwei.core.crypto.CipherParameters)2 ECPublicKey (com.github.zhenwei.provider.jce.interfaces.ECPublicKey)2 GOST3410Key (com.github.zhenwei.provider.jce.interfaces.GOST3410Key)2 InvalidKeyException (java.security.InvalidKeyException)2 SignatureException (java.security.SignatureException)2