rc5.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_RC5_H
  10. # define HEADER_RC5_H
  11. # include <openssl/opensslconf.h>
  12. # ifndef OPENSSL_NO_RC5
  13. # ifdef __cplusplus
  14. extern "C" {
  15. # endif
  16. # define RC5_ENCRYPT 1
  17. # define RC5_DECRYPT 0
  18. # define RC5_32_INT unsigned int
  19. # define RC5_32_BLOCK 8
  20. # define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */
  21. /*
  22. * This are the only values supported. Tweak the code if you want more The
  23. * most supported modes will be RC5-32/12/16 RC5-32/16/8
  24. */
  25. # define RC5_8_ROUNDS 8
  26. # define RC5_12_ROUNDS 12
  27. # define RC5_16_ROUNDS 16
  28. typedef struct rc5_key_st {
  29. /* Number of rounds */
  30. int rounds;
  31. RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)];
  32. } RC5_32_KEY;
  33. void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
  34. int rounds);
  35. void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,
  36. RC5_32_KEY *key, int enc);
  37. void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key);
  38. void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key);
  39. void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
  40. long length, RC5_32_KEY *ks, unsigned char *iv,
  41. int enc);
  42. void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
  43. long length, RC5_32_KEY *schedule,
  44. unsigned char *ivec, int *num, int enc);
  45. void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
  46. long length, RC5_32_KEY *schedule,
  47. unsigned char *ivec, int *num);
  48. # ifdef __cplusplus
  49. }
  50. # endif
  51. # endif
  52. #endif