summaryrefslogtreecommitdiff
path: root/open-vm-tools/lib/include/cryptoError.h
blob: 7744a5d13802c3ec36bdf35ceeb8bbd8e8316374 (plain)
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
/*********************************************************
 * Copyright (C) 2005 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation version 2.1 and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *********************************************************/

/*
 * cryptoError.h --
 *
 *      Error code for cryptographic infrastructure library.
 */

#ifndef VMWARE_CRYPTOERROR_H
#define VMWARE_CRYPTOERROR_H 1

#define INCLUDE_ALLOW_USERLEVEL
#include "includeCheck.h"

#include "vmware.h"

typedef int CryptoError;

/*
 * This set of errors should not be expanded beyond a maximum value of 15
 * without also updating the code for AIOMgr errors, which allots only 4 bits
 * for sub-error codes.
 *
 * Adding a lot of error codes to describe particular errors is a bad idea
 * anyhow, because it can be a security hole in itself; see, for example, the
 * SSL vulnerability described at <http://www.openssl.org/~bodo/tls-cbc.txt>.
 * It is best to distinguish only those types of errors that the caller can
 * legitimately use to figure out how to fix the problem and try again.
 */
#define CRYPTO_ERROR_SUCCESS            ((CryptoError) 0)
#define CRYPTO_ERROR_OPERATION_FAILED   ((CryptoError) 1)
#define CRYPTO_ERROR_UNKNOWN_ALGORITHM  ((CryptoError) 2)
#define CRYPTO_ERROR_BAD_BUFFER_SIZE    ((CryptoError) 3)
#define CRYPTO_ERROR_INVALID_OPERATION  ((CryptoError) 4)
#define CRYPTO_ERROR_NOMEM              ((CryptoError) 5)
#define CRYPTO_ERROR_NEED_PASSWORD      ((CryptoError) 6)
#define CRYPTO_ERROR_BAD_PASSWORD       ((CryptoError) 7)
#define CRYPTO_ERROR_IO_ERROR           ((CryptoError) 8)
#define CRYPTO_ERROR_UNKNOWN_ERROR      ((CryptoError) 9)
#define CRYPTO_ERROR_NAME_NOT_FOUND     ((CryptoError) 10)
#define CRYPTO_ERROR_NO_CRYPTO          ((CryptoError) 11)
#define CRYPTO_ERROR_LOCK_FAILURE       ((CryptoError) 12)

const char *
CryptoError_ToString(CryptoError error);

const char *
CryptoError_ToMsgString(CryptoError error);


static INLINE int
CryptoError_ToInteger(CryptoError error)
{
   return (int) error;
}

static INLINE CryptoError
CryptoError_FromInteger(int index)
{
   return (CryptoError) index;
}

static INLINE Bool
CryptoError_IsSuccess(CryptoError error)
{
   return (CRYPTO_ERROR_SUCCESS == error);
}

static INLINE Bool
CryptoError_IsFailure(CryptoError error)
{
   return (CRYPTO_ERROR_SUCCESS != error);
}

#endif /* cryptoError.h */