A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

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