调用openssl实现aes_gcm加密解密

易语言 2020-07-30 07:00:01

调用openssl实现aes_gcm加密解密

outbuf = 取空白字节集 (1024)
ctx = EVP_CIPHER_CTX_new ()
EVP_DecryptInit_ex (ctx, EVP_aes_256_gcm (), 0, 0, 0)
EVP_CIPHER_CTX_ctrl (ctx, #EVP_CTRL_GCM_SET_IVLEN, 取字节集长度 (iv), 0)
EVP_DecryptInit_ex (ctx, 0, 0, 取指针地址 (key), 取指针地址 (iv))
EVP_DecryptUpdate (ctx, 取指针地址 (outbuf), 取指针整数_ (outlen), 取指针地址 (密文), 取字节集长度 (密文))
outbuf = 取字节集左边 (outbuf, outlen)
EVP_CIPHER_CTX_ctrl (ctx, #EVP_CTRL_GCM_SET_TAG, 取字节集长度 (tag), 取指针地址 (tag))
EVP_DecryptFinal_ex (ctx, 取指针地址 (outbuf), 取指针整数_ (outlen))
EVP_CIPHER_CTX_free (ctx)