rc5.h 2.1 KB

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