2
0

rc2_ecb.c 996 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * Subject: Specification for Ron Rivests Cipher No.2
  16. * Message-ID: <4fk39f$f70@net.auckland.ac.nz>
  17. * Date: 11 Feb 1996 06:45:03 GMT
  18. */
  19. void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, RC2_KEY *ks,
  20. int encrypt)
  21. {
  22. unsigned long l, d[2];
  23. c2l(in, l);
  24. d[0] = l;
  25. c2l(in, l);
  26. d[1] = l;
  27. if (encrypt)
  28. RC2_encrypt(d, ks);
  29. else
  30. RC2_decrypt(d, ks);
  31. l = d[0];
  32. l2c(l, out);
  33. l = d[1];
  34. l2c(l, out);
  35. l = d[0] = d[1] = 0;
  36. }