#include "polarssl/config.h"
#include "polarssl/asn1write.h"
#include <stdlib.h>
Go to the source code of this file.
Defines | |
#define | polarssl_malloc malloc |
#define | polarssl_free free |
Functions | |
int | asn1_write_len (unsigned char **p, unsigned char *start, size_t len) |
Write a length field in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_tag (unsigned char **p, unsigned char *start, unsigned char tag) |
Write a ASN.1 tag in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_raw_buffer (unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size) |
Write raw buffer data Note: function works backwards in data buffer. | |
int | asn1_write_mpi (unsigned char **p, unsigned char *start, mpi *X) |
int | asn1_write_null (unsigned char **p, unsigned char *start) |
Write a NULL tag (ASN1_NULL) with zero data in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_oid (unsigned char **p, unsigned char *start, const char *oid, size_t oid_len) |
Write an OID tag (ASN1_OID) and data in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_algorithm_identifier (unsigned char **p, unsigned char *start, const char *oid, size_t oid_len, size_t par_len) |
Write an AlgorithmIdentifier sequence in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_bool (unsigned char **p, unsigned char *start, int boolean) |
Write a boolean tag (ASN1_BOOLEAN) and value in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_int (unsigned char **p, unsigned char *start, int val) |
Write an int tag (ASN1_INTEGER) and value in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_printable_string (unsigned char **p, unsigned char *start, const char *text, size_t text_len) |
Write a printable string tag (ASN1_PRINTABLE_STRING) and value in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_ia5_string (unsigned char **p, unsigned char *start, const char *text, size_t text_len) |
Write an IA5 string tag (ASN1_IA5_STRING) and value in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_bitstring (unsigned char **p, unsigned char *start, const unsigned char *buf, size_t bits) |
Write a bitstring tag (ASN1_BIT_STRING) and value in ASN.1 format Note: function works backwards in data buffer. | |
int | asn1_write_octet_string (unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size) |
Write an octet string tag (ASN1_OCTET_STRING) and value in ASN.1 format Note: function works backwards in data buffer. | |
asn1_named_data * | asn1_store_named_data (asn1_named_data **head, const char *oid, size_t oid_len, const unsigned char *val, size_t val_len) |
Create or find a specific named_data entry for writing in a sequence or list based on the OID. |
#define polarssl_free free |
Definition at line 37 of file asn1write.c.
#define polarssl_malloc malloc |
Definition at line 36 of file asn1write.c.
asn1_named_data* asn1_store_named_data | ( | asn1_named_data ** | list, | |
const char * | oid, | |||
size_t | oid_len, | |||
const unsigned char * | val, | |||
size_t | val_len | |||
) |
Create or find a specific named_data entry for writing in a sequence or list based on the OID.
If not already in there, a new entry is added to the head of the list. Warning: Destructive behaviour for the val data!
list | Pointer to the location of the head of the list to seek through (will be updated in case of a new entry) | |
oid | The OID to look for | |
oid_len | Size of the OID | |
val | Data to store (can be NULL if you want to fill it by hand) | |
val_len | Minimum length of the data buffer needed |
Definition at line 299 of file asn1write.c.
References asn1_find_named_data(), _asn1_buf::len, _asn1_named_data::next, _asn1_named_data::oid, _asn1_buf::p, polarssl_free, polarssl_malloc, and _asn1_named_data::val.
Referenced by x509_set_extension(), and x509_string_to_names().
int asn1_write_algorithm_identifier | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const char * | oid, | |||
size_t | oid_len, | |||
size_t | par_len | |||
) |
Write an AlgorithmIdentifier sequence in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
oid | the OID of the algorithm | |
oid_len | length of the OID | |
par_len | length of parameters, which must be already written. If 0, NULL parameters are added |
Definition at line 160 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_CONSTRUCTED, ASN1_SEQUENCE, asn1_write_len(), asn1_write_null(), asn1_write_oid(), and asn1_write_tag().
Referenced by pk_write_pubkey_der(), x509_write_sig(), and x509write_crt_der().
int asn1_write_bitstring | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const unsigned char * | buf, | |||
size_t | bits | |||
) |
Write a bitstring tag (ASN1_BIT_STRING) and value in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
buf | the bitstring | |
bits | the total number of bits in the bitstring |
Definition at line 258 of file asn1write.c.
References ASN1_BIT_STRING, ASN1_CHK_ADD, asn1_write_len(), asn1_write_tag(), and POLARSSL_ERR_ASN1_BUF_TOO_SMALL.
Referenced by x509write_crt_set_key_usage(), x509write_crt_set_ns_cert_type(), x509write_csr_set_key_usage(), and x509write_csr_set_ns_cert_type().
int asn1_write_bool | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
int | boolean | |||
) |
Write a boolean tag (ASN1_BOOLEAN) and value in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
boolean | 0 or 1 |
Definition at line 181 of file asn1write.c.
References ASN1_BOOLEAN, ASN1_CHK_ADD, asn1_write_len(), asn1_write_tag(), and POLARSSL_ERR_ASN1_BUF_TOO_SMALL.
Referenced by x509_write_extension(), and x509write_crt_set_basic_constraints().
int asn1_write_ia5_string | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const char * | text, | |||
size_t | text_len | |||
) |
Write an IA5 string tag (ASN1_IA5_STRING) and value in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
text | the text to write | |
text_len | length of the text |
Definition at line 243 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_IA5_STRING, asn1_write_len(), asn1_write_raw_buffer(), and asn1_write_tag().
Referenced by x509_write_name().
int asn1_write_int | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
int | val | |||
) |
Write an int tag (ASN1_INTEGER) and value in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
val | the integer value |
Definition at line 198 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_INTEGER, asn1_write_len(), asn1_write_tag(), and POLARSSL_ERR_ASN1_BUF_TOO_SMALL.
Referenced by pk_write_key_der(), x509write_crt_der(), x509write_crt_set_basic_constraints(), and x509write_csr_der().
int asn1_write_len | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
size_t | len | |||
) |
Write a length field in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
len | the length to write |
Definition at line 40 of file asn1write.c.
References POLARSSL_ERR_ASN1_BUF_TOO_SMALL.
Referenced by asn1_write_algorithm_identifier(), asn1_write_bitstring(), asn1_write_bool(), asn1_write_ia5_string(), asn1_write_int(), asn1_write_mpi(), asn1_write_null(), asn1_write_octet_string(), asn1_write_oid(), asn1_write_printable_string(), ecdsa_write_signature(), pk_write_key_der(), pk_write_pubkey_der(), pk_write_rsa_pubkey(), x509_write_extension(), x509_write_name(), x509_write_names(), x509_write_sig(), x509_write_time(), x509write_crt_der(), x509write_crt_set_authority_key_identifier(), x509write_crt_set_basic_constraints(), x509write_crt_set_subject_key_identifier(), and x509write_csr_der().
int asn1_write_mpi | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
mpi * | X | |||
) |
Definition at line 99 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_INTEGER, asn1_write_len(), asn1_write_tag(), mpi_size(), mpi_write_binary(), POLARSSL_ERR_ASN1_BUF_TOO_SMALL, and mpi::s.
Referenced by ecdsa_write_signature(), pk_write_key_der(), pk_write_rsa_pubkey(), and x509write_crt_der().
int asn1_write_null | ( | unsigned char ** | p, | |
unsigned char * | start | |||
) |
Write a NULL tag (ASN1_NULL) with zero data in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) |
Definition at line 133 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_NULL, asn1_write_len(), and asn1_write_tag().
Referenced by asn1_write_algorithm_identifier().
int asn1_write_octet_string | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const unsigned char * | buf, | |||
size_t | size | |||
) |
Write an octet string tag (ASN1_OCTET_STRING) and value in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
buf | data buffer to write | |
size | length of the data buffer |
Definition at line 285 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_OCTET_STRING, asn1_write_len(), asn1_write_raw_buffer(), and asn1_write_tag().
int asn1_write_oid | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const char * | oid, | |||
size_t | oid_len | |||
) |
Write an OID tag (ASN1_OID) and data in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
oid | the OID to write | |
oid_len | length of the OID |
Definition at line 146 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_OID, asn1_write_len(), asn1_write_raw_buffer(), and asn1_write_tag().
Referenced by asn1_write_algorithm_identifier(), pk_write_ec_param(), x509_write_name(), and x509write_csr_der().
int asn1_write_printable_string | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const char * | text, | |||
size_t | text_len | |||
) |
Write a printable string tag (ASN1_PRINTABLE_STRING) and value in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
text | the text to write | |
text_len | length of the text |
Definition at line 228 of file asn1write.c.
References ASN1_CHK_ADD, ASN1_PRINTABLE_STRING, asn1_write_len(), asn1_write_raw_buffer(), and asn1_write_tag().
Referenced by x509_write_name().
int asn1_write_raw_buffer | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
const unsigned char * | buf, | |||
size_t | size | |||
) |
Write raw buffer data Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
buf | data buffer to write | |
size | length of the data buffer |
Definition at line 83 of file asn1write.c.
References POLARSSL_ERR_ASN1_BUF_TOO_SMALL.
Referenced by asn1_write_ia5_string(), asn1_write_octet_string(), asn1_write_oid(), asn1_write_printable_string(), x509_write_extension(), and x509_write_time().
int asn1_write_tag | ( | unsigned char ** | p, | |
unsigned char * | start, | |||
unsigned char | tag | |||
) |
Write a ASN.1 tag in ASN.1 format Note: function works backwards in data buffer.
p | reference to current position pointer | |
start | start of the buffer (for bounds-checking) | |
tag | the tag to write |
Definition at line 73 of file asn1write.c.
References POLARSSL_ERR_ASN1_BUF_TOO_SMALL.
Referenced by asn1_write_algorithm_identifier(), asn1_write_bitstring(), asn1_write_bool(), asn1_write_ia5_string(), asn1_write_int(), asn1_write_mpi(), asn1_write_null(), asn1_write_octet_string(), asn1_write_oid(), asn1_write_printable_string(), ecdsa_write_signature(), pk_write_key_der(), pk_write_pubkey_der(), pk_write_rsa_pubkey(), x509_write_extension(), x509_write_name(), x509_write_names(), x509_write_sig(), x509_write_time(), x509write_crt_der(), x509write_crt_set_authority_key_identifier(), x509write_crt_set_basic_constraints(), x509write_crt_set_subject_key_identifier(), and x509write_csr_der().