sntrup4591761.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env sh
  2. # $OpenBSD: sntrup4591761.sh,v 1.3 2019/01/30 19:51:15 markus Exp $
  3. # Placed in the Public Domain.
  4. #
  5. AUTHOR="libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/implementors"
  6. FILES="
  7. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/int32_sort.h
  8. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/int32_sort.c
  9. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/small.h
  10. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/mod3.h
  11. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/modq.h
  12. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/params.h
  13. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/r3.h
  14. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/rq.h
  15. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/swap.h
  16. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/dec.c
  17. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/enc.c
  18. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/keypair.c
  19. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/r3_mult.c
  20. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/r3_recip.c
  21. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/randomsmall.c
  22. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/randomweightw.c
  23. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/rq.c
  24. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/rq_mult.c
  25. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/rq_recip3.c
  26. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/rq_round3.c
  27. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/rq_rounded.c
  28. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/small.c
  29. libpqcrypto-20180314/crypto_kem/sntrup4591761/ref/swap.c
  30. "
  31. ###
  32. set -e
  33. cd $1
  34. echo -n '/* $'
  35. echo 'OpenBSD: $ */'
  36. echo
  37. echo '/*'
  38. echo ' * Public Domain, Authors:'
  39. sed -e '/Alphabetical order:/d' -e 's/^/ * - /' < $AUTHOR
  40. echo ' */'
  41. echo
  42. echo '#include <string.h>'
  43. echo '#include "crypto_api.h"'
  44. echo
  45. for i in $FILES; do
  46. echo "/* from $i */"
  47. b=$(basename $i .c)
  48. grep \
  49. -v '#include' $i |
  50. grep -v "extern crypto_int32 small_random32" |
  51. sed -e "s/crypto_kem_/crypto_kem_sntrup4591761_/g" \
  52. -e "s/smaller_mask/smaller_mask_${b}/g" \
  53. -e "s/^extern void /static void /" \
  54. -e "s/^void /static void /"
  55. echo
  56. done