mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-03 07:27:23 +00:00
x509: make profile checking functions internally available
Following functions - x509_profile_check_md_alg - x509_profile_check_pk_alg are made non-static and moved to x509_internal.h so that other library files can used them. Signed-off-by: Valerio Setti <[email protected]>
This commit is contained in:
+9
-17
@@ -167,12 +167,8 @@ const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_none =
|
|||||||
(uint32_t) -1,
|
(uint32_t) -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
int mbedtls_x509_profile_check_md_alg(const mbedtls_x509_crt_profile *profile,
|
||||||
* Check md_alg against profile
|
mbedtls_md_type_t md_alg)
|
||||||
* Return 0 if md_alg is acceptable for this profile, -1 otherwise
|
|
||||||
*/
|
|
||||||
static int x509_profile_check_md_alg(const mbedtls_x509_crt_profile *profile,
|
|
||||||
mbedtls_md_type_t md_alg)
|
|
||||||
{
|
{
|
||||||
if (md_alg == MBEDTLS_MD_NONE) {
|
if (md_alg == MBEDTLS_MD_NONE) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -185,12 +181,8 @@ static int x509_profile_check_md_alg(const mbedtls_x509_crt_profile *profile,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int mbedtls_x509_profile_check_pk_alg(const mbedtls_x509_crt_profile *profile,
|
||||||
* Check pk_alg against profile
|
mbedtls_pk_sigalg_t pk_alg)
|
||||||
* Return 0 if pk_alg is acceptable for this profile, -1 otherwise
|
|
||||||
*/
|
|
||||||
static int x509_profile_check_pk_alg(const mbedtls_x509_crt_profile *profile,
|
|
||||||
mbedtls_pk_sigalg_t pk_alg)
|
|
||||||
{
|
{
|
||||||
if (pk_alg == MBEDTLS_PK_SIGALG_NONE) {
|
if (pk_alg == MBEDTLS_PK_SIGALG_NONE) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -2050,11 +2042,11 @@ static int x509_crt_verifycrl(mbedtls_x509_crt *crt, mbedtls_x509_crt *ca,
|
|||||||
/*
|
/*
|
||||||
* Check if CRL is correctly signed by the trusted CA
|
* Check if CRL is correctly signed by the trusted CA
|
||||||
*/
|
*/
|
||||||
if (x509_profile_check_md_alg(profile, crl_list->sig_md) != 0) {
|
if (mbedtls_x509_profile_check_md_alg(profile, crl_list->sig_md) != 0) {
|
||||||
flags |= MBEDTLS_X509_BADCRL_BAD_MD;
|
flags |= MBEDTLS_X509_BADCRL_BAD_MD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x509_profile_check_pk_alg(profile, crl_list->sig_pk) != 0) {
|
if (mbedtls_x509_profile_check_pk_alg(profile, crl_list->sig_pk) != 0) {
|
||||||
flags |= MBEDTLS_X509_BADCRL_BAD_PK;
|
flags |= MBEDTLS_X509_BADCRL_BAD_PK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2563,11 +2555,11 @@ static int x509_crt_verify_chain(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check signature algorithm: MD & PK algs */
|
/* Check signature algorithm: MD & PK algs */
|
||||||
if (x509_profile_check_md_alg(profile, child->sig_md) != 0) {
|
if (mbedtls_x509_profile_check_md_alg(profile, child->sig_md) != 0) {
|
||||||
*flags |= MBEDTLS_X509_BADCERT_BAD_MD;
|
*flags |= MBEDTLS_X509_BADCERT_BAD_MD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x509_profile_check_pk_alg(profile, child->sig_pk) != 0) {
|
if (mbedtls_x509_profile_check_pk_alg(profile, child->sig_pk) != 0) {
|
||||||
*flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
*flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3075,7 +3067,7 @@ static int x509_crt_verify_restartable_ca_cb(mbedtls_x509_crt *crt,
|
|||||||
/* Check the type and size of the key */
|
/* Check the type and size of the key */
|
||||||
pk_type = mbedtls_pk_get_type(&crt->pk);
|
pk_type = mbedtls_pk_get_type(&crt->pk);
|
||||||
|
|
||||||
if (x509_profile_check_pk_alg(profile, (mbedtls_pk_sigalg_t) pk_type) != 0) {
|
if (mbedtls_x509_profile_check_pk_alg(profile, (mbedtls_pk_sigalg_t) pk_type) != 0) {
|
||||||
ee_flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
ee_flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "mbedtls/private_access.h"
|
#include "mbedtls/private_access.h"
|
||||||
|
|
||||||
#include "mbedtls/x509.h"
|
#include "mbedtls/x509.h"
|
||||||
|
#include "mbedtls/x509_crt.h"
|
||||||
#include "mbedtls/asn1.h"
|
#include "mbedtls/asn1.h"
|
||||||
|
|
||||||
#include "pk_internal.h" // for a lot of things, including in SSL
|
#include "pk_internal.h" // for a lot of things, including in SSL
|
||||||
@@ -79,4 +80,18 @@ int mbedtls_x509_info_key_usage(char **buf, size_t *size,
|
|||||||
int mbedtls_x509_write_set_san_common(mbedtls_asn1_named_data **extensions,
|
int mbedtls_x509_write_set_san_common(mbedtls_asn1_named_data **extensions,
|
||||||
const mbedtls_x509_san_list *san_list);
|
const mbedtls_x509_san_list *san_list);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check md_alg against profile
|
||||||
|
* Return 0 if md_alg is acceptable for this profile, -1 otherwise
|
||||||
|
*/
|
||||||
|
int mbedtls_x509_profile_check_md_alg(const mbedtls_x509_crt_profile *profile,
|
||||||
|
mbedtls_md_type_t md_alg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check pk_alg against profile
|
||||||
|
* Return 0 if pk_alg is acceptable for this profile, -1 otherwise
|
||||||
|
*/
|
||||||
|
int mbedtls_x509_profile_check_pk_alg(const mbedtls_x509_crt_profile *profile,
|
||||||
|
mbedtls_pk_sigalg_t pk_alg);
|
||||||
|
|
||||||
#endif /* MBEDTLS_X509_INTERNAL_H */
|
#endif /* MBEDTLS_X509_INTERNAL_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user