| Hanno Becker | f6bc888 | 2019-05-02 13:05:58 +0100 | [diff] [blame] | 1 | /** | 
|  | 2 | * \file x509_internal.h | 
|  | 3 | * | 
|  | 4 | * \brief Internal X.509 functions | 
|  | 5 | */ | 
|  | 6 | /* | 
|  | 7 | *  Copyright (C) 2006-2019, ARM Limited, All Rights Reserved | 
|  | 8 | *  SPDX-License-Identifier: Apache-2.0 | 
|  | 9 | * | 
|  | 10 | *  Licensed under the Apache License, Version 2.0 (the "License"); you may | 
|  | 11 | *  not use this file except in compliance with the License. | 
|  | 12 | *  You may obtain a copy of the License at | 
|  | 13 | * | 
|  | 14 | *  http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 15 | * | 
|  | 16 | *  Unless required by applicable law or agreed to in writing, software | 
|  | 17 | *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 18 | *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 19 | *  See the License for the specific language governing permissions and | 
|  | 20 | *  limitations under the License. | 
|  | 21 | * | 
|  | 22 | *  This file is part of Mbed TLS (https://tls.mbed.org) | 
|  | 23 | * | 
|  | 24 | */ | 
|  | 25 | #ifndef MBEDTLS_X509_INTERNAL_H | 
|  | 26 | #define MBEDTLS_X509_INTERNAL_H | 
|  | 27 |  | 
|  | 28 | #include "x509.h" | 
| Hanno Becker | 00d3903 | 2019-05-13 12:39:44 +0100 | [diff] [blame] | 29 | #include "threading.h" | 
|  | 30 |  | 
|  | 31 | /* Internal structure used for caching parsed data from an X.509 CRT. */ | 
|  | 32 |  | 
|  | 33 | struct mbedtls_x509_crt; | 
|  | 34 | struct mbedtls_pk_context; | 
|  | 35 | struct mbedtls_x509_crt_frame; | 
| Hanno Becker | 2ba9fbd | 2019-05-28 16:11:43 +0100 | [diff] [blame] | 36 | #define MBEDTLS_X509_CACHE_PK_READERS_MAX    ((uint32_t) -1) | 
|  | 37 | #define MBEDTLS_X509_CACHE_FRAME_READERS_MAX ((uint32_t) -1) | 
| Hanno Becker | 00d3903 | 2019-05-13 12:39:44 +0100 | [diff] [blame] | 38 | typedef struct mbedtls_x509_crt_cache | 
|  | 39 | { | 
| Hanno Becker | fc99a09 | 2019-06-28 14:45:26 +0100 | [diff] [blame] | 40 | #if !defined(MBEDTLS_X509_ALWAYS_FLUSH) || \ | 
|  | 41 | defined(MBEDTLS_THREADING_C) | 
| Hanno Becker | 2ba9fbd | 2019-05-28 16:11:43 +0100 | [diff] [blame] | 42 | uint32_t frame_readers; | 
|  | 43 | uint32_t pk_readers; | 
| Hanno Becker | fc99a09 | 2019-06-28 14:45:26 +0100 | [diff] [blame] | 44 | #endif /* !MBEDTLS_X509_ALWAYS_FLUSH || MBEDTLS_THREADING_C */ | 
| Hanno Becker | a4bfaa8 | 2019-06-28 10:34:23 +0100 | [diff] [blame] | 45 | #if defined(MBEDTLS_THREADING_C) | 
| Hanno Becker | 00d3903 | 2019-05-13 12:39:44 +0100 | [diff] [blame] | 46 | mbedtls_threading_mutex_t frame_mutex; | 
|  | 47 | mbedtls_threading_mutex_t pk_mutex; | 
|  | 48 | #endif | 
|  | 49 | mbedtls_x509_buf_raw pk_raw; | 
|  | 50 | struct mbedtls_x509_crt_frame *frame; | 
|  | 51 | struct mbedtls_pk_context *pk; | 
|  | 52 | } mbedtls_x509_crt_cache; | 
| Hanno Becker | f6bc888 | 2019-05-02 13:05:58 +0100 | [diff] [blame] | 53 |  | 
| Hanno Becker | a4dfc0d | 2019-05-13 13:45:11 +0100 | [diff] [blame] | 54 | /* Internal X.509 CRT cache handling functions. */ | 
|  | 55 |  | 
|  | 56 | int mbedtls_x509_crt_flush_cache_frame( struct mbedtls_x509_crt const *crt ); | 
|  | 57 | int mbedtls_x509_crt_flush_cache_pk( struct mbedtls_x509_crt const *crt ); | 
|  | 58 |  | 
|  | 59 | int mbedtls_x509_crt_cache_provide_frame( struct mbedtls_x509_crt const *crt ); | 
|  | 60 | int mbedtls_x509_crt_cache_provide_pk( struct mbedtls_x509_crt const *crt ); | 
|  | 61 |  | 
|  | 62 | /* Uncategorized internal X.509 functions */ | 
|  | 63 |  | 
| Hanno Becker | f6bc888 | 2019-05-02 13:05:58 +0100 | [diff] [blame] | 64 | int mbedtls_x509_get_name( unsigned char *p, size_t len, | 
|  | 65 | mbedtls_x509_name *cur ); | 
|  | 66 | int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end, | 
|  | 67 | mbedtls_x509_buf *alg ); | 
|  | 68 | int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end, | 
|  | 69 | mbedtls_x509_buf *alg, mbedtls_x509_buf *params ); | 
|  | 70 | #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) | 
|  | 71 | int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params, | 
|  | 72 | mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md, | 
|  | 73 | int *salt_len ); | 
|  | 74 | #endif | 
|  | 75 | int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig ); | 
|  | 76 | int mbedtls_x509_get_sig_alg_raw( unsigned char **p, unsigned char const *end, | 
|  | 77 | mbedtls_md_type_t *md_alg, | 
|  | 78 | mbedtls_pk_type_t *pk_alg, | 
|  | 79 | void **sig_opts ); | 
|  | 80 | int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, | 
|  | 81 | mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, | 
|  | 82 | void **sig_opts ); | 
|  | 83 | int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end, | 
|  | 84 | mbedtls_x509_time *t ); | 
|  | 85 | int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end, | 
|  | 86 | mbedtls_x509_buf *serial ); | 
|  | 87 | int mbedtls_x509_name_cmp_raw( mbedtls_x509_buf_raw const *a, | 
|  | 88 | mbedtls_x509_buf_raw const *b, | 
|  | 89 | int (*check)( void *ctx, | 
|  | 90 | mbedtls_x509_buf *oid, | 
|  | 91 | mbedtls_x509_buf *val, | 
|  | 92 | int next_merged ), | 
|  | 93 | void *check_ctx ); | 
|  | 94 | int mbedtls_x509_memcasecmp( const void *s1, const void *s2, | 
| Hanno Becker | 2656bfe | 2019-06-25 09:44:56 +0100 | [diff] [blame] | 95 | size_t len1, size_t len2 ); | 
| Hanno Becker | f6bc888 | 2019-05-02 13:05:58 +0100 | [diff] [blame] | 96 | int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end, | 
|  | 97 | mbedtls_x509_buf *ext, int tag ); | 
|  | 98 |  | 
|  | 99 | #if !defined(MBEDTLS_X509_REMOVE_INFO) | 
|  | 100 | int mbedtls_x509_sig_alg_gets( char *buf, size_t size, | 
|  | 101 | mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, | 
|  | 102 | const void *sig_opts ); | 
|  | 103 | #endif | 
|  | 104 | int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name ); | 
|  | 105 | int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name ); | 
|  | 106 | int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len, | 
|  | 107 | int critical, const unsigned char *val, | 
|  | 108 | size_t val_len ); | 
|  | 109 | int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start, | 
|  | 110 | mbedtls_asn1_named_data *first ); | 
|  | 111 | int mbedtls_x509_write_names( unsigned char **p, unsigned char *start, | 
|  | 112 | mbedtls_asn1_named_data *first ); | 
|  | 113 | int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start, | 
|  | 114 | const char *oid, size_t oid_len, | 
|  | 115 | unsigned char *sig, size_t size ); | 
|  | 116 |  | 
|  | 117 | #endif /* MBEDTLS_X509_INTERNAL_H */ |