Lines Matching refs:p

183 static int pk_get_ecparams( unsigned char **p, const unsigned char *end,  in pk_get_ecparams()  argument
188 if ( end - *p < 1 ) in pk_get_ecparams()
193 params->tag = **p; in pk_get_ecparams()
204 if( ( ret = mbedtls_asn1_get_tag( p, end, &params->len, params->tag ) ) != 0 ) in pk_get_ecparams()
209 params->p = *p; in pk_get_ecparams()
210 *p += params->len; in pk_get_ecparams()
212 if( *p != end ) in pk_get_ecparams()
242 unsigned char *p = params->p; in pk_group_from_specified() local
243 const unsigned char * const end = params->p + params->len; in pk_group_from_specified()
249 if( ( ret = mbedtls_asn1_get_int( &p, end, &ver ) ) != 0 ) in pk_group_from_specified()
261 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_group_from_specified()
265 end_field = p + len; in pk_group_from_specified()
275 if( ( ret = mbedtls_asn1_get_tag( &p, end_field, &len, MBEDTLS_ASN1_OID ) ) != 0 ) in pk_group_from_specified()
279 memcmp( p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len ) != 0 ) in pk_group_from_specified()
284 p += len; in pk_group_from_specified()
287 if( ( ret = mbedtls_asn1_get_mpi( &p, end_field, &grp->P ) ) != 0 ) in pk_group_from_specified()
292 if( p != end_field ) in pk_group_from_specified()
305 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_group_from_specified()
309 end_curve = p + len; in pk_group_from_specified()
315 if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 || in pk_group_from_specified()
316 ( ret = mbedtls_mpi_read_binary( &grp->A, p, len ) ) != 0 ) in pk_group_from_specified()
321 p += len; in pk_group_from_specified()
323 if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 || in pk_group_from_specified()
324 ( ret = mbedtls_mpi_read_binary( &grp->B, p, len ) ) != 0 ) in pk_group_from_specified()
329 p += len; in pk_group_from_specified()
332 if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_BIT_STRING ) ) == 0 ) in pk_group_from_specified()
333 p += len; in pk_group_from_specified()
335 if( p != end_curve ) in pk_group_from_specified()
342 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) in pk_group_from_specified()
346 ( const unsigned char *) p, len ) ) != 0 ) in pk_group_from_specified()
353 ( p[0] != 0x02 && p[0] != 0x03 ) || in pk_group_from_specified()
355 mbedtls_mpi_read_binary( &grp->G.X, p + 1, len - 1 ) != 0 || in pk_group_from_specified()
356 mbedtls_mpi_lset( &grp->G.Y, p[0] - 2 ) != 0 || in pk_group_from_specified()
363 p += len; in pk_group_from_specified()
368 if( ( ret = mbedtls_asn1_get_mpi( &p, end, &grp->N ) ) != 0 ) in pk_group_from_specified()
495 static int pk_get_ecpubkey( unsigned char **p, const unsigned char *end, in pk_get_ecpubkey() argument
501 (const unsigned char *) *p, end - *p ) ) == 0 ) in pk_get_ecpubkey()
509 *p = (unsigned char *) end; in pk_get_ecpubkey()
522 static int pk_get_rsapubkey( unsigned char **p, in pk_get_rsapubkey() argument
529 if( ( ret = mbedtls_asn1_get_tag( p, end, &len, in pk_get_rsapubkey()
533 if( *p + len != end ) in pk_get_rsapubkey()
538 if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 ) in pk_get_rsapubkey()
541 if( ( ret = mbedtls_rsa_import_raw( rsa, *p, len, NULL, 0, NULL, 0, in pk_get_rsapubkey()
545 *p += len; in pk_get_rsapubkey()
548 if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 ) in pk_get_rsapubkey()
552 NULL, 0, *p, len ) ) != 0 ) in pk_get_rsapubkey()
555 *p += len; in pk_get_rsapubkey()
563 if( *p != end ) in pk_get_rsapubkey()
577 static int pk_get_pk_alg( unsigned char **p, in pk_get_pk_alg() argument
586 if( ( ret = mbedtls_asn1_get_alg( p, end, &alg_oid, params ) ) != 0 ) in pk_get_pk_alg()
610 int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end, in mbedtls_pk_parse_subpubkey() argument
619 PK_VALIDATE_RET( p != NULL ); in mbedtls_pk_parse_subpubkey()
620 PK_VALIDATE_RET( *p != NULL ); in mbedtls_pk_parse_subpubkey()
624 if( ( ret = mbedtls_asn1_get_tag( p, end, &len, in mbedtls_pk_parse_subpubkey()
630 end = *p + len; in mbedtls_pk_parse_subpubkey()
632 if( ( ret = pk_get_pk_alg( p, end, &pk_alg, &alg_params ) ) != 0 ) in mbedtls_pk_parse_subpubkey()
635 if( ( ret = mbedtls_asn1_get_bitstring_null( p, end, &len ) ) != 0 ) in mbedtls_pk_parse_subpubkey()
638 if( *p + len != end ) in mbedtls_pk_parse_subpubkey()
651 ret = pk_get_rsapubkey( p, end, mbedtls_pk_rsa( *pk ) ); in mbedtls_pk_parse_subpubkey()
659 ret = pk_get_ecpubkey( p, end, mbedtls_pk_ec( *pk ) ); in mbedtls_pk_parse_subpubkey()
664 if( ret == 0 && *p != end ) in mbedtls_pk_parse_subpubkey()
685 static int asn1_get_nonzero_mpi( unsigned char **p, in asn1_get_nonzero_mpi() argument
691 ret = mbedtls_asn1_get_mpi( p, end, X ); in asn1_get_nonzero_mpi()
710 unsigned char *p, *end; in pk_parse_key_pkcs1_der() local
715 p = (unsigned char *) key; in pk_parse_key_pkcs1_der()
716 end = p + keylen; in pk_parse_key_pkcs1_der()
734 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_parse_key_pkcs1_der()
740 end = p + len; in pk_parse_key_pkcs1_der()
742 if( ( ret = mbedtls_asn1_get_int( &p, end, &version ) ) != 0 ) in pk_parse_key_pkcs1_der()
753 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
759 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
765 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
771 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
777 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
795 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
800 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
805 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
811 if( ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
812 ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 || in pk_parse_key_pkcs1_der()
813 ( ret = asn1_get_nonzero_mpi( &p, end, &T ) ) != 0 ) in pk_parse_key_pkcs1_der()
832 if( p != end ) in pk_parse_key_pkcs1_der()
869 unsigned char *p = (unsigned char *) key; in pk_parse_key_sec1_der() local
870 unsigned char *end = p + keylen; in pk_parse_key_sec1_der()
883 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_parse_key_sec1_der()
889 end = p + len; in pk_parse_key_sec1_der()
891 if( ( ret = mbedtls_asn1_get_int( &p, end, &version ) ) != 0 ) in pk_parse_key_sec1_der()
897 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) in pk_parse_key_sec1_der()
900 if( ( ret = mbedtls_mpi_read_binary( &eck->d, p, len ) ) != 0 ) in pk_parse_key_sec1_der()
906 p += len; in pk_parse_key_sec1_der()
909 if( p != end ) in pk_parse_key_sec1_der()
914 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_parse_key_sec1_der()
917 if( ( ret = pk_get_ecparams( &p, p + len, &params) ) != 0 || in pk_parse_key_sec1_der()
931 if( p != end ) in pk_parse_key_sec1_der()
937 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_parse_key_sec1_der()
940 end2 = p + len; in pk_parse_key_sec1_der()
942 if( ( ret = mbedtls_asn1_get_bitstring_null( &p, end2, &len ) ) != 0 ) in pk_parse_key_sec1_der()
945 if( p + len != end2 ) in pk_parse_key_sec1_der()
949 if( ( ret = pk_get_ecpubkey( &p, end2, eck ) ) == 0 ) in pk_parse_key_sec1_der()
1007 unsigned char *p = (unsigned char *) key; in pk_parse_key_pkcs8_unencrypted_der() local
1008 unsigned char *end = p + keylen; in pk_parse_key_pkcs8_unencrypted_der()
1028 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_parse_key_pkcs8_unencrypted_der()
1034 end = p + len; in pk_parse_key_pkcs8_unencrypted_der()
1036 if( ( ret = mbedtls_asn1_get_int( &p, end, &version ) ) != 0 ) in pk_parse_key_pkcs8_unencrypted_der()
1042 if( ( ret = pk_get_pk_alg( &p, end, &pk_alg, &params ) ) != 0 ) in pk_parse_key_pkcs8_unencrypted_der()
1047 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) in pk_parse_key_pkcs8_unencrypted_der()
1063 if( ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ), p, len ) ) != 0 ) in pk_parse_key_pkcs8_unencrypted_der()
1074 ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), p, len ) ) != 0 ) in pk_parse_key_pkcs8_unencrypted_der()
1104 unsigned char *p, *end; in pk_parse_key_pkcs8_encrypted_der() local
1111 p = key; in pk_parse_key_pkcs8_encrypted_der()
1112 end = p + keylen; in pk_parse_key_pkcs8_encrypted_der()
1132 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, in pk_parse_key_pkcs8_encrypted_der()
1138 end = p + len; in pk_parse_key_pkcs8_encrypted_der()
1140 if( ( ret = mbedtls_asn1_get_alg( &p, end, &pbe_alg_oid, &pbe_params ) ) != 0 ) in pk_parse_key_pkcs8_encrypted_der()
1143 if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) in pk_parse_key_pkcs8_encrypted_der()
1146 buf = p; in pk_parse_key_pkcs8_encrypted_der()
1156 pwd, pwdlen, p, len, buf ) ) != 0 ) in pk_parse_key_pkcs8_encrypted_der()
1171 p, len, buf ) ) != 0 ) in pk_parse_key_pkcs8_encrypted_der()
1190 p, len, buf ) ) != 0 ) in pk_parse_key_pkcs8_encrypted_der()
1436 unsigned char *p; in mbedtls_pk_parse_public_key() local
1464 p = pem.buf; in mbedtls_pk_parse_public_key()
1471 if ( ( ret = pk_get_rsapubkey( &p, p + pem.buflen, mbedtls_pk_rsa( *ctx ) ) ) != 0 ) in mbedtls_pk_parse_public_key()
1498 p = pem.buf; in mbedtls_pk_parse_public_key()
1500 ret = mbedtls_pk_parse_subpubkey( &p, p + pem.buflen, ctx ); in mbedtls_pk_parse_public_key()
1519 p = (unsigned char *)key; in mbedtls_pk_parse_public_key()
1520 ret = pk_get_rsapubkey( &p, p + keylen, mbedtls_pk_rsa( *ctx ) ); in mbedtls_pk_parse_public_key()
1532 p = (unsigned char *) key; in mbedtls_pk_parse_public_key()
1534 ret = mbedtls_pk_parse_subpubkey( &p, p + keylen, ctx ); in mbedtls_pk_parse_public_key()