xref: /netbsd-src/crypto/external/bsd/openssl/dist/include/internal/sm3.h (revision b0d1725196a7921d003d2c66a14f186abda4176b)
1*b0d17251Schristos /*
2*b0d17251Schristos  * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b0d17251Schristos  * Copyright 2017 Ribose Inc. All Rights Reserved.
4*b0d17251Schristos  *
5*b0d17251Schristos  * Licensed under the Apache License 2.0 (the "License").  You may not use
6*b0d17251Schristos  * this file except in compliance with the License.  You can obtain a copy
7*b0d17251Schristos  * in the file LICENSE in the source distribution or at
8*b0d17251Schristos  * https://www.openssl.org/source/license.html
9*b0d17251Schristos  */
10*b0d17251Schristos 
11*b0d17251Schristos /* This header can move into provider when legacy support is removed */
12*b0d17251Schristos #ifndef OSSL_INTERNAL_SM3_H
13*b0d17251Schristos # define OSSL_INTERNAL_SM3_H
14*b0d17251Schristos # pragma once
15*b0d17251Schristos 
16*b0d17251Schristos # include <openssl/opensslconf.h>
17*b0d17251Schristos 
18*b0d17251Schristos # ifdef OPENSSL_NO_SM3
19*b0d17251Schristos #  error SM3 is disabled.
20*b0d17251Schristos # endif
21*b0d17251Schristos 
22*b0d17251Schristos # define SM3_DIGEST_LENGTH 32
23*b0d17251Schristos # define SM3_WORD unsigned int
24*b0d17251Schristos 
25*b0d17251Schristos # define SM3_CBLOCK      64
26*b0d17251Schristos # define SM3_LBLOCK      (SM3_CBLOCK/4)
27*b0d17251Schristos 
28*b0d17251Schristos typedef struct SM3state_st {
29*b0d17251Schristos    SM3_WORD A, B, C, D, E, F, G, H;
30*b0d17251Schristos    SM3_WORD Nl, Nh;
31*b0d17251Schristos    SM3_WORD data[SM3_LBLOCK];
32*b0d17251Schristos    unsigned int num;
33*b0d17251Schristos } SM3_CTX;
34*b0d17251Schristos 
35*b0d17251Schristos int ossl_sm3_init(SM3_CTX *c);
36*b0d17251Schristos int ossl_sm3_update(SM3_CTX *c, const void *data, size_t len);
37*b0d17251Schristos int ossl_sm3_final(unsigned char *md, SM3_CTX *c);
38*b0d17251Schristos 
39*b0d17251Schristos #endif /* OSSL_INTERNAL_SM3_H */
40