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

Kyber derand tasks #6

Open
31 of 36 tasks
falko-strenzke opened this issue May 10, 2023 · 1 comment
Open
31 of 36 tasks

Kyber derand tasks #6

falko-strenzke opened this issue May 10, 2023 · 1 comment
Labels
enhancement New feature or request test to be done as part of test work package

Comments

@falko-strenzke
Copy link

falko-strenzke commented May 10, 2023

file / task remove file add AVX2 no assg. in if format code prefix funs cleanup code other
kyber.c N/A [X] [X] [X] [X] [X] [-] implement self test function
[X] implement _gcry_kyber_check_secret_key
[-] implement _gcry_kyber_compute_keygrip
[X] decide nbits implementation
kyber_aux.c/.h N/A [X] [X] [X] [X] [X]
kyber_cbd.c/.h N/A [X] [X] [X] [X] [X]
kyber-common.c/.h N/A [X] [X] [X] [X] [X]
kyber_ntt.c/.h N/A [X] [X] [X] [X] [X]
kyber_params.h N/A [X] [X] [X] [X] [X]
kyber_poly.c/.h N/A [X] [X] [X] [X] [X]
kyber_polyvec.c/.h N/A [X] [X] [X] [X] [X]
kyber_symmetric.c/.h N/A [X] [X] [X] [X] [X]
  • bugs
    • resolve memory leak in kyber_check_secret_key()
      • when this function is invoked by kyber_generate(), then after already with three iterations of the gen-enc-dec test, libgcrypt produces an allocation failure. Valgrind show no leak. Needs to be debugged.
    • rework memory allocation:
  • add AVX implementation
    • make new set of files:
      • kyber_xxx.c => kyber_xxx_avx2.c
    • for now conditional compilation of the code inside the files which implement functions with AVX2
      • libgcrypt does it already in this way:
        if defined(ENABLE_AVX2_SUPPORT)
    • Note that we will be restricted to compilers featuring this immintrin.h
  • reduce number of files
  • header guards need to be prefixed (e.g. GCRY_KYBER)
  • Format code everywhere
  • prefix all functions with_gcry_kyber_
  • add self-test in cipher/kyber.c
  • dynamic kyber parameters
    • Kyber instance modelled by parameter object
    • employ everywhere
    • remove replaced kyber parameter preproc-defs
  • use gcry hash/xof everywhere
  • Implement new FO transform
    • adapt enc/dec
    • make new testvectors from kyber ref. impl.
  • implement and test derand version (the non-derand functions call derand version)
    • implement for key gen
    • imlement for encap
  • implement new SHAKE-based randombytes replacement for derand algos (used for test vectors: test/test_vectors.c:randombytes = SHAKE128. we can control the state of this RNG at least in a temporary implementation for the KAT tests. Then we can have full KAT tests (not only decryption as it is now. For a real solution for upstream integration might have to check the RNG framework of libgcrypt)
    • create new test vectors (not NIST-KAT for now, as that requires their AES DRBG)
    • implement new test using derand-functions
      • make derand functions available through API: optional seed argument.
        Note: there is already used in cipher/pubkey-util.c a "random-override" parameter in the S-EXP.
        See the use in src/visibility.c: gcry_pk_hash_sign(), apparently this function is part of the API (is used from tests).
        But only certain functions in this file receive a gcry_ctx_t that can be used for this purpose.
        • for key-gen: place into key-params S-EXP
        • for encap: additional buffer-argument or probably better: add gcry_ctx_t to the signature
  • missing function implementations
    • kyber.c:
      • compute_keygrip()
      • selftests_kyber

Notes on GNU coding style matching:

  • unsigned char pointers are commonly used in function signatures, see for instance cipher/rsa-common.c
@TJ-91
Copy link
Collaborator

TJ-91 commented Jun 16, 2023

  • header guards should be prefixed (e.g. _GCRY_KYBER_)

@falko-strenzke falko-strenzke added the test to be done as part of test work package label Jan 30, 2024
@falko-strenzke falko-strenzke added the enhancement New feature or request label Feb 8, 2024
@falko-strenzke falko-strenzke changed the title Kyber implementation tasks Kyber derand tasks Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test to be done as part of test work package
Projects
None yet
Development

No branches or pull requests

2 participants