|
| 1 | +/*--------------------------------------------------------------------------- |
| 2 | + * Copyright (c) 2016, u-blox Malmö, All Rights Reserved |
| 3 | + * SPDX-License-Identifier: LicenseRef-PBL |
| 4 | + * |
| 5 | + * This file and the related binary are licensed under the |
| 6 | + * Permissive Binary License, Version 1.0 (the "License"); |
| 7 | + * you may not use these files except in compliance with the License. |
| 8 | + * |
| 9 | + * You may obtain a copy of the License here: |
| 10 | + * LICENSE-permissive-binary-license-1.0.txt and at |
| 11 | + * https://www.mbed.com/licenses/PBL-1.0 |
| 12 | + * |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * Component : WLAN |
| 17 | + * File : cb_cert_utils.h |
| 18 | + * |
| 19 | + * Description : |
| 20 | + *-------------------------------------------------------------------------*/ |
| 21 | + |
| 22 | +/** |
| 23 | + * @file cb_cert_utils.h The main WLAN component interface. |
| 24 | + * All functions declared extern needs to be provided by another/upper layer. |
| 25 | + * @ingroup wlan |
| 26 | + */ |
| 27 | + |
| 28 | +#ifndef _CB_CERT_UTILS_H_ |
| 29 | +#define _CB_CERT_UTILS_H_ |
| 30 | + |
| 31 | +#include "cb_types.h" |
| 32 | +#include "cb_status.h" |
| 33 | + |
| 34 | +#ifdef __cplusplus |
| 35 | +extern "C" { |
| 36 | +#endif |
| 37 | + |
| 38 | + |
| 39 | +/*=========================================================================== |
| 40 | + * DEFINES |
| 41 | + *=========================================================================*/ |
| 42 | +#define cbCERT_CRT_MAX_CHAIN_LENGTH 5ul |
| 43 | + |
| 44 | +/*=========================================================================== |
| 45 | + * TYPES |
| 46 | + *=========================================================================*/ |
| 47 | + |
| 48 | +typedef struct cbCERT_Stream_s cbCERT_Stream; |
| 49 | +typedef cb_uint32 cbCERT_StreamPosition; |
| 50 | + |
| 51 | +/** |
| 52 | + * Stream vtable interface used by WLAN supplicant to access SSL certificates |
| 53 | + * for WPA Enterprise authentication. |
| 54 | + * |
| 55 | + * @ingroup wlan |
| 56 | + */ |
| 57 | +struct cbCERT_Stream_s { |
| 58 | + cb_int32(*read)(const cbCERT_Stream *stream, void *buf, cb_uint32 count); /**< Read function pointer, place count bytes in buf. */ |
| 59 | + cb_int32(*write)(const cbCERT_Stream *stream, void *buf, cb_uint32 count); /**< Read function pointer, place count bytes in buf. */ |
| 60 | + void(*rewind)(const cbCERT_Stream *stream); /**< Rewind function pointer, rewind stream internal iterator to the beginning. Mandatory for all streams. */ |
| 61 | + void(*setPosition)(const cbCERT_Stream *stream, cbCERT_StreamPosition position); /**< Set absolute position. */ |
| 62 | + cbCERT_StreamPosition(*getPosition)(const cbCERT_Stream *stream); /**< Get current position. */ |
| 63 | + cb_uint32(*getSize)(const cbCERT_Stream *stream); /**< GetSize function pointer, return total size of stream contents. */ |
| 64 | +}; |
| 65 | + |
| 66 | +/*=========================================================================== |
| 67 | + * CERT API |
| 68 | + *=========================================================================*/ |
| 69 | + |
| 70 | +cbRTSL_Status cbCERT_Util_parseDERCert(cbCERT_Stream const * const certificate, cbCERT_Stream const * const outputStream); |
| 71 | +cbRTSL_Status cbCERT_Util_parseDERKey(cbCERT_Stream const * const key, cbCERT_Stream const * const outputStream); |
| 72 | +cbRTSL_Status cbCERT_Util_parsePEMCert(cbCERT_Stream const * const certificate, cbCERT_Stream const * const outputStream); |
| 73 | +cbRTSL_Status cbCERT_Util_parsePEMKey(cbCERT_Stream const * const certificate, cb_char const * const key, cb_uint32 keyLength, cbCERT_Stream const * const outputStream); |
| 74 | + |
| 75 | +#ifdef __cplusplus |
| 76 | +} |
| 77 | +#endif |
| 78 | + |
| 79 | +#endif /* _CB_CERT_UTILS_H_ */ |
| 80 | + |
0 commit comments