Switch pkparse to use new mbedtls_pkcs12_pbe_ext function

Switch pkparse to use new mbedtls_pkcs12_pbe_ext function
and deprecate mbedtls_pkcs12_pbe function.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
diff --git a/library/pkcs12.c b/library/pkcs12.c
index ad0f9e6..dd3a240 100644
--- a/library/pkcs12.c
+++ b/library/pkcs12.c
@@ -138,6 +138,7 @@
                            size_t *output_len);
 #endif
 
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
 int mbedtls_pkcs12_pbe(mbedtls_asn1_buf *pbe_params, int mode,
                        mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type,
                        const unsigned char *pwd,  size_t pwdlen,
@@ -154,6 +155,7 @@
                                   pwd, pwdlen, data, len, output, SIZE_MAX,
                                   &output_len);
 }
+#endif
 
 int mbedtls_pkcs12_pbe_ext(mbedtls_asn1_buf *pbe_params, int mode,
                            mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type,
diff --git a/library/pkparse.c b/library/pkparse.c
index 188cc28..9a8c7ee 100644
--- a/library/pkparse.c
+++ b/library/pkparse.c
@@ -1417,13 +1417,12 @@
 #endif /* MBEDTLS_PK_HAVE_ECC_KEYS */
     return MBEDTLS_ERR_PK_UNKNOWN_PK_ALG;
 
-#if !defined(MBEDTLS_PKCS12_C)
     end = p + len;
     if (end != (key + keylen)) {
         return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT,
                                  MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
     }
-#endif
+
     return 0;
 }
 
@@ -1498,16 +1497,16 @@
      */
 #if defined(MBEDTLS_PKCS12_C)
     if (mbedtls_oid_get_pkcs12_pbe_alg(&pbe_alg_oid, &md_alg, &cipher_alg) == 0) {
-        if ((ret = mbedtls_pkcs12_pbe(&pbe_params, MBEDTLS_PKCS12_PBE_DECRYPT,
+        if ((ret = mbedtls_pkcs12_pbe_ext(&pbe_params, MBEDTLS_PKCS12_PBE_DECRYPT,
                                       cipher_alg, md_alg,
-                                      pwd, pwdlen, p, len, buf)) != 0) {
+                                      pwd, pwdlen, p, len, buf, len, &outlen)) != 0) {
             if (ret == MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH) {
                 return MBEDTLS_ERR_PK_PASSWORD_MISMATCH;
             }
 
             return ret;
         }
-        outlen = len;
+
         decrypted = 1;
     } else
 #endif /* MBEDTLS_PKCS12_C */