rc2_ecb.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. /*
  10. * RC2 low level APIs are deprecated for public use, but still ok for internal
  11. * use.
  12. */
  13. #include "internal/deprecated.h"
  14. #include <openssl/rc2.h>
  15. #include "rc2_local.h"
  16. #include <openssl/opensslv.h>
  17. /*-
  18. * RC2 as implemented frm a posting from
  19. * Newsgroups: sci.crypt
  20. * Subject: Specification for Ron Rivests Cipher No.2
  21. * Message-ID: <4fk39f$f70@net.auckland.ac.nz>
  22. * Date: 11 Feb 1996 06:45:03 GMT
  23. */
  24. void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, RC2_KEY *ks,
  25. int encrypt)
  26. {
  27. unsigned long l, d[2];
  28. c2l(in, l);
  29. d[0] = l;
  30. c2l(in, l);
  31. d[1] = l;
  32. if (encrypt)
  33. RC2_encrypt(d, ks);
  34. else
  35. RC2_decrypt(d, ks);
  36. l = d[0];
  37. l2c(l, out);
  38. l = d[1];
  39. l2c(l, out);
  40. l = d[0] = d[1] = 0;
  41. }