Line | Count | Source (jump to first uncovered line) |
1 | | /* $OpenBSD: ssherr.c,v 1.10 2020/01/25 23:13:09 djm Exp $ */ |
2 | | /* |
3 | | * Copyright (c) 2011 Damien Miller |
4 | | * |
5 | | * Permission to use, copy, modify, and 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 | | #include <errno.h> |
19 | | #include <string.h> |
20 | | #include "ssherr.h" |
21 | | |
22 | | const char * |
23 | | ssh_err(int n) |
24 | 0 | { |
25 | 0 | switch (n) { |
26 | 0 | case SSH_ERR_SUCCESS: |
27 | 0 | return "success"; |
28 | 0 | case SSH_ERR_INTERNAL_ERROR: |
29 | 0 | return "unexpected internal error"; |
30 | 0 | case SSH_ERR_ALLOC_FAIL: |
31 | 0 | return "memory allocation failed"; |
32 | 0 | case SSH_ERR_MESSAGE_INCOMPLETE: |
33 | 0 | return "incomplete message"; |
34 | 0 | case SSH_ERR_INVALID_FORMAT: |
35 | 0 | return "invalid format"; |
36 | 0 | case SSH_ERR_BIGNUM_IS_NEGATIVE: |
37 | 0 | return "bignum is negative"; |
38 | 0 | case SSH_ERR_STRING_TOO_LARGE: |
39 | 0 | return "string is too large"; |
40 | 0 | case SSH_ERR_BIGNUM_TOO_LARGE: |
41 | 0 | return "bignum is too large"; |
42 | 0 | case SSH_ERR_ECPOINT_TOO_LARGE: |
43 | 0 | return "elliptic curve point is too large"; |
44 | 0 | case SSH_ERR_NO_BUFFER_SPACE: |
45 | 0 | return "insufficient buffer space"; |
46 | 0 | case SSH_ERR_INVALID_ARGUMENT: |
47 | 0 | return "invalid argument"; |
48 | 0 | case SSH_ERR_KEY_BITS_MISMATCH: |
49 | 0 | return "key bits do not match"; |
50 | 0 | case SSH_ERR_EC_CURVE_INVALID: |
51 | 0 | return "invalid elliptic curve"; |
52 | 0 | case SSH_ERR_KEY_TYPE_MISMATCH: |
53 | 0 | return "key type does not match"; |
54 | 0 | case SSH_ERR_KEY_TYPE_UNKNOWN: |
55 | 0 | return "unknown or unsupported key type"; |
56 | 0 | case SSH_ERR_EC_CURVE_MISMATCH: |
57 | 0 | return "elliptic curve does not match"; |
58 | 0 | case SSH_ERR_EXPECTED_CERT: |
59 | 0 | return "plain key provided where certificate required"; |
60 | 0 | case SSH_ERR_KEY_LACKS_CERTBLOB: |
61 | 0 | return "key lacks certificate data"; |
62 | 0 | case SSH_ERR_KEY_CERT_UNKNOWN_TYPE: |
63 | 0 | return "unknown/unsupported certificate type"; |
64 | 0 | case SSH_ERR_KEY_CERT_INVALID_SIGN_KEY: |
65 | 0 | return "invalid certificate signing key"; |
66 | 0 | case SSH_ERR_KEY_INVALID_EC_VALUE: |
67 | 0 | return "invalid elliptic curve value"; |
68 | 0 | case SSH_ERR_SIGNATURE_INVALID: |
69 | 0 | return "incorrect signature"; |
70 | 0 | case SSH_ERR_LIBCRYPTO_ERROR: |
71 | 0 | return "error in libcrypto"; /* XXX fetch and return */ |
72 | 0 | case SSH_ERR_UNEXPECTED_TRAILING_DATA: |
73 | 0 | return "unexpected bytes remain after decoding"; |
74 | 0 | case SSH_ERR_SYSTEM_ERROR: |
75 | 0 | return strerror(errno); |
76 | 0 | case SSH_ERR_KEY_CERT_INVALID: |
77 | 0 | return "invalid certificate"; |
78 | 0 | case SSH_ERR_AGENT_COMMUNICATION: |
79 | 0 | return "communication with agent failed"; |
80 | 0 | case SSH_ERR_AGENT_FAILURE: |
81 | 0 | return "agent refused operation"; |
82 | 0 | case SSH_ERR_DH_GEX_OUT_OF_RANGE: |
83 | 0 | return "DH GEX group out of range"; |
84 | 0 | case SSH_ERR_DISCONNECTED: |
85 | 0 | return "disconnected"; |
86 | 0 | case SSH_ERR_MAC_INVALID: |
87 | 0 | return "message authentication code incorrect"; |
88 | 0 | case SSH_ERR_NO_CIPHER_ALG_MATCH: |
89 | 0 | return "no matching cipher found"; |
90 | 0 | case SSH_ERR_NO_MAC_ALG_MATCH: |
91 | 0 | return "no matching MAC found"; |
92 | 0 | case SSH_ERR_NO_COMPRESS_ALG_MATCH: |
93 | 0 | return "no matching compression method found"; |
94 | 0 | case SSH_ERR_NO_KEX_ALG_MATCH: |
95 | 0 | return "no matching key exchange method found"; |
96 | 0 | case SSH_ERR_NO_HOSTKEY_ALG_MATCH: |
97 | 0 | return "no matching host key type found"; |
98 | 0 | case SSH_ERR_PROTOCOL_MISMATCH: |
99 | 0 | return "protocol version mismatch"; |
100 | 0 | case SSH_ERR_NO_PROTOCOL_VERSION: |
101 | 0 | return "could not read protocol version"; |
102 | 0 | case SSH_ERR_NO_HOSTKEY_LOADED: |
103 | 0 | return "could not load host key"; |
104 | 0 | case SSH_ERR_NEED_REKEY: |
105 | 0 | return "rekeying not supported by peer"; |
106 | 0 | case SSH_ERR_PASSPHRASE_TOO_SHORT: |
107 | 0 | return "passphrase is too short (minimum five characters)"; |
108 | 0 | case SSH_ERR_FILE_CHANGED: |
109 | 0 | return "file changed while reading"; |
110 | 0 | case SSH_ERR_KEY_UNKNOWN_CIPHER: |
111 | 0 | return "key encrypted using unsupported cipher"; |
112 | 0 | case SSH_ERR_KEY_WRONG_PASSPHRASE: |
113 | 0 | return "incorrect passphrase supplied to decrypt private key"; |
114 | 0 | case SSH_ERR_KEY_BAD_PERMISSIONS: |
115 | 0 | return "bad permissions"; |
116 | 0 | case SSH_ERR_KEY_CERT_MISMATCH: |
117 | 0 | return "certificate does not match key"; |
118 | 0 | case SSH_ERR_KEY_NOT_FOUND: |
119 | 0 | return "key not found"; |
120 | 0 | case SSH_ERR_AGENT_NOT_PRESENT: |
121 | 0 | return "agent not present"; |
122 | 0 | case SSH_ERR_AGENT_NO_IDENTITIES: |
123 | 0 | return "agent contains no identities"; |
124 | 0 | case SSH_ERR_BUFFER_READ_ONLY: |
125 | 0 | return "internal error: buffer is read-only"; |
126 | 0 | case SSH_ERR_KRL_BAD_MAGIC: |
127 | 0 | return "KRL file has invalid magic number"; |
128 | 0 | case SSH_ERR_KEY_REVOKED: |
129 | 0 | return "Key is revoked"; |
130 | 0 | case SSH_ERR_CONN_CLOSED: |
131 | 0 | return "Connection closed"; |
132 | 0 | case SSH_ERR_CONN_TIMEOUT: |
133 | 0 | return "Connection timed out"; |
134 | 0 | case SSH_ERR_CONN_CORRUPT: |
135 | 0 | return "Connection corrupted"; |
136 | 0 | case SSH_ERR_PROTOCOL_ERROR: |
137 | 0 | return "Protocol error"; |
138 | 0 | case SSH_ERR_KEY_LENGTH: |
139 | 0 | return "Invalid key length"; |
140 | 0 | case SSH_ERR_NUMBER_TOO_LARGE: |
141 | 0 | return "number is too large"; |
142 | 0 | case SSH_ERR_SIGN_ALG_UNSUPPORTED: |
143 | 0 | return "signature algorithm not supported"; |
144 | 0 | case SSH_ERR_FEATURE_UNSUPPORTED: |
145 | 0 | return "requested feature not supported"; |
146 | 0 | case SSH_ERR_DEVICE_NOT_FOUND: |
147 | 0 | return "device not found"; |
148 | 0 | default: |
149 | 0 | return "unknown error"; |
150 | 0 | } |
151 | 0 | } |