blob: 19d63ec00121e3aa74060f56a8198bdb7513f57c [file] [log] [blame]
Hanno Beckerf6bc8882019-05-02 13:05:58 +01001/**
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 Becker00d39032019-05-13 12:39:44 +010029#include "threading.h"
30
31/* Internal structure used for caching parsed data from an X.509 CRT. */
32
33struct mbedtls_x509_crt;
34struct mbedtls_pk_context;
35struct mbedtls_x509_crt_frame;
36typedef struct mbedtls_x509_crt_cache
37{
38#if defined(MBEDTLS_THREADING_C)
39 mbedtls_threading_mutex_t frame_mutex;
40 mbedtls_threading_mutex_t pk_mutex;
41#endif
42 mbedtls_x509_buf_raw pk_raw;
43 struct mbedtls_x509_crt_frame *frame;
44 struct mbedtls_pk_context *pk;
45} mbedtls_x509_crt_cache;
Hanno Beckerf6bc8882019-05-02 13:05:58 +010046
Hanno Beckera4dfc0d2019-05-13 13:45:11 +010047/* Internal X.509 CRT cache handling functions. */
48
49int mbedtls_x509_crt_flush_cache_frame( struct mbedtls_x509_crt const *crt );
50int mbedtls_x509_crt_flush_cache_pk( struct mbedtls_x509_crt const *crt );
51
52int mbedtls_x509_crt_cache_provide_frame( struct mbedtls_x509_crt const *crt );
53int mbedtls_x509_crt_cache_provide_pk( struct mbedtls_x509_crt const *crt );
54
55/* Uncategorized internal X.509 functions */
56
Hanno Beckerf6bc8882019-05-02 13:05:58 +010057int mbedtls_x509_get_name( unsigned char *p, size_t len,
58 mbedtls_x509_name *cur );
59int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end,
60 mbedtls_x509_buf *alg );
61int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end,
62 mbedtls_x509_buf *alg, mbedtls_x509_buf *params );
63#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
64int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params,
65 mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md,
66 int *salt_len );
67#endif
68int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig );
69int mbedtls_x509_get_sig_alg_raw( unsigned char **p, unsigned char const *end,
70 mbedtls_md_type_t *md_alg,
71 mbedtls_pk_type_t *pk_alg,
72 void **sig_opts );
73int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
74 mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
75 void **sig_opts );
76int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end,
77 mbedtls_x509_time *t );
78int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end,
79 mbedtls_x509_buf *serial );
80int mbedtls_x509_name_cmp_raw( mbedtls_x509_buf_raw const *a,
81 mbedtls_x509_buf_raw const *b,
82 int (*check)( void *ctx,
83 mbedtls_x509_buf *oid,
84 mbedtls_x509_buf *val,
85 int next_merged ),
86 void *check_ctx );
87int mbedtls_x509_memcasecmp( const void *s1, const void *s2,
88 size_t len1, size_t lend2 );
89int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end,
90 mbedtls_x509_buf *ext, int tag );
91
92#if !defined(MBEDTLS_X509_REMOVE_INFO)
93int mbedtls_x509_sig_alg_gets( char *buf, size_t size,
94 mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg,
95 const void *sig_opts );
96#endif
97int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name );
98int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name );
99int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len,
100 int critical, const unsigned char *val,
101 size_t val_len );
102int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start,
103 mbedtls_asn1_named_data *first );
104int mbedtls_x509_write_names( unsigned char **p, unsigned char *start,
105 mbedtls_asn1_named_data *first );
106int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start,
107 const char *oid, size_t oid_len,
108 unsigned char *sig, size_t size );
109
110#endif /* MBEDTLS_X509_INTERNAL_H */