ecb_enc.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 1995-2017 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. #include "des_locl.h"
  10. #include <openssl/opensslv.h>
  11. #include <openssl/bio.h>
  12. const char *DES_options(void)
  13. {
  14. static int init = 1;
  15. static char buf[12];
  16. if (init) {
  17. if (sizeof(DES_LONG) != sizeof(long))
  18. OPENSSL_strlcpy(buf, "des(int)", sizeof(buf));
  19. else
  20. OPENSSL_strlcpy(buf, "des(long)", sizeof(buf));
  21. init = 0;
  22. }
  23. return buf;
  24. }
  25. void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
  26. DES_key_schedule *ks, int enc)
  27. {
  28. register DES_LONG l;
  29. DES_LONG ll[2];
  30. const unsigned char *in = &(*input)[0];
  31. unsigned char *out = &(*output)[0];
  32. c2l(in, l);
  33. ll[0] = l;
  34. c2l(in, l);
  35. ll[1] = l;
  36. DES_encrypt1(ll, ks, enc);
  37. l = ll[0];
  38. l2c(l, out);
  39. l = ll[1];
  40. l2c(l, out);
  41. l = ll[0] = ll[1] = 0;
  42. }