1.6 解密接口的说明
EVP_DecryptInit
int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, const unsigned char *key, const unsigned char *iv);
功能描述: 解密初始化
说 明: EVP_DecryptInit_ex的简化版本(无ENGINE),实际调用
EVP_CipherInit(*,0).
参数说明:
ctx (in/out) 对称算法封装数据
cipher (in) 密码算法信息
key (in) 密钥
iv (in) 初始化向量
返 回 值: 1[成功],<=0[失败]
EVP_DecryptInit_ex
int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv);
功能描述: 加密初始化
说 明: EVP_DecryptInit的增强版(有ENGINE),实际调用EVP_CipherInit_ex(*,0).
参数说明:
ctx (in/out) 对称算法封装数据
cipher (in) 密码算法信息
impl (in) 引擎
key (in) 密钥
iv (in) 初始化向量
返 回 值: 1[成功],<=0[失败]
EVP_DecryptUpdate
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl);
功能描述: 解密数据
说 明: 输入数据长度不一定为分组大小,所以输出数据长度可能为零。
参数说明:
ctx (in/out) 对称算法封装数据
out (out) 明文
outl (out) 明文的长度
in (in) 密文
inl (in) 密文的长度
返 回 值: 1[成功],<=0[失败]
EVP_DecryptFinal
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
功能描述: 解密结束并输出可能的残留数据
说 明: 实际调用EVP_DecryptFinal_ex。
参数说明:
ctx (in/out) 对称算法封装数据
outm (out) 输出明文
outl (out) 输出明文的长度
返 回 值: 1[成功],<=0[失败]
EVP_DecryptFinal_ex
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
功能描述: 解密结束并输出可能的残留数据
说 明: EVP_DecryptFinal也是调用EVP_DecryptFinal_ex。
参数说明:
ctx (in/out) 对称算法封装数据
outm (out) 输出明文
outl (out) 输出明文的长度
返 回 值: 1[成功],<=0[失败]