Search in sources :

Example 1 with BCECPublicKey

use of com.github.zhenwei.provider.jcajce.provider.asymmetric.ec.BCECPublicKey in project LinLong-Java by zhenwei1108.

the class HashBuilder method sm3Digest.

/**
 * @param [publicKey, source]
 * @return byte[]
 * @author zhangzhenwei
 * @description SM3公钥参与运算
 * @date 2022/2/9 22:48
 */
private byte[] sm3Digest(DigestParams digestParams, byte[] source) {
    SM3Digest digest = new SM3Digest();
    PublicKey publicKey = digestParams.getPublicKey();
    if (publicKey instanceof BCECPublicKey) {
        BCECPublicKey key = (BCECPublicKey) publicKey;
        digest.init(digestParams.getUserID(), key.getParameters().getCurve(), key.getParameters().getG(), key.getQ());
    }
    byte[] hash = new byte[digest.getDigestSize()];
    digest.update(source, 0, source.length);
    digest.doFinal(hash, 0);
    return hash;
}
Also used : SM3Digest(com.github.zhenwei.core.crypto.digests.SM3Digest) BCECPublicKey(com.github.zhenwei.provider.jcajce.provider.asymmetric.ec.BCECPublicKey) PublicKey(java.security.PublicKey) BCECPublicKey(com.github.zhenwei.provider.jcajce.provider.asymmetric.ec.BCECPublicKey)

Aggregations

SM3Digest (com.github.zhenwei.core.crypto.digests.SM3Digest)1 BCECPublicKey (com.github.zhenwei.provider.jcajce.provider.asymmetric.ec.BCECPublicKey)1 PublicKey (java.security.PublicKey)1