Function report |
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 activity | Download SCCT | Chinese |
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:
| Type | Parameter | Name |
|---|---|---|
| struct scatterlist * | src | |
| const size_t | src_len | |
| const u8 * | ad | |
| const size_t | ad_len | |
| const u64 | nonce | |
| const u8 | key | |
| int | encrypt |
| 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))) |
| 241 | chacha_load_key(k, key) |
| 243 | iv[0] = 0 |
| 246 | chacha_init(chacha_state, k, (u8 * )iv) |
| 247 | chacha20_crypt(chacha_state, block0, pad0, size of block0 ) |
| 248 | poly1305_init( & poly1305_state, block0) |
| 251 | poly1305_update( & poly1305_state, ad, ad_len) |
| 252 | If ad_len & 0xf Then poly1305_update( & poly1305_state, pad0, 0x10 - (ad_len & 0xf)) |
| 257 | If Not preemptible() Then flags |= use kmap_atomic |
| 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) |
| 270 | l = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(length, CHACHA_BLOCK_SIZE - partial) |
| 272 | crypto_xor(addr, chacha_stream + partial, l) |
| 273 | partial = partial + l & CHACHA_BLOCK_SIZE - 1 |
| 279 | If Value is more likely to compile time(length >= CHACHA_BLOCK_SIZE || length == sl) Then |
| 282 | If Value for the false possibility is greater at compile time(length < sl) Then l &= ~(CHACHA_BLOCK_SIZE - 1) |
| 284 | chacha20_crypt(chacha_state, addr, addr, l) |
| 289 | If Value for the false possibility is greater at compile time(length > 0) Then |
| 292 | crypto_xor(addr, chacha_stream, length) |
| 301 | If src_len & 0xf Then poly1305_update( & poly1305_state, pad0, 0x10 - (src_len & 0xf)) |
| 306 | poly1305_update( & poly1305_state, (u8 * )lens, size of lens ) |
| 308 | If Value is more likely to compile time(sl <= - POLY1305_DIGEST_SIZE) Then |
| 324 | poly1305_final( & poly1305_state, mac[1]) |
| 334 | Return ret |
| Name | Describe |
|---|---|
| chacha20poly1305_encrypt_sg_inplace | |
| chacha20poly1305_decrypt_sg_inplace |
| Source code conversion tool public plug-in interface | X |
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |