Loading...
Searching...
No Matches
x509_csr.h
Go to the documentation of this file.
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef MBEDTLS_X509_CSR_H
#define MBEDTLS_X509_CSR_H
#include "mbedtls/private_access.h"
#include "mbedtls/build_info.h"
#include "mbedtls/x509.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mbedtls_x509_csr {
mbedtls_x509_buf raw;
mbedtls_x509_buf cri;
int version;
mbedtls_x509_buf subject_raw;
mbedtls_x509_name subject;
mbedtls_pk_context pk;
unsigned int key_usage;
unsigned char ns_cert_type;
mbedtls_x509_sequence subject_alt_names;
int MBEDTLS_PRIVATE(ext_types);
mbedtls_x509_buf sig_oid;
mbedtls_x509_buf MBEDTLS_PRIVATE(sig);
mbedtls_md_type_t MBEDTLS_PRIVATE(sig_md);
mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk);
void *MBEDTLS_PRIVATE(sig_opts);
}
mbedtls_x509_csr;
typedef struct mbedtls_x509write_csr {
mbedtls_pk_context *MBEDTLS_PRIVATE(key);
mbedtls_asn1_named_data *MBEDTLS_PRIVATE(subject);
mbedtls_md_type_t MBEDTLS_PRIVATE(md_alg);
mbedtls_asn1_named_data *MBEDTLS_PRIVATE(extensions);
}
mbedtls_x509write_csr;
#if defined(MBEDTLS_X509_CSR_PARSE_C)
int mbedtls_x509_csr_parse_der(mbedtls_x509_csr *csr,
const unsigned char *buf, size_t buflen);
typedef int (*mbedtls_x509_csr_ext_cb_t)(void *p_ctx,
mbedtls_x509_csr const *csr,
mbedtls_x509_buf const *oid,
int critical,
const unsigned char *p,
const unsigned char *end);
int mbedtls_x509_csr_parse_der_with_ext_cb(mbedtls_x509_csr *csr,
const unsigned char *buf, size_t buflen,
mbedtls_x509_csr_ext_cb_t cb,
void *p_ctx);
int mbedtls_x509_csr_parse(mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen);
#if defined(MBEDTLS_FS_IO)
int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path);
#endif /* MBEDTLS_FS_IO */
#if !defined(MBEDTLS_X509_REMOVE_INFO)
int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix,
const mbedtls_x509_csr *csr);
#endif /* !MBEDTLS_X509_REMOVE_INFO */
void mbedtls_x509_csr_init(mbedtls_x509_csr *csr);
void mbedtls_x509_csr_free(mbedtls_x509_csr *csr);
#endif /* MBEDTLS_X509_CSR_PARSE_C */
#if defined(MBEDTLS_X509_CSR_WRITE_C)
void mbedtls_x509write_csr_init(mbedtls_x509write_csr *ctx);
int mbedtls_x509write_csr_set_subject_name(mbedtls_x509write_csr *ctx,
const char *subject_name);
void mbedtls_x509write_csr_set_key(mbedtls_x509write_csr *ctx, mbedtls_pk_context *key);
void mbedtls_x509write_csr_set_md_alg(mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg);
int mbedtls_x509write_csr_set_key_usage(mbedtls_x509write_csr *ctx, unsigned char key_usage);
int mbedtls_x509write_csr_set_subject_alternative_name(mbedtls_x509write_csr *ctx,
const mbedtls_x509_san_list *san_list);
int mbedtls_x509write_csr_set_ns_cert_type(mbedtls_x509write_csr *ctx,
unsigned char ns_cert_type);
int mbedtls_x509write_csr_set_extension(mbedtls_x509write_csr *ctx,
const char *oid, size_t oid_len,
int critical,
const unsigned char *val, size_t val_len);
void mbedtls_x509write_csr_free(mbedtls_x509write_csr *ctx);
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);
#if defined(MBEDTLS_PEM_WRITE_C)
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);
#endif /* MBEDTLS_PEM_WRITE_C */
#endif /* MBEDTLS_X509_CSR_WRITE_C */
#ifdef __cplusplus
}
#endif
#endif /* mbedtls_x509_csr.h */
mbedtls_x509_csr_ext_cb_t
int(* mbedtls_x509_csr_ext_cb_t)(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid, int critical, const unsigned char *p, const unsigned char *end)
The type of certificate extension callbacks.
Definition x509_csr.h:123
mbedtls_x509write_csr_set_subject_alternative_name
int mbedtls_x509write_csr_set_subject_alternative_name(mbedtls_x509write_csr *ctx, const mbedtls_x509_san_list *san_list)
Set Subject Alternative Name.
mbedtls_x509write_csr_free
void mbedtls_x509write_csr_free(mbedtls_x509write_csr *ctx)
Free the contents of a CSR context.
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_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_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_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_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_x509write_csr_init
void mbedtls_x509write_csr_init(mbedtls_x509write_csr *ctx)
Initialize a CSR context.
mbedtls_x509_csr_parse_der_with_ext_cb
int mbedtls_x509_csr_parse_der_with_ext_cb(mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen, mbedtls_x509_csr_ext_cb_t cb, void *p_ctx)
Load a Certificate Signing Request (CSR) in DER 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_init
void mbedtls_x509_csr_init(mbedtls_x509_csr *csr)
Initialize a CSR.
mbedtls_x509write_csr_set_extension
int mbedtls_x509write_csr_set_extension(mbedtls_x509write_csr *ctx, const char *oid, size_t oid_len, int critical, const unsigned char *val, size_t val_len)
Generic function to add to or replace an extension in the CSR.
mbedtls_x509_csr_free
void mbedtls_x509_csr_free(mbedtls_x509_csr *csr)
Unallocate all CSR data.
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_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_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_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_x509_csr_parse_file
int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path)
Load a Certificate Signing Request (CSR)
build_info.h
Build-time configuration info.
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition md.h:47
mbedtls_pk_type_t
mbedtls_pk_type_t
Public key types.
Definition pk.h:73
private_access.h
Macro wrapper for struct's members.
MBEDTLS_PRIVATE
#define MBEDTLS_PRIVATE(member)
Definition private_access.h:15
mbedtls_asn1_buf
Definition asn1.h:141
mbedtls_asn1_named_data
Definition asn1.h:178
mbedtls_asn1_sequence
Definition asn1.h:161
mbedtls_pk_context
Public key container.
Definition pk.h:220
mbedtls_x509_csr
Definition x509_csr.h:38
mbedtls_x509_csr::subject
mbedtls_x509_name subject
Definition x509_csr.h:45
mbedtls_x509_csr::subject_alt_names
mbedtls_x509_sequence subject_alt_names
Definition x509_csr.h:51
mbedtls_x509_csr::ns_cert_type
unsigned char ns_cert_type
Definition x509_csr.h:50
mbedtls_x509_csr::sig_oid
mbedtls_x509_buf sig_oid
Definition x509_csr.h:55
mbedtls_x509_csr::version
int version
Definition x509_csr.h:42
mbedtls_x509_csr::cri
mbedtls_x509_buf cri
Definition x509_csr.h:40
mbedtls_x509_csr::pk
mbedtls_pk_context pk
Definition x509_csr.h:47
mbedtls_x509_csr::key_usage
unsigned int key_usage
Definition x509_csr.h:49
mbedtls_x509_csr::raw
mbedtls_x509_buf raw
Definition x509_csr.h:39
mbedtls_x509_csr::subject_raw
mbedtls_x509_buf subject_raw
Definition x509_csr.h:44
mbedtls_x509_san_list
Definition x509.h:303
mbedtls_x509write_csr
Definition x509_csr.h:66
x509.h
X.509 generic defines and structures.