Function ot_certs::codegen::generate_cert
source · pub fn generate_cert(from_file: &str, tmpl: &Template) -> Result<Codegen>
Expand description
Generate the certificate template header and source file.
The generated files will indicate that they have been automatically
generated from from_file
.
Returns the implementation first and the header file second.
NOTE: the implementation file will #include "<header>.h"
the header
where <header>
comes from tmpl.name
.
The generated header file contains the following elements. Below <name>
refers to tmpl.name
and <Name>
to the “camel-case” variant of <name>
.
- License header, warning, include guard.
- Relevant includes.
- Definition of a data structure to hold the values of the variables
used in the TBS. It is named
<name>_tbs_values_t
. - Definition of a data structure to hold the values of the variables
used in the signature. It is named
<name>_sig_values_t
. Note that this structure contains an extra field calledtbs
(and its sizetbs_size
) that must point to the buffer containing the TBS. - An enumeration hold two values: one gives the maximum size of the TBS
given the variables sizes defined in the template, and another one for
the maximum size of the whole certificate. They are named
k<Name>MaxTbsSizeBytes
andk<Name>MaxCertSizeBytes
respectively. - Definition and documentation of a function that takes as input a
a
<name>_tbs_values_t
and a buffer to produce the TBS. It is named<name>_build_tbs
and returns arom_error_t
. - Definition and documentation of a function that takes as input a
a
<name>_sig_values_t
and a buffer to produce the certificate. It is named<name>_build_cert
and returns arom_error_t
.