Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CONTRIBUTING.md 5.9 KiB

vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Contributing new schemes to PQClean
  2. ===================================
  3. Why contribute to PQClean
  4. -------------------------
  5. PQClean hopes to provide your scheme to people who want to integrate post-quantum cryptography into their own libraries and applications. But our extensive testing framework might also help you catch bugs in your implementation, that might have otherwise gone unnoticed. We run our builds on (emulated) ARMv7, ARMv8, 32-bit PowerPC, x86 and amd64. Also, we apply static and dynamic analysis tools.
  6. Adding your scheme
  7. ------------------
  8. For this text, we will assume that you want to contribute a **key encapsulation mechanism (KEM)** to PQClean. For a signature scheme, these steps are equivalent, but the API is slightly different.
  9. See the section [API](#API) below.
  10. 1. Fork our repository. You will be creating a pull request soon.
  11. * **Tip:** Do not wait until you think you have gotten everything perfect, before you open the pull request. We set up things so Github and the CI environment will give you feedback and guidance on the steps to follow.
  12. 2. Create the following folder structure: `crypto_kem/yourschemename/clean`. We follow the SUPERCOP layout, so please create a separate folder under `crypto_kem` for each parameter set.
  13. For now, we only accept **pure, portable C code**. Our coding conventions impose certain constraints on the C code -- C99 code, fixed sized integer types (e.g., `uint64_t` rather than `unsigned long long`), and more. See README.md for more information.
  14. 3. Create a `META.yml` file in `crypto_(kem|sign)/yourschemename` following this template:
  15. ```yaml
  16. name: Name
  17. type: <kem|signature>
  18. claimed-nist-level: <N>
  19. claimed-security: IND-CPA/IND-CCA2 # KEM only
  20. length-public-key: <N> # KEM and signature
  21. length-secret-key: <N> # KEM and signature
  22. length-ciphertext: <N> # KEM only
  23. length-shared-secret: <N> # KEM only
  24. length-signature: <N> # Signature only
  25. nistkat-sha256: sha256sum of 1st NIST KAT test case # KEM and signature
  26. testvectors-sha256: sha256sum of output of testvectors # Signature only
  27. principal-submitters:
  28. - Alice
  29. - Bob
  30. - ...
  31. auxiliary-submitters: # optional
  32. - Alice
  33. - Bob
  34. - ...
  35. implementations:
  36. - name: clean
  37. version: <some version indicator>
  38. ```
  39. This file needs to be valid [YAML](https://yaml.org/).
  40. 4. Put your scheme's C source code into `crypto_kem/yourschemename/clean`.
  41. 1. Make sure all symbols are prefixed with `PQCLEAN_YOURSCHEME_CLEAN_`.
  42. 2. Include `api.h` into your scheme with the symbols specified in the section [API](#API). Make sure it does not include other files.
  43. 3. We use `astyle` to format code. You may consider running the following command on your submission:
  44. ```
  45. astyle --project crypto_kem/yourschemename/clean/*.[ch]
  46. ```
  47. 4. You may run the tests in the `tests/` folder. See the `README` for how to run the test suite.
  48. 5. Migrate your use of AES, SHA-2, and SHA-3 to the API in the `common` directory. Note that if you use the AES API, you must use the `aes128_keyexp` routine (or 192 or 256) to expand the key into a key schedule object, then use `aes128_ctx_release` to release the key schedule object once you're finished with it.
  49. 5. Create `Makefile` and `Makefile.Microsoft_nmake` files to compile your scheme as static library.
  50. * We suggest you copy these from `crypto_kem/kyber768/clean` and modify them to suit your scheme.
  51. 6. Add a `LICENSE` file to your implementation folder.
  52. 7. Commit everything and push it to your fork.
  53. 8. Open a pull request on our Github repository and process the feedback given to you by the CI environment. The pull request will also set up a checklist for you and us to follow. Feel free to ask us questions via the pull request.
  54. API
  55. ---
  56. These items should be available in your `api.h` file.
  57. ### KEMs
  58. Functions:
  59. ```c
  60. int PQCLEAN_YOURSCHEME_CLEAN_crypto_kem_keypair(
  61. uint8_t *pk, uint8_t *sk);
  62. int PQCLEAN_YOURSCHEME_CLEAN_crypto_kem_enc(
  63. uint8_t *ct, uint8_t *ss, const uint8_t *pk);
  64. int PQCLEAN_YOURSCHEME_CLEAN_crypto_kem_dec(
  65. uint8_t *ss, const uint8_t *ct, const uint8_t *sk);
  66. ```
  67. `#define` macros:
  68. * `CRYPTO_SECRETKEYBYTES`
  69. * `CRYPTO_PUBLICKEYBYTES`
  70. * `CRYPTO_CIPHERTEXTBYTES`
  71. * `CRYPTO_BYTES`
  72. * `CRYPTO_ALGNAME`
  73. ### Signature schemes
  74. Functions:
  75. ```c
  76. int PQCLEAN_YOURSCHEME_CLEAN_crypto_sign_keypair(
  77. uint8_t *pk, uint8_t *sk);
  78. int PQCLEAN_YOURSCHEME_CLEAN_crypto_sign(
  79. uint8_t *sm, size_t *smlen,
  80. const uint8_t *msg, size_t len,
  81. const uint8_t *sk);
  82. int PQCLEAN_YOURSCHEME_CLEAN_crypto_sign_open(
  83. uint8_t *m, size_t *mlen,
  84. const uint8_t *sm, size_t smlen,
  85. const uint8_t *pk);
  86. int PQCLEAN_YOURSCHEME_CLEAN_crypto_sign_signature(
  87. uint8_t *sig, size_t *siglen,
  88. const uint8_t *m, size_t mlen,
  89. const uint8_t *sk);
  90. int PQCLEAN_YOURSCHEME_CLEAN_crypto_sign_verify(
  91. const uint8_t *sig, size_t siglen,
  92. const uint8_t *m, size_t mlen,
  93. const uint8_t *pk);
  94. ```
  95. `#define` macros:
  96. * `PQCLEAN_YOURSCHEME_CLEAN_CRYPTO_SECRETKEYBYTES`
  97. * `PQCLEAN_YOURSCHEME_CLEAN_CRYPTO_PUBLICKEYBYTES`
  98. * `PQCLEAN_YOURSCHEME_CLEAN_CRYPTO_ALGNAME`
  99. * `PQCLEAN_YOURSCHEME_CLEAN_CRYPTO_BYTES`
  100. for KEMs, additionally define:
  101. * `PQCLEAN_YOURSCHEME_CLEAN_CRYPTO_CIPHERTEXTBYTES`
  102. Please make sure your `api.h` file does not include any other files.
  103. ### Return codes
  104. Your schemes should return 0 on success, or a negative value on failure.
  105. Notably, `crypto_sign_open` should return `-1` if signature verification failed.
  106. Contributing to the framework of PQClean
  107. ========================================
  108. We also welcome contributions to the testing framework. Open an issue or pull request on Github and we will review your suggestion. In general, we are always looking to improve the experience of submitters of schemes and of people consuming the implementations collected by this project.