m_wp.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2005-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. #include <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #ifndef OPENSSL_NO_WHIRLPOOL
  12. # include <openssl/evp.h>
  13. # include <openssl/objects.h>
  14. # include <openssl/x509.h>
  15. # include <openssl/whrlpool.h>
  16. # include "internal/evp_int.h"
  17. static int init(EVP_MD_CTX *ctx)
  18. {
  19. return WHIRLPOOL_Init(EVP_MD_CTX_md_data(ctx));
  20. }
  21. static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
  22. {
  23. return WHIRLPOOL_Update(EVP_MD_CTX_md_data(ctx), data, count);
  24. }
  25. static int final(EVP_MD_CTX *ctx, unsigned char *md)
  26. {
  27. return WHIRLPOOL_Final(md, EVP_MD_CTX_md_data(ctx));
  28. }
  29. static const EVP_MD whirlpool_md = {
  30. NID_whirlpool,
  31. 0,
  32. WHIRLPOOL_DIGEST_LENGTH,
  33. 0,
  34. init,
  35. update,
  36. final,
  37. NULL,
  38. NULL,
  39. WHIRLPOOL_BBLOCK / 8,
  40. sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX),
  41. };
  42. const EVP_MD *EVP_whirlpool(void)
  43. {
  44. return &whirlpool_md;
  45. }
  46. #endif