ntru.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Internal functions for the NTRU cryptosystem, exposed in a header
  3. * that is expected to be included only by ntru.c and test programs.
  4. */
  5. #ifndef PUTTY_CRYPTO_NTRU_H
  6. #define PUTTY_CRYPTO_NTRU_H
  7. unsigned ntru_ring_invert(uint16_t *out, const uint16_t *in,
  8. unsigned p, unsigned q);
  9. void ntru_ring_multiply(uint16_t *out, const uint16_t *a, const uint16_t *b,
  10. unsigned p, unsigned q);
  11. void ntru_mod3(uint16_t *out, const uint16_t *in, unsigned p, unsigned q);
  12. void ntru_round3(uint16_t *out, const uint16_t *in, unsigned p, unsigned q);
  13. void ntru_bias(uint16_t *out, const uint16_t *in, unsigned bias,
  14. unsigned p, unsigned q);
  15. void ntru_scale(uint16_t *out, const uint16_t *in, uint16_t scale,
  16. unsigned p, unsigned q);
  17. NTRUEncodeSchedule *ntru_encode_schedule(const uint16_t *ms_in, size_t n);
  18. void ntru_encode_schedule_free(NTRUEncodeSchedule *sched);
  19. size_t ntru_encode_schedule_length(NTRUEncodeSchedule *sched);
  20. size_t ntru_encode_schedule_nvals(NTRUEncodeSchedule *sched);
  21. void ntru_encode(NTRUEncodeSchedule *sched, const uint16_t *rs_in,
  22. BinarySink *bs);
  23. void ntru_decode(NTRUEncodeSchedule *sched, uint16_t *rs_out, ptrlen data);
  24. void ntru_gen_short(uint16_t *v, unsigned p, unsigned w);
  25. NTRUKeyPair *ntru_keygen_attempt(unsigned p, unsigned q, unsigned w);
  26. NTRUKeyPair *ntru_keygen(unsigned p, unsigned q, unsigned w);
  27. void ntru_keypair_free(NTRUKeyPair *keypair);
  28. void ntru_encrypt(uint16_t *ciphertext, const uint16_t *plaintext,
  29. uint16_t *pubkey, unsigned p, unsigned q);
  30. void ntru_decrypt(uint16_t *plaintext, const uint16_t *ciphertext,
  31. NTRUKeyPair *keypair);
  32. void ntru_encode_pubkey(const uint16_t *pubkey, unsigned p, unsigned q,
  33. BinarySink *bs);
  34. ptrlen ntru_decode_pubkey(uint16_t *pubkey, unsigned p, unsigned q,
  35. BinarySource *src);
  36. void ntru_encode_ciphertext(const uint16_t *ciphertext, unsigned p, unsigned q,
  37. BinarySink *bs);
  38. ptrlen ntru_decode_ciphertext(uint16_t *ct, NTRUKeyPair *keypair,
  39. BinarySource *src);
  40. void ntru_encode_plaintext(const uint16_t *plaintext, unsigned p,
  41. BinarySink *bs);
  42. unsigned ntru_keypair_p(NTRUKeyPair *keypair);
  43. const uint16_t *ntru_pubkey(NTRUKeyPair *keypair);
  44. #endif /* PUTTY_CRYPTO_NTRU_H */