mdc2_one.c 896 B

123456789101112131415161718192021222324252627282930313233
  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. /*
  10. * MD2 low level APIs are deprecated for public use, but still ok for
  11. * internal use.
  12. */
  13. #include "internal/deprecated.h"
  14. #include <stdio.h>
  15. #include "internal/cryptlib.h"
  16. #include <openssl/mdc2.h>
  17. unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md)
  18. {
  19. MDC2_CTX c;
  20. static unsigned char m[MDC2_DIGEST_LENGTH];
  21. if (md == NULL)
  22. md = m;
  23. if (!MDC2_Init(&c))
  24. return NULL;
  25. MDC2_Update(&c, d, n);
  26. MDC2_Final(md, &c);
  27. OPENSSL_cleanse(&c, sizeof(c)); /* security consideration */
  28. return md;
  29. }