scorpiox-bot-plugin-fetch
←x509_internal.hc
101 lines · 4 KBHEADBlameDownload
1/**
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
12#include "mbedtls/private_access.h"
13
14#include "mbedtls/build_info.h"
15
16#include "mbedtls/x509.h"
17#include "mbedtls/x509_crt.h"
18#include "mbedtls/asn1.h"
19#include "pk_internal.h"
20
21#if defined(MBEDTLS_RSA_C)
22#include "mbedtls/rsa.h"
23#endif
24
25int 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,
38 mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
39 void **sig_opts);
40int mbedtls_x509_get_time(unsigned char **p, const unsigned char *end,
41 mbedtls_x509_time *t);
42int mbedtls_x509_get_serial(unsigned char **p, const unsigned char *end,
43 mbedtls_x509_buf *serial);
44int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end,
45 mbedtls_x509_buf *ext, int tag);
46#if !defined(MBEDTLS_X509_REMOVE_INFO)
47int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *sig_oid,
48 mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg,
49 const void *sig_opts);
50#endif
51int mbedtls_x509_key_size_helper(char *buf, size_t buf_size, const char *name);
52int mbedtls_x509_set_extension(mbedtls_asn1_named_data **head, const char *oid, size_t oid_len,
53 int critical, const unsigned char *val,
54 size_t val_len);
55int mbedtls_x509_write_extensions(unsigned char **p, unsigned char *start,
56 mbedtls_asn1_named_data *first);
57int mbedtls_x509_write_names(unsigned char **p, unsigned char *start,
58 mbedtls_asn1_named_data *first);
59int mbedtls_x509_write_sig(unsigned char **p, unsigned char *start,
60 const char *oid, size_t oid_len,
61 unsigned char *sig, size_t size,
62 mbedtls_pk_type_t pk_alg);
63int mbedtls_x509_get_ns_cert_type(unsigned char **p,
64 const unsigned char *end,
65 unsigned char *ns_cert_type);
66int mbedtls_x509_get_key_usage(unsigned char **p,
67 const unsigned char *end,
68 unsigned int *key_usage);
69int mbedtls_x509_get_subject_alt_name(unsigned char **p,
70 const unsigned char *end,
71 mbedtls_x509_sequence *subject_alt_name);
72int mbedtls_x509_get_subject_alt_name_ext(unsigned char **p,
73 const unsigned char *end,
74 mbedtls_x509_sequence *subject_alt_name);
75int mbedtls_x509_info_subject_alt_name(char **buf, size_t *size,
76 const mbedtls_x509_sequence
77 *subject_alt_name,
78 const char *prefix);
79int mbedtls_x509_info_cert_type(char **buf, size_t *size,
80 unsigned char ns_cert_type);
81int mbedtls_x509_info_key_usage(char **buf, size_t *size,
82 unsigned int key_usage);
83
84int mbedtls_x509_write_set_san_common(mbedtls_asn1_named_data **extensions,
85 const mbedtls_x509_san_list *san_list);
86
87/*
88 * Check md_alg against profile
89 * Return 0 if md_alg is acceptable for this profile, -1 otherwise
90 */
91int mbedtls_x509_profile_check_md_alg(const mbedtls_x509_crt_profile *profile,
92 mbedtls_md_type_t md_alg);
93
94/*
95 * Check pk_alg against profile
96 * Return 0 if pk_alg is acceptable for this profile, -1 otherwise
97 */
98int mbedtls_x509_profile_check_pk_alg(const mbedtls_x509_crt_profile *profile,
99 mbedtls_pk_type_t pk_alg);
100
101#endif /* MBEDTLS_X509_INTERNAL_H */