blob: 9360471b962a2a72730ebb38fc2db8a5d2c42fdd [file] [log] [blame]
Valerio Setti25b282e2024-01-17 10:55:32 +01001/**
2 * \file x509.h
3 *
4 * \brief Internal part of the public "x509.h".
5 */
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 */
10#ifndef MBEDTLS_X509_INTERNAL_H
11#define MBEDTLS_X509_INTERNAL_H
Harry Ramsey0f6bc412024-10-04 10:36:54 +010012
13#include "common.h"
Ronald Cron51f228c2024-11-06 14:32:52 +010014#include "mbedtls/build_info.h"
Valerio Setti25b282e2024-01-17 10:55:32 +010015#include "mbedtls/private_access.h"
16
Valerio Setti25b282e2024-01-17 10:55:32 +010017#include "mbedtls/x509.h"
18#include "mbedtls/asn1.h"
Valerio Setti639d5672024-01-17 11:04:56 +010019#include "pk_internal.h"
Valerio Setti25b282e2024-01-17 10:55:32 +010020
21#if defined(MBEDTLS_RSA_C)
22#include "mbedtls/rsa.h"
23#endif
24
Valerio Setti25b282e2024-01-17 10:55:32 +010025int mbedtls_x509_get_name(unsigned char **p, const unsigned char *end,
26 mbedtls_x509_name *cur);
27int mbedtls_x509_get_alg_null(unsigned char **p, const unsigned char *end,
28 mbedtls_x509_buf *alg);
29int mbedtls_x509_get_alg(unsigned char **p, const unsigned char *end,
30 mbedtls_x509_buf *alg, mbedtls_x509_buf *params);
31#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
32int mbedtls_x509_get_rsassa_pss_params(const mbedtls_x509_buf *params,
33 mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md,
34 int *salt_len);
35#endif
36int mbedtls_x509_get_sig(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig);
37int mbedtls_x509_get_sig_alg(const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
Valerio Setti68878cc2025-04-10 23:30:26 +020038 mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg);
Valerio Setti25b282e2024-01-17 10:55:32 +010039int mbedtls_x509_get_time(unsigned char **p, const unsigned char *end,
40 mbedtls_x509_time *t);
41int mbedtls_x509_get_serial(unsigned char **p, const unsigned char *end,
42 mbedtls_x509_buf *serial);
43int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end,
44 mbedtls_x509_buf *ext, int tag);
45#if !defined(MBEDTLS_X509_REMOVE_INFO)
46int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *sig_oid,
Valerio Settid24dfad2025-04-23 11:13:02 +020047 mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg);
Valerio Setti25b282e2024-01-17 10:55:32 +010048#endif
49int mbedtls_x509_key_size_helper(char *buf, size_t buf_size, const char *name);
50int mbedtls_x509_set_extension(mbedtls_asn1_named_data **head, const char *oid, size_t oid_len,
51 int critical, const unsigned char *val,
52 size_t val_len);
53int mbedtls_x509_write_extensions(unsigned char **p, unsigned char *start,
54 mbedtls_asn1_named_data *first);
55int mbedtls_x509_write_names(unsigned char **p, unsigned char *start,
56 mbedtls_asn1_named_data *first);
57int mbedtls_x509_write_sig(unsigned char **p, unsigned char *start,
58 const char *oid, size_t oid_len,
59 unsigned char *sig, size_t size,
60 mbedtls_pk_type_t pk_alg);
61int mbedtls_x509_get_ns_cert_type(unsigned char **p,
62 const unsigned char *end,
63 unsigned char *ns_cert_type);
64int mbedtls_x509_get_key_usage(unsigned char **p,
65 const unsigned char *end,
66 unsigned int *key_usage);
67int mbedtls_x509_get_subject_alt_name(unsigned char **p,
68 const unsigned char *end,
69 mbedtls_x509_sequence *subject_alt_name);
70int mbedtls_x509_get_subject_alt_name_ext(unsigned char **p,
71 const unsigned char *end,
72 mbedtls_x509_sequence *subject_alt_name);
73int mbedtls_x509_info_subject_alt_name(char **buf, size_t *size,
74 const mbedtls_x509_sequence
75 *subject_alt_name,
76 const char *prefix);
77int mbedtls_x509_info_cert_type(char **buf, size_t *size,
78 unsigned char ns_cert_type);
79int mbedtls_x509_info_key_usage(char **buf, size_t *size,
80 unsigned int key_usage);
81
82int mbedtls_x509_write_set_san_common(mbedtls_asn1_named_data **extensions,
83 const mbedtls_x509_san_list *san_list);
84
85#endif /* MBEDTLS_X509_INTERNAL_H */