mbed TLS v2.16.3: x509_csr.h Source File

mbed TLS v2.16.3

x509_csr.h
Go to the documentation of this file.
1
6 /*
7 * Copyright (C) 2006-2015, 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 #ifndef MBEDTLS_X509_CSR_H
25 #define MBEDTLS_X509_CSR_H
26
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32
33 #include "x509.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
51 typedef struct mbedtls_x509_csr
52 {
53 mbedtls_x509_buf raw;
54 mbedtls_x509_buf cri;
56 int version;
58 mbedtls_x509_buf subject_raw;
59 mbedtls_x509_name subject;
61 mbedtls_pk_context pk;
63 mbedtls_x509_buf sig_oid;
64 mbedtls_x509_buf sig;
65 mbedtls_md_type_t sig_md;
66 mbedtls_pk_type_t sig_pk;
67 void *sig_opts;
68 }
69 mbedtls_x509_csr;
70
74 typedef struct mbedtls_x509write_csr
75 {
76 mbedtls_pk_context *key;
77 mbedtls_asn1_named_data *subject;
78 mbedtls_md_type_t md_alg;
79 mbedtls_asn1_named_data *extensions;
80 }
81 mbedtls_x509write_csr;
82
83 #if defined(MBEDTLS_X509_CSR_PARSE_C)
84
95 int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr,
96 const unsigned char *buf, size_t buflen );
97
110 int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen );
111
112 #if defined(MBEDTLS_FS_IO)
113
123 int mbedtls_x509_csr_parse_file( mbedtls_x509_csr *csr, const char *path );
124 #endif /* MBEDTLS_FS_IO */
125
138 int mbedtls_x509_csr_info( char *buf, size_t size, const char *prefix,
139 const mbedtls_x509_csr *csr );
140
146 void mbedtls_x509_csr_init( mbedtls_x509_csr *csr );
147
153 void mbedtls_x509_csr_free( mbedtls_x509_csr *csr );
154 #endif /* MBEDTLS_X509_CSR_PARSE_C */
155
156 /* \} name */
157 /* \} addtogroup x509_module */
158
159 #if defined(MBEDTLS_X509_CSR_WRITE_C)
160
165 void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx );
166
179 int mbedtls_x509write_csr_set_subject_name( mbedtls_x509write_csr *ctx,
180 const char *subject_name );
181
189 void mbedtls_x509write_csr_set_key( mbedtls_x509write_csr *ctx, mbedtls_pk_context *key );
190
198 void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg );
199
217 int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage );
218
228 int mbedtls_x509write_csr_set_ns_cert_type( mbedtls_x509write_csr *ctx,
229 unsigned char ns_cert_type );
230
243 int mbedtls_x509write_csr_set_extension( mbedtls_x509write_csr *ctx,
244 const char *oid, size_t oid_len,
245 const unsigned char *val, size_t val_len );
246
252 void mbedtls_x509write_csr_free( mbedtls_x509write_csr *ctx );
253
275 int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size,
276 int (*f_rng)(void *, unsigned char *, size_t),
277 void *p_rng );
278
279 #if defined(MBEDTLS_PEM_WRITE_C)
280
297 int mbedtls_x509write_csr_pem( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size,
298 int (*f_rng)(void *, unsigned char *, size_t),
299 void *p_rng );
300 #endif /* MBEDTLS_PEM_WRITE_C */
301 #endif /* MBEDTLS_X509_CSR_WRITE_C */
302
303 #ifdef __cplusplus
304 }
305 #endif
306
307 #endif /* mbedtls_x509_csr.h */
mbedtls_x509write_csr_set_md_alg
void mbedtls_x509write_csr_set_md_alg(mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg)
Set the MD algorithm to use for the signature (e.g. MBEDTLS_MD_SHA1)
mbedtls_x509write_csr_set_key_usage
int mbedtls_x509write_csr_set_key_usage(mbedtls_x509write_csr *ctx, unsigned char key_usage)
Set the Key Usage Extension flags (e.g. MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_KEY_CERT_...
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition: md.h:58
mbedtls_x509write_csr
struct mbedtls_x509write_csr mbedtls_x509write_csr
mbedtls_x509_csr::sig_oid
mbedtls_x509_buf sig_oid
Definition: x509_csr.h:63
mbedtls_x509write_csr_set_ns_cert_type
int mbedtls_x509write_csr_set_ns_cert_type(mbedtls_x509write_csr *ctx, unsigned char ns_cert_type)
Set the Netscape Cert Type flags (e.g. MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT | MBEDTLS_X509_NS_CERT_TY...
mbedtls_x509_csr_parse_der
int mbedtls_x509_csr_parse_der(mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen)
Load a Certificate Signing Request (CSR) in DER format.
mbedtls_x509_csr_free
void mbedtls_x509_csr_free(mbedtls_x509_csr *csr)
Unallocate all CSR data.
mbedtls_x509_csr
Definition: x509_csr.h:51
mbedtls_x509_csr::sig
mbedtls_x509_buf sig
Definition: x509_csr.h:64
mbedtls_asn1_named_data
Definition: asn1.h:166
mbedtls_pk_context
Public key container.
Definition: pk.h:130
mbedtls_x509write_csr::key
mbedtls_pk_context * key
Definition: x509_csr.h:76
mbedtls_x509_csr::raw
mbedtls_x509_buf raw
Definition: x509_csr.h:53
mbedtls_x509write_csr::md_alg
mbedtls_md_type_t md_alg
Definition: x509_csr.h:78
mbedtls_x509_csr_parse
int mbedtls_x509_csr_parse(mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen)
Load a Certificate Signing Request (CSR), DER or PEM format.
mbedtls_x509write_csr_set_subject_name
int mbedtls_x509write_csr_set_subject_name(mbedtls_x509write_csr *ctx, const char *subject_name)
Set the subject name for a CSR Subject names should contain a comma-separated list of OID types and v...
mbedtls_x509_csr
struct mbedtls_x509_csr mbedtls_x509_csr
mbedtls_x509_csr::subject_raw
mbedtls_x509_buf subject_raw
Definition: x509_csr.h:58
mbedtls_pk_type_t
mbedtls_pk_type_t
Public key types.
Definition: pk.h:78
mbedtls_x509_csr::version
int version
Definition: x509_csr.h:56
mbedtls_x509_csr::sig_opts
void * sig_opts
Definition: x509_csr.h:67
mbedtls_x509write_csr_set_key
void mbedtls_x509write_csr_set_key(mbedtls_x509write_csr *ctx, mbedtls_pk_context *key)
Set the key for a CSR (public key will be included, private key used to sign the CSR when writing it)
mbedtls_x509_csr::sig_md
mbedtls_md_type_t sig_md
Definition: x509_csr.h:65
mbedtls_x509_csr::cri
mbedtls_x509_buf cri
Definition: x509_csr.h:54
mbedtls_x509_csr_parse_file
int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path)
Load a Certificate Signing Request (CSR)
mbedtls_x509_csr::subject
mbedtls_x509_name subject
Definition: x509_csr.h:59
mbedtls_x509_csr::sig_pk
mbedtls_pk_type_t sig_pk
Definition: x509_csr.h:66
config.h
Configuration options (set of defines)
mbedtls_x509write_csr_set_extension
int mbedtls_x509write_csr_set_extension(mbedtls_x509write_csr *ctx, const char *oid, size_t oid_len, const unsigned char *val, size_t val_len)
Generic function to add to or replace an extension in the CSR.
mbedtls_x509write_csr::extensions
mbedtls_asn1_named_data * extensions
Definition: x509_csr.h:79
mbedtls_x509write_csr_pem
int mbedtls_x509write_csr_pem(mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Write a CSR (Certificate Signing Request) to a PEM string.
mbedtls_asn1_buf
Definition: asn1.h:134
mbedtls_x509_csr_init
void mbedtls_x509_csr_init(mbedtls_x509_csr *csr)
Initialize a CSR.
mbedtls_x509_csr_info
int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix, const mbedtls_x509_csr *csr)
Returns an informational string about the CSR.
mbedtls_x509write_csr
Definition: x509_csr.h:74
mbedtls_x509write_csr::subject
mbedtls_asn1_named_data * subject
Definition: x509_csr.h:77
mbedtls_x509write_csr_free
void mbedtls_x509write_csr_free(mbedtls_x509write_csr *ctx)
Free the contents of a CSR context.
mbedtls_x509_csr::pk
mbedtls_pk_context pk
Definition: x509_csr.h:61
mbedtls_x509write_csr_der
int mbedtls_x509write_csr_der(mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Write a CSR (Certificate Signing Request) to a DER structure Note: data is written at the end of the ...
mbedtls_x509write_csr_init
void mbedtls_x509write_csr_init(mbedtls_x509write_csr *ctx)
Initialize a CSR context.
x509.h
X.509 generic defines and structures.