summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sm3/sm3.h
diff options
context:
space:
mode:
authortb <>2018-11-11 06:53:31 +0000
committertb <>2018-11-11 06:53:31 +0000
commitc247a32a9d35da8568530b68935cbf846e741929 (patch)
treec825763485b682e2b4d62f2c543f52d67260398e /src/lib/libcrypto/sm3/sm3.h
parentca9928e7c9c11578cf638e830236c837232fabc6 (diff)
downloadopenbsd-c247a32a9d35da8568530b68935cbf846e741929.tar.gz
openbsd-c247a32a9d35da8568530b68935cbf846e741929.tar.bz2
openbsd-c247a32a9d35da8568530b68935cbf846e741929.zip
Add Ribose Inc's implementation of the SM3 hashing function with
tweaks from jsing and myself. The SM2/SM3/SM4 algorithms are mandatory for legal use of cryptography within China and [are] widely applied in the country, covering identification/financial cards, contactless, TPM 2.0 and PKI. ok beck inoguchi jsing
Diffstat (limited to 'src/lib/libcrypto/sm3/sm3.h')
-rw-r--r--src/lib/libcrypto/sm3/sm3.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/lib/libcrypto/sm3/sm3.h b/src/lib/libcrypto/sm3/sm3.h
new file mode 100644
index 0000000000..553c64dcdb
--- /dev/null
+++ b/src/lib/libcrypto/sm3/sm3.h
@@ -0,0 +1,53 @@
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
18#ifndef HEADER_SM3_H
19#define HEADER_SM3_H
20
21#include <stddef.h>
22#include <openssl/opensslconf.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#ifdef OPENSSL_NO_SM3
29#error SM3 is disabled.
30#endif
31
32#define SM3_DIGEST_LENGTH 32
33#define SM3_WORD unsigned int
34
35#define SM3_CBLOCK 64
36#define SM3_LBLOCK (SM3_CBLOCK / 4)
37
38typedef struct SM3state_st {
39 SM3_WORD A, B, C, D, E, F, G, H;
40 SM3_WORD Nl, Nh;
41 SM3_WORD data[SM3_LBLOCK];
42 unsigned int num;
43} SM3_CTX;
44
45int SM3_Init(SM3_CTX *c);
46int SM3_Update(SM3_CTX *c, const void *data, size_t len);
47int SM3_Final(unsigned char *md, SM3_CTX *c);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif /* HEADER_SM3_H */