Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:chacha20poly1305_crypt_sg_inplace

Proto:static bool chacha20poly1305_crypt_sg_inplace(struct scatterlist *src, const size_t src_len, const u8 *ad, const size_t ad_len, const u64 nonce, const u8 key[CHACHA20POLY1305_KEY_SIZE], int encrypt)

Type:bool

Parameter:

TypeParameterName
struct scatterlist *src
const size_tsrc_len
const u8 *ad
const size_tad_len
const u64nonce
const u8key
intencrypt
217  pad0 = page_address(ZERO_PAGE(0))
221  partial = 0
223  bool ret = true
225  union{struct{u32 k[(32 / sizeof(u32))];__le64 iv[2];}u8 block0[32];u8 chacha_stream[64];struct{u8 mac[2][16];}__le64 lens[2];}b((__aligned__(16))) __attribute__((__aligned__(16)))
238  If WARN_ON(src_len > INT_MAX) Then Return false
241  chacha_load_key(k, key)
243  iv[0] = 0
244  iv[1] = The following macros are to be defined by (nonce)
246  chacha_init(chacha_state, k, (u8 * )iv)
247  chacha20_crypt(chacha_state, block0, pad0, size of block0 )
248  poly1305_init( & poly1305_state, block0)
250  If Value for the false possibility is greater at compile time(ad_len) Then
251  poly1305_update( & poly1305_state, ad, ad_len)
252  If ad_len & 0xf Then poly1305_update( & poly1305_state, pad0, 0x10 - (ad_len & 0xf))
256  flags = lush back to phys on unmap
257  If Not preemptible() Then flags |= use kmap_atomic
260  sg_miter_start - start mapping iteration over a sg list*@miter: sg mapping iter to be started*@sgl: sg list to iterate over*@nents: number of sg entries* Description:* Starts mapping iterator @miter.* Context:* Don't care.
262  When sl > 0 && sg_miter_next - proceed mapping iterator to the next mapping*@miter: sg mapping iter to proceed* Description:* Proceeds @miter to the next mapping. @miter should have been started* using sg_miter_start(). On successful return, @miter->page, cycle
263  addr = pointer to the mapped area
264  length = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(size_t, sl, length of the mapped area )
266  If Not encrypt Then poly1305_update( & poly1305_state, addr, length)
275  addr += l
276  length -= l
280  l = length
285  addr += l
286  length -= l
293  partial = length
296  If encrypt Then poly1305_update( & poly1305_state, pointer to the mapped area , min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(size_t, sl, length of the mapped area ))
301  If src_len & 0xf Then poly1305_update( & poly1305_state, pad0, 0x10 - (src_len & 0xf))
304  lens[0] = The following macros are to be defined by (ad_len)
305  lens[1] = The following macros are to be defined by (src_len)
306  poly1305_update( & poly1305_state, (u8 * )lens, size of lens )
308  If Value is more likely to compile time(sl <= - POLY1305_DIGEST_SIZE) Then
309  If encrypt Then
312  ret = true
313  Else
321  sg_miter_stop - stop mapping iteration*@miter: sg mapping iter to be stopped* Description:* Stops mapping iterator @miter. @miter should have been started* using sg_miter_start(). A stopped iteration can be resumed by* calling sg_miter_next() on it
323  If Value for the false possibility is greater at compile time(sl > - POLY1305_DIGEST_SIZE) Then
324  poly1305_final( & poly1305_state, mac[1])
325  scatterwalk_map_and_copy(mac[encrypt], src, src_len, size of mac[1] , encrypt)
327  ret = encrypt || Not rypto_memneq - Compare two areas of memory without leaking* timing information.*@a: One area of memory*@b: Another area of memory*@size: The size of the area.* Returns 0 when data is equal, 1 otherwise.
331  memzero_explicit - Fill a region of memory (e
332  memzero_explicit - Fill a region of memory (e
334  Return ret
Caller
NameDescribe
chacha20poly1305_encrypt_sg_inplace
chacha20poly1305_decrypt_sg_inplace