blob: ead68869318ccf1a4273223a3f09c6c5e2bc48c5 [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;
Hanno Becker2ba9fbd2019-05-28 16:11:43 +010036#define MBEDTLS_X509_CACHE_PK_READERS_MAX ((uint32_t) -1)
37#define MBEDTLS_X509_CACHE_FRAME_READERS_MAX ((uint32_t) -1)
Hanno Beckerf6bc8882019-05-02 13:05:58 +010038
Hanno Beckera4dfc0d2019-05-13 13:45:11 +010039/* Internal X.509 CRT cache handling functions. */
40
41int mbedtls_x509_crt_flush_cache_frame( struct mbedtls_x509_crt const *crt );
42int mbedtls_x509_crt_flush_cache_pk( struct mbedtls_x509_crt const *crt );
43
44int mbedtls_x509_crt_cache_provide_frame( struct mbedtls_x509_crt const *crt );
45int mbedtls_x509_crt_cache_provide_pk( struct mbedtls_x509_crt const *crt );
46
47/* Uncategorized internal X.509 functions */
48
Hanno Beckerf6bc8882019-05-02 13:05:58 +010049int mbedtls_x509_get_name( unsigned char *p, size_t len,
50 mbedtls_x509_name *cur );
51int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end,
52 mbedtls_x509_buf *alg );
53int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end,
54 mbedtls_x509_buf *alg, mbedtls_x509_buf *params );
55#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
56int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params,
57 mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md,
58 int *salt_len );
59#endif
60int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig );
61int mbedtls_x509_get_sig_alg_raw( unsigned char **p, unsigned char const *end,
62 mbedtls_md_type_t *md_alg,
63 mbedtls_pk_type_t *pk_alg,
64 void **sig_opts );
65int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
66 mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
67 void **sig_opts );
68int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end,
69 mbedtls_x509_time *t );
70int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end,
71 mbedtls_x509_buf *serial );
72int mbedtls_x509_name_cmp_raw( mbedtls_x509_buf_raw const *a,
73 mbedtls_x509_buf_raw const *b,
74 int (*check)( void *ctx,
75 mbedtls_x509_buf *oid,
76 mbedtls_x509_buf *val,
77 int next_merged ),
78 void *check_ctx );
79int mbedtls_x509_memcasecmp( const void *s1, const void *s2,
Hanno Becker2656bfe2019-06-25 09:44:56 +010080 size_t len1, size_t len2 );
Hanno Beckerf6bc8882019-05-02 13:05:58 +010081int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end,
82 mbedtls_x509_buf *ext, int tag );
83
84#if !defined(MBEDTLS_X509_REMOVE_INFO)
85int mbedtls_x509_sig_alg_gets( char *buf, size_t size,
86 mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg,
87 const void *sig_opts );
88#endif
89int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name );
90int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name );
91int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len,
92 int critical, const unsigned char *val,
93 size_t val_len );
94int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start,
95 mbedtls_asn1_named_data *first );
96int mbedtls_x509_write_names( unsigned char **p, unsigned char *start,
97 mbedtls_asn1_named_data *first );
98int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start,
99 const char *oid, size_t oid_len,
100 unsigned char *sig, size_t size );
101
102#endif /* MBEDTLS_X509_INTERNAL_H */