errors.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*############################################################################
  2. # Copyright 2016 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. } EpidStatus;
  59. /// Returns string representation of error code.
  60. /*!
  61. \param e
  62. The status value.
  63. \returns The string describing the status.
  64. */
  65. char const* EpidStatusToString(EpidStatus e);
  66. /*! @} */
  67. #endif // EPID_COMMON_ERRORS_H_