| 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 | #include "olm/olm_export.h" |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | enum OlmErrorCode { |
| 25 | OLM_SUCCESS = 0, /*!< There wasn't an error */ |
| 26 | OLM_NOT_ENOUGH_RANDOM = 1, /*!< Not enough entropy was supplied */ |
| 27 | OLM_OUTPUT_BUFFER_TOO_SMALL = 2, /*!< Supplied output buffer is too small */ |
| 28 | OLM_BAD_MESSAGE_VERSION = 3, /*!< The message version is unsupported */ |
| 29 | OLM_BAD_MESSAGE_FORMAT = 4, /*!< The message couldn't be decoded */ |
| 30 | OLM_BAD_MESSAGE_MAC = 5, /*!< The message couldn't be decrypted */ |
| 31 | OLM_BAD_MESSAGE_KEY_ID = 6, /*!< The message references an unknown key id */ |
| 32 | OLM_INVALID_BASE64 = 7, /*!< The input base64 was invalid */ |
| 33 | OLM_BAD_ACCOUNT_KEY = 8, /*!< The supplied account key is invalid */ |
| 34 | OLM_UNKNOWN_PICKLE_VERSION = 9, /*!< The pickled object is too new */ |
| 35 | OLM_CORRUPTED_PICKLE = 10, /*!< The pickled object couldn't be decoded */ |
| 36 | |
| 37 | OLM_BAD_SESSION_KEY = 11, /*!< Attempt to initialise an inbound group |
| 38 | session from an invalid session key */ |
| 39 | OLM_UNKNOWN_MESSAGE_INDEX = 12, /*!< Attempt to decode a message whose |
| 40 | * index is earlier than our earliest |
| 41 | * known session key. |
| 42 | */ |
| 43 | |
| 44 | /** |
| 45 | * Attempt to unpickle an account which uses pickle version 1 (which did |
| 46 | * not save enough space for the Ed25519 key; the key should be considered |
| 47 | * compromised. We don't let the user reload the account. |
| 48 | */ |
| 49 | OLM_BAD_LEGACY_ACCOUNT_PICKLE = 13, |
| 50 | |
| 51 | /** |
| 52 | * Received message had a bad signature |
| 53 | */ |
| 54 | OLM_BAD_SIGNATURE = 14, |
| 55 | |
| 56 | OLM_INPUT_BUFFER_TOO_SMALL = 15, |
| 57 | |
| 58 | /** |
| 59 | * SAS doesn't have their key set. |
| 60 | */ |
| 61 | OLM_SAS_THEIR_KEY_NOT_SET = 16, |
| 62 | |
| 63 | /** |
| 64 | * The pickled object was successfully decoded, but the unpickling still failed |
| 65 | * because it had some extraneous junk data at the end. |
| 66 | */ |
| 67 | = 17, |
| 68 | |
| 69 | /* remember to update the list of string constants in error.c when updating |
| 70 | * this list. */ |
| 71 | }; |
| 72 | |
| 73 | /** get a string representation of the given error code. */ |
| 74 | OLM_EXPORT const char * _olm_error_to_string(enum OlmErrorCode error); |
| 75 | |
| 76 | #ifdef __cplusplus |
| 77 | } // extern "C" |
| 78 | #endif |
| 79 | |
| 80 | #endif /* OLM_ERROR_H_ */ |
| 81 | |