| 1 |
nmaya |
9210 |
/* Imported via OpenSSH-8.5p1, TeraTerm Project */ |
| 2 |
|
|
|
| 3 |
|
|
/* $OpenBSD: ssherr.c,v 1.10 2020/01/25 23:13:09 djm Exp $ */ |
| 4 |
|
|
/* |
| 5 |
|
|
* Copyright (c) 2011 Damien Miller |
| 6 |
|
|
* |
| 7 |
|
|
* Permission to use, copy, modify, and distribute this software for any |
| 8 |
|
|
* purpose with or without fee is hereby granted, provided that the above |
| 9 |
|
|
* copyright notice and this permission notice appear in all copies. |
| 10 |
|
|
* |
| 11 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 12 |
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 13 |
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 14 |
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 15 |
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 16 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 17 |
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 18 |
|
|
*/ |
| 19 |
|
|
|
| 20 |
|
|
#include <errno.h> |
| 21 |
|
|
#include <string.h> |
| 22 |
|
|
#include "ssherr.h" |
| 23 |
|
|
|
| 24 |
|
|
const char * |
| 25 |
|
|
ssh_err(int n) |
| 26 |
|
|
{ |
| 27 |
|
|
switch (n) { |
| 28 |
|
|
case SSH_ERR_SUCCESS: |
| 29 |
|
|
return "success"; |
| 30 |
|
|
case SSH_ERR_INTERNAL_ERROR: |
| 31 |
|
|
return "unexpected internal error"; |
| 32 |
|
|
case SSH_ERR_ALLOC_FAIL: |
| 33 |
|
|
return "memory allocation failed"; |
| 34 |
|
|
case SSH_ERR_MESSAGE_INCOMPLETE: |
| 35 |
|
|
return "incomplete message"; |
| 36 |
|
|
case SSH_ERR_INVALID_FORMAT: |
| 37 |
|
|
return "invalid format"; |
| 38 |
|
|
case SSH_ERR_BIGNUM_IS_NEGATIVE: |
| 39 |
|
|
return "bignum is negative"; |
| 40 |
|
|
case SSH_ERR_STRING_TOO_LARGE: |
| 41 |
|
|
return "string is too large"; |
| 42 |
|
|
case SSH_ERR_BIGNUM_TOO_LARGE: |
| 43 |
|
|
return "bignum is too large"; |
| 44 |
|
|
case SSH_ERR_ECPOINT_TOO_LARGE: |
| 45 |
|
|
return "elliptic curve point is too large"; |
| 46 |
|
|
case SSH_ERR_NO_BUFFER_SPACE: |
| 47 |
|
|
return "insufficient buffer space"; |
| 48 |
|
|
case SSH_ERR_INVALID_ARGUMENT: |
| 49 |
|
|
return "invalid argument"; |
| 50 |
|
|
case SSH_ERR_KEY_BITS_MISMATCH: |
| 51 |
|
|
return "key bits do not match"; |
| 52 |
|
|
case SSH_ERR_EC_CURVE_INVALID: |
| 53 |
|
|
return "invalid elliptic curve"; |
| 54 |
|
|
case SSH_ERR_KEY_TYPE_MISMATCH: |
| 55 |
|
|
return "key type does not match"; |
| 56 |
|
|
case SSH_ERR_KEY_TYPE_UNKNOWN: |
| 57 |
|
|
return "unknown or unsupported key type"; |
| 58 |
|
|
case SSH_ERR_EC_CURVE_MISMATCH: |
| 59 |
|
|
return "elliptic curve does not match"; |
| 60 |
|
|
case SSH_ERR_EXPECTED_CERT: |
| 61 |
|
|
return "plain key provided where certificate required"; |
| 62 |
|
|
case SSH_ERR_KEY_LACKS_CERTBLOB: |
| 63 |
|
|
return "key lacks certificate data"; |
| 64 |
|
|
case SSH_ERR_KEY_CERT_UNKNOWN_TYPE: |
| 65 |
|
|
return "unknown/unsupported certificate type"; |
| 66 |
|
|
case SSH_ERR_KEY_CERT_INVALID_SIGN_KEY: |
| 67 |
|
|
return "invalid certificate signing key"; |
| 68 |
|
|
case SSH_ERR_KEY_INVALID_EC_VALUE: |
| 69 |
|
|
return "invalid elliptic curve value"; |
| 70 |
|
|
case SSH_ERR_SIGNATURE_INVALID: |
| 71 |
|
|
return "incorrect signature"; |
| 72 |
|
|
case SSH_ERR_LIBCRYPTO_ERROR: |
| 73 |
|
|
return "error in libcrypto"; /* XXX fetch and return */ |
| 74 |
|
|
case SSH_ERR_UNEXPECTED_TRAILING_DATA: |
| 75 |
|
|
return "unexpected bytes remain after decoding"; |
| 76 |
|
|
case SSH_ERR_SYSTEM_ERROR: |
| 77 |
|
|
return strerror(errno); |
| 78 |
|
|
case SSH_ERR_KEY_CERT_INVALID: |
| 79 |
|
|
return "invalid certificate"; |
| 80 |
|
|
case SSH_ERR_AGENT_COMMUNICATION: |
| 81 |
|
|
return "communication with agent failed"; |
| 82 |
|
|
case SSH_ERR_AGENT_FAILURE: |
| 83 |
|
|
return "agent refused operation"; |
| 84 |
|
|
case SSH_ERR_DH_GEX_OUT_OF_RANGE: |
| 85 |
|
|
return "DH GEX group out of range"; |
| 86 |
|
|
case SSH_ERR_DISCONNECTED: |
| 87 |
|
|
return "disconnected"; |
| 88 |
|
|
case SSH_ERR_MAC_INVALID: |
| 89 |
|
|
return "message authentication code incorrect"; |
| 90 |
|
|
case SSH_ERR_NO_CIPHER_ALG_MATCH: |
| 91 |
|
|
return "no matching cipher found"; |
| 92 |
|
|
case SSH_ERR_NO_MAC_ALG_MATCH: |
| 93 |
|
|
return "no matching MAC found"; |
| 94 |
|
|
case SSH_ERR_NO_COMPRESS_ALG_MATCH: |
| 95 |
|
|
return "no matching compression method found"; |
| 96 |
|
|
case SSH_ERR_NO_KEX_ALG_MATCH: |
| 97 |
|
|
return "no matching key exchange method found"; |
| 98 |
|
|
case SSH_ERR_NO_HOSTKEY_ALG_MATCH: |
| 99 |
|
|
return "no matching host key type found"; |
| 100 |
|
|
case SSH_ERR_PROTOCOL_MISMATCH: |
| 101 |
|
|
return "protocol version mismatch"; |
| 102 |
|
|
case SSH_ERR_NO_PROTOCOL_VERSION: |
| 103 |
|
|
return "could not read protocol version"; |
| 104 |
|
|
case SSH_ERR_NO_HOSTKEY_LOADED: |
| 105 |
|
|
return "could not load host key"; |
| 106 |
|
|
case SSH_ERR_NEED_REKEY: |
| 107 |
|
|
return "rekeying not supported by peer"; |
| 108 |
|
|
case SSH_ERR_PASSPHRASE_TOO_SHORT: |
| 109 |
|
|
return "passphrase is too short (minimum five characters)"; |
| 110 |
|
|
case SSH_ERR_FILE_CHANGED: |
| 111 |
|
|
return "file changed while reading"; |
| 112 |
|
|
case SSH_ERR_KEY_UNKNOWN_CIPHER: |
| 113 |
|
|
return "key encrypted using unsupported cipher"; |
| 114 |
|
|
case SSH_ERR_KEY_WRONG_PASSPHRASE: |
| 115 |
|
|
return "incorrect passphrase supplied to decrypt private key"; |
| 116 |
|
|
case SSH_ERR_KEY_BAD_PERMISSIONS: |
| 117 |
|
|
return "bad permissions"; |
| 118 |
|
|
case SSH_ERR_KEY_CERT_MISMATCH: |
| 119 |
|
|
return "certificate does not match key"; |
| 120 |
|
|
case SSH_ERR_KEY_NOT_FOUND: |
| 121 |
|
|
return "key not found"; |
| 122 |
|
|
case SSH_ERR_AGENT_NOT_PRESENT: |
| 123 |
|
|
return "agent not present"; |
| 124 |
|
|
case SSH_ERR_AGENT_NO_IDENTITIES: |
| 125 |
|
|
return "agent contains no identities"; |
| 126 |
|
|
case SSH_ERR_BUFFER_READ_ONLY: |
| 127 |
|
|
return "internal error: buffer is read-only"; |
| 128 |
|
|
case SSH_ERR_KRL_BAD_MAGIC: |
| 129 |
|
|
return "KRL file has invalid magic number"; |
| 130 |
|
|
case SSH_ERR_KEY_REVOKED: |
| 131 |
|
|
return "Key is revoked"; |
| 132 |
|
|
case SSH_ERR_CONN_CLOSED: |
| 133 |
|
|
return "Connection closed"; |
| 134 |
|
|
case SSH_ERR_CONN_TIMEOUT: |
| 135 |
|
|
return "Connection timed out"; |
| 136 |
|
|
case SSH_ERR_CONN_CORRUPT: |
| 137 |
|
|
return "Connection corrupted"; |
| 138 |
|
|
case SSH_ERR_PROTOCOL_ERROR: |
| 139 |
|
|
return "Protocol error"; |
| 140 |
|
|
case SSH_ERR_KEY_LENGTH: |
| 141 |
|
|
return "Invalid key length"; |
| 142 |
|
|
case SSH_ERR_NUMBER_TOO_LARGE: |
| 143 |
|
|
return "number is too large"; |
| 144 |
|
|
case SSH_ERR_SIGN_ALG_UNSUPPORTED: |
| 145 |
|
|
return "signature algorithm not supported"; |
| 146 |
|
|
case SSH_ERR_FEATURE_UNSUPPORTED: |
| 147 |
|
|
return "requested feature not supported"; |
| 148 |
|
|
case SSH_ERR_DEVICE_NOT_FOUND: |
| 149 |
|
|
return "device not found"; |
| 150 |
|
|
default: |
| 151 |
|
|
return "unknown error"; |
| 152 |
|
|
} |
| 153 |
|
|
} |