m_blake2b.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright 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_BLAKE2
  10. # include <stddef.h>
  11. # include <openssl/obj_mac.h>
  12. # include "internal/evp_int.h"
  13. # include "internal/blake2.h"
  14. static int init(EVP_MD_CTX *ctx)
  15. {
  16. return blake2b512_init(EVP_MD_CTX_md_data(ctx));
  17. }
  18. static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
  19. {
  20. return blake2b_update(EVP_MD_CTX_md_data(ctx), data, count);
  21. }
  22. static int final(EVP_MD_CTX *ctx, unsigned char *md)
  23. {
  24. return blake2b_final(md, EVP_MD_CTX_md_data(ctx));
  25. }
  26. static const EVP_MD blake2b_md = {
  27. NID_blake2b512,
  28. 0,
  29. BLAKE2B_DIGEST_LENGTH,
  30. 0,
  31. init,
  32. update,
  33. final,
  34. NULL,
  35. NULL,
  36. BLAKE2B_BLOCKBYTES,
  37. sizeof(BLAKE2B_CTX),
  38. };
  39. const EVP_MD *EVP_blake2b512(void)
  40. {
  41. return &blake2b_md;
  42. }
  43. #endif /* OPENSSL_NO_BLAKE2 */