[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 0/4] lib/ukswrand: Add ChaCha20



Hi Vlad,

thanks a lot for your work. I was trying out your patches and it looks good so far.

Design-wise I would like to change the way how the seed is handled. I think we have two options (although I prefer the second idea):

1) Remove the seed argument from the init function API (`uk_swrandr_init_r`). The random number generators would call the function as often as seeds are needed by themselves.

2) Extend the seed argument at the init function API (`uk_swrandr_init_r`) with a custom sized vector:

void uk_swrand_init_r(struct uk_swrand *r, unsigned int seedc, const __u32 seedv[]);

...or even abstract it with a random byte buffer:

void uk_swrand_init_r(struct uk_swrand *r, __sz seedlen, const void *seed);

A helper function in `chacha.c` would make it easy to access as many bytes as needed (as example to the vector):

static inline __u32 _infvec_val(unsigned int c, __u32 v[], unsinged int pos)
{
        if (c == 0)
                return 0x0;
        return vec[pos % c];
}

This would keep us the ability that we can initialize multiple random number generator instances while keeping it flexible which seed source someone wants to use (similar to libc's random functions). In the library constructor we would need to dimension the vector size according to the selected default random number generator. We could do this by using a vector of 2 numbers as default and use a compile-guard'ed version with 10 numbers for ChaCha.

Independent of this, we should also decide if we want to make `_get_random_seed()` public on the API or if we want to keep internal to the library. In the public case, I would rename it to `__u32 uk_swrandr_gen_seed32(void)` (and adding it to `exportsyms.uk`). In the other case, try to remove it from the API header and introduce a small internal header (e.g, `/lib/ukswrandr/swrandr.h`) that is included with quotes in your sources: `#include "swrandr.h"`

What do you think?

Thanks,

Simon

On 21.10.19 13:35, Vlad-Andrei BĂDOIU (78692) wrote:
We add the ChaCha20 algorithm. This patch series refactors the
existing code for multiple algorithms support.

Changes since v2:
* Moved _uk_rotl32 to chacha.c
* Moved the constructor and _get_random_seed32 to swrand.c
* Added compile check for rdrand
* Changed to drop-down menu in config.


Vlad-Andrei Badoiu (4):
   lib/ukswrand: Adapt the library to work with multiple algorithms
   lib/ukswrand: Add seed generating function
   lib/ukswrand: Add ChaCha algorithm
   lib/ukswrand: Fix uk_swrand_fill_buffer to fill the entire buffer

  lib/ukswrand/Config.uk           |  29 +++++-
  lib/ukswrand/Makefile.uk         |   2 +
  lib/ukswrand/chacha.c            | 151 +++++++++++++++++++++++++++++++
  lib/ukswrand/include/uk/swrand.h |  10 +-
  lib/ukswrand/mwc.c               |  37 ++------
  lib/ukswrand/swrand.c            |  86 ++++++++++++++++++
  6 files changed, 273 insertions(+), 42 deletions(-)
  create mode 100644 lib/ukswrand/chacha.c
  create mode 100644 lib/ukswrand/swrand.c


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.