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