m_md5_sha1.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2015-2019 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. #ifndef OPENSSL_NO_MD5
  10. # include <string.h>
  11. # include <openssl/evp.h>
  12. # include <openssl/obj_mac.h>
  13. # include "internal/evp_int.h"
  14. # include "internal/md5_sha1.h"
  15. static int init(EVP_MD_CTX *ctx)
  16. {
  17. return md5_sha1_init(EVP_MD_CTX_md_data(ctx));
  18. }
  19. static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
  20. {
  21. return md5_sha1_update(EVP_MD_CTX_md_data(ctx), data, count);
  22. }
  23. static int final(EVP_MD_CTX *ctx, unsigned char *md)
  24. {
  25. return md5_sha1_final(md, EVP_MD_CTX_md_data(ctx));
  26. }
  27. static int ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms)
  28. {
  29. return md5_sha1_ctrl(EVP_MD_CTX_md_data(ctx), cmd, mslen, ms);
  30. }
  31. static const EVP_MD md5_sha1_md = {
  32. NID_md5_sha1,
  33. NID_md5_sha1,
  34. MD5_SHA1_DIGEST_LENGTH,
  35. 0,
  36. init,
  37. update,
  38. final,
  39. NULL,
  40. NULL,
  41. MD5_SHA1_CBLOCK,
  42. sizeof(EVP_MD *) + sizeof(MD5_SHA1_CTX),
  43. ctrl
  44. };
  45. const EVP_MD *EVP_md5_sha1(void)
  46. {
  47. return &md5_sha1_md;
  48. }
  49. #endif /* OPENSSL_NO_MD5 */