mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-23 04:26:46 -04:00
Switch library and tests to the x509_oid module
``` git grep -l -P 'mbedtls_oid_get_(?!numeric_string\b)' | xargs perl -i -pe 's/\bmbedtls_oid_get_(?!numeric_string\b)/mbedtls_x509_oid_get_/' ./framework/scripts/code_style.py --since HEAD~1 --fix ``` Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
d2fe51cfc4
commit
532e3ee104
@ -480,7 +480,7 @@ static int pkcs7_get_signed_data(unsigned char *buf, size_t buflen,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mbedtls_oid_get_md_alg(&signed_data->digest_alg_identifiers, &md_alg);
|
||||
ret = mbedtls_x509_oid_get_md_alg(&signed_data->digest_alg_identifiers, &md_alg);
|
||||
if (ret != 0) {
|
||||
return MBEDTLS_ERR_PKCS7_INVALID_ALG;
|
||||
}
|
||||
@ -659,7 +659,7 @@ static int mbedtls_pkcs7_data_or_hash_verify(mbedtls_pkcs7 *pkcs7,
|
||||
return MBEDTLS_ERR_PKCS7_CERT_DATE_INVALID;
|
||||
}
|
||||
|
||||
ret = mbedtls_oid_get_md_alg(&pkcs7->signed_data.digest_alg_identifiers, &md_alg);
|
||||
ret = mbedtls_x509_oid_get_md_alg(&pkcs7->signed_data.digest_alg_identifiers, &md_alg);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ static int x509_get_hash_alg(const mbedtls_x509_buf *alg, mbedtls_md_type_t *md_
|
||||
p += md_oid.len;
|
||||
|
||||
/* Get md_alg from md_oid */
|
||||
if ((ret = mbedtls_oid_get_md_alg(&md_oid, md_alg)) != 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_md_alg(&md_oid, md_alg)) != 0) {
|
||||
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_ALG, ret);
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ int mbedtls_x509_get_rsassa_pss_params(const mbedtls_x509_buf *params,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = mbedtls_oid_get_md_alg(&alg_id, md_alg)) != 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_md_alg(&alg_id, md_alg)) != 0) {
|
||||
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_ALG, ret);
|
||||
}
|
||||
|
||||
@ -719,7 +719,7 @@ int mbedtls_x509_get_sig_alg(const mbedtls_x509_buf *sig_oid, const mbedtls_x509
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if ((ret = mbedtls_oid_get_sig_alg(sig_oid, md_alg, pk_alg)) != 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_sig_alg(sig_oid, md_alg, pk_alg)) != 0) {
|
||||
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG, ret);
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
||||
(name->val.tag != MBEDTLS_ASN1_PRINTABLE_STRING) &&
|
||||
(name->val.tag != MBEDTLS_ASN1_IA5_STRING);
|
||||
|
||||
if ((ret = mbedtls_oid_get_attr_short_name(&name->oid, &short_name)) == 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_attr_short_name(&name->oid, &short_name)) == 0) {
|
||||
ret = mbedtls_snprintf(p, n, "%s=", short_name);
|
||||
} else {
|
||||
if ((ret = mbedtls_oid_get_numeric_string(p, n, &name->oid)) > 0) {
|
||||
@ -1044,7 +1044,7 @@ int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *si
|
||||
size_t n = size;
|
||||
const char *desc = NULL;
|
||||
|
||||
ret = mbedtls_oid_get_sig_alg_desc(sig_oid, &desc);
|
||||
ret = mbedtls_x509_oid_get_sig_alg_desc(sig_oid, &desc);
|
||||
if (ret != 0) {
|
||||
ret = mbedtls_snprintf(p, n, "???");
|
||||
} else {
|
||||
|
@ -926,7 +926,7 @@ static int x509_get_crt_ext(unsigned char **p,
|
||||
/*
|
||||
* Detect supported extensions
|
||||
*/
|
||||
ret = mbedtls_oid_get_x509_ext_type(&extn_oid, &ext_type);
|
||||
ret = mbedtls_x509_oid_get_x509_ext_type(&extn_oid, &ext_type);
|
||||
|
||||
if (ret != 0) {
|
||||
/* Give the callback (if any) a chance to handle the extension */
|
||||
@ -1692,7 +1692,7 @@ static int x509_info_ext_key_usage(char **buf, size_t *size,
|
||||
const char *sep = "";
|
||||
|
||||
while (cur != NULL) {
|
||||
if (mbedtls_oid_get_extended_key_usage(&cur->buf, &desc) != 0) {
|
||||
if (mbedtls_x509_oid_get_extended_key_usage(&cur->buf, &desc) != 0) {
|
||||
desc = "???";
|
||||
}
|
||||
|
||||
@ -1721,7 +1721,7 @@ static int x509_info_cert_policies(char **buf, size_t *size,
|
||||
const char *sep = "";
|
||||
|
||||
while (cur != NULL) {
|
||||
if (mbedtls_oid_get_certificate_policies(&cur->buf, &desc) != 0) {
|
||||
if (mbedtls_x509_oid_get_certificate_policies(&cur->buf, &desc) != 0) {
|
||||
desc = "???";
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ static int x509_csr_parse_extensions(mbedtls_x509_csr *csr,
|
||||
/*
|
||||
* Detect supported extensions and skip unsupported extensions
|
||||
*/
|
||||
ret = mbedtls_oid_get_x509_ext_type(&extn_oid, &ext_type);
|
||||
ret = mbedtls_x509_oid_get_x509_ext_type(&extn_oid, &ext_type);
|
||||
|
||||
if (ret != 0) {
|
||||
/* Give the callback (if any) a chance to handle the extension */
|
||||
|
@ -413,8 +413,8 @@ int mbedtls_x509write_crt_der(mbedtls_x509write_cert *ctx,
|
||||
return MBEDTLS_ERR_X509_INVALID_ALG;
|
||||
}
|
||||
|
||||
if ((ret = mbedtls_oid_get_oid_by_sig_alg(pk_alg, ctx->md_alg,
|
||||
&sig_oid, &sig_oid_len)) != 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_oid_by_sig_alg(pk_alg, ctx->md_alg,
|
||||
&sig_oid, &sig_oid_len)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,8 @@ static int x509write_csr_der_internal(mbedtls_x509write_csr *ctx,
|
||||
return MBEDTLS_ERR_X509_INVALID_ALG;
|
||||
}
|
||||
|
||||
if ((ret = mbedtls_oid_get_oid_by_sig_alg(pk_alg, ctx->md_alg,
|
||||
&sig_oid, &sig_oid_len)) != 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_oid_by_sig_alg(pk_alg, ctx->md_alg,
|
||||
&sig_oid, &sig_oid_len)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -105,42 +105,42 @@ oid_get_md_alg_id:"2b24030201":MBEDTLS_MD_RIPEMD160
|
||||
OID hash id - invalid oid
|
||||
oid_get_md_alg_id:"2B864886f70d0204":-1
|
||||
|
||||
mbedtls_oid_get_md_hmac - RIPEMD160
|
||||
mbedtls_x509_oid_get_md_hmac - RIPEMD160
|
||||
depends_on:PSA_WANT_ALG_RIPEMD160
|
||||
mbedtls_oid_get_md_hmac:"2B06010505080104":MBEDTLS_MD_RIPEMD160
|
||||
mbedtls_x509_oid_get_md_hmac:"2B06010505080104":MBEDTLS_MD_RIPEMD160
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA1
|
||||
mbedtls_x509_oid_get_md_hmac - SHA1
|
||||
depends_on:PSA_WANT_ALG_SHA_1
|
||||
mbedtls_oid_get_md_hmac:"2A864886F70D0207":MBEDTLS_MD_SHA1
|
||||
mbedtls_x509_oid_get_md_hmac:"2A864886F70D0207":MBEDTLS_MD_SHA1
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA224
|
||||
mbedtls_x509_oid_get_md_hmac - SHA224
|
||||
depends_on:PSA_WANT_ALG_SHA_224
|
||||
mbedtls_oid_get_md_hmac:"2A864886F70D0208":MBEDTLS_MD_SHA224
|
||||
mbedtls_x509_oid_get_md_hmac:"2A864886F70D0208":MBEDTLS_MD_SHA224
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA256
|
||||
mbedtls_x509_oid_get_md_hmac - SHA256
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
mbedtls_oid_get_md_hmac:"2A864886F70D0209":MBEDTLS_MD_SHA256
|
||||
mbedtls_x509_oid_get_md_hmac:"2A864886F70D0209":MBEDTLS_MD_SHA256
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA384
|
||||
mbedtls_x509_oid_get_md_hmac - SHA384
|
||||
depends_on:PSA_WANT_ALG_SHA_384
|
||||
mbedtls_oid_get_md_hmac:"2A864886F70D020A":MBEDTLS_MD_SHA384
|
||||
mbedtls_x509_oid_get_md_hmac:"2A864886F70D020A":MBEDTLS_MD_SHA384
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA512
|
||||
mbedtls_x509_oid_get_md_hmac - SHA512
|
||||
depends_on:PSA_WANT_ALG_SHA_512
|
||||
mbedtls_oid_get_md_hmac:"2A864886F70D020B":MBEDTLS_MD_SHA512
|
||||
mbedtls_x509_oid_get_md_hmac:"2A864886F70D020B":MBEDTLS_MD_SHA512
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA3_224
|
||||
mbedtls_x509_oid_get_md_hmac - SHA3_224
|
||||
depends_on:PSA_WANT_ALG_SHA3_224
|
||||
mbedtls_oid_get_md_hmac:"60864801650304020D":MBEDTLS_MD_SHA3_224
|
||||
mbedtls_x509_oid_get_md_hmac:"60864801650304020D":MBEDTLS_MD_SHA3_224
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA3_256
|
||||
mbedtls_x509_oid_get_md_hmac - SHA3_256
|
||||
depends_on:PSA_WANT_ALG_SHA3_256
|
||||
mbedtls_oid_get_md_hmac:"60864801650304020E":MBEDTLS_MD_SHA3_256
|
||||
mbedtls_x509_oid_get_md_hmac:"60864801650304020E":MBEDTLS_MD_SHA3_256
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA3_384
|
||||
mbedtls_x509_oid_get_md_hmac - SHA3_384
|
||||
depends_on:PSA_WANT_ALG_SHA3_384
|
||||
mbedtls_oid_get_md_hmac:"60864801650304020F":MBEDTLS_MD_SHA3_384
|
||||
mbedtls_x509_oid_get_md_hmac:"60864801650304020F":MBEDTLS_MD_SHA3_384
|
||||
|
||||
mbedtls_oid_get_md_hmac - SHA3_512
|
||||
mbedtls_x509_oid_get_md_hmac - SHA3_512
|
||||
depends_on:PSA_WANT_ALG_SHA3_512
|
||||
mbedtls_oid_get_md_hmac:"608648016503040210":MBEDTLS_MD_SHA3_512
|
||||
mbedtls_x509_oid_get_md_hmac:"608648016503040210":MBEDTLS_MD_SHA3_512
|
||||
|
@ -21,7 +21,7 @@ void oid_get_certificate_policies(data_t *oid, char *result_str)
|
||||
asn1_buf.p = oid->x;
|
||||
asn1_buf.len = oid->len;
|
||||
|
||||
ret = mbedtls_oid_get_certificate_policies(&asn1_buf, &desc);
|
||||
ret = mbedtls_x509_oid_get_certificate_policies(&asn1_buf, &desc);
|
||||
if (strlen(result_str) == 0) {
|
||||
TEST_ASSERT(ret == MBEDTLS_ERR_OID_NOT_FOUND);
|
||||
} else {
|
||||
@ -42,7 +42,7 @@ void oid_get_extended_key_usage(data_t *oid, char *result_str)
|
||||
asn1_buf.p = oid->x;
|
||||
asn1_buf.len = oid->len;
|
||||
|
||||
ret = mbedtls_oid_get_extended_key_usage(&asn1_buf, &desc);
|
||||
ret = mbedtls_x509_oid_get_extended_key_usage(&asn1_buf, &desc);
|
||||
if (strlen(result_str) == 0) {
|
||||
TEST_ASSERT(ret == MBEDTLS_ERR_OID_NOT_FOUND);
|
||||
} else {
|
||||
@ -63,7 +63,7 @@ void oid_get_x509_extension(data_t *oid, int exp_type)
|
||||
ext_oid.p = oid->x;
|
||||
ext_oid.len = oid->len;
|
||||
|
||||
ret = mbedtls_oid_get_x509_ext_type(&ext_oid, &ext_type);
|
||||
ret = mbedtls_x509_oid_get_x509_ext_type(&ext_oid, &ext_type);
|
||||
if (exp_type == 0) {
|
||||
TEST_ASSERT(ret == MBEDTLS_ERR_OID_NOT_FOUND);
|
||||
} else {
|
||||
@ -84,7 +84,7 @@ void oid_get_md_alg_id(data_t *oid, int exp_md_id)
|
||||
md_oid.p = oid->x;
|
||||
md_oid.len = oid->len;
|
||||
|
||||
ret = mbedtls_oid_get_md_alg(&md_oid, &md_id);
|
||||
ret = mbedtls_x509_oid_get_md_alg(&md_oid, &md_id);
|
||||
|
||||
if (exp_md_id < 0) {
|
||||
TEST_ASSERT(ret == MBEDTLS_ERR_OID_NOT_FOUND);
|
||||
@ -97,7 +97,7 @@ void oid_get_md_alg_id(data_t *oid, int exp_md_id)
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_oid_get_md_hmac(data_t *oid, int exp_md_id)
|
||||
void mbedtls_x509_oid_get_md_hmac(data_t *oid, int exp_md_id)
|
||||
{
|
||||
mbedtls_asn1_buf md_oid = { 0, 0, NULL };
|
||||
int ret;
|
||||
@ -107,7 +107,7 @@ void mbedtls_oid_get_md_hmac(data_t *oid, int exp_md_id)
|
||||
md_oid.p = oid->x;
|
||||
md_oid.len = oid->len;
|
||||
|
||||
ret = mbedtls_oid_get_md_hmac(&md_oid, &md_id);
|
||||
ret = mbedtls_x509_oid_get_md_hmac(&md_oid, &md_id);
|
||||
|
||||
if (exp_md_id < 0) {
|
||||
TEST_ASSERT(ret == MBEDTLS_ERR_OID_NOT_FOUND);
|
||||
|
@ -1010,8 +1010,8 @@ void mbedtls_x509_dn_get_next(char *name_str,
|
||||
parsed_cur = &parsed;
|
||||
len = 0;
|
||||
for (i = 0; parsed_cur != NULL; i++) {
|
||||
TEST_EQUAL(mbedtls_oid_get_attr_short_name(&parsed_cur->oid,
|
||||
&short_name), 0);
|
||||
TEST_EQUAL(mbedtls_x509_oid_get_attr_short_name(&parsed_cur->oid,
|
||||
&short_name), 0);
|
||||
len += mbedtls_snprintf((char *) out + len, out_size - len, "%s ", short_name);
|
||||
parsed_cur = mbedtls_x509_dn_get_next(parsed_cur);
|
||||
}
|
||||
@ -1516,7 +1516,7 @@ void x509_oid_desc(data_t *buf, char *ref_desc)
|
||||
oid.p = buf->x;
|
||||
oid.len = buf->len;
|
||||
|
||||
ret = mbedtls_oid_get_extended_key_usage(&oid, &desc);
|
||||
ret = mbedtls_x509_oid_get_extended_key_usage(&oid, &desc);
|
||||
|
||||
if (strcmp(ref_desc, "notfound") == 0) {
|
||||
TEST_ASSERT(ret != 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user