Lines Matching refs:p
167 static int pk_get_ecparams(unsigned char **p, const unsigned char *end, in pk_get_ecparams() argument
172 if (end - *p < 1) { in pk_get_ecparams()
178 params->tag = **p; in pk_get_ecparams()
188 if ((ret = mbedtls_asn1_get_tag(p, end, ¶ms->len, params->tag)) != 0) { in pk_get_ecparams()
192 params->p = *p; in pk_get_ecparams()
193 *p += params->len; in pk_get_ecparams()
195 if (*p != end) { in pk_get_ecparams()
226 unsigned char *p = params->p; in pk_group_from_specified() local
227 const unsigned char * const end = params->p + params->len; in pk_group_from_specified()
233 if ((ret = mbedtls_asn1_get_int(&p, end, &ver)) != 0) { in pk_group_from_specified()
247 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_group_from_specified()
252 end_field = p + len; in pk_group_from_specified()
262 if ((ret = mbedtls_asn1_get_tag(&p, end_field, &len, MBEDTLS_ASN1_OID)) != 0) { in pk_group_from_specified()
267 memcmp(p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len) != 0) { in pk_group_from_specified()
271 p += len; in pk_group_from_specified()
274 if ((ret = mbedtls_asn1_get_mpi(&p, end_field, &grp->P)) != 0) { in pk_group_from_specified()
280 if (p != end_field) { in pk_group_from_specified()
294 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_group_from_specified()
299 end_curve = p + len; in pk_group_from_specified()
305 if ((ret = mbedtls_asn1_get_tag(&p, end_curve, &len, MBEDTLS_ASN1_OCTET_STRING)) != 0 || in pk_group_from_specified()
306 (ret = mbedtls_mpi_read_binary(&grp->A, p, len)) != 0) { in pk_group_from_specified()
310 p += len; in pk_group_from_specified()
312 if ((ret = mbedtls_asn1_get_tag(&p, end_curve, &len, MBEDTLS_ASN1_OCTET_STRING)) != 0 || in pk_group_from_specified()
313 (ret = mbedtls_mpi_read_binary(&grp->B, p, len)) != 0) { in pk_group_from_specified()
317 p += len; in pk_group_from_specified()
320 if ((ret = mbedtls_asn1_get_tag(&p, end_curve, &len, MBEDTLS_ASN1_BIT_STRING)) == 0) { in pk_group_from_specified()
321 p += len; in pk_group_from_specified()
324 if (p != end_curve) { in pk_group_from_specified()
332 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OCTET_STRING)) != 0) { in pk_group_from_specified()
337 (const unsigned char *) p, len)) != 0) { in pk_group_from_specified()
343 (p[0] != 0x02 && p[0] != 0x03) || in pk_group_from_specified()
345 mbedtls_mpi_read_binary(&grp->G.X, p + 1, len - 1) != 0 || in pk_group_from_specified()
346 mbedtls_mpi_lset(&grp->G.Y, p[0] - 2) != 0 || in pk_group_from_specified()
352 p += len; in pk_group_from_specified()
357 if ((ret = mbedtls_asn1_get_mpi(&p, end, &grp->N)) != 0) { in pk_group_from_specified()
497 static int pk_get_ecpubkey(unsigned char **p, const unsigned char *end, in pk_get_ecpubkey() argument
503 (const unsigned char *) *p, end - *p)) == 0) { in pk_get_ecpubkey()
510 *p = (unsigned char *) end; in pk_get_ecpubkey()
523 static int pk_get_rsapubkey(unsigned char **p, in pk_get_rsapubkey() argument
530 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in pk_get_rsapubkey()
535 if (*p + len != end) { in pk_get_rsapubkey()
541 if ((ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_INTEGER)) != 0) { in pk_get_rsapubkey()
545 if ((ret = mbedtls_rsa_import_raw(rsa, *p, len, NULL, 0, NULL, 0, in pk_get_rsapubkey()
550 *p += len; in pk_get_rsapubkey()
553 if ((ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_INTEGER)) != 0) { in pk_get_rsapubkey()
558 NULL, 0, *p, len)) != 0) { in pk_get_rsapubkey()
562 *p += len; in pk_get_rsapubkey()
569 if (*p != end) { in pk_get_rsapubkey()
584 static int pk_get_pk_alg(unsigned char **p, in pk_get_pk_alg() argument
593 if ((ret = mbedtls_asn1_get_alg(p, end, &alg_oid, params)) != 0) { in pk_get_pk_alg()
618 int mbedtls_pk_parse_subpubkey(unsigned char **p, const unsigned char *end, in mbedtls_pk_parse_subpubkey() argument
627 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in mbedtls_pk_parse_subpubkey()
632 end = *p + len; in mbedtls_pk_parse_subpubkey()
634 if ((ret = pk_get_pk_alg(p, end, &pk_alg, &alg_params)) != 0) { in mbedtls_pk_parse_subpubkey()
638 if ((ret = mbedtls_asn1_get_bitstring_null(p, end, &len)) != 0) { in mbedtls_pk_parse_subpubkey()
642 if (*p + len != end) { in mbedtls_pk_parse_subpubkey()
657 ret = pk_get_rsapubkey(p, end, mbedtls_pk_rsa(*pk)); in mbedtls_pk_parse_subpubkey()
664 ret = pk_get_ecpubkey(p, end, mbedtls_pk_ec(*pk)); in mbedtls_pk_parse_subpubkey()
670 if (ret == 0 && *p != end) { in mbedtls_pk_parse_subpubkey()
693 static int asn1_get_nonzero_mpi(unsigned char **p, in asn1_get_nonzero_mpi() argument
699 ret = mbedtls_asn1_get_mpi(p, end, X); in asn1_get_nonzero_mpi()
720 unsigned char *p, *end; in pk_parse_key_pkcs1_der() local
725 p = (unsigned char *) key; in pk_parse_key_pkcs1_der()
726 end = p + keylen; in pk_parse_key_pkcs1_der()
744 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_parse_key_pkcs1_der()
749 end = p + len; in pk_parse_key_pkcs1_der()
751 if ((ret = mbedtls_asn1_get_int(&p, end, &version)) != 0) { in pk_parse_key_pkcs1_der()
760 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
767 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
774 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
781 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
788 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
807 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
813 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
819 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
826 if ((ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
827 (ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0 || in pk_parse_key_pkcs1_der()
828 (ret = asn1_get_nonzero_mpi(&p, end, &T)) != 0) { in pk_parse_key_pkcs1_der()
847 if (p != end) { in pk_parse_key_pkcs1_der()
883 unsigned char *p = (unsigned char *) key; in pk_parse_key_sec1_der() local
884 unsigned char *end = p + keylen; in pk_parse_key_sec1_der()
897 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_parse_key_sec1_der()
902 end = p + len; in pk_parse_key_sec1_der()
904 if ((ret = mbedtls_asn1_get_int(&p, end, &version)) != 0) { in pk_parse_key_sec1_der()
912 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OCTET_STRING)) != 0) { in pk_parse_key_sec1_der()
916 if ((ret = mbedtls_mpi_read_binary(&eck->d, p, len)) != 0) { in pk_parse_key_sec1_der()
921 p += len; in pk_parse_key_sec1_der()
924 if (p != end) { in pk_parse_key_sec1_der()
928 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_parse_key_sec1_der()
931 if ((ret = pk_get_ecparams(&p, p + len, ¶ms)) != 0 || in pk_parse_key_sec1_der()
942 if (p != end) { in pk_parse_key_sec1_der()
947 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_parse_key_sec1_der()
950 end2 = p + len; in pk_parse_key_sec1_der()
952 if ((ret = mbedtls_asn1_get_bitstring_null(&p, end2, &len)) != 0) { in pk_parse_key_sec1_der()
956 if (p + len != end2) { in pk_parse_key_sec1_der()
961 if ((ret = pk_get_ecpubkey(&p, end2, eck)) == 0) { in pk_parse_key_sec1_der()
1015 unsigned char *p = (unsigned char *) key; in pk_parse_key_pkcs8_unencrypted_der() local
1016 unsigned char *end = p + keylen; in pk_parse_key_pkcs8_unencrypted_der()
1041 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_parse_key_pkcs8_unencrypted_der()
1046 end = p + len; in pk_parse_key_pkcs8_unencrypted_der()
1048 if ((ret = mbedtls_asn1_get_int(&p, end, &version)) != 0) { in pk_parse_key_pkcs8_unencrypted_der()
1056 if ((ret = pk_get_pk_alg(&p, end, &pk_alg, ¶ms)) != 0) { in pk_parse_key_pkcs8_unencrypted_der()
1060 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OCTET_STRING)) != 0) { in pk_parse_key_pkcs8_unencrypted_der()
1079 if ((ret = pk_parse_key_pkcs1_der(mbedtls_pk_rsa(*pk), p, len)) != 0) { in pk_parse_key_pkcs8_unencrypted_der()
1088 (ret = pk_parse_key_sec1_der(mbedtls_pk_ec(*pk), p, len, f_rng, p_rng)) != 0) { in pk_parse_key_pkcs8_unencrypted_der()
1118 unsigned char *p, *end; in pk_parse_key_pkcs8_encrypted_der() local
1125 p = key; in pk_parse_key_pkcs8_encrypted_der()
1126 end = p + keylen; in pk_parse_key_pkcs8_encrypted_der()
1147 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, in pk_parse_key_pkcs8_encrypted_der()
1152 end = p + len; in pk_parse_key_pkcs8_encrypted_der()
1154 if ((ret = mbedtls_asn1_get_alg(&p, end, &pbe_alg_oid, &pbe_params)) != 0) { in pk_parse_key_pkcs8_encrypted_der()
1158 if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OCTET_STRING)) != 0) { in pk_parse_key_pkcs8_encrypted_der()
1162 buf = p; in pk_parse_key_pkcs8_encrypted_der()
1171 pwd, pwdlen, p, len, buf)) != 0) { in pk_parse_key_pkcs8_encrypted_der()
1185 p, len, buf)) != 0) { in pk_parse_key_pkcs8_encrypted_der()
1425 unsigned char *p; in mbedtls_pk_parse_public_key() local
1452 p = pem.buf; in mbedtls_pk_parse_public_key()
1463 if ((ret = pk_get_rsapubkey(&p, p + pem.buflen, mbedtls_pk_rsa(*ctx))) != 0) { in mbedtls_pk_parse_public_key()
1489 p = pem.buf; in mbedtls_pk_parse_public_key()
1491 ret = mbedtls_pk_parse_subpubkey(&p, p + pem.buflen, ctx); in mbedtls_pk_parse_public_key()
1510 p = (unsigned char *) key; in mbedtls_pk_parse_public_key()
1511 ret = pk_get_rsapubkey(&p, p + keylen, mbedtls_pk_rsa(*ctx)); in mbedtls_pk_parse_public_key()
1521 p = (unsigned char *) key; in mbedtls_pk_parse_public_key()
1523 ret = mbedtls_pk_parse_subpubkey(&p, p + keylen, ctx); in mbedtls_pk_parse_public_key()