1 /* Copyright 2015-2016 OpenMarket Ltd
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef OLM_ERROR_H_
16 #define OLM_ERROR_H_
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 enum OlmErrorCode {
23     OLM_SUCCESS = 0, /*!< There wasn't an error */
24     OLM_NOT_ENOUGH_RANDOM = 1,  /*!< Not enough entropy was supplied */
25     OLM_OUTPUT_BUFFER_TOO_SMALL = 2, /*!< Supplied output buffer is too small */
26     OLM_BAD_MESSAGE_VERSION = 3,  /*!< The message version is unsupported */
27     OLM_BAD_MESSAGE_FORMAT = 4, /*!< The message couldn't be decoded */
28     OLM_BAD_MESSAGE_MAC = 5, /*!< The message couldn't be decrypted */
29     OLM_BAD_MESSAGE_KEY_ID = 6, /*!< The message references an unknown key id */
30     OLM_INVALID_BASE64 = 7, /*!< The input base64 was invalid */
31     OLM_BAD_ACCOUNT_KEY = 8, /*!< The supplied account key is invalid */
32     OLM_UNKNOWN_PICKLE_VERSION = 9, /*!< The pickled object is too new */
33     OLM_CORRUPTED_PICKLE = 10, /*!< The pickled object couldn't be decoded */
34 
35     OLM_BAD_SESSION_KEY = 11,  /*!< Attempt to initialise an inbound group
36                                  session from an invalid session key */
37     OLM_UNKNOWN_MESSAGE_INDEX = 12,  /*!< Attempt to decode a message whose
38                                       * index is earlier than our earliest
39                                       * known session key.
40                                       */
41 
42     /**
43      * Attempt to unpickle an account which uses pickle version 1 (which did
44      * not save enough space for the Ed25519 key; the key should be considered
45      * compromised. We don't let the user reload the account.
46      */
47     OLM_BAD_LEGACY_ACCOUNT_PICKLE = 13,
48 
49     /**
50      * Received message had a bad signature
51      */
52     OLM_BAD_SIGNATURE = 14,
53 
54     OLM_INPUT_BUFFER_TOO_SMALL = 15,
55 
56     /**
57      * SAS doesn't have their key set.
58      */
59     OLM_SAS_THEIR_KEY_NOT_SET = 16,
60 
61     /**
62      * The pickled object was successfully decoded, but the unpickling still failed
63      * because it had some extraneous junk data at the end.
64      */
65     OLM_PICKLE_EXTRA_DATA = 17,
66 
67     /* remember to update the list of string constants in error.c when updating
68      * this list. */
69 };
70 
71 /** get a string representation of the given error code. */
72 const char * _olm_error_to_string(enum OlmErrorCode error);
73 
74 #ifdef __cplusplus
75 } // extern "C"
76 #endif
77 
78 #endif /* OLM_ERROR_H_ */
79