Lines Matching +full:- +full:p

5  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
8 * The ITU-T X.509 standard defines a certificate format for PKI.
14 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf
15 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
63 int mbedtls_x509_get_serial(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_serial() argument
68 if ((end - *p) < 1) { in mbedtls_x509_get_serial()
73 if (**p != (MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_PRIMITIVE | 2) && in mbedtls_x509_get_serial()
74 **p != MBEDTLS_ASN1_INTEGER) { in mbedtls_x509_get_serial()
79 serial->tag = *(*p)++; in mbedtls_x509_get_serial()
81 if ((ret = mbedtls_asn1_get_len(p, end, &serial->len)) != 0) { in mbedtls_x509_get_serial()
85 serial->p = *p; in mbedtls_x509_get_serial()
86 *p += serial->len; in mbedtls_x509_get_serial()
97 int mbedtls_x509_get_alg_null(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_alg_null() argument
102 if ((ret = mbedtls_asn1_get_alg_null(p, end, alg)) != 0) { in mbedtls_x509_get_alg_null()
112 int mbedtls_x509_get_alg(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_alg() argument
117 if ((ret = mbedtls_asn1_get_alg(p, end, alg, params)) != 0) { in mbedtls_x509_get_alg()
182 unsigned char *p; in x509_get_hash_alg() local
188 if (alg->tag != (MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) { in x509_get_hash_alg()
193 p = alg->p; in x509_get_hash_alg()
194 end = p + alg->len; in x509_get_hash_alg()
196 if (p >= end) { in x509_get_hash_alg()
202 md_oid.tag = *p; in x509_get_hash_alg()
204 if ((ret = mbedtls_asn1_get_tag(&p, end, &md_oid.len, MBEDTLS_ASN1_OID)) != 0) { in x509_get_hash_alg()
208 md_oid.p = p; in x509_get_hash_alg()
209 p += md_oid.len; in x509_get_hash_alg()
217 if (p == end) { in x509_get_hash_alg()
221 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_NULL)) != 0 || len != 0) { in x509_get_hash_alg()
225 if (p != end) { in x509_get_hash_alg()
234 * RSASSA-PSS-params ::= SEQUENCE {
239 * -- Note that the tags in this Sequence are explicit.
241 * RFC 4055 (which defines use of RSASSA-PSS in PKIX) states that the value
250 unsigned char *p; in mbedtls_x509_get_rsassa_pss_params() local
261 if (params->tag != (MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) { in mbedtls_x509_get_rsassa_pss_params()
266 p = (unsigned char *) params->p; in mbedtls_x509_get_rsassa_pss_params()
267 end = p + params->len; in mbedtls_x509_get_rsassa_pss_params()
269 if (p == end) { in mbedtls_x509_get_rsassa_pss_params()
276 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in mbedtls_x509_get_rsassa_pss_params()
279 end2 = p + len; in mbedtls_x509_get_rsassa_pss_params()
282 if ((ret = mbedtls_x509_get_alg_null(&p, end2, &alg_id)) != 0) { in mbedtls_x509_get_rsassa_pss_params()
290 if (p != end2) { in mbedtls_x509_get_rsassa_pss_params()
298 if (p == end) { in mbedtls_x509_get_rsassa_pss_params()
305 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in mbedtls_x509_get_rsassa_pss_params()
308 end2 = p + len; in mbedtls_x509_get_rsassa_pss_params()
311 if ((ret = mbedtls_x509_get_alg(&p, end2, &alg_id, &alg_params)) != 0) { in mbedtls_x509_get_rsassa_pss_params()
326 if (p != end2) { in mbedtls_x509_get_rsassa_pss_params()
334 if (p == end) { in mbedtls_x509_get_rsassa_pss_params()
341 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in mbedtls_x509_get_rsassa_pss_params()
344 end2 = p + len; in mbedtls_x509_get_rsassa_pss_params()
346 if ((ret = mbedtls_asn1_get_int(&p, end2, salt_len)) != 0) { in mbedtls_x509_get_rsassa_pss_params()
350 if (p != end2) { in mbedtls_x509_get_rsassa_pss_params()
358 if (p == end) { in mbedtls_x509_get_rsassa_pss_params()
365 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in mbedtls_x509_get_rsassa_pss_params()
370 end2 = p + len; in mbedtls_x509_get_rsassa_pss_params()
372 if ((ret = mbedtls_asn1_get_int(&p, end2, &trailer_field)) != 0) { in mbedtls_x509_get_rsassa_pss_params()
376 if (p != end2) { in mbedtls_x509_get_rsassa_pss_params()
388 if (p != end) { in mbedtls_x509_get_rsassa_pss_params()
406 static int x509_get_attr_type_value(unsigned char **p, in x509_get_attr_type_value() argument
415 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in x509_get_attr_type_value()
420 end = *p + len; in x509_get_attr_type_value()
422 if ((end - *p) < 1) { in x509_get_attr_type_value()
427 oid = &cur->oid; in x509_get_attr_type_value()
428 oid->tag = **p; in x509_get_attr_type_value()
430 if ((ret = mbedtls_asn1_get_tag(p, end, &oid->len, MBEDTLS_ASN1_OID)) != 0) { in x509_get_attr_type_value()
434 oid->p = *p; in x509_get_attr_type_value()
435 *p += oid->len; in x509_get_attr_type_value()
437 if ((end - *p) < 1) { in x509_get_attr_type_value()
442 if (**p != MBEDTLS_ASN1_BMP_STRING && **p != MBEDTLS_ASN1_UTF8_STRING && in x509_get_attr_type_value()
443 **p != MBEDTLS_ASN1_T61_STRING && **p != MBEDTLS_ASN1_PRINTABLE_STRING && in x509_get_attr_type_value()
444 **p != MBEDTLS_ASN1_IA5_STRING && **p != MBEDTLS_ASN1_UNIVERSAL_STRING && in x509_get_attr_type_value()
445 **p != MBEDTLS_ASN1_BIT_STRING) { in x509_get_attr_type_value()
450 val = &cur->val; in x509_get_attr_type_value()
451 val->tag = *(*p)++; in x509_get_attr_type_value()
453 if ((ret = mbedtls_asn1_get_len(p, end, &val->len)) != 0) { in x509_get_attr_type_value()
457 val->p = *p; in x509_get_attr_type_value()
458 *p += val->len; in x509_get_attr_type_value()
460 if (*p != end) { in x509_get_attr_type_value()
465 cur->next = NULL; in x509_get_attr_type_value()
471 * Name ::= CHOICE { -- only one possibility for now --
493 * On success, this function may allocate a linked list starting at cur->next
498 int mbedtls_x509_get_name(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_name() argument
511 if ((ret = mbedtls_asn1_get_tag(p, end, &set_len, in mbedtls_x509_get_name()
517 end_set = *p + set_len; in mbedtls_x509_get_name()
520 if ((ret = x509_get_attr_type_value(p, end_set, cur)) != 0) { in mbedtls_x509_get_name()
524 if (*p == end_set) { in mbedtls_x509_get_name()
529 cur->next_merged = 1; in mbedtls_x509_get_name()
531 cur->next = mbedtls_calloc(1, sizeof(mbedtls_x509_name)); in mbedtls_x509_get_name()
533 if (cur->next == NULL) { in mbedtls_x509_get_name()
538 cur = cur->next; in mbedtls_x509_get_name()
544 if (*p == end) { in mbedtls_x509_get_name()
548 cur->next = mbedtls_calloc(1, sizeof(mbedtls_x509_name)); in mbedtls_x509_get_name()
550 if (cur->next == NULL) { in mbedtls_x509_get_name()
555 cur = cur->next; in mbedtls_x509_get_name()
560 mbedtls_asn1_free_named_data_list_shallow(head->next); in mbedtls_x509_get_name()
561 head->next = NULL; in mbedtls_x509_get_name()
570 switch (t->mon) { in x509_date_is_valid()
578 year = (unsigned int) t->year; in x509_date_is_valid()
587 if ((unsigned int) (t->day - 1) >= month_days || /* (1 - days in month) */ in x509_date_is_valid()
588 /* (unsigned int) (t->mon - 1) >= 12 || */ /* (1 - 12) checked above */ in x509_date_is_valid()
589 (unsigned int) t->year > 9999 || /* (0 - 9999) */ in x509_date_is_valid()
590 (unsigned int) t->hour > 23 || /* (0 - 23) */ in x509_date_is_valid()
591 (unsigned int) t->min > 59 || /* (0 - 59) */ in x509_date_is_valid()
592 (unsigned int) t->sec > 59) { /* (0 - 59) */ in x509_date_is_valid()
599 static int x509_parse2_int(const unsigned char *p) in x509_parse2_int() argument
601 uint32_t d1 = p[0] - '0'; in x509_parse2_int()
602 uint32_t d2 = p[1] - '0'; in x509_parse2_int()
603 return (d1 < 10 && d2 < 10) ? (int) (d1 * 10 + d2) : -1; in x509_parse2_int()
610 static int x509_parse_time(const unsigned char *p, mbedtls_x509_time *tm, in x509_parse_time() argument
618 tm->year = x509_parse2_int(p); in x509_parse_time()
619 if (tm->year < 0) { in x509_parse_time()
624 x = tm->year * 100; in x509_parse_time()
625 p += 2; in x509_parse_time()
626 tm->year = x509_parse2_int(p); in x509_parse_time()
627 if (tm->year < 0) { in x509_parse_time()
631 x = (tm->year < 50) ? 2000 : 1900; in x509_parse_time()
633 tm->year += x; in x509_parse_time()
635 tm->mon = x509_parse2_int(p + 2); in x509_parse_time()
636 tm->day = x509_parse2_int(p + 4); in x509_parse_time()
637 tm->hour = x509_parse2_int(p + 6); in x509_parse_time()
638 tm->min = x509_parse2_int(p + 8); in x509_parse_time()
639 tm->sec = x509_parse2_int(p + 10); in x509_parse_time()
649 int mbedtls_x509_get_time(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_time() argument
656 if ((end - *p) < 1) { in mbedtls_x509_get_time()
661 tag = **p; in mbedtls_x509_get_time()
672 (*p)++; in mbedtls_x509_get_time()
673 ret = mbedtls_asn1_get_len(p, end, &len); in mbedtls_x509_get_time()
681 !(len == year_len + 11 && (*p)[(len - 1)] == 'Z')) { in mbedtls_x509_get_time()
685 (*p) += len; in mbedtls_x509_get_time()
686 return x509_parse_time(*p - len, tm, year_len); in mbedtls_x509_get_time()
689 int mbedtls_x509_get_sig(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig) in mbedtls_x509_get_sig() argument
695 if ((end - *p) < 1) { in mbedtls_x509_get_sig()
700 tag_type = **p; in mbedtls_x509_get_sig()
702 if ((ret = mbedtls_asn1_get_bitstring_null(p, end, &len)) != 0) { in mbedtls_x509_get_sig()
706 sig->tag = tag_type; in mbedtls_x509_get_sig()
707 sig->len = len; in mbedtls_x509_get_sig()
708 sig->p = *p; in mbedtls_x509_get_sig()
710 *p += len; in mbedtls_x509_get_sig()
743 &pss_opts->mgf1_hash_id, in mbedtls_x509_get_sig_alg()
744 &pss_opts->expected_salt_len); in mbedtls_x509_get_sig_alg()
755 if ((sig_params->tag != MBEDTLS_ASN1_NULL && sig_params->tag != 0) || in mbedtls_x509_get_sig_alg()
756 sig_params->len != 0) { in mbedtls_x509_get_sig_alg()
768 int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_ext() argument
775 * `Extensions` structure is wrapped by a tag-length pair using in mbedtls_x509_get_ext()
776 * the respective context-specific tag. */ in mbedtls_x509_get_ext()
777 ret = mbedtls_asn1_get_tag(p, end, &ext->len, in mbedtls_x509_get_ext()
783 ext->tag = MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | tag; in mbedtls_x509_get_ext()
784 ext->p = *p; in mbedtls_x509_get_ext()
785 end = *p + ext->len; in mbedtls_x509_get_ext()
790 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in mbedtls_x509_get_ext()
795 if (end != *p + len) { in mbedtls_x509_get_ext()
805 return (i < 10) ? (i + '0') : (i - 10 + 'A'); in nibble_to_hex_digit()
823 char s[MBEDTLS_X509_MAX_DN_NAME_SIZE], *p; in mbedtls_x509_dn_gets() local
829 p = buf; in mbedtls_x509_dn_gets()
833 if (!name->oid.p) { in mbedtls_x509_dn_gets()
834 name = name->next; in mbedtls_x509_dn_gets()
839 ret = mbedtls_snprintf(p, n, merge ? " + " : ", "); in mbedtls_x509_dn_gets()
843 print_hexstring = (name->val.tag != MBEDTLS_ASN1_UTF8_STRING) && in mbedtls_x509_dn_gets()
844 (name->val.tag != MBEDTLS_ASN1_PRINTABLE_STRING) && in mbedtls_x509_dn_gets()
845 (name->val.tag != MBEDTLS_ASN1_IA5_STRING); in mbedtls_x509_dn_gets()
847 if ((ret = mbedtls_oid_get_attr_short_name(&name->oid, &short_name)) == 0) { in mbedtls_x509_dn_gets()
848 ret = mbedtls_snprintf(p, n, "%s=", short_name); in mbedtls_x509_dn_gets()
850 if ((ret = mbedtls_oid_get_numeric_string(p, n, &name->oid)) > 0) { in mbedtls_x509_dn_gets()
851 n -= ret; in mbedtls_x509_dn_gets()
852 p += ret; in mbedtls_x509_dn_gets()
853 ret = mbedtls_snprintf(p, n, "="); in mbedtls_x509_dn_gets()
858 ret = mbedtls_snprintf(p, n, "\?\?="); in mbedtls_x509_dn_gets()
867 if ((ret = mbedtls_asn1_write_len(&asn1_len_p, asn1_tag_len_buf, name->val.len)) < 0) { in mbedtls_x509_dn_gets()
871 if ((ret = mbedtls_asn1_write_tag(&asn1_len_p, asn1_tag_len_buf, name->val.tag)) < 0) { in mbedtls_x509_dn_gets()
875 asn1_tag_len_buf_start = sizeof(asn1_tag_len_buf) - asn1_len_size - asn1_tag_size; in mbedtls_x509_dn_gets()
877 if (j + 1 >= sizeof(s) - 1) { in mbedtls_x509_dn_gets()
886 for (i = 0; i < name->val.len; i++) { in mbedtls_x509_dn_gets()
887 if (j + 1 >= sizeof(s) - 1) { in mbedtls_x509_dn_gets()
890 c = name->val.p[i]; in mbedtls_x509_dn_gets()
897 for (i = 0, j = 0; i < name->val.len; i++, j++) { in mbedtls_x509_dn_gets()
898 if (j >= sizeof(s) - 1) { in mbedtls_x509_dn_gets()
902 c = name->val.p[i]; in mbedtls_x509_dn_gets()
909 ((i == name->val.len-1) && (c == ' '))) { in mbedtls_x509_dn_gets()
910 if (j + 1 >= sizeof(s) - 1) { in mbedtls_x509_dn_gets()
917 if (j + 3 >= sizeof(s) - 1) { in mbedtls_x509_dn_gets()
931 ret = mbedtls_snprintf(p, n, "%s", s); in mbedtls_x509_dn_gets()
934 merge = name->next_merged; in mbedtls_x509_dn_gets()
935 name = name->next; in mbedtls_x509_dn_gets()
938 return (int) (size - n); in mbedtls_x509_dn_gets()
949 char *p; in mbedtls_x509_serial_gets() local
951 p = buf; in mbedtls_x509_serial_gets()
954 nr = (serial->len <= 32) in mbedtls_x509_serial_gets()
955 ? serial->len : 28; in mbedtls_x509_serial_gets()
958 if (i == 0 && nr > 1 && serial->p[i] == 0x0) { in mbedtls_x509_serial_gets()
962 ret = mbedtls_snprintf(p, n, "%02X%s", in mbedtls_x509_serial_gets()
963 serial->p[i], (i < nr - 1) ? ":" : ""); in mbedtls_x509_serial_gets()
967 if (nr != serial->len) { in mbedtls_x509_serial_gets()
968 ret = mbedtls_snprintf(p, n, "...."); in mbedtls_x509_serial_gets()
972 return (int) (size - n); in mbedtls_x509_serial_gets()
984 char *p = buf; in mbedtls_x509_sig_alg_gets() local
990 ret = mbedtls_snprintf(p, n, "???"); in mbedtls_x509_sig_alg_gets()
992 ret = mbedtls_snprintf(p, n, "%s", desc); in mbedtls_x509_sig_alg_gets()
1003 const char *mgf_name = md_type_to_string(pss_opts->mgf1_hash_id); in mbedtls_x509_sig_alg_gets()
1005 ret = mbedtls_snprintf(p, n, " (%s, MGF1-%s, 0x%02X)", in mbedtls_x509_sig_alg_gets()
1008 (unsigned int) pss_opts->expected_salt_len); in mbedtls_x509_sig_alg_gets()
1017 return (int) (size - n); in mbedtls_x509_sig_alg_gets()
1026 char *p = buf; in mbedtls_x509_key_size_helper() local
1030 ret = mbedtls_snprintf(p, n, "%s key size", name); in mbedtls_x509_key_size_helper()
1041 x = (((t1->year << 9) | (t1->mon << 5) | (t1->day)) - in mbedtls_x509_time_cmp()
1042 ((t2->year << 9) | (t2->mon << 5) | (t2->day))); in mbedtls_x509_time_cmp()
1047 x = (((t1->hour << 12) | (t1->min << 6) | (t1->sec)) - in mbedtls_x509_time_cmp()
1048 ((t2->hour << 12) | (t2->min << 6) | (t2->sec))); in mbedtls_x509_time_cmp()
1058 return -1; in mbedtls_x509_time_gmtime()
1061 now->year = tm.tm_year + 1900; in mbedtls_x509_time_gmtime()
1062 now->mon = tm.tm_mon + 1; in mbedtls_x509_time_gmtime()
1063 now->day = tm.tm_mday; in mbedtls_x509_time_gmtime()
1064 now->hour = tm.tm_hour; in mbedtls_x509_time_gmtime()
1065 now->min = tm.tm_min; in mbedtls_x509_time_gmtime()
1066 now->sec = tm.tm_sec; in mbedtls_x509_time_gmtime()
1116 * type-id OBJECT IDENTIFIER,
1117 * value [0] EXPLICIT ANY DEFINED BY type-id }
1131 unsigned char *p = subject_alt_name->p; in x509_get_other_name() local
1132 const unsigned char *end = p + subject_alt_name->len; in x509_get_other_name()
1135 if ((subject_alt_name->tag & in x509_get_other_name()
1144 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in x509_get_other_name()
1150 cur_oid.p = p; in x509_get_other_name()
1159 other_name->type_id = cur_oid; in x509_get_other_name()
1161 p += len; in x509_get_other_name()
1162 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in x509_get_other_name()
1168 if (end != p + len) { in x509_get_other_name()
1173 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in x509_get_other_name()
1178 if (end != p + len) { in x509_get_other_name()
1183 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OID)) != 0) { in x509_get_other_name()
1187 other_name->value.hardware_module_name.oid.tag = MBEDTLS_ASN1_OID; in x509_get_other_name()
1188 other_name->value.hardware_module_name.oid.p = p; in x509_get_other_name()
1189 other_name->value.hardware_module_name.oid.len = len; in x509_get_other_name()
1191 p += len; in x509_get_other_name()
1192 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in x509_get_other_name()
1197 other_name->value.hardware_module_name.val.tag = MBEDTLS_ASN1_OCTET_STRING; in x509_get_other_name()
1198 other_name->value.hardware_module_name.val.p = p; in x509_get_other_name()
1199 other_name->value.hardware_module_name.val.len = len; in x509_get_other_name()
1200 p += len; in x509_get_other_name()
1201 if (p != end) { in x509_get_other_name()
1213 int mbedtls_x509_get_subject_alt_name_ext(unsigned char **p, in mbedtls_x509_get_subject_alt_name_ext() argument
1221 while (*p < end) { in mbedtls_x509_get_subject_alt_name_ext()
1226 tmp_san_buf.tag = **p; in mbedtls_x509_get_subject_alt_name_ext()
1227 (*p)++; in mbedtls_x509_get_subject_alt_name_ext()
1229 if ((ret = mbedtls_asn1_get_len(p, end, &tag_len)) != 0) { in mbedtls_x509_get_subject_alt_name_ext()
1233 tmp_san_buf.p = *p; in mbedtls_x509_get_subject_alt_name_ext()
1252 mbedtls_asn1_sequence_free(subject_alt_name->next); in mbedtls_x509_get_subject_alt_name_ext()
1253 subject_alt_name->next = NULL; in mbedtls_x509_get_subject_alt_name_ext()
1259 if (cur->buf.p != NULL) { in mbedtls_x509_get_subject_alt_name_ext()
1260 if (cur->next != NULL) { in mbedtls_x509_get_subject_alt_name_ext()
1264 cur->next = mbedtls_calloc(1, sizeof(mbedtls_asn1_sequence)); in mbedtls_x509_get_subject_alt_name_ext()
1266 if (cur->next == NULL) { in mbedtls_x509_get_subject_alt_name_ext()
1271 cur = cur->next; in mbedtls_x509_get_subject_alt_name_ext()
1274 cur->buf = tmp_san_buf; in mbedtls_x509_get_subject_alt_name_ext()
1275 *p += tmp_san_buf.len; in mbedtls_x509_get_subject_alt_name_ext()
1279 cur->next = NULL; in mbedtls_x509_get_subject_alt_name_ext()
1281 if (*p != end) { in mbedtls_x509_get_subject_alt_name_ext()
1306 * type-id OBJECT IDENTIFIER,
1307 * value [0] EXPLICIT ANY DEFINED BY type-id }
1317 int mbedtls_x509_get_subject_alt_name(unsigned char **p, in mbedtls_x509_get_subject_alt_name() argument
1325 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in mbedtls_x509_get_subject_alt_name()
1330 if (*p + len != end) { in mbedtls_x509_get_subject_alt_name()
1335 return mbedtls_x509_get_subject_alt_name_ext(p, end, subject_alt_name); in mbedtls_x509_get_subject_alt_name()
1338 int mbedtls_x509_get_ns_cert_type(unsigned char **p, in mbedtls_x509_get_ns_cert_type() argument
1345 if ((ret = mbedtls_asn1_get_bitstring(p, end, &bs)) != 0) { in mbedtls_x509_get_ns_cert_type()
1362 *ns_cert_type = *bs.p; in mbedtls_x509_get_ns_cert_type()
1366 int mbedtls_x509_get_key_usage(unsigned char **p, in mbedtls_x509_get_key_usage() argument
1374 if ((ret = mbedtls_asn1_get_bitstring(p, end, &bs)) != 0) { in mbedtls_x509_get_key_usage()
1388 *key_usage |= (unsigned int) bs.p[i] << (8*i); in mbedtls_x509_get_key_usage()
1398 switch (san_buf->tag & in mbedtls_x509_parse_subject_alt_name()
1414 san->type = MBEDTLS_X509_SAN_OTHER_NAME; in mbedtls_x509_parse_subject_alt_name()
1415 memcpy(&san->san.other_name, in mbedtls_x509_parse_subject_alt_name()
1426 san->type = MBEDTLS_X509_SAN_UNIFORM_RESOURCE_IDENTIFIER; in mbedtls_x509_parse_subject_alt_name()
1428 memcpy(&san->san.unstructured_name, in mbedtls_x509_parse_subject_alt_name()
1439 san->type = MBEDTLS_X509_SAN_DNS_NAME; in mbedtls_x509_parse_subject_alt_name()
1441 memcpy(&san->san.unstructured_name, in mbedtls_x509_parse_subject_alt_name()
1451 san->type = MBEDTLS_X509_SAN_IP_ADDRESS; in mbedtls_x509_parse_subject_alt_name()
1453 if (san_buf->len == 4 || san_buf->len == 16) { in mbedtls_x509_parse_subject_alt_name()
1454 memcpy(&san->san.unstructured_name, in mbedtls_x509_parse_subject_alt_name()
1467 san->type = MBEDTLS_X509_SAN_RFC822_NAME; in mbedtls_x509_parse_subject_alt_name()
1468 memcpy(&san->san.unstructured_name, san_buf, sizeof(*san_buf)); in mbedtls_x509_parse_subject_alt_name()
1477 unsigned char *p = san_buf->p; in mbedtls_x509_parse_subject_alt_name() local
1479 san->type = MBEDTLS_X509_SAN_DIRECTORY_NAME; in mbedtls_x509_parse_subject_alt_name()
1481 ret = mbedtls_asn1_get_tag(&p, p + san_buf->len, &name_len, in mbedtls_x509_parse_subject_alt_name()
1488 if ((ret = mbedtls_x509_get_name(&p, p + name_len, in mbedtls_x509_parse_subject_alt_name()
1489 &san->san.directory_name)) != 0) { in mbedtls_x509_parse_subject_alt_name()
1505 if (san->type == MBEDTLS_X509_SAN_DIRECTORY_NAME) { in mbedtls_x509_free_subject_alt_name()
1506 mbedtls_asn1_free_named_data_list_shallow(san->san.directory_name.next); in mbedtls_x509_free_subject_alt_name()
1519 char *p = *buf; in mbedtls_x509_info_subject_alt_name() local
1526 parse_ret = mbedtls_x509_parse_subject_alt_name(&cur->buf, &san); in mbedtls_x509_info_subject_alt_name()
1529 ret = mbedtls_snprintf(p, n, "\n%s <unsupported>", prefix); in mbedtls_x509_info_subject_alt_name()
1532 ret = mbedtls_snprintf(p, n, "\n%s <malformed>", prefix); in mbedtls_x509_info_subject_alt_name()
1535 cur = cur->next; in mbedtls_x509_info_subject_alt_name()
1547 ret = mbedtls_snprintf(p, n, "\n%s otherName :", prefix); in mbedtls_x509_info_subject_alt_name()
1551 &other_name->type_id) == 0) { in mbedtls_x509_info_subject_alt_name()
1552 ret = mbedtls_snprintf(p, n, "\n%s hardware module name :", prefix); in mbedtls_x509_info_subject_alt_name()
1555 mbedtls_snprintf(p, n, "\n%s hardware type : ", prefix); in mbedtls_x509_info_subject_alt_name()
1558 ret = mbedtls_oid_get_numeric_string(p, in mbedtls_x509_info_subject_alt_name()
1560 … &other_name->value.hardware_module_name.oid); in mbedtls_x509_info_subject_alt_name()
1564 mbedtls_snprintf(p, n, "\n%s hardware serial number : ", prefix); in mbedtls_x509_info_subject_alt_name()
1567 for (i = 0; i < other_name->value.hardware_module_name.val.len; i++) { in mbedtls_x509_info_subject_alt_name()
1568 ret = mbedtls_snprintf(p, in mbedtls_x509_info_subject_alt_name()
1571 other_name->value.hardware_module_name.val.p[i]); in mbedtls_x509_info_subject_alt_name()
1582 ret = mbedtls_snprintf(p, n, "\n%s uniformResourceIdentifier : ", prefix); in mbedtls_x509_info_subject_alt_name()
1586 *p = '\0'; in mbedtls_x509_info_subject_alt_name()
1591 memcpy(p, san.san.unstructured_name.p, san.san.unstructured_name.len); in mbedtls_x509_info_subject_alt_name()
1592 p += san.san.unstructured_name.len; in mbedtls_x509_info_subject_alt_name()
1593 n -= san.san.unstructured_name.len; in mbedtls_x509_info_subject_alt_name()
1606 ret = mbedtls_snprintf(p, n, in mbedtls_x509_info_subject_alt_name()
1614 *p = '\0'; in mbedtls_x509_info_subject_alt_name()
1619 memcpy(p, san.san.unstructured_name.p, san.san.unstructured_name.len); in mbedtls_x509_info_subject_alt_name()
1620 p += san.san.unstructured_name.len; in mbedtls_x509_info_subject_alt_name()
1621 n -= san.san.unstructured_name.len; in mbedtls_x509_info_subject_alt_name()
1629 ret = mbedtls_snprintf(p, n, "\n%s %s : ", in mbedtls_x509_info_subject_alt_name()
1634 *p = '\0'; in mbedtls_x509_info_subject_alt_name()
1639 unsigned char *ip = san.san.unstructured_name.p; in mbedtls_x509_info_subject_alt_name()
1642 ret = mbedtls_snprintf(p, n, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); in mbedtls_x509_info_subject_alt_name()
1645 ret = mbedtls_snprintf(p, n, in mbedtls_x509_info_subject_alt_name()
1653 *p = '\0'; in mbedtls_x509_info_subject_alt_name()
1664 ret = mbedtls_snprintf(p, n, "\n%s directoryName : ", prefix); in mbedtls_x509_info_subject_alt_name()
1670 ret = mbedtls_x509_dn_gets(p, n, &san.san.directory_name); in mbedtls_x509_info_subject_alt_name()
1675 *p = '\0'; in mbedtls_x509_info_subject_alt_name()
1680 p += ret; in mbedtls_x509_info_subject_alt_name()
1681 n -= ret; in mbedtls_x509_info_subject_alt_name()
1688 ret = mbedtls_snprintf(p, n, "\n%s <unsupported>", prefix); in mbedtls_x509_info_subject_alt_name()
1696 cur = cur->next; in mbedtls_x509_info_subject_alt_name()
1699 *p = '\0'; in mbedtls_x509_info_subject_alt_name()
1702 *buf = p; in mbedtls_x509_info_subject_alt_name()
1709 ret = mbedtls_snprintf(p, n, "%s" i, sep); \
1726 char *p = *buf; in mbedtls_x509_info_cert_type() local
1739 *buf = p; in mbedtls_x509_info_cert_type()
1756 char *p = *buf; in mbedtls_x509_info_key_usage() local
1770 *buf = p; in mbedtls_x509_info_key_usage()