sntrup761.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env sh
  2. # $OpenBSD: sntrup761.sh,v 1.1 2020/12/29 00:59:15 djm Exp $
  3. # Placed in the Public Domain.
  4. #
  5. AUTHOR="supercop-20201130/crypto_kem/sntrup761/ref/implementors"
  6. FILES="
  7. supercop-20201130/crypto_kem/sntrup761/ref/uint64.h
  8. supercop-20201130/crypto_kem/sntrup761/ref/uint16.h
  9. supercop-20201130/crypto_kem/sntrup761/ref/uint32.h
  10. supercop-20201130/crypto_kem/sntrup761/ref/int8.h
  11. supercop-20201130/crypto_kem/sntrup761/ref/int16.h
  12. supercop-20201130/crypto_kem/sntrup761/ref/int32.h
  13. supercop-20201130/crypto_kem/sntrup761/ref/uint32.c
  14. supercop-20201130/crypto_kem/sntrup761/ref/int32.c
  15. supercop-20201130/crypto_kem/sntrup761/ref/paramsmenu.h
  16. supercop-20201130/crypto_kem/sntrup761/ref/params.h
  17. supercop-20201130/crypto_kem/sntrup761/ref/Decode.h
  18. supercop-20201130/crypto_kem/sntrup761/ref/Decode.c
  19. supercop-20201130/crypto_kem/sntrup761/ref/Encode.h
  20. supercop-20201130/crypto_kem/sntrup761/ref/Encode.c
  21. supercop-20201130/crypto_kem/sntrup761/ref/kem.c
  22. "
  23. SORT_I32="
  24. supercop-20201130/crypto_sort/int32/portable4/sort.c
  25. "
  26. SORT_U32="supercop-20201130/crypto_sort/uint32/useint32/sort.c"
  27. ###
  28. set -e
  29. cd $1
  30. echo -n '/* $'
  31. echo 'OpenBSD: $ */'
  32. echo
  33. echo '/*'
  34. echo ' * Public Domain, Authors:'
  35. sed -e '/Alphabetical order:/d' -e 's/^/ * - /' < $AUTHOR
  36. echo ' */'
  37. echo
  38. echo '#include <string.h>'
  39. echo '#include "crypto_api.h"'
  40. echo '#include "int32_minmax.inc"'
  41. echo
  42. echo '#define CRYPTO_NAMESPACE(s) s'
  43. echo
  44. for i in $SORT_I32; do
  45. echo "/* from $i */"
  46. grep \
  47. -v '#include' $i | \
  48. sed -e "s/void crypto_sort/static void crypto_sort_int32/g"
  49. echo
  50. done
  51. echo "/* from $SORT_U32 */"
  52. grep \
  53. -v '#include' $SORT_U32 | \
  54. sed -e "s/void crypto_sort/static void crypto_sort_uint32/g"
  55. echo
  56. for i in $FILES; do
  57. echo "/* from $i */"
  58. grep \
  59. -v '#include' $i | \
  60. sed -e "s/crypto_kem_/crypto_kem_sntrup761_/g" \
  61. -e "s/^extern void /static void /" \
  62. -e "s/^void /static void /" \
  63. -e "/^typedef int32_t int32;$/d"
  64. echo
  65. done