struct AlgorithmParams {
std::string uid; // unique identifier
std::string strIn; // input string
std::string strOut; // output string
unsigned int lenOut = 0;// length of output string
std::string sm4_ecb_key;// key for sm4_ecb cipher
std::string ec_pub_key; // public key for ECC
std::string ec_pri_key; // private key for ECC
std::string filePath; // directory path to save asymmetric key
};
class AlgoProcLib
{
public:
enum PROC_RES
{
RES_OK = 0, // success
RES_NOT_SUPPORTED, // request not supported
RES_SERVER_ERROR, // server internal error(call openssl interface)
RES_VERIFY_FAILURE, // verify signature failure
};
}
// generate a random string
bool GenerateRandom(GB::AlgorithmParams ¶m);
// compute signature with SM2
bool SignBySM2(GB::AlgorithmParams ¶m);
// verify signature with SM2
bool VerifySignBySM2(GB::AlgorithmParams ¶m);
// compute hash value with SM3
bool HashBySM3(GB::AlgorithmParams ¶m);
// encode string with SM4_ECB
bool EncryptBySM4ECB(GB::AlgorithmParams ¶m);
// decode string with SM4_ECB
bool DecryptBySM4ECB(GB::AlgorithmParams ¶m);
// generate symmetric key
bool GenerateSymmKey(GB::AlgorithmParams ¶m);
// generate asymmetric key for ECC
bool GenerateECKey(GB::AlgorithmParams ¶m);
// convert hex string to buffer
bool HexStr2Buffer(GB::AlgorithmParams ¶m);
// convert buffer to hex string
bool Buffer2HexStr(GB::AlgorithmParams ¶m);
// encode string with Base 64
bool Base64Encode(GB::AlgorithmParams ¶m);
// decode string with Base 64
bool Base64Decode(GB::AlgorithmParams ¶m);