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