1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
GenProtoBasedErrorCode!({
      kind: ERRORKIND_API,
      sym: APIError,
      desc: "API errors.
 The following errors can occur during a call to the Context API.",
      values: [
        APIERROR_CONFIGURATION => "Configuration error.",
APIERROR_SOCKET => "Socket error.",
APIERROR_TUNNEL => "Tunnel error.",

      ],
  },
{
      kind: ERRORKIND_CONFIGURATION,
      sym: ConfigurationError,
      desc: "Errors regarding configurations.",
      values: [
        CONFIGURATIONERROR_INVALID_IMPLEMENTATION => "The selected implementation is invalid.",
CONFIGURATIONERROR_UNSUPPORTED_IMPLEMENTATION => "The selected implementation isn't supported.",
CONFIGURATIONERROR_INVALID => "Invalid configuration.",
CONFIGURATIONERROR_INVALID_LISTENER => "Invalid Listener configuration.",

      ],
  },
{
      kind: ERRORKIND_PROTOBUF,
      sym: ProtobufError,
      desc: "Errors regarding protobuf.",
      values: [
        PROTOBUFERROR_EMPTY => "The protobuf message is empty.",
PROTOBUFERROR_TOO_BIG => "The protobuf message is too large.",
PROTOBUFERROR_PARSE_FAILED => "Failed to parse the protobuf message.",
PROTOBUFERROR_NULLPTR => "A null pointer was supplied.
 This error is thrown by 'sandwich_context_new', when the given source
 buffer is a null pointer.",
PROTOBUFERROR_INVALID_ARGUMENT => "/ An invalid value was given.",

      ],
  },
{
      kind: ERRORKIND_TLS_CONFIGURATION,
      sym: TLSConfigurationError,
      desc: "Errors regarding TLS configurations.",
      values: [
        TLSCONFIGURATIONERROR_UNSUPPORTED_IMPLEMENTATION => "The selected implementation isn't supported.",
TLSCONFIGURATIONERROR_INVALID_CASE => "The configuration case (client/server) isn't valid.",
TLSCONFIGURATIONERROR_EMPTY => "The configuration is empty.",
TLSCONFIGURATIONERROR_UNSUPPORTED_PROTOCOL_VERSION => "Unsupported protocol version error.",
TLSCONFIGURATIONERROR_PRIVATE_KEY_INCONSISTENT_WITH_CERTIFICATE => "Inconsistency between a private key and the corresponding certificate.",
TLSCONFIGURATIONERROR_UNSUPPORTED_CIPHERSUITE => "Unsupported TLS ciphersuite error.",
TLSCONFIGURATIONERROR_UNSUPPORTED_CONTROL_CHARACTERS => "Control characters are not allowed.",
TLSCONFIGURATIONERROR_INVALID => "Invalid configuration.",

      ],
  },
{
      kind: ERRORKIND_CERTIFICATE,
      sym: CertificateError,
      desc: "Certificate errors.",
      values: [
        CERTIFICATEERROR_MALFORMED => "Malformed certificate.",
CERTIFICATEERROR_EXPIRED => "Expired certificate.",
CERTIFICATEERROR_NOT_FOUND => "Certificate not found.",
CERTIFICATEERROR_UNKNOWN => "Unknown error. Can wrap a SystemError.",
CERTIFICATEERROR_UNSUPPORTED => "Certificate not supported by the underlying implementation.",

      ],
  },
{
      kind: ERRORKIND_PRIVATE_KEY,
      sym: PrivateKeyError,
      desc: "Private key errors.",
      values: [
        PRIVATEKEYERROR_MALFORMED => "Malformed private key.",
PRIVATEKEYERROR_NOT_FOUND => "Private key not found.",
PRIVATEKEYERROR_UNKNOWN => "Unknown error. Can wrap a SystemError.",
PRIVATEKEYERROR_UNSUPPORTED => "Certificate not supported by the underlying implementation.",
PRIVATEKEYERROR_NOT_SERVER => "Not a server configuration.",

      ],
  },
{
      kind: ERRORKIND_ASN1,
      sym: ASN1Error,
      desc: "ASN.1 errors.",
      values: [
        ASN1ERROR_INVALID_FORMAT => "Invalid format.",
ASN1ERROR_MALFORMED => "Malformed ASN.1 document.",

      ],
  },
{
      kind: ERRORKIND_ALPN,
      sym: ALPNError,
      desc: "ALPN errors.",
      values: [
        ALPNERROR_LENGTH_ERROR => "Protocol length is longer than 255 bytes.",
ALPNERROR_INVALID_STRING => "Protocol contains '\x00' byte or invalid string.",

      ],
  },
{
      kind: ERRORKIND_DATA_SOURCE,
      sym: DataSourceError,
      desc: "DataSource errors.",
      values: [
        DATASOURCEERROR_EMPTY => "Empty data source.",
DATASOURCEERROR_INVALID_CASE => "Invalid case for data source.",
DATASOURCEERROR_NOT_FOUND => "Data not found on local filesystem.",

      ],
  },
{
      kind: ERRORKIND_KEM,
      sym: KEMError,
      desc: "KEM errors.",
      values: [
        KEMERROR_INVALID => "Invalid or unsupported KEM.",
KEMERROR_TOO_MANY => "Too many KEMs.",

      ],
  },
{
      kind: ERRORKIND_SYSTEM,
      sym: SystemError,
      desc: "System errors.",
      values: [
        SYSTEMERROR_MEMORY => "Memory error (e.g. allocation failed).",
SYSTEMERROR_INTEGER_OVERFLOW => "Integer overflow.",
SYSTEMERROR_BACKEND => "Backend error.",

      ],
  },
{
      kind: ERRORKIND_SOCKET,
      sym: SocketError,
      desc: "Socket errors.
 These errors are used in io/socket.",
      values: [
        SOCKETERROR_BAD_FD => "Bad file descriptor.",
SOCKETERROR_CREATION_FAILED => "Socket creation failed.",
SOCKETERROR_BAD_NETADDR => "Invalid network address.",
SOCKETERROR_NETADDR_UNKNOWN => "Failed to resolve network address.",
SOCKETERROR_FSTAT_FAILED => "Syscall 'fstat' failed.",
SOCKETERROR_NOT_SOCK => "File descriptor is not a socket.",
SOCKETERROR_GETSOCKNAME_FAILED => "Syscall getsockname failed.",
SOCKETERROR_SETSOCKOPT_FAILED => "Syscall setsockopt failed.",
SOCKETERROR_INVALID_AI_FAMILY => "Invalid AI family.",

      ],
  },
{
      kind: ERRORKIND_HANDSHAKE,
      sym: HandshakeError,
      desc: "",
      values: [
        HANDSHAKEERROR_INVALID_SERVER_NAME => "Invalid Server Name.",
HANDSHAKEERROR_CERTIFICATE_VERIFICATION_FAILED => "Certficate verification failed.",
HANDSHAKEERROR_CERTIFICATE_EXPIRED => "Certificate has expired.",
HANDSHAKEERROR_CERTIFICATE_REVOKED => "Certificate was revoked.",
HANDSHAKEERROR_INVALID_CERTIFICATE => "Invalid Certificate.",
HANDSHAKEERROR_CERTIFICATE_SIGNATURE_VERIFICATION_FAILED => "Signature verification error.",
HANDSHAKEERROR_DEPTH_EXCEEDED => "Certificate chain too long or pathlen exceeded.",
HANDSHAKEERROR_UNSUPPORTED_PROTOCOL => "Unsupported protocol.",
HANDSHAKEERROR_NO_SHARED_CIPHER => "No shared cipher.",
HANDSHAKEERROR_NO_SUITABLE_KEY_SHARE => "No suitable key share.",
HANDSHAKEERROR_UNKNOWN_ERROR => "Unknown handshake error.",

      ],
  },
{
      kind: ERRORKIND_TUNNEL,
      sym: TunnelError,
      desc: "Tunnel error.",
      values: [
        TUNNELERROR_INVALID => "Invalid tunnel configuration.",
TUNNELERROR_VERIFIER => "Invalid tunnel verifier.",
TUNNELERROR_UNKNOWN => "Unknown error.",

      ],
  },
);