blowfish.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OPENSSL_BLOWFISH_H
  10. # define OPENSSL_BLOWFISH_H
  11. # pragma once
  12. # include <openssl/macros.h>
  13. # ifndef OPENSSL_NO_DEPRECATED_3_0
  14. # define HEADER_BLOWFISH_H
  15. # endif
  16. # include <openssl/opensslconf.h>
  17. # ifndef OPENSSL_NO_BF
  18. # include <openssl/e_os2.h>
  19. # ifdef __cplusplus
  20. extern "C" {
  21. # endif
  22. # define BF_BLOCK 8
  23. # ifndef OPENSSL_NO_DEPRECATED_3_0
  24. # define BF_ENCRYPT 1
  25. # define BF_DECRYPT 0
  26. /*-
  27. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  28. * ! BF_LONG has to be at least 32 bits wide. !
  29. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  30. */
  31. # define BF_LONG unsigned int
  32. # define BF_ROUNDS 16
  33. typedef struct bf_key_st {
  34. BF_LONG P[BF_ROUNDS + 2];
  35. BF_LONG S[4 * 256];
  36. } BF_KEY;
  37. # endif /* OPENSSL_NO_DEPRECATED_3_0 */
  38. # ifndef OPENSSL_NO_DEPRECATED_3_0
  39. OSSL_DEPRECATEDIN_3_0 void BF_set_key(BF_KEY *key, int len,
  40. const unsigned char *data);
  41. OSSL_DEPRECATEDIN_3_0 void BF_encrypt(BF_LONG *data, const BF_KEY *key);
  42. OSSL_DEPRECATEDIN_3_0 void BF_decrypt(BF_LONG *data, const BF_KEY *key);
  43. OSSL_DEPRECATEDIN_3_0 void BF_ecb_encrypt(const unsigned char *in,
  44. unsigned char *out, const BF_KEY *key,
  45. int enc);
  46. OSSL_DEPRECATEDIN_3_0 void BF_cbc_encrypt(const unsigned char *in,
  47. unsigned char *out, long length,
  48. const BF_KEY *schedule,
  49. unsigned char *ivec, int enc);
  50. OSSL_DEPRECATEDIN_3_0 void BF_cfb64_encrypt(const unsigned char *in,
  51. unsigned char *out,
  52. long length, const BF_KEY *schedule,
  53. unsigned char *ivec, int *num,
  54. int enc);
  55. OSSL_DEPRECATEDIN_3_0 void BF_ofb64_encrypt(const unsigned char *in,
  56. unsigned char *out,
  57. long length, const BF_KEY *schedule,
  58. unsigned char *ivec, int *num);
  59. OSSL_DEPRECATEDIN_3_0 const char *BF_options(void);
  60. # endif
  61. # ifdef __cplusplus
  62. }
  63. # endif
  64. # endif
  65. #endif