errors.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*############################################################################
  2. # Copyright 2016-2017 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. #ifndef EPID_COMMON_ERRORS_H_
  17. #define EPID_COMMON_ERRORS_H_
  18. /*!
  19. * \file
  20. * \brief Error reporting.
  21. */
  22. /// Error reporting interface.
  23. /*!
  24. \defgroup ErrorCodes errors
  25. This module defines the return status type. It also provides tools for
  26. interactions with status values, such as converting them to a string.
  27. \ingroup EpidCommon
  28. @{
  29. */
  30. /// Return status for SDK functions.
  31. /*!
  32. Convention for status values is as follows:
  33. - Zero indicates "success"
  34. - Any positive number indicates "success with status"
  35. - Any negative number indicates "failure"
  36. */
  37. typedef enum {
  38. kEpidNoErr = 0, //!< no error
  39. kEpidSigValid = 0, //!< Signature is valid
  40. kEpidSigInvalid = 1, //!< Signature is invalid
  41. kEpidSigRevokedInGroupRl = 2, //!< Signature revoked in GroupRl
  42. kEpidSigRevokedInPrivRl = 3, //!< Signature revoked in PrivRl
  43. kEpidSigRevokedInSigRl = 4, //!< Signature revoked in SigRl
  44. kEpidSigRevokedInVerifierRl = 5, //!< Signature revoked in VerifierRl
  45. kEpidErr = -999, //!< unspecified error
  46. kEpidNotImpl, //!< not implemented error
  47. kEpidBadArgErr, //!< incorrect arg to function
  48. kEpidNoMemErr, //!< not enough memory for the operation
  49. kEpidMemAllocErr, //!< insufficient memory allocated for operation
  50. kEpidMathErr, //!< internal math error
  51. kEpidDivByZeroErr, //!< an attempt to divide by zero
  52. kEpidUnderflowErr, //!< a value became less than minimum supported level
  53. kEpidHashAlgorithmNotSupported, //!< unsupported hash algorithm type
  54. kEpidRandMaxIterErr, //!< reached max iteration for random number generation
  55. kEpidDuplicateErr, //!< argument would add duplicate entry
  56. kEpidInconsistentBasenameSetErr, //!< set basename conflicts with arguments
  57. kEpidMathQuadraticNonResidueError, //!< quadratic Non-Residue Error
  58. kEpidOutOfSequenceError, //!< operation was performed out of sequence
  59. } EpidStatus;
  60. /// Returns string representation of error code.
  61. /*!
  62. \param e
  63. The status value.
  64. \returns The string describing the status.
  65. */
  66. char const* EpidStatusToString(EpidStatus e);
  67. /*! @} */
  68. #endif // EPID_COMMON_ERRORS_H_