Hi Remco, On Fri, May 29, 2020 at 03:51:52PM -0400, Remco Rijnders wrote: > +/* Generate and Base64 encode 96 random bits and fill the buffer > + output_B64 with the result. */ > +void mutt_base64_random96(char output_B64[static 17]) > +{ > + u_int32_t randombits[3] = { mutt_random32(), mutt_random32(), > mutt_random32() };
I'd strongly prefer to adopt the concept from the crypto libraries of variable length random number generation. In worst case when only 1 number is requested, this adds a loop with only 1 cycle. In situation with multiple numbers it removes overhead of extra function calls (a bit more in crypto librares, where seeds are checked for refresh based on time). With length as a parameter we'd have a generic function, and you can forget about chunks, repetition left only in a single place. Creating buffers and passing pointers/sizes instead of int is not an issue. Gero