crypto_ope.h 913 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* Copyright (c) 2018, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef CRYPTO_OPE_H
  4. #define CRYPTO_OPE_H
  5. #include "orconfig.h"
  6. #include "crypto.h"
  7. #include "crypto_util.h"
  8. #include "crypto_ope.h"
  9. /** Length of OPE key, in bytes. */
  10. #define OPE_KEY_LEN 32
  11. /** Largest value that can be passed to crypto_ope_encrypt() */
  12. #define OPE_INPUT_MAX 131072
  13. typedef struct crypto_ope_c crypto_ope_t;
  14. crypto_ope_t *crypto_ope_new(const uint8_t *key);
  15. void crypto_ope_free_(crypto_ope_t *ope);
  16. #define crypto_ope_free(ope) \
  17. FREE_AND_NULL(crypto_ope_t, crypto_ope_free_, (ope))
  18. uint64_t crypto_ope_encrypt(const crypto_ope_t *ope, int plaintext);
  19. #ifdef CRYPTO_OPE_PRIVATE
  20. STATIC crypto_cipher_t *ope_get_cipher(const crypto_ope_t *ope,
  21. uint32_t initial_idx);
  22. STATIC uint64_t sum_values_from_cipher(crypto_cipher_t *c, size_t n);
  23. #endif
  24. #endif