Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\encrypted-keys\encrypted.c Create Date:2022-07-28 18:33:33
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Allocate memory for decrypted key and datablob.

Proto:static struct encrypted_key_payload *encrypted_key_alloc(struct key *key, const char *format, const char *master_desc, const char *datalen)

Type:struct encrypted_key_payload

Parameter:

TypeParameterName
struct key *key
const char *format
const char *master_desc
const char *datalen
612  struct encrypted_key_payload * epayload = NULL
621  ret = kstrtol - convert a string to a long*@s: The start of the string. The string must be null-terminated, and may also* include a single newline before its terminating null. The first character* may also be a plus sign or a minus sign.
622  If ret < 0 || dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE Then Return ERR_PTR( - EINVAL)
625  format_len = If Not format Then strlen - Find the length of a string*@s: The string to be sized Else strlen - Find the length of a string*@s: The string to be sized
626  decrypted_datalen = dlen
627  payload_datalen = decrypted_datalen
628  If format Then
629  If Not strcmp(format, key_format_ecryptfs) Then
630  If dlen != ECRYPTFS_MAX_KEY_BYTES Then
631  pr_err("encrypted_key: keylen for the ecryptfs format must be equal to %d bytes\n", ECRYPTFS_MAX_KEY_BYTES)
633  Return ERR_PTR( - EINVAL)
637  Else if Not strcmp(format, key_format_enc32) Then
639  pr_err("encrypted_key: enc32 key payload incorrect length: %d\n", decrypted_datalen)
641  Return ERR_PTR( - EINVAL)
646  encrypted_datalen = undup - round up to the next specified multiple*@x: the value to up*@y: multiple to round up to* Rounds @x up to next multiple of @y. If @y will always be a power* of 2, consider using the faster round_up().(decrypted_datalen, blksize)
648  datablob_len = format_len + 1 + strlen - Find the length of a string*@s: The string to be sized + 1 + strlen - Find the length of a string*@s: The string to be sized + 1 + ivsize + 1 + encrypted_datalen
651  ret = key_payload_reserve - Adjust data quota reservation for the key's payload*@key: The key to make the reservation for
653  If ret < 0 Then Return ERR_PTR(ret)
656  epayload = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
658  If Not epayload Then Return ERR_PTR( - ENOMEM)
661  payload data length = payload_datalen
662  decrypted data length = decrypted_datalen
663  length of datablob = datablob_len
664  Return epayload
Caller
NameDescribe
encrypted_instantiaterypted_instantiate - instantiate an encrypted key* Decrypt an existing encrypted datablob or create a new encrypted key* based on a kernel random number.* On success, return 0. Otherwise return errno.
encrypted_updaterypted_update - update the master key description* Change the master key description for an existing encrypted key.* The next read will return an encrypted datablob using the new* master key description.* On success, return 0. Otherwise return errno.