ssherr.c revision 276707
1153761Swollman/* $OpenBSD: ssherr.c,v 1.1 2014/04/30 05:29:56 djm Exp $ */ 2226976Sedwin/* 3192886Sedwin * Copyright (c) 2011 Damien Miller 4192886Sedwin * 5153761Swollman * Permission to use, copy, modify, and distribute this software for any 62742Swollman * purpose with or without fee is hereby granted, provided that the above 786464Swollman * copyright notice and this permission notice appear in all copies. 82742Swollman * 92742Swollman * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 102742Swollman * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 112742Swollman * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 122742Swollman * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 132742Swollman * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1486222Swollman * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1586222Swollman * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 162742Swollman */ 1758787Sru 182742Swollman#include <errno.h> 192742Swollman#include <string.h> 202742Swollman#include "ssherr.h" 212742Swollman 222742Swollmanconst char * 232742Swollmanssh_err(int n) 2458787Sru{ 2558787Sru switch (n) { 2658787Sru case SSH_ERR_SUCCESS: 272742Swollman return "success"; 282742Swollman case SSH_ERR_INTERNAL_ERROR: 299908Swollman return "unexpected internal error"; 302742Swollman case SSH_ERR_ALLOC_FAIL: 3130711Swollman return "memory allocation failed"; 322742Swollman case SSH_ERR_MESSAGE_INCOMPLETE: 339908Swollman return "incomplete message"; 34169811Swollman case SSH_ERR_INVALID_FORMAT: 35169811Swollman return "invalid format"; 36169811Swollman case SSH_ERR_BIGNUM_IS_NEGATIVE: 37169811Swollman return "bignum is negative"; 38169811Swollman case SSH_ERR_STRING_TOO_LARGE: 39169811Swollman return "string is too large"; 40169811Swollman case SSH_ERR_BIGNUM_TOO_LARGE: 41169811Swollman return "bignum is too large"; 42169811Swollman case SSH_ERR_ECPOINT_TOO_LARGE: 43169811Swollman return "elliptic curve point is too large"; 44169811Swollman case SSH_ERR_NO_BUFFER_SPACE: 452742Swollman return "insufficient buffer space"; 4658787Sru case SSH_ERR_INVALID_ARGUMENT: 47169811Swollman return "invalid argument"; 48169811Swollman case SSH_ERR_KEY_BITS_MISMATCH: 49169811Swollman return "key bits do not match"; 50169811Swollman case SSH_ERR_EC_CURVE_INVALID: 51169811Swollman return "invalid elliptic curve"; 529908Swollman case SSH_ERR_KEY_TYPE_MISMATCH: 5320094Swollman return "key type does not match"; 54149514Swollman case SSH_ERR_KEY_TYPE_UNKNOWN: 5520094Swollman return "unknown or unsupported key type"; 5620094Swollman case SSH_ERR_EC_CURVE_MISMATCH: 5720094Swollman return "elliptic curve does not match"; 5820094Swollman case SSH_ERR_EXPECTED_CERT: 5920094Swollman return "plain key provided where certificate required"; 6020094Swollman case SSH_ERR_KEY_LACKS_CERTBLOB: 6120094Swollman return "key lacks certificate data"; 6220094Swollman case SSH_ERR_KEY_CERT_UNKNOWN_TYPE: 6320094Swollman return "unknown/unsupported certificate type"; 6420094Swollman case SSH_ERR_KEY_CERT_INVALID_SIGN_KEY: 6520094Swollman return "invalid certificate signing key"; 6658787Sru case SSH_ERR_KEY_INVALID_EC_VALUE: 6758787Sru return "invalid elliptic curve value"; 6821217Swollman case SSH_ERR_SIGNATURE_INVALID: 6921217Swollman return "incorrect signature"; 7058787Sru case SSH_ERR_LIBCRYPTO_ERROR: 7158787Sru return "error in libcrypto"; /* XXX fetch and return */ 722742Swollman case SSH_ERR_UNEXPECTED_TRAILING_DATA: 7358787Sru return "unexpected bytes remain after decoding"; 7421217Swollman case SSH_ERR_SYSTEM_ERROR: 7520094Swollman return strerror(errno); 7658787Sru case SSH_ERR_KEY_CERT_INVALID: 7758787Sru return "invalid certificate"; 7820094Swollman case SSH_ERR_AGENT_COMMUNICATION: 792742Swollman return "communication with agent failed"; 809908Swollman case SSH_ERR_AGENT_FAILURE: 812742Swollman return "agent refused operation"; 8214343Swollman case SSH_ERR_DH_GEX_OUT_OF_RANGE: 8314343Swollman return "DH GEX group out of range"; 84171948Sedwin case SSH_ERR_DISCONNECTED: 8514343Swollman return "disconnected"; 8614343Swollman case SSH_ERR_MAC_INVALID: 87218122Sedwin return "message authentication code incorrect"; 88218122Sedwin case SSH_ERR_NO_CIPHER_ALG_MATCH: 89218122Sedwin return "no matching cipher found"; 90218122Sedwin case SSH_ERR_NO_MAC_ALG_MATCH: 91218122Sedwin return "no matching MAC found"; 92149514Swollman case SSH_ERR_NO_COMPRESS_ALG_MATCH: 93218122Sedwin return "no matching compression method found"; 94171948Sedwin case SSH_ERR_NO_KEX_ALG_MATCH: 95171948Sedwin return "no matching key exchange method found"; 96171948Sedwin case SSH_ERR_NO_HOSTKEY_ALG_MATCH: 972742Swollman return "no matching host key type found"; 982742Swollman case SSH_ERR_PROTOCOL_MISMATCH: 992742Swollman return "protocol version mismatch"; 10058787Sru case SSH_ERR_NO_PROTOCOL_VERSION: 1012742Swollman return "could not read protocol version"; 1022742Swollman case SSH_ERR_NO_HOSTKEY_LOADED: 1039908Swollman return "could not load host key"; 104149514Swollman case SSH_ERR_NEED_REKEY: 105149514Swollman return "rekeying not supported by peer"; 106149514Swollman case SSH_ERR_PASSPHRASE_TOO_SHORT: 107149514Swollman return "passphrase is too short (minimum four characters)"; 108149514Swollman case SSH_ERR_FILE_CHANGED: 1092742Swollman return "file changed while reading"; 11058787Sru case SSH_ERR_KEY_UNKNOWN_CIPHER: 11158787Sru return "key encrypted using unsupported cipher"; 11214343Swollman case SSH_ERR_KEY_WRONG_PASSPHRASE: 11314343Swollman return "incorrect passphrase supplied to decrypt private key"; 11458787Sru case SSH_ERR_KEY_BAD_PERMISSIONS: 11514343Swollman return "bad permissions"; 11614343Swollman case SSH_ERR_KEY_CERT_MISMATCH: 11714343Swollman return "certificate does not match key"; 11858787Sru case SSH_ERR_KEY_NOT_FOUND: 11914343Swollman return "key not found"; 12058787Sru case SSH_ERR_AGENT_NOT_PRESENT: 12158787Sru return "agent not present"; 12258787Sru case SSH_ERR_AGENT_NO_IDENTITIES: 123149514Swollman return "agent contains no identities"; 12458787Sru case SSH_ERR_KRL_BAD_MAGIC: 12558787Sru return "KRL file has invalid magic number"; 126149514Swollman case SSH_ERR_KEY_REVOKED: 127171948Sedwin return "Key is revoked"; 128171948Sedwin default: 1292742Swollman return "unknown error"; 1302742Swollman } 13158787Sru} 13258787Sru