blowfish.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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 HEADER_BLOWFISH_H
  10. # define HEADER_BLOWFISH_H
  11. # include <openssl/opensslconf.h>
  12. # ifndef OPENSSL_NO_BF
  13. # include <openssl/e_os2.h>
  14. # ifdef __cplusplus
  15. extern "C" {
  16. # endif
  17. # define BF_ENCRYPT 1
  18. # define BF_DECRYPT 0
  19. /*-
  20. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  21. * ! BF_LONG has to be at least 32 bits wide. !
  22. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  23. */
  24. # define BF_LONG unsigned int
  25. # define BF_ROUNDS 16
  26. # define BF_BLOCK 8
  27. typedef struct bf_key_st {
  28. BF_LONG P[BF_ROUNDS + 2];
  29. BF_LONG S[4 * 256];
  30. } BF_KEY;
  31. void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
  32. void BF_encrypt(BF_LONG *data, const BF_KEY *key);
  33. void BF_decrypt(BF_LONG *data, const BF_KEY *key);
  34. void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
  35. const BF_KEY *key, int enc);
  36. void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
  37. const BF_KEY *schedule, unsigned char *ivec, int enc);
  38. void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
  39. long length, const BF_KEY *schedule,
  40. unsigned char *ivec, int *num, int enc);
  41. void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
  42. long length, const BF_KEY *schedule,
  43. unsigned char *ivec, int *num);
  44. const char *BF_options(void);
  45. # ifdef __cplusplus
  46. }
  47. # endif
  48. # endif
  49. #endif