32 #if defined(MBEDTLS_X509_USE_C)
42 #if defined(MBEDTLS_PEM_PARSE_C)
48 #if defined(MBEDTLS_HAVE_TIME)
51 #if defined(MBEDTLS_HAVE_TIME_DATE)
56 #define CHECK(code) if ((ret = (code)) != 0) { return ret; }
57 #define CHECK_RANGE(min, max, val) \
60 if ((val) < (min) || (val) > (max)) \
85 serial->
tag = *(*p)++;
130 #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
144 const unsigned char *end;
212 const unsigned char *end, *end2;
227 p = (
unsigned char *) params->
p;
228 end = p + params->
len;
342 if (trailer_field != 1) {
368 const unsigned char *end,
383 if ((end - *p) < 1) {
398 if ((end - *p) < 1) {
464 const unsigned char *end_set;
479 end_set = *p + set_len;
522 allocated =
head->next;
524 while (allocated !=
NULL) {
526 allocated = allocated->
next;
542 if ((**p <
'0') || (**p >
'9')) {
547 *res += (*(*p)++ -
'0');
564 case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
567 case 4:
case 6:
case 9:
case 11:
571 if ((!(
t->year % 4) &&
t->year % 100) ||
598 if (
len < yearlen + 8) {
633 if (1 ==
len &&
'Z' == **p) {
659 size_t len, year_len;
662 if ((end - *p) < 1) {
694 if ((end - *p) < 1) {
723 if (*sig_opts !=
NULL) {
731 #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
736 if (pss_opts ==
NULL) {
749 *sig_opts = (
void *) pss_opts;
755 sig_params->
len != 0) {
794 if (end != *p +
len) {
810 unsigned char c, merge = 0;
812 const char *short_name =
NULL;
815 memset(s, 0,
sizeof(s));
821 while (name !=
NULL) {
841 for (
i = 0, j = 0;
i < name->
val.
len;
i++, j++) {
842 if (j >=
sizeof(s) - 1) {
848 if (c && strchr(
",=+<>#;\"\\", c)) {
849 if (j + 1 >=
sizeof(s) - 1) {
854 if (c < 32 || c >= 127) {
868 return (
int) (
size -
n);
884 nr = (serial->
len <= 32)
887 for (
i = 0;
i < nr;
i++) {
888 if (
i == 0 && nr > 1 && serial->
p[
i] == 0x0) {
893 serial->
p[
i], (
i < nr - 1) ?
":" :
"");
897 if (nr != serial->
len) {
902 return (
int) (
size -
n);
910 const void *sig_opts)
915 const char *desc =
NULL;
925 #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
947 return (
int) (
size -
n);
965 #if defined(MBEDTLS_HAVE_TIME_DATE)
972 struct tm *
lt, tm_buf;
982 now->
year =
lt->tm_year + 1900;
983 now->
mon =
lt->tm_mon + 1;
984 now->
day =
lt->tm_mday;
986 now->
min =
lt->tm_min;
987 now->
sec =
lt->tm_sec;
1003 before->
mon > after->
mon) {
1008 before->
mon == after->
mon &&
1009 before->
day > after->
day) {
1014 before->
mon == after->
mon &&
1015 before->
day == after->
day &&
1021 before->
mon == after->
mon &&
1022 before->
day == after->
day &&
1024 before->
min > after->
min) {
1029 before->
mon == after->
mon &&
1030 before->
day == after->
day &&
1032 before->
min == after->
min &&
1033 before->
sec > after->
sec) {
1077 #if defined(MBEDTLS_SELF_TEST)
1085 int mbedtls_x509_self_test(
int verbose)
1088 #if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_SHA256_C)
Sample certificates and DHM parameters for testing.
const size_t mbedtls_test_cli_crt_len
const char * mbedtls_test_ca_crt
const size_t mbedtls_test_ca_crt_len
const char * mbedtls_test_cli_crt
static void cleanup(void)
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define MBEDTLS_OID_CMP(oid_str, oid_buf)
Compares an mbedtls_asn1_buf structure to a reference OID.
int mbedtls_asn1_get_bitstring_null(unsigned char **p, const unsigned char *end, size_t *len)
Retrieve a bitstring ASN.1 tag without unused bits and its value.
#define MBEDTLS_ERR_ASN1_OUT_OF_DATA
Out of data when parsing an ASN1 data structure.
#define MBEDTLS_ASN1_GENERALIZED_TIME
#define MBEDTLS_ASN1_IA5_STRING
#define MBEDTLS_ASN1_BMP_STRING
#define MBEDTLS_ASN1_PRINTABLE_STRING
#define MBEDTLS_ASN1_SEQUENCE
#define MBEDTLS_ASN1_INTEGER
int mbedtls_asn1_get_int(unsigned char **p, const unsigned char *end, int *val)
Retrieve an integer ASN.1 tag and its value.
#define MBEDTLS_ASN1_PRIMITIVE
#define MBEDTLS_ASN1_CONTEXT_SPECIFIC
#define MBEDTLS_ASN1_CONSTRUCTED
#define MBEDTLS_ERR_ASN1_UNEXPECTED_TAG
ASN1 tag was of an unexpected value.
#define MBEDTLS_ASN1_T61_STRING
#define MBEDTLS_ASN1_UTC_TIME
#define MBEDTLS_ASN1_UNIVERSAL_STRING
#define MBEDTLS_ERR_ASN1_LENGTH_MISMATCH
Actual length differs from expected length.
int mbedtls_asn1_get_len(unsigned char **p, const unsigned char *end, size_t *len)
Get the length of an ASN.1 element.
int mbedtls_asn1_get_alg_null(unsigned char **p, const unsigned char *end, mbedtls_asn1_buf *alg)
Retrieve an AlgorithmIdentifier ASN.1 sequence with NULL or no params.
int mbedtls_asn1_get_alg(unsigned char **p, const unsigned char *end, mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params)
Retrieve an AlgorithmIdentifier ASN.1 sequence.
#define MBEDTLS_ASN1_NULL
int mbedtls_asn1_get_tag(unsigned char **p, const unsigned char *end, size_t *len, int tag)
Get the tag and length of the element.
#define MBEDTLS_ASN1_UTF8_STRING
#define MBEDTLS_ASN1_BIT_STRING
#define MBEDTLS_ERR_X509_INVALID_SIGNATURE
The signature tag or value invalid.
int mbedtls_x509_time_is_past(const mbedtls_x509_time *to)
Check a given mbedtls_x509_time against the system time and tell if it's in the past.
int mbedtls_x509_time_is_future(const mbedtls_x509_time *from)
Check a given mbedtls_x509_time against the system time and tell if it's in the future.
#define MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE
Unavailable feature, e.g.
#define MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG
Signature algorithm (oid) is unsupported.
int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
Store the certificate DN in printable form into buf; no more than size characters will be written.
#define MBEDTLS_ERR_X509_INVALID_SERIAL
The serial tag or value is invalid.
#define MBEDTLS_ERR_X509_INVALID_NAME
The name tag or value is invalid.
#define MBEDTLS_ERR_X509_INVALID_EXTENSIONS
The extension tag or value is invalid.
#define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL
Destination buffer is too small.
#define MBEDTLS_ERR_X509_INVALID_DATE
The date tag or value is invalid.
#define MBEDTLS_ERR_X509_ALLOC_FAILED
Allocation of memory failed.
#define MBEDTLS_ERR_X509_INVALID_ALG
The algorithm tag or value is invalid.
#define MBEDTLS_ERR_X509_BAD_INPUT_DATA
Input invalid.
int mbedtls_x509_serial_gets(char *buf, size_t size, const mbedtls_x509_buf *serial)
Store the certificate serial in printable form into buf; no more than size characters will be written...
for(len=0;yy_str[len];++len)
if(yy_accept[yy_current_state])
mbedtls_md_type_t
Supported message digests.
@ MBEDTLS_MD_SHA1
The SHA-1 message digest.
const char * mbedtls_md_get_name(const mbedtls_md_info_t *md_info)
This function extracts the message-digest name from the message-digest information structure.
const mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
This function returns the message-digest information associated with the given digest type.
const struct ncbi::grid::netcache::search::fields::SIZE size
#define mbedtls_oid_get_sig_alg
#define mbedtls_x509_get_rsassa_pss_params
#define mbedtls_platform_gmtime_r
#define mbedtls_oid_get_sig_alg_desc
#define mbedtls_x509_crt_init
#define mbedtls_x509_crt_free
#define mbedtls_x509_crt_parse
#define mbedtls_x509_crt_verify
#define mbedtls_oid_get_md_alg
Object Identifier (OID) database.
int mbedtls_oid_get_attr_short_name(const mbedtls_asn1_buf *oid, const char **short_name)
Translate an X.509 attribute type OID into the short name (e.g.
#define MBEDTLS_OID_MGF1
id-mgf1 ::= { pkcs-1 8 }
#define MBEDTLS_ERR_OID_NOT_FOUND
OID is not found.
Privacy Enhanced Mail (PEM) decoding.
mbedtls_pk_type_t
Public key types.
Error to string translation.
#define MBEDTLS_ERROR_ADD(high, low)
Combines a high-level and low-level error code together.
#define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED
This is a bug in the library.
Type-length-value structure that allows for ASN1 using DER.
size_t len
ASN1 length, in octets.
unsigned char * p
ASN1 data, e.g.
Container for a sequence or list of 'named' ASN.1 data items.
mbedtls_asn1_buf oid
The object identifier.
struct mbedtls_asn1_named_data * next
The next entry in the sequence.
mbedtls_asn1_buf val
The named value.
unsigned char next_merged
Merge next item into the current one?
Message digest information.
Options for RSASSA-PSS signature verification.
mbedtls_md_type_t mgf1_hash_id
Container for an X.509 certificate.
Container for date and time (precision in seconds).
static int x509_get_attr_type_value(unsigned char **p, const unsigned char *end, mbedtls_x509_name *cur)
static int x509_date_is_valid(const mbedtls_x509_time *t)
static int x509_parse_int(unsigned char **p, size_t n, int *res)
static int x509_get_hash_alg(const mbedtls_x509_buf *alg, mbedtls_md_type_t *md_alg)
static int x509_get_current_time(mbedtls_x509_time *now)
static int x509_check_time(const mbedtls_x509_time *before, const mbedtls_x509_time *after)
#define CHECK_RANGE(min, max, val)
static int x509_parse_time(unsigned char **p, size_t len, size_t yearlen, mbedtls_x509_time *tm)
X.509 generic defines and structures.
int mbedtls_x509_get_name(unsigned char **p, const unsigned char *end, mbedtls_x509_name *cur)
int mbedtls_x509_get_alg_null(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *alg)
#define MBEDTLS_X509_SAFE_SNPRINTF
int mbedtls_x509_get_sig_alg(const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, void **sig_opts)
int mbedtls_x509_get_alg(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *alg, mbedtls_x509_buf *params)
int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *ext, int tag)
int mbedtls_x509_key_size_helper(char *buf, size_t buf_size, const char *name)
int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *sig_oid, mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, const void *sig_opts)
int mbedtls_x509_get_serial(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *serial)
int mbedtls_x509_get_sig(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig)
int mbedtls_x509_get_time(unsigned char **p, const unsigned char *end, mbedtls_x509_time *t)
#define MBEDTLS_X509_MAX_DN_NAME_SIZE
Maximum value size of a DN entry.
X.509 certificate parsing and writing.