summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sm2/sm2_err.c
diff options
context:
space:
mode:
authortb <>2021-08-18 16:04:32 +0000
committertb <>2021-08-18 16:04:32 +0000
commit27a4a421da356671ca87fff69b8b7340d284659c (patch)
treeff95b8757df3a4b8d97a0f3f19a7c9962ba1076f /src/lib/libcrypto/sm2/sm2_err.c
parente9cfb6e09338ad2081dfa06cdae4acc1dc0c78d9 (diff)
downloadopenbsd-27a4a421da356671ca87fff69b8b7340d284659c.tar.gz
openbsd-27a4a421da356671ca87fff69b8b7340d284659c.tar.bz2
openbsd-27a4a421da356671ca87fff69b8b7340d284659c.zip
Import initial code for the SM2 cipher
This adds the SM2 algorithm defined in the Chinese standards GB/T 32918.1-2016, GB/T 32918.2-2016, GB/T 32918.3-2016, GB/T 32918.4-2016 and GB/T 32918.5-2017. This is an ISC licensed implementation contributed by Ribose.inc, based on the same code that was contributed to OpenSSL by Jack Lloyd. The port to LibreSSL was done by Ronald Tse and Nickolay Olshevsky. Github PR #105 I made quite a few cleanup passes on this, but more is needed, some of which will happen in-tree before this is linked to the build. ok deraadt inoguchi (a long time ago), jsing
Diffstat (limited to 'src/lib/libcrypto/sm2/sm2_err.c')
-rw-r--r--src/lib/libcrypto/sm2/sm2_err.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/lib/libcrypto/sm2/sm2_err.c b/src/lib/libcrypto/sm2/sm2_err.c
new file mode 100644
index 0000000000..d34123cbf9
--- /dev/null
+++ b/src/lib/libcrypto/sm2/sm2_err.c
@@ -0,0 +1,106 @@
1/* $OpenBSD: sm2_err.c,v 1.1.1.1 2021/08/18 16:04:32 tb Exp $ */
2/*
3 * Generated by util/mkerr.pl DO NOT EDIT
4 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
5 *
6 * Licensed under the OpenSSL license (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
10 */
11
12#ifndef OPENSSL_NO_SM2
13
14#include <openssl/err.h>
15#include <openssl/sm2.h>
16
17#ifndef OPENSSL_NO_ERR
18
19#define ERR_FUNC(func) ERR_PACK(ERR_LIB_SM2,func,0)
20#define ERR_REASON(reason) ERR_PACK(ERR_LIB_SM2,0,reason)
21
22static ERR_STRING_DATA SM2_str_functs[] = {
23 {ERR_FUNC(0xfff), "CRYPTO_internal"},
24 {0, NULL}
25};
26
27static ERR_STRING_DATA SM2_str_reasons[] = {
28 {ERR_REASON(SM2_R_ASN1_ERROR), "asn1 error"},
29 {ERR_REASON(SM2_R_ASN5_ERROR), "asn5 error"},
30 {ERR_REASON(SM2_R_BAD_SIGNATURE), "bad signature"},
31 {ERR_REASON(SM2_R_BIGNUM_OUT_OF_RANGE), "bignum out of range"},
32 {ERR_REASON(SM2_R_BUFFER_TOO_SMALL), "buffer too small"},
33 {ERR_REASON(SM2_R_COORDINATES_OUT_OF_RANGE), "coordinates out of range"},
34 {ERR_REASON(SM2_R_CURVE_DOES_NOT_SUPPORT_ECDH), "curve does not support ecdh"},
35 {ERR_REASON(SM2_R_CURVE_DOES_NOT_SUPPORT_SIGNING), "curve does not support signing"},
36 {ERR_REASON(SM2_R_D2I_ECPKPARAMETERS_FAILURE), "d2i ecpkparameters failure"},
37 {ERR_REASON(SM2_R_DECODE_ERROR), "decode error"},
38 {ERR_REASON(SM2_R_DIGEST_FAILURE), "digest calculation failure"},
39 {ERR_REASON(SM2_R_DISCRIMINANT_IS_ZERO), "discriminant is zero"},
40 {ERR_REASON(SM2_R_EC_GROUP_NEW_BY_NAME_FAILURE), "ec group new by name failure"},
41 {ERR_REASON(SM2_R_FIELD_TOO_LARGE), "field too large"},
42 {ERR_REASON(SM2_R_GF2M_NOT_SUPPORTED), "gf2m not supported"},
43 {ERR_REASON(SM2_R_GROUP2PKPARAMETERS_FAILURE), "group2pkparameters failure"},
44 {ERR_REASON(SM2_R_I2D_ECPKPARAMETERS_FAILURE), "i2d ecpkparameters failure"},
45 {ERR_REASON(SM2_R_INCOMPATIBLE_OBJECTS), "incompatible objects"},
46 {ERR_REASON(SM2_R_INVALID_ARGUMENT), "invalid argument"},
47 {ERR_REASON(SM2_R_INVALID_COMPRESSED_POINT), "invalid compressed point"},
48 {ERR_REASON(SM2_R_INVALID_COMPRESSION_BIT), "invalid compression bit"},
49 {ERR_REASON(SM2_R_INVALID_CURVE), "invalid curve"},
50 {ERR_REASON(SM2_R_INVALID_DIGEST), "invalid digest"},
51 {ERR_REASON(SM2_R_INVALID_DIGEST_TYPE), "invalid digest type"},
52 {ERR_REASON(SM2_R_INVALID_ENCODING), "invalid encoding"},
53 {ERR_REASON(SM2_R_INVALID_FIELD), "invalid field"},
54 {ERR_REASON(SM2_R_INVALID_FORM), "invalid form"},
55 {ERR_REASON(SM2_R_INVALID_GROUP_ORDER), "invalid group order"},
56 {ERR_REASON(SM2_R_INVALID_KEY), "invalid key"},
57 {ERR_REASON(SM2_R_INVALID_OUTPUT_LENGTH), "invalid output length"},
58 {ERR_REASON(SM2_R_INVALID_PEER_KEY), "invalid peer key"},
59 {ERR_REASON(SM2_R_INVALID_PENTANOMIAL_BASIS), "invalid pentanomial basis"},
60 {ERR_REASON(SM2_R_INVALID_PRIVATE_KEY), "invalid private key"},
61 {ERR_REASON(SM2_R_INVALID_TRINOMIAL_BASIS), "invalid trinomial basis"},
62 {ERR_REASON(SM2_R_KDF_FAILURE), "kdf calculation failure"},
63 {ERR_REASON(SM2_R_KDF_PARAMETER_ERROR), "kdf parameter error"},
64 {ERR_REASON(SM2_R_KEYS_NOT_SET), "keys not set"},
65 {ERR_REASON(SM2_R_MISSING_PARAMETERS), "missing parameters"},
66 {ERR_REASON(SM2_R_MISSING_PRIVATE_KEY), "missing private key"},
67 {ERR_REASON(SM2_R_NEED_NEW_SETUP_VALUES), "need new setup values"},
68 {ERR_REASON(SM2_R_NOT_A_NIST_PRIME), "not a NIST prime"},
69 {ERR_REASON(SM2_R_NOT_IMPLEMENTED), "not implemented"},
70 {ERR_REASON(SM2_R_NOT_INITIALIZED), "not initialized"},
71 {ERR_REASON(SM2_R_NO_PARAMETERS_SET), "no parameters set"},
72 {ERR_REASON(SM2_R_NO_PRIVATE_VALUE), "no private value"},
73 {ERR_REASON(SM2_R_OPERATION_NOT_SUPPORTED), "operation not supported"},
74 {ERR_REASON(SM2_R_PASSED_NULL_PARAMETER), "passed null parameter"},
75 {ERR_REASON(SM2_R_PEER_KEY_ERROR), "peer key error"},
76 {ERR_REASON(SM2_R_PKPARAMETERS2GROUP_FAILURE), "pkparameters2group failure"},
77 {ERR_REASON(SM2_R_POINT_ARITHMETIC_FAILURE), "point arithmetic failure"},
78 {ERR_REASON(SM2_R_POINT_AT_INFINITY), "point at infinity"},
79 {ERR_REASON(SM2_R_POINT_IS_NOT_ON_CURVE), "point is not on curve"},
80 {ERR_REASON(SM2_R_RANDOM_NUMBER_GENERATION_FAILED), "random number generation failed"},
81 {ERR_REASON(SM2_R_SHARED_INFO_ERROR), "shared info error"},
82 {ERR_REASON(SM2_R_SLOT_FULL), "slot full"},
83 {ERR_REASON(SM2_R_UNDEFINED_GENERATOR), "undefined generator"},
84 {ERR_REASON(SM2_R_UNDEFINED_ORDER), "undefined order"},
85 {ERR_REASON(SM2_R_UNKNOWN_GROUP), "unknown group"},
86 {ERR_REASON(SM2_R_UNKNOWN_ORDER), "unknown order"},
87 {ERR_REASON(SM2_R_UNSUPPORTED_FIELD), "unsupported field"},
88 {ERR_REASON(SM2_R_WRONG_CURVE_PARAMETERS), "wrong curve parameters"},
89 {ERR_REASON(SM2_R_WRONG_ORDER), "wrong order"},
90 {0, NULL}
91};
92
93#endif
94
95void
96ERR_load_SM2_strings(void)
97{
98#ifndef OPENSSL_NO_ERR
99 if (ERR_func_error_string(SM2_str_functs[0].error) == NULL) {
100 ERR_load_strings(0, SM2_str_functs);
101 ERR_load_strings(0, SM2_str_reasons);
102 }
103#endif
104}
105
106#endif /* OPENSSL_NO_SM2 */