Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/ukswrand: Add Fortuna PRNG #1412

Draft
wants to merge 45 commits into
base: staging
Choose a base branch
from

Conversation

Alex-deVis
Copy link
Contributor

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.uk on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): N/A
  • Platform(s): N/A
  • Application(s): N/A

Additional configuration

Description of changes

This PR aims to integrate the FreeBSD implementation of Fortuna into Unikraft as a replacement for ChaCha20. The source code of the algorithm spans multiple files, thus a similar file hierarchy must be created to avoid striving away from the source implementation. These dependencies are stored in ukswrand/fortuna-utils.

Add unmodified files from the freeBSD implementation. This commit shoul
be adapted and removed at some point as it does not compile.
I haven't found an equivalent in Unikraft and couldn't determine what is
its purpose in FreeBSD.
Remove machine/endian.h as it has no equivalent in Unikraft.
Remove typedefs covered by stdint.h: uint8_t, uint16_t, uint32_t,
uint64_t.
So far this only contains the files required for chacha20. I opted for
this approach to avoid name conflicts  with the current chacha
implmentation.
The first covers uint8_t and uint32_t types and the second covers the
definition of NULL.
This contains a test file and a Makefile for it. They should be adapted
in the future.
Do not add the sources for sha*_arm64.c in the Makefile.uk yet.
Keep the internal directory organisation from FreeBSD in the
fortuna-utils directory. Hence, move sha2, chacha20, and rijndael to
fortuna-utils/crypto.
Remove files that are not referrenced by any of the other files so far.
Initially, I assumed there will be fewer dependencies so I opted to
change the file structure of fortuna. I was wrong, moving everything
back into place.
Required for EINVAL error code and uint*_t types
KASSERT gets a condition and a message. For now, ignore the message and only call assert on the condition.
I could not find an implmentation for explicit_bzero in the freeBSD source. Use a stub for the moment and leave a TODO to replace it later.
@github-actions github-actions bot added area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ lib/nolibc Only neccessary subset of libc functionality lib/ukswrand labels May 10, 2024
@Alex-deVis Alex-deVis changed the title ukswrand: Add Fortuna PRNG lib/ukswrand: Add Fortuna PRNG May 10, 2024
Add comments on how to handle SYSINIT not passing the data argument to
the initialization function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ lib/nolibc Only neccessary subset of libc functionality lib/ukswrand
Projects
Status: 🧊 Icebox
Development

Successfully merging this pull request may close these issues.

None yet

3 participants