Re: [PATCH v1 2/3] zinc: Introduce minimal cryptography library
From: Andy Lutomirski <luto@amacapital.net>
Date: 2018-08-03 21:29:26
Also in:
lkml, netdev
On Thu, Aug 2, 2018 at 7:48 PM, Jason A. Donenfeld [off-list ref] wrote:
Hey Andy, Thanks too for the feedback. Responses below: On Wed, Aug 1, 2018 at 7:09 PM Andy Lutomirski [off-list ref] wrote:quoted
quoted
I think the above changes would also naturally lead to a much saner patch series where each algorithm is added by its own patch, rather than one monster patch that adds many algorithms and 24000 lines of code.Yes, please.Ack, will be in v2.quoted
I like this a *lot*. (But why are you passing have_simd? Shouldn't that check live in chacha20_arch? If there's some init code needed, then chacha20_arch() should just return false before the init code runs. Once the arch does whatever feature detection it needs, it can make chacha20_arch() start returning true.)The have_simd stuff is so that the FPU state can be amortized across several calls to the crypto functions. Here's a snippet from WireGuard's send.c: void packet_encrypt_worker(struct work_struct *work) { struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr; struct sk_buff *first, *skb, *next; bool have_simd = simd_get();
Gotcha. That was very hidden in the 24k lines. Please make this (and any similar goodies) be their own patches. Also, please consider spelling it differently: simd_context_t simd_context = simd_get(); Because we'll feel very silly the first time some architecture has more than one possible state. (It wouldn't be entirely insane for x86 to distinguish between "no SIMD", "XMM only", and "go to town!", for example.)