Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers est_defs.h Source File

est_defs.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2018 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #ifndef __EST_DEFS_H__
00020 #define __EST_DEFS_H__
00021 
00022 #include <stdint.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /**
00029 * The structure describing a certificate within a certificate chain.
00030 * \param cert_length, The length of the certificate.
00031 * \param cert, A buffer containing the certificate.
00032 * \param next, A pointer to the next certificate in chain, NULL if last certificate.
00033 */
00034 struct cert_context_s {
00035     uint16_t cert_length;
00036     uint8_t *cert;
00037     struct cert_context_s *next;
00038 };
00039 
00040 /**
00041 * The structure describing a certificate chain with.
00042 * \param chain_length, The number of certificates in the certificate chain.
00043 * \param cert_data_context, A context pointer, user should ignore.
00044 * \param first_cert, A pointer to the first certificate in chain.
00045 */
00046 struct cert_chain_context_s {
00047     uint8_t chain_length;
00048     void *cert_data_context;
00049     struct cert_context_s *certs;
00050 };
00051 
00052 typedef enum {
00053     EST_ENROLLMENT_SUCCESS,
00054     EST_ENROLLMENT_FAILURE
00055 } est_enrollment_result_e;
00056 
00057 typedef enum {
00058     EST_STATUS_SUCCESS,
00059     EST_STATUS_INVALID_PARAMETERS,
00060     EST_STATUS_MEMORY_ALLOCATION_FAILURE
00061 } est_status_e;
00062 
00063 /**
00064 * \brief When the enrollment result has been handled by the callback, the free_cert_chain_context
00065 *        function must be called with the cert_chain as parameter to free the certificate chain
00066 *        buffer(s).
00067 * \param result, The result of the enrollment operation.
00068 * \param cert_chain, A pointer to cert_chain_context_s if enrollment was successful, otherwise NULL.
00069 * \param context, The user context.
00070 */
00071 typedef void(*est_enrollment_result_cb)(est_enrollment_result_e result,
00072                                         struct cert_chain_context_s *cert_chain,
00073                                         void *context);
00074 
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078 
00079 #endif // __EST_DEFS_H__