Edit online

接口设计

3 Mar 2025
Read time: 4 minute(s)
1. aic_skcipher_alg_init

函数原型

int aic_skcipher_alg_init(struct crypto_skcipher *tfm)

功能说明

对称密钥算法的初始化函数

参数定义

struct crypto_skcipher *tfm 算法实例指针

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

2. aic_skcipher_alg_exit

函数原型

void aic_skcipher_alg_exit(struct crypto_skcipher *tfm)

功能说明

对称密钥算法使用完毕,释放相关资源

参数定义

struct crypto_skcipher *tfm 算法实例指针

返回值

注意事项

-

3. aic_skcipher_alg_setkey

函数原型

int aic_skcipher_alg_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen)

功能说明

设置对称密钥算法的密钥

参数定义

  • struct crypto_skcipher *tfm 算法实例指针
  • const u8 *key 密钥的指针
  • keylen 密钥的长度

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

4. aic_skcipher_crypt

函数原型

int aic_skcipher_crypt(struct skcipher_request *req, unsigned long flg)

功能说明

发起一个对称密钥算法的加解密处理的请求

参数定义

  • struct skcipher_request *req 加解密请求的指针
  • flg 算法标记,用来标识算法类型和算法模式

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

5. aic_akcipher_rsa_alg_init

函数原型

int aic_akcipher_rsa_alg_init(struct crypto_akcipher *tfm)

功能说明

RSA 算法初始化

参数定义

struct crypto_akcipher *tfm 算法实例的指针

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

6. aic_akcipher_rsa_alg_exit

函数原型

void aic_akcipher_rsa_alg_exit(struct crypto_akcipher *tfm)

功能说明

RSA 算法使用完毕,释放相关资源

参数定义

struct crypto_akcipher *tfm 算法实例的指针

返回值

注意事项

-

7. aic_akcipher_rsa_set_pub_key

函数原型

int aic_akcipher_rsa_set_pub_key(struct crypto_akcipher *tfm, const void *key,unsigned int keylen)

功能说明

设置 RSA 算法的公钥

参数定义

  • struct crypto_akcipher *tfm 算法实例指针
  • const void *key 密钥数据的指针
  • keylen 密钥的长度

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

8. aic_akcipher_rsa_set_priv_key

函数原型

int aic_akcipher_rsa_set_priv_key(struct crypto_akcipher *tfm, const void *key,unsigned int keylen)

功能说明

设置 RSA 算法的私钥

参数定义

  • struct crypto_akcipher *tfm 算法实例指针
  • const void *key 密钥数据的指针
  • keylen 密钥的长度

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

9. aic_akcipher_rsa_max_size

函数原型

int aic_akcipher_rsa_max_size(struct crypto_akcipher *tfm)

功能说明

获取当前 RSA 算法的密钥长度

参数定义

struct crypto_akcipher *tfm 算法实例指针

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

10. aic_akcipher_rsa_crypt

函数原型

int aic_akcipher_rsa_crypt(struct akcipher_request *req, unsigned long flag)

功能说明

发起一个 RSA 算法的加解密请求

参数定义

struct akcipher_request *req 请求的指针 flag 算法标记

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

11. aic_hash_alg_init

函数原型

int aic_hash_alg_init(struct crypto_tfm *tfm)

功能说明

HASH 算法的初始化

参数定义

struct crypto_tfm *tfm 算法实例的指针

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

12. aic_hash_alg_exit

函数原型

void aic_hash_alg_exit(struct crypto_tfm *tfm)

功能说明

HASH 算法使用完毕,释放相关资源

参数定义

struct crypto_tfm *tfm 算法实例的指针

返回值

注意事项

-

13. aic_hash_init

函数原型

int aic_hash_init(struct ahash_request *req)

功能说明

初始化一个 HASH 运算的操作

参数定义

struct ahash_request *req

HASH 运算的请求,具体所使用的算法,根据消息摘要的大小决定

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

14. aic_hash_update

函数原型

int aic_hash_update(struct ahash_request *req)

功能说明

更新一笔 HASH 运算的数据,用于数据分多次输入的场景

参数定义

struct ahash_request *req

HASH 运算的请求,数据信息保存在该结构体中

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

15. aic_hash_final

函数原型

int aic_hash_final(struct ahash_request *req)

功能说明

HASH 运算的数据输入结束,获取结果

参数定义

struct ahash_request *req

HASH 运算的请求,本请求不带数据,只获取结果

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

16. aic_hash_finup

函数原型

int aic_hash_finup(struct ahash_request *req)

功能说明

HASH 运算的最后一笔数据,并且获取结果

参数定义

struct ahash_request *req

HASH 运算的请求,本请求带最后一笔数据,并获取结果

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-

17. aic_hash_digest

函数原型

int aic_hash_digest(struct ahash_request *req)

功能说明

针对一笔数据,完成 init 和 finup 的 HASH 运算操作,并获取结果

参数定义

struct ahash_request *req

HASH 运算的请求,本请求带最后一笔数据,并获取结果

返回值

  • 0: 成功
  • 其它: 失败

注意事项

-