mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-03-20 19:21:09 +01:00
switch to mbedtls_pk_sigalg_t
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
This commit is contained in:
@@ -82,7 +82,7 @@ typedef struct mbedtls_x509_crl {
|
||||
mbedtls_x509_buf MBEDTLS_PRIVATE(sig_oid2);
|
||||
mbedtls_x509_buf MBEDTLS_PRIVATE(sig);
|
||||
mbedtls_md_type_t MBEDTLS_PRIVATE(sig_md); /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */
|
||||
mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
|
||||
mbedtls_pk_sigalg_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
|
||||
|
||||
/** Next element in the linked list of CRL.
|
||||
* \p NULL indicates the end of the list.
|
||||
|
||||
@@ -81,7 +81,7 @@ typedef struct mbedtls_x509_crt {
|
||||
|
||||
mbedtls_x509_buf MBEDTLS_PRIVATE(sig); /**< Signature: hash of the tbs part signed with the private key. */
|
||||
mbedtls_md_type_t MBEDTLS_PRIVATE(sig_md); /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */
|
||||
mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
|
||||
mbedtls_pk_sigalg_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
|
||||
|
||||
/** Next certificate in the linked list that constitutes the CA chain.
|
||||
* \p NULL indicates the end of the list.
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef struct mbedtls_x509_csr {
|
||||
mbedtls_x509_buf sig_oid;
|
||||
mbedtls_x509_buf MBEDTLS_PRIVATE(sig);
|
||||
mbedtls_md_type_t MBEDTLS_PRIVATE(sig_md); /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */
|
||||
mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
|
||||
mbedtls_pk_sigalg_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
|
||||
}
|
||||
mbedtls_x509_csr;
|
||||
|
||||
|
||||
@@ -717,16 +717,16 @@ int mbedtls_x509_get_sig(unsigned char **p, const unsigned char *end, mbedtls_x5
|
||||
* Get signature algorithm from alg OID and optional parameters
|
||||
*/
|
||||
int mbedtls_x509_get_sig_alg(const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
|
||||
mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg)
|
||||
mbedtls_md_type_t *md_alg, mbedtls_pk_sigalg_t *pk_alg)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if ((ret = mbedtls_x509_oid_get_sig_alg(sig_oid, md_alg, pk_alg)) != 0) {
|
||||
if ((ret = mbedtls_x509_oid_get_sig_alg(sig_oid, md_alg, (mbedtls_pk_type_t*)pk_alg)) != 0) {
|
||||
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG, ret);
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
if (*pk_alg == MBEDTLS_PK_RSASSA_PSS) {
|
||||
if (*pk_alg == MBEDTLS_PK_SIGALG_RSA_PSS) {
|
||||
mbedtls_md_type_t mgf1_hash_id;
|
||||
int expected_salt_len;
|
||||
|
||||
@@ -1039,7 +1039,7 @@ int mbedtls_x509_serial_gets(char *buf, size_t size, const mbedtls_x509_buf *ser
|
||||
* Helper for writing signature algorithms
|
||||
*/
|
||||
int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *sig_oid,
|
||||
mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg)
|
||||
mbedtls_pk_sigalg_t pk_alg, mbedtls_md_type_t md_alg)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
char *p = buf;
|
||||
@@ -1055,7 +1055,7 @@ int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *si
|
||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
if (pk_alg == MBEDTLS_PK_RSASSA_PSS) {
|
||||
if (pk_alg == MBEDTLS_PK_SIGALG_RSA_PSS) {
|
||||
const char *name = md_type_to_string(md_alg);
|
||||
if (name != NULL) {
|
||||
ret = mbedtls_snprintf(p, n, " (%s)", name);
|
||||
|
||||
@@ -646,7 +646,7 @@ int mbedtls_x509_write_names(unsigned char **p, unsigned char *start,
|
||||
int mbedtls_x509_write_sig(unsigned char **p, unsigned char *start,
|
||||
const char *oid, size_t oid_len,
|
||||
unsigned char *sig, size_t size,
|
||||
mbedtls_pk_type_t pk_alg)
|
||||
mbedtls_pk_sigalg_t pk_alg)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
int write_null_par;
|
||||
@@ -672,7 +672,7 @@ int mbedtls_x509_write_sig(unsigned char **p, unsigned char *start,
|
||||
|
||||
// Write OID
|
||||
//
|
||||
if (pk_alg == MBEDTLS_PK_ECDSA) {
|
||||
if (pk_alg == MBEDTLS_PK_SIGALG_ECDSA) {
|
||||
/*
|
||||
* The AlgorithmIdentifier's parameters field must be absent for DSA/ECDSA signature
|
||||
* algorithms, see https://www.rfc-editor.org/rfc/rfc5480#page-17 and
|
||||
|
||||
@@ -188,9 +188,9 @@ static int x509_profile_check_md_alg(const mbedtls_x509_crt_profile *profile,
|
||||
* 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_type_t pk_alg)
|
||||
mbedtls_pk_sigalg_t pk_alg)
|
||||
{
|
||||
if (pk_alg == MBEDTLS_PK_NONE) {
|
||||
if (pk_alg == MBEDTLS_PK_SIGALG_NONE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2121,7 +2121,7 @@ static int x509_crt_check_signature(const mbedtls_x509_crt *child,
|
||||
}
|
||||
|
||||
/* Skip expensive computation on obvious mismatch */
|
||||
if (!mbedtls_pk_can_do(&parent->pk, child->sig_pk)) {
|
||||
if (!mbedtls_pk_can_do(&parent->pk, (mbedtls_pk_type_t) child->sig_pk)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -3057,7 +3057,7 @@ static int x509_crt_verify_restartable_ca_cb(mbedtls_x509_crt *crt,
|
||||
/* Check the type and size of the key */
|
||||
pk_type = mbedtls_pk_get_type(&crt->pk);
|
||||
|
||||
if (x509_profile_check_pk_alg(profile, pk_type) != 0) {
|
||||
if (x509_profile_check_pk_alg(profile, (mbedtls_pk_sigalg_t)pk_type) != 0) {
|
||||
ee_flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ int mbedtls_x509_get_rsassa_pss_params(const mbedtls_x509_buf *params,
|
||||
#endif
|
||||
int mbedtls_x509_get_sig(unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig);
|
||||
int mbedtls_x509_get_sig_alg(const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
|
||||
mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg);
|
||||
mbedtls_md_type_t *md_alg, mbedtls_pk_sigalg_t *pk_alg);
|
||||
int mbedtls_x509_get_time(unsigned char **p, const unsigned char *end,
|
||||
mbedtls_x509_time *t);
|
||||
int mbedtls_x509_get_serial(unsigned char **p, const unsigned char *end,
|
||||
@@ -44,7 +44,7 @@ int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end,
|
||||
mbedtls_x509_buf *ext, int tag);
|
||||
#if !defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
int mbedtls_x509_sig_alg_gets(char *buf, size_t size, const mbedtls_x509_buf *sig_oid,
|
||||
mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg);
|
||||
mbedtls_pk_sigalg_t pk_alg, mbedtls_md_type_t md_alg);
|
||||
#endif
|
||||
int mbedtls_x509_key_size_helper(char *buf, size_t buf_size, const char *name);
|
||||
int mbedtls_x509_set_extension(mbedtls_asn1_named_data **head, const char *oid, size_t oid_len,
|
||||
@@ -57,7 +57,7 @@ int mbedtls_x509_write_names(unsigned char **p, unsigned char *start,
|
||||
int mbedtls_x509_write_sig(unsigned char **p, unsigned char *start,
|
||||
const char *oid, size_t oid_len,
|
||||
unsigned char *sig, size_t size,
|
||||
mbedtls_pk_type_t pk_alg);
|
||||
mbedtls_pk_sigalg_t pk_alg);
|
||||
int mbedtls_x509_get_ns_cert_type(unsigned char **p,
|
||||
const unsigned char *end,
|
||||
unsigned char *ns_cert_type);
|
||||
|
||||
@@ -587,7 +587,7 @@ int mbedtls_x509write_crt_der(mbedtls_x509write_cert *ctx,
|
||||
c2 = buf + size;
|
||||
MBEDTLS_ASN1_CHK_ADD(sig_and_oid_len, mbedtls_x509_write_sig(&c2, c,
|
||||
sig_oid, sig_oid_len,
|
||||
sig, sig_len, pk_alg));
|
||||
sig, sig_len, (mbedtls_pk_sigalg_t)pk_alg));
|
||||
|
||||
/*
|
||||
* Memory layout after this step:
|
||||
|
||||
@@ -249,7 +249,7 @@ static int x509write_csr_der_internal(mbedtls_x509write_csr *ctx,
|
||||
c2 = buf + size;
|
||||
MBEDTLS_ASN1_CHK_ADD(sig_and_oid_len,
|
||||
mbedtls_x509_write_sig(&c2, buf + len, sig_oid, sig_oid_len,
|
||||
sig, sig_len, pk_alg));
|
||||
sig, sig_len, (mbedtls_pk_sigalg_t)pk_alg));
|
||||
|
||||
/*
|
||||
* Compact the space between the CSR data and signature by moving the
|
||||
|
||||
Reference in New Issue
Block a user