Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:RSA Signature verification with public key

Proto:static int digsig_verify_rsa(struct key *key, const char *sig, int siglen, const char *h, int hlen)

Type:int

Parameter:

TypeParameterName
struct key *key
const char *sig
intsiglen
const char *h
inthlen
71  err = -EINVAL
76  unsigned char * out1 = NULL
78  in = NULL , res = NULL
84  lock for reading
85  ukp = user_key_payload_locked(key)
87  If Not ukp Then
89  err = -EKEYREVOKED
90  Go to err1
93  If length of this data < size of pkh Then Go to err1
96  pkh = actual data
98  If key format version != 1 Then Go to err1
101  If algo != PUBKEY_ALGO_RSA Then Go to err1
104  If nmpi != 2 Then Go to err1
107  datap = mpi
108  endp = actual data + length of this data
110  When i < nmpi cycle
111  remaining = endp - datap
112  pkey[i] = mpi_read_from_buffer(datap, & remaining)
113  If IS_ERR(pkey[i]) Then
114  err = PTR_ERR(pkey[i])
115  Go to err
117  datap += remaining
120  mblen = Return the number of bits in A.
121  mlen = DIV_ROUND_UP(mblen, 8)
123  If mlen == 0 Then
124  err = -EINVAL
125  Go to err
128  err = -ENOMEM
130  out1 = 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).
131  If Not out1 Then Go to err
134  nret = siglen
135  in = mpi_read_from_buffer(sig, & nret)
136  If IS_ERR(in) Then
137  err = PTR_ERR(in)
138  Go to err
141  res = Note: It was a bad idea to use the number of limbs to allocate* because on a alpha the limbs are large but we normally need* integers of n bits - So we should chnage this to bits (or bytes).* But mpi_alloc is used in a lot of places :-)
142  If Not res Then Go to err
145  err = RES = BASE ^ EXP mod MOD
146  If err Then Go to err
149  If number of valid limbs * BYTES_PER_MPI_LIMB > mlen Then
150  err = -EINVAL
151  Go to err
154  p = mpi_get_buffer() - Returns an allocated buffer with the MPI (msb first).* Caller must free the return string.* This function does return a 0 byte buffer with nbytes set to zero if the* value of A is zero.*@a: a multi precision integer.
155  If Not p Then
156  err = -EINVAL
157  Go to err
160  len = mlen
161  head = len - l
162  memset(out1, 0, head)
163  No 3D Now!(out1 + head, p, l)
165  kfree(p)
167  m = pkcs_1_v1_5_decode_emsa(out1, len, mblen, & len)
169  If Not m || len != hlen || memcmp(m, h, hlen) Then err = -EINVAL
172  err :
173  mpi_free(in)
174  mpi_free(res)
175  kfree(out1)
176  When --i >= 0 cycle
177  mpi_free(pkey[i])
178  err1 :
179  lease a read lock
181  Return err
Caller
NameDescribe
digsig_verifydigsig_verify() - digital signature verification with public key*@keyring: keyring to search key in*@sig: digital signature*@siglen: length of the signature*@data: data*@datalen: length of the data* Returns 0 on success, -EINVAL otherwise