1
0

sm3.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* $OpenBSD: sm3.h,v 1.1 2018/11/11 06:53:31 tb Exp $ */
  2. /*
  3. * Copyright (c) 2018, Ribose Inc
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef HEADER_SM3_H
  18. #define HEADER_SM3_H
  19. #include <stddef.h>
  20. #include <openssl/opensslconf.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #ifdef OPENSSL_NO_SM3
  25. #error SM3 is disabled.
  26. #endif
  27. #define SM3_DIGEST_LENGTH 32
  28. #define SM3_WORD unsigned int
  29. #define SM3_CBLOCK 64
  30. #define SM3_LBLOCK (SM3_CBLOCK / 4)
  31. typedef struct SM3state_st {
  32. SM3_WORD A, B, C, D, E, F, G, H;
  33. SM3_WORD Nl, Nh;
  34. SM3_WORD data[SM3_LBLOCK];
  35. unsigned int num;
  36. } SM3_CTX;
  37. int SM3_Init(SM3_CTX *c);
  38. int SM3_Update(SM3_CTX *c, const void *data, size_t len);
  39. int SM3_Final(unsigned char *md, SM3_CTX *c);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* HEADER_SM3_H */