blob: 0bd9c03ebfc83275e8c6a9fa77bf5b3ac26fe324 [file] [log] [blame]
Gilles Peskinee59236f2018-01-27 23:32:46 +01001/**
2 * \file psa/crypto.h
3 * \brief Platform Security Architecture cryptography module
4 */
5
6#ifndef PSA_CRYPTO_H
7#define PSA_CRYPTO_H
8
9#include "crypto_platform.h"
10
Gilles Peskine62a7e7e2018-02-07 21:54:47 +010011#ifdef __DOXYGEN_ONLY__
12/** \defgroup platform Implementation-specific definitions
13 * @{
14 */
15
16/**@}*/
17#endif
18
Gilles Peskinee59236f2018-01-27 23:32:46 +010019#ifdef __cplusplus
20extern "C" {
21#endif
22
23/** \defgroup basic Basic definitions
24 * @{
25 */
26
27/**
28 * \brief Function return status.
29 *
30 * Zero indicates success, anything else indicates an error.
31 */
32typedef enum {
33 /** The action was completed successfully. */
34 PSA_SUCCESS = 0,
35 /** The requested operation or a parameter is not supported
36 by this implementation. */
37 PSA_ERROR_NOT_SUPPORTED,
38 /** The requested action is denied by a policy. */
39 PSA_ERROR_NOT_PERMITTED,
40 /** An output buffer is too small. */
41 PSA_ERROR_BUFFER_TOO_SMALL,
42 /** A slot is occupied, but must be empty to carry out the
43 requested action. */
44 PSA_ERROR_OCCUPIED_SLOT,
45 /** A slot is empty, but must be occupied to carry out the
46 requested action. */
47 PSA_ERROR_EMPTY_SLOT,
48 /** The requested action cannot be performed in the current state. */
49 PSA_ERROR_BAD_STATE,
50 /** The parameters passed to the function are invalid. */
51 PSA_ERROR_INVALID_ARGUMENT,
52 /** There is not enough runtime memory. */
53 PSA_ERROR_INSUFFICIENT_MEMORY,
54 /** There is not enough persistent storage. */
55 PSA_ERROR_INSUFFICIENT_STORAGE,
56 /** There was a communication failure inside the implementation. */
57 PSA_ERROR_COMMUNICATION_FAILURE,
58 /** A hardware failure was detected. */
59 PSA_ERROR_HARDWARE_FAILURE,
60 /** A tampering attempt was detected. */
61 PSA_ERROR_TAMPERING_DETECTED,
62 /** There is not enough entropy to generate random data needed
63 for the requested action. */
64 PSA_ERROR_INSUFFICIENT_ENTROPY,
65 /** The signature or MAC is incorrect. */
66 PSA_ERROR_INVALID_SIGNATURE,
67 /** An error occurred that does not correspond to any defined
68 failure cause. */
69 PSA_ERROR_UNKNOWN_ERROR,
70} psa_status_t;
71
72/**
73 * \brief Library initialization.
74 *
75 * Applications must call this function before calling any other
76 * function in this module.
77 *
78 * Applications may call this function more than once. Once a call
79 * succeeds, subsequent calls are guaranteed to succeed.
80 *
81 * \return * \c PSA_SUCCESS: success.
82 * * \c PSA_ERROR_INSUFFICIENT_MEMORY
83 * * \c PSA_ERROR_COMMUNICATION_FAILURE
84 * * \c PSA_ERROR_HARDWARE_FAILURE
85 * * \c PSA_ERROR_TAMPERING_DETECTED
86 * * \c PSA_ERROR_INSUFFICIENT_ENTROPY
87 */
88psa_status_t psa_crypto_init(void);
89
90/**@}*/
91
92#ifdef __cplusplus
93}
94#endif
95
96#include "crypto_extra.h"
97
98#endif /* PSA_CRYPTO_H */