Home GnuPG

Use memset for constant length wipememory2

Description

Use memset for constant length wipememory2

* src/g10lib.h (fast_wipememory2_inline): New.
(wipememory2): Use 'fast_wipememory2_inline', remove 'fast_wipememory2'
use; Use _gcry_fast_wipememory* when _len or _set is not constant.
(fast_wipememory_s, fast_wipememory2): Remove.

Use of memset allows better code generation by compiler - for example,
use of vector registers for memory clearing. Dead store elimination
of memset by compiler optimization is avoided by using assembly block
after memset:

memset(ptr_mem_wipe, 0, constant_mem_len);
asm volatile ("\n" :: "r" (ptr_mem_wipe) : "memory");
  • Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>

Details

Provenance
jukiviliAuthored on Apr 26 2021, 9:41 PM
Parents
rCa208f6af5033: doc: Clarify gcry_md_setkey for keyed BLAKE hashes.
Branches
Unknown
Tags
Unknown