Lines Matching +full:- +full:s

5  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
34 * MBEDTLS_ASN1_UTF8_STRING for UTF-8. */
37 #define ADD_STRLEN(s) s, sizeof(s) - 1 argument
105 for (cur = x509_attrs; cur->name != NULL; cur++) { in x509_attr_descr_from_name()
106 if (cur->name_len == name_len && in x509_attr_descr_from_name()
107 strncmp(cur->name, name, name_len) == 0) { in x509_attr_descr_from_name()
112 if (cur->name == NULL) { in x509_attr_descr_from_name()
121 return ('0' <= c && c <= '9') ? (c - '0') : in hex_to_int()
122 ('a' <= c && c <= 'f') ? (c - 'a' + 10) : in hex_to_int()
123 ('A' <= c && c <= 'F') ? (c - 'A' + 10) : -1; in hex_to_int()
131 if (n1 != -1 && n2 != -1) { in hexpair_to_int()
134 return -1; in hexpair_to_int()
138 static int parse_attribute_value_string(const char *s, in parse_attribute_value_string() argument
144 const char *end = s + len; in parse_attribute_value_string()
148 for (c = s; c < end; c++) { in parse_attribute_value_string()
153 if (c + 1 < end && (n = hexpair_to_int(c)) != -1) { in parse_attribute_value_string()
168 if (d - data == MBEDTLS_X509_MAX_DN_NAME_SIZE) { in parse_attribute_value_string()
172 *data_len = (size_t) (d - data); in parse_attribute_value_string()
176 /** Parse a hexstring containing a DER-encoded string.
178 * \param s A string of \p len bytes hexadecimal digits.
179 * \param len Number of bytes to read from \p s.
181 * On success, it contains the payload that's DER-encoded
192 * \retval #MBEDTLS_ERR_X509_INVALID_NAME if \p s does not contain
202 static int parse_attribute_value_hex_der_encoded(const char *s, in parse_attribute_value_hex_der_encoded() argument
223 /* Avoid empty-buffer shenanigans. A valid DER encoding is never in parse_attribute_value_hex_der_encoded()
235 int c = hexpair_to_int(s + 2 * i); in parse_attribute_value_hex_der_encoded()
285 const char *s = name, *c = s; in mbedtls_x509_string_to_names() local
286 const char *end = s + strlen(s); in mbedtls_x509_string_to_names()
300 if ((attr_descr = x509_attr_descr_from_name(s, (size_t) (c - s))) == NULL) { in mbedtls_x509_string_to_names()
301 if ((mbedtls_oid_from_numeric_string(&oid, s, (size_t) (c - s))) != 0) { in mbedtls_x509_string_to_names()
307 oid.len = strlen(attr_descr->oid); in mbedtls_x509_string_to_names()
309 memcpy(oid.p, attr_descr->oid, oid.len); in mbedtls_x509_string_to_names()
313 s = c + 1; in mbedtls_x509_string_to_names()
317 if (!in_attr_type && ((*c == ',' && *(c-1) != '\\') || c == end)) { in mbedtls_x509_string_to_names()
318 if (s == c) { in mbedtls_x509_string_to_names()
321 } else if (*s == '#') { in mbedtls_x509_string_to_names()
322 /* We know that c >= s (loop invariant) and c != s (in this in mbedtls_x509_string_to_names()
323 * else branch), hence c - s - 1 >= 0. */ in mbedtls_x509_string_to_names()
325 s + 1, (size_t) (c - s) - 1, in mbedtls_x509_string_to_names()
337 parse_attribute_value_string(s, (int) (c - s), data, in mbedtls_x509_string_to_names()
342 tag = attr_descr->default_tag; in mbedtls_x509_string_to_names()
357 cur->val.tag = tag; in mbedtls_x509_string_to_names()
363 s = c + 1; in mbedtls_x509_string_to_names()
385 if (val_len > (SIZE_MAX - 1)) { in mbedtls_x509_set_extension()
394 cur->val.p[0] = critical; in mbedtls_x509_set_extension()
395 memcpy(cur->val.p + 1, val, val_len); in mbedtls_x509_set_extension()
418 const char *oid = (const char *) cur_name->oid.p; in x509_write_name()
419 size_t oid_len = cur_name->oid.len; in x509_write_name()
420 const unsigned char *name = cur_name->val.p; in x509_write_name()
421 size_t name_len = cur_name->val.len; in x509_write_name()
425 cur_name->val.tag, in x509_write_name()
455 cur = cur->next; in mbedtls_x509_write_names()
474 if (*p < start || (size_t) (*p - start) < size) { in mbedtls_x509_write_sig()
479 (*p) -= len; in mbedtls_x509_write_sig()
482 if (*p - start < 1) { in mbedtls_x509_write_sig()
486 *--(*p) = 0; in mbedtls_x509_write_sig()
496 * The AlgorithmIdentifier's parameters field must be absent for DSA/ECDSA signature in mbedtls_x509_write_sig()
497 * algorithms, see https://www.rfc-editor.org/rfc/rfc5480#page-17 and in mbedtls_x509_write_sig()
498 * https://www.rfc-editor.org/rfc/rfc5758#section-3. in mbedtls_x509_write_sig()
517 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_raw_buffer(p, start, ext->val.p + 1, in x509_write_extension()
518 ext->val.len - 1)); in x509_write_extension()
519 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, ext->val.len - 1)); in x509_write_extension()
522 if (ext->val.p[0] != 0) { in x509_write_extension()
526 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_raw_buffer(p, start, ext->oid.p, in x509_write_extension()
527 ext->oid.len)); in x509_write_extension()
528 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, ext->oid.len)); in x509_write_extension()
543 * -- contains the DER encoding of an ASN.1 value
544 * -- corresponding to the extension type identified
545 * -- by extnID
557 cur_ext = cur_ext->next; in mbedtls_x509_write_extensions()