Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\crypto\keysetup_v1.c Create Date:2022-07-28 20:24:09
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:v1 key derivation function

Proto:static int derive_key_aes(const u8 *master_key, const u8 nonce[16], u8 *derived_key, unsigned int derived_keysize)

Type:int

Parameter:

TypeParameterName
const u8 *master_key
const u8nonce
u8 *derived_key
unsigned intderived_keysize
51  res = 0
52  struct skcipher_request * req = NULL
55  tfm = rypto_alloc_skcipher() - allocate symmetric key cipher handle*@alg_name: is the cra_name / name or cra_driver_name / driver name of the* skcipher cipher*@type: specifies the type of the cipher*@mask: specifies the mask for the cipher
57  If IS_ERR(tfm) Then
58  res = PTR_ERR(tfm)
59  tfm = NULL
60  Go to out
62  crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)
63  req = skcipher_request_alloc() - allocate request data structure*@tfm: cipher handle to be registered with the request*@gfp: memory allocation flag that is handed to kmalloc by the API call
64  If Not req Then
65  res = -ENOMEM
66  Go to out
68  skcipher_request_set_callback() - set asynchronous callback function*@req: request handle*@flags: specify zero or an ORing of the flags* CRYPTO_TFM_REQ_MAY_BACKLOG the request queue may back log and* increase the wait queue beyond the initial maximum
71  res = rypto_skcipher_setkey() - set key for cipher*@tfm: cipher handle*@key: buffer holding the key*@keylen: length of the key in bytes* The caller provided key is set for the skcipher referenced by the cipher* handle.
72  If res < 0 Then Go to out
75  sg_init_one - Initialize a single entry sg list*@sg: SG entry*@buf: Virtual address for IO*@buflen: IO length
76  sg_init_one - Initialize a single entry sg list*@sg: SG entry*@buf: Virtual address for IO*@buflen: IO length
77  skcipher_request_set_crypt() - set data buffers*@req: request handle*@src: source scatter / gather list*@dst: destination scatter / gather list*@cryptlen: number of bytes to process from @src*@iv: IV for the cipher operation which must comply with the IV
79  res = crypto_wait_req(rypto_skcipher_encrypt() - encrypt plaintext*@req: reference to the skcipher_request handle that holds all information* needed to perform the cipher operation* Encrypt plaintext data using the skcipher_request handle, & wait)
80  out :
81  skcipher_request_free() - zeroize and free request data structure*@req: request data structure cipher handle to be freed
82  rypto_free_skcipher() - zeroize and free cipher handle*@tfm: cipher handle to be freed
83  Return res
Caller
NameDescribe
setup_v1_file_key_derivedv1 policy, !DIRECT_KEY: derive the file's encryption key