uencrypt.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0-or-later
  2. * Copyright (C) 2022-2023 Eneas Ulir de Queiroz
  3. */
  4. #include <stdio.h>
  5. #define CRYPT_BUF_SIZE 1024
  6. #ifdef USE_MBEDTLS
  7. # include <mbedtls/cipher.h>
  8. # if defined(MBEDTLS_MAX_BLOCK_LENGTH) \
  9. && MBEDTLS_MAX_BLOCK_LENGTH > CRYPT_BUF_SIZE
  10. # undef CRYPT_BUF_SIZE
  11. # define CRYPT_BUF_SIZE MAX_BLOCK_LENGTH
  12. # endif
  13. unsigned char *hexstr2buf(const char* str, long *len);
  14. #else /* USE_MBEDTLS */
  15. # ifdef USE_WOLFSSL
  16. # include <wolfssl/options.h>
  17. # include <wolfssl/openssl/evp.h>
  18. # else
  19. # include <openssl/evp.h>
  20. # endif
  21. # if defined(EVP_MAX_BLOCK_LENGTH) \
  22. && EVP_MAX_BLOCK_LENGTH > CRYPT_BUF_SIZE
  23. # undef CRYPT_BUF_SIZE
  24. # define CRYPT_BUF_SIZE EVP_MAX_BLOCK_LENGTH
  25. # endif
  26. # define hexstr2buf OPENSSL_hexstr2buf
  27. #endif /* USE_MBEDTLS */
  28. typedef void cipher_t;
  29. typedef void ctx_t;
  30. const cipher_t *get_default_cipher(void);
  31. const cipher_t *get_cipher_or_print_error(char *name);
  32. int get_cipher_ivsize(const cipher_t *cipher);
  33. int get_cipher_keysize(const cipher_t *cipher);
  34. ctx_t *create_ctx(const cipher_t *cipher, const unsigned char *key,
  35. const unsigned char *iv, int enc, int padding);
  36. int do_crypt(FILE *infile, FILE *outfile, ctx_t *ctx);
  37. void free_ctx(ctx_t *ctx);