leo hendrickson / Mbed OS example-Ethernet-mbed-Cloud-connect
Committer:
leothedragon
Date:
Tue May 04 08:55:12 2021 +0000
Revision:
0:8f0bb79ddd48
nmn

Who changed what in which revision?

UserRevisionLine numberNew contents of line
leothedragon 0:8f0bb79ddd48 1 // ----------------------------------------------------------------------------
leothedragon 0:8f0bb79ddd48 2 // Copyright 2018 ARM Ltd.
leothedragon 0:8f0bb79ddd48 3 //
leothedragon 0:8f0bb79ddd48 4 // Licensed under the Apache License, Version 2.0 (the "License");
leothedragon 0:8f0bb79ddd48 5 // you may not use this file except in compliance with the License.
leothedragon 0:8f0bb79ddd48 6 // You may obtain a copy of the License at
leothedragon 0:8f0bb79ddd48 7 //
leothedragon 0:8f0bb79ddd48 8 // http://www.apache.org/licenses/LICENSE-2.0
leothedragon 0:8f0bb79ddd48 9 //
leothedragon 0:8f0bb79ddd48 10 // Unless required by applicable law or agreed to in writing, software
leothedragon 0:8f0bb79ddd48 11 // distributed under the License is distributed on an "AS IS" BASIS,
leothedragon 0:8f0bb79ddd48 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
leothedragon 0:8f0bb79ddd48 13 // See the License for the specific language governing permissions and
leothedragon 0:8f0bb79ddd48 14 // limitations under the License.
leothedragon 0:8f0bb79ddd48 15 // ----------------------------------------------------------------------------
leothedragon 0:8f0bb79ddd48 16
leothedragon 0:8f0bb79ddd48 17 #ifndef __CERTIFICATE_ENROLLMENT_H__
leothedragon 0:8f0bb79ddd48 18 #define __CERTIFICATE_ENROLLMENT_H__
leothedragon 0:8f0bb79ddd48 19
leothedragon 0:8f0bb79ddd48 20 #include <stdint.h>
leothedragon 0:8f0bb79ddd48 21 #include <stddef.h>
leothedragon 0:8f0bb79ddd48 22 #include <stdlib.h>
leothedragon 0:8f0bb79ddd48 23
leothedragon 0:8f0bb79ddd48 24 #include "ce_status.h"
leothedragon 0:8f0bb79ddd48 25 #include "cs_der_keys_and_csrs.h"
leothedragon 0:8f0bb79ddd48 26
leothedragon 0:8f0bb79ddd48 27
leothedragon 0:8f0bb79ddd48 28 #ifdef __cplusplus
leothedragon 0:8f0bb79ddd48 29 extern "C" {
leothedragon 0:8f0bb79ddd48 30 #endif
leothedragon 0:8f0bb79ddd48 31
leothedragon 0:8f0bb79ddd48 32 typedef struct ce_renewal_params_ {
leothedragon 0:8f0bb79ddd48 33 struct cert_chain_context_s *cert_data;// Not owner
leothedragon 0:8f0bb79ddd48 34 cs_key_handle_t crypto_handle;//This should include pointer to private key/private and public key object optional - Not owner
leothedragon 0:8f0bb79ddd48 35 } ce_renewal_params_s;
leothedragon 0:8f0bb79ddd48 36
leothedragon 0:8f0bb79ddd48 37
leothedragon 0:8f0bb79ddd48 38 ce_status_e ce_init(void);
leothedragon 0:8f0bb79ddd48 39
leothedragon 0:8f0bb79ddd48 40
leothedragon 0:8f0bb79ddd48 41 /** Translates key-configurator-manager (KCM) statuses into certificate enrollment statuses.
leothedragon 0:8f0bb79ddd48 42 *
leothedragon 0:8f0bb79ddd48 43 * @param kcm_status[in] The KCM status to translate
leothedragon 0:8f0bb79ddd48 44 *
leothedragon 0:8f0bb79ddd48 45 * @returns
leothedragon 0:8f0bb79ddd48 46 * one of the `::ce_status_e` statuses listed in ce_status.h.
leothedragon 0:8f0bb79ddd48 47 */
leothedragon 0:8f0bb79ddd48 48 ce_status_e ce_error_handler(kcm_status_e kcm_status);
leothedragon 0:8f0bb79ddd48 49
leothedragon 0:8f0bb79ddd48 50 /** Generates key pair and a CSR from a given certificate name.
leothedragon 0:8f0bb79ddd48 51 * Calling to cs_ec_key_new(..) prior calling this function is mandatory in order to achieve the handle to the key object in store.
leothedragon 0:8f0bb79ddd48 52 * Calling to cs_ec_key_free(..) prior calling this function is mandatory in order to evacuate the handle resources.
leothedragon 0:8f0bb79ddd48 53 * Please refer cs_der_keys_and_csr.h for specific API details.
leothedragon 0:8f0bb79ddd48 54 *
leothedragon 0:8f0bb79ddd48 55 * @param certifcate_name[in] Certificate name to search in store, the certificate
leothedragon 0:8f0bb79ddd48 56 * name must be NULL terminated string
leothedragon 0:8f0bb79ddd48 57 * @param key_h[in] A handle to a key object that obtained by calling to cs_ec_key_new(..)
leothedragon 0:8f0bb79ddd48 58 * @param csr_out[out] A pointer to a newly allocated buffer that accommodate the CSR.
leothedragon 0:8f0bb79ddd48 59 * It is the user responsibility to evacuate this buffer.
leothedragon 0:8f0bb79ddd48 60 * @param csr_size_out[out] The size in bytes of the newly created CSR
leothedragon 0:8f0bb79ddd48 61 * @returns
leothedragon 0:8f0bb79ddd48 62 * CE_STATUS_SUCCESS in case of success or one of the `::ce_status_e` errors otherwise.
leothedragon 0:8f0bb79ddd48 63 */
leothedragon 0:8f0bb79ddd48 64 ce_status_e ce_generate_keys_and_create_csr_from_certificate(
leothedragon 0:8f0bb79ddd48 65 const char *certificate_name, const cs_key_handle_t key_h,
leothedragon 0:8f0bb79ddd48 66 uint8_t **csr_out, size_t *csr_size_out);
leothedragon 0:8f0bb79ddd48 67
leothedragon 0:8f0bb79ddd48 68 /*! The API updates certificate/certificate chain and correlated key/key pair.
leothedragon 0:8f0bb79ddd48 69 *
leothedragon 0:8f0bb79ddd48 70 * @param[in] item_name item name.
leothedragon 0:8f0bb79ddd48 71 * @param[in] item_name_len item name length.
leothedragon 0:8f0bb79ddd48 72 * @param[in] renewal_data pointer to renewal data structure.
leothedragon 0:8f0bb79ddd48 73 *
leothedragon 0:8f0bb79ddd48 74 * @returns
leothedragon 0:8f0bb79ddd48 75 * CE_STATUS_SUCCESS in case of success or one of the `::ce_status_e` errors otherwise.
leothedragon 0:8f0bb79ddd48 76 */
leothedragon 0:8f0bb79ddd48 77 ce_status_e ce_safe_renewal(const char *item_name, ce_renewal_params_s *renewal_data);
leothedragon 0:8f0bb79ddd48 78
leothedragon 0:8f0bb79ddd48 79 /*! The API called during kcm_init() in case of error during renewal_certificate API.
leothedragon 0:8f0bb79ddd48 80 * The functions checks status of the renewal process, restores original data and deletes redundant files.
leothedragon 0:8f0bb79ddd48 81 * The APIs checks the status based on renewal file and its data.
leothedragon 0:8f0bb79ddd48 82 * @void
leothedragon 0:8f0bb79ddd48 83 */
leothedragon 0:8f0bb79ddd48 84 void ce_check_and_restore_backup_status(void);
leothedragon 0:8f0bb79ddd48 85
leothedragon 0:8f0bb79ddd48 86 #ifdef __cplusplus
leothedragon 0:8f0bb79ddd48 87 }
leothedragon 0:8f0bb79ddd48 88 #endif
leothedragon 0:8f0bb79ddd48 89
leothedragon 0:8f0bb79ddd48 90 #endif //__CERTIFICATE_ENROLLMENT_H__