m_ripemd.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #ifndef OPENSSL_NO_RMD160
  12. # include <openssl/ripemd.h>
  13. # include <openssl/evp.h>
  14. # include <openssl/objects.h>
  15. # include <openssl/x509.h>
  16. # include <openssl/rsa.h>
  17. # include "crypto/evp.h"
  18. static int init(EVP_MD_CTX *ctx)
  19. {
  20. return RIPEMD160_Init(EVP_MD_CTX_md_data(ctx));
  21. }
  22. static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
  23. {
  24. return RIPEMD160_Update(EVP_MD_CTX_md_data(ctx), data, count);
  25. }
  26. static int final(EVP_MD_CTX *ctx, unsigned char *md)
  27. {
  28. return RIPEMD160_Final(md, EVP_MD_CTX_md_data(ctx));
  29. }
  30. static const EVP_MD ripemd160_md = {
  31. NID_ripemd160,
  32. NID_ripemd160WithRSA,
  33. RIPEMD160_DIGEST_LENGTH,
  34. 0,
  35. init,
  36. update,
  37. final,
  38. NULL,
  39. NULL,
  40. RIPEMD160_CBLOCK,
  41. sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX),
  42. };
  43. const EVP_MD *EVP_ripemd160(void)
  44. {
  45. return &ripemd160_md;
  46. }
  47. #endif