Lines Matching refs:p

40 static int pkcs7_get_next_content_len(unsigned char **p, unsigned char *end,  in pkcs7_get_next_content_len()  argument
45 ret = mbedtls_asn1_get_tag(p, end, len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_next_content_len()
49 } else if ((size_t) (end - *p) != *len) { in pkcs7_get_next_content_len()
61 static int pkcs7_get_version(unsigned char **p, unsigned char *end, int *ver) in pkcs7_get_version() argument
65 ret = mbedtls_asn1_get_int(p, end, ver); in pkcs7_get_version()
84 static int pkcs7_get_content_info_type(unsigned char **p, unsigned char *end, in pkcs7_get_content_info_type() argument
90 unsigned char *start = *p; in pkcs7_get_content_info_type()
92 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_content_info_type()
95 *p = start; in pkcs7_get_content_info_type()
98 *seq_end = *p + len; in pkcs7_get_content_info_type()
99 ret = mbedtls_asn1_get_tag(p, *seq_end, &len, MBEDTLS_ASN1_OID); in pkcs7_get_content_info_type()
101 *p = start; in pkcs7_get_content_info_type()
107 pkcs7->p = *p; in pkcs7_get_content_info_type()
108 *p += len; in pkcs7_get_content_info_type()
118 static int pkcs7_get_digest_algorithm(unsigned char **p, unsigned char *end, in pkcs7_get_digest_algorithm() argument
123 if ((ret = mbedtls_asn1_get_alg_null(p, end, alg)) != 0) { in pkcs7_get_digest_algorithm()
133 static int pkcs7_get_digest_algorithm_set(unsigned char **p, in pkcs7_get_digest_algorithm_set() argument
140 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_digest_algorithm_set()
146 end = *p + len; in pkcs7_get_digest_algorithm_set()
148 ret = mbedtls_asn1_get_alg_null(p, end, alg); in pkcs7_get_digest_algorithm_set()
154 if (*p != end) { in pkcs7_get_digest_algorithm_set()
170 static int pkcs7_get_certificates(unsigned char **p, unsigned char *end, in pkcs7_get_certificates() argument
178 ret = mbedtls_asn1_get_tag(p, end, &len1, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_certificates()
186 start = *p; in pkcs7_get_certificates()
187 end_set = *p + len1; in pkcs7_get_certificates()
189 ret = mbedtls_asn1_get_tag(p, end_set, &len2, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_certificates()
195 end_cert = *p + len2; in pkcs7_get_certificates()
211 *p = end_cert; in pkcs7_get_certificates()
223 static int pkcs7_get_signature(unsigned char **p, unsigned char *end, in pkcs7_get_signature() argument
229 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_OCTET_STRING); in pkcs7_get_signature()
236 signature->p = *p; in pkcs7_get_signature()
238 *p = *p + len; in pkcs7_get_signature()
277 static int pkcs7_get_signer_info(unsigned char **p, unsigned char *end, in pkcs7_get_signer_info() argument
285 asn1_ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_signer_info()
291 end_signer = *p + len; in pkcs7_get_signer_info()
293 ret = pkcs7_get_version(p, end_signer, &signer->version); in pkcs7_get_signer_info()
298 asn1_ret = mbedtls_asn1_get_tag(p, end_signer, &len, in pkcs7_get_signer_info()
304 end_issuer_and_sn = *p + len; in pkcs7_get_signer_info()
306 signer->issuer_raw.p = *p; in pkcs7_get_signer_info()
308 asn1_ret = mbedtls_asn1_get_tag(p, end_issuer_and_sn, &len, in pkcs7_get_signer_info()
314 ret = mbedtls_x509_get_name(p, *p + len, &signer->issuer); in pkcs7_get_signer_info()
319 signer->issuer_raw.len = *p - signer->issuer_raw.p; in pkcs7_get_signer_info()
321 ret = mbedtls_x509_get_serial(p, end_issuer_and_sn, &signer->serial); in pkcs7_get_signer_info()
327 if (*p != end_issuer_and_sn) { in pkcs7_get_signer_info()
332 ret = pkcs7_get_digest_algorithm(p, end_signer, &signer->alg_identifier); in pkcs7_get_signer_info()
340 memcmp(signer->alg_identifier.p, alg->p, alg->len) != 0) { in pkcs7_get_signer_info()
346 ret = pkcs7_get_digest_algorithm(p, end_signer, &signer->sig_alg_identifier); in pkcs7_get_signer_info()
351 ret = pkcs7_get_signature(p, end_signer, &signer->sig); in pkcs7_get_signer_info()
357 if (*p != end_signer) { in pkcs7_get_signer_info()
377 static int pkcs7_get_signers_info_set(unsigned char **p, unsigned char *end, in pkcs7_get_signers_info_set() argument
386 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_signers_info_set()
397 end_set = *p + len; in pkcs7_get_signers_info_set()
399 ret = pkcs7_get_signer_info(p, end_set, signers_set, digest_alg); in pkcs7_get_signers_info_set()
406 while (*p != end_set) { in pkcs7_get_signers_info_set()
414 ret = pkcs7_get_signer_info(p, end_set, signer, digest_alg); in pkcs7_get_signers_info_set()
454 unsigned char *p = buf; in pkcs7_get_signed_data() local
461 ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_signed_data()
467 if (p + len != end) { in pkcs7_get_signed_data()
473 ret = pkcs7_get_version(&p, end, &signed_data->version); in pkcs7_get_signed_data()
479 ret = pkcs7_get_digest_algorithm_set(&p, end, in pkcs7_get_signed_data()
492 ret = pkcs7_get_content_info_type(&p, end, &end_content_info, &content_type); in pkcs7_get_signed_data()
500 if (p != end_content_info) { in pkcs7_get_signed_data()
502 ret = mbedtls_asn1_get_tag(&p, in pkcs7_get_signed_data()
509 p += len; in pkcs7_get_signed_data()
510 if (p != end_content_info) { in pkcs7_get_signed_data()
519 ret = pkcs7_get_certificates(&p, end, &signed_data->certs); in pkcs7_get_signed_data()
535 ret = pkcs7_get_signers_info_set(&p, in pkcs7_get_signed_data()
546 if (p != end) { in pkcs7_get_signed_data()
556 unsigned char *p; in mbedtls_pkcs7_parse_der() local
566 pkcs7->raw.p = p = mbedtls_calloc(1, buflen); in mbedtls_pkcs7_parse_der()
567 if (pkcs7->raw.p == NULL) { in mbedtls_pkcs7_parse_der()
571 memcpy(p, buf, buflen); in mbedtls_pkcs7_parse_der()
573 end = p + buflen; in mbedtls_pkcs7_parse_der()
575 ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in mbedtls_pkcs7_parse_der()
582 if ((size_t) (end - p) != len) { in mbedtls_pkcs7_parse_der()
588 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OID)) != 0) { in mbedtls_pkcs7_parse_der()
592 p = pkcs7->raw.p; in mbedtls_pkcs7_parse_der()
597 if (MBEDTLS_OID_CMP_RAW(MBEDTLS_OID_PKCS7_SIGNED_DATA, p, len)) { in mbedtls_pkcs7_parse_der()
599 if (!MBEDTLS_OID_CMP_RAW(MBEDTLS_OID_PKCS7_DATA, p, len) in mbedtls_pkcs7_parse_der()
600 || !MBEDTLS_OID_CMP_RAW(MBEDTLS_OID_PKCS7_ENCRYPTED_DATA, p, len) in mbedtls_pkcs7_parse_der()
601 || !MBEDTLS_OID_CMP_RAW(MBEDTLS_OID_PKCS7_ENVELOPED_DATA, p, len) in mbedtls_pkcs7_parse_der()
602 || !MBEDTLS_OID_CMP_RAW(MBEDTLS_OID_PKCS7_SIGNED_AND_ENVELOPED_DATA, p, len) in mbedtls_pkcs7_parse_der()
603 || !MBEDTLS_OID_CMP_RAW(MBEDTLS_OID_PKCS7_DIGESTED_DATA, p, len)) { in mbedtls_pkcs7_parse_der()
613 p += len; in mbedtls_pkcs7_parse_der()
615 ret = pkcs7_get_next_content_len(&p, end, &len); in mbedtls_pkcs7_parse_der()
621 if (p + len != end) { in mbedtls_pkcs7_parse_der()
627 ret = pkcs7_get_signed_data(p, len, &pkcs7->signed_data); in mbedtls_pkcs7_parse_der()
710 signer->sig.p, signer->sig.len); in mbedtls_pkcs7_data_or_hash_verify()
752 if (pkcs7 == NULL || pkcs7->raw.p == NULL) { in mbedtls_pkcs7_free()
756 mbedtls_free(pkcs7->raw.p); in mbedtls_pkcs7_free()
770 pkcs7->raw.p = NULL; in mbedtls_pkcs7_free()