package cn.anicert.secure.access.crypto.service;

import javax.security.auth.Subject;

/**
 * @Description
 * @Date 2024/5/29 15:30
 * @Author yourongbin
 **/
public interface ISoftCryptoService {

    /**
     * 数字信封加密
     * @param cert 证书的base64编码
     * @param data 加密数据
     * @return
     */
    public String encodeEnvelop(String cert, String data)  throws Exception ;
    /**
     * 数字信封加密
     * @param cert 证书的base64编码
     * @param dataByte
     * @return
     */
    public String encodeEnvelop(String cert, byte[] dataByte) throws Exception;

    /**
     * 数字信封解密 返回明文
     * @param priKey
     * @param envelop
     * @return
     * @throws Exception
     */
    public String decodeEnvelop(String priKey, String envelop) throws Exception;

    /**
     * 数字信封解密 返回明文
     * @param priKey
     * @param envelop
     * @return
     * @throws Exception
     */
    public String decodeEnvelop(String priKey, byte[] envelop) throws Exception;

    /**
     * sm2加密
     * @param publicKey
     * @param data
     * @return
     * @throws Exception
     */
    public String encrypt(String publicKey, String data) throws Exception;

    /**
     * sm2解密
     * @param privateKey
     * @param encryptedData
     * @return
     * @throws Exception
     */
    public String decrypt(String privateKey, String encryptedData) throws Exception;
    /**
     * p7加签
     * @param prikey 私钥
     * @param cert  证书
     * @param oriData 数据
     * @return
     * @throws Exception
     */
    public String p7Sign(String prikey, String cert ,String oriData) throws Exception;

    /**
     * p7验签
     * @param sign  签名值
     * @param source    原文
     * @return
     * @throws Exception
     */
    public Boolean p7Verify(String sign,String source) throws Exception;

    /**
     * p1加签
     * @param prikey
     * @param oriData
     * @return
     * @throws Exception
     */
    public String p1Sign(String prikey,String oriData) throws Exception;

    /**
     * p1验签
     * @param publicKey
     * @param data
     * @param signature
     * @return
     * @throws Exception
     */
    public boolean verify(String publicKey, String data, String signature) throws Exception;

    /**
     * sm2加签
     * @param prikey
     * @param oriData
     * @return
     * @throws Exception
     */
    public String sm2Sign(String prikey,String oriData) throws Exception;

    /**
     * sm2验签
     * @param publicKey
     * @param data
     * @param signature
     * @return
     * @throws Exception
     */
    public boolean sm2SignVerify(String publicKey, String data, String signature) throws Exception;
    /**
     * p1验签
     * @param publicKey
     * @param data
     * @param charset
     * @param signature
     * @return
     * @throws Exception
     */
    public boolean verify(String publicKey, String data, String charset, String signature) throws Exception;

    /**
     * 获取业务站点号
     * @param signature
     * @return
     * @throws Exception
     */
    public String getCommonNameFromP7Sign(String signature) throws Exception;

    /**
     * sm3算法
     * @param source
     * @return
     * @throws Exception
     */
    public String sm3Hash(String source) throws Exception;
}
