From 9113603b6bfe72a2aa41d6c15772381dd3f92bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 5 Jun 2014 15:41:39 +0200 Subject: [PATCH] Use sig_opts in x509_sig_alg_gets() --- include/polarssl/x509.h | 3 ++- library/x509.c | 19 +++++++++---------- library/x509_crl.c | 7 ++++--- library/x509_crt.c | 7 ++++--- library/x509_csr.c | 7 ++++--- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/polarssl/x509.h b/include/polarssl/x509.h index 452ea31f6..bd34617c5 100644 --- a/include/polarssl/x509.h +++ b/include/polarssl/x509.h @@ -295,7 +295,8 @@ int x509_get_ext( unsigned char **p, const unsigned char *end, x509_buf *ext, int tag ); int x509_load_file( const char *path, unsigned char **buf, size_t *n ); int x509_sig_alg_gets( char *buf, size_t size, const x509_buf *sig_oid, - pk_type_t pk_alg, const x509_buf *sig_params ); + pk_type_t pk_alg, md_type_t md_alg, + const void *sig_opts ); int x509_key_size_helper( char *buf, size_t size, const char *name ); int x509_string_to_names( asn1_named_data **head, const char *name ); int x509_set_extension( asn1_named_data **head, const char *oid, size_t oid_len, diff --git a/library/x509.c b/library/x509.c index ffa798052..57dfd64fd 100644 --- a/library/x509.c +++ b/library/x509.c @@ -836,10 +836,11 @@ int x509_serial_gets( char *buf, size_t size, const x509_buf *serial ) } /* - * Helper for writing signature alrogithms + * Helper for writing signature algorithms */ int x509_sig_alg_gets( char *buf, size_t size, const x509_buf *sig_oid, - pk_type_t pk_alg, const x509_buf *sig_params ) + pk_type_t pk_alg, md_type_t md_alg, + const void *sig_opts ) { int ret; char *p = buf; @@ -856,26 +857,24 @@ int x509_sig_alg_gets( char *buf, size_t size, const x509_buf *sig_oid, #if defined(POLARSSL_RSASSA_PSS_CERTIFICATES) if( pk_alg == POLARSSL_PK_RSASSA_PSS ) { - md_type_t md_alg, mgf_md; + const pk_rsassa_pss_options *pss_opts; const md_info_t *md_info, *mgf_md_info; - int salt_len; - if( ( ret = x509_get_rsassa_pss_params( sig_params, - &md_alg, &mgf_md, &salt_len ) ) != 0 ) - return( ret ); + pss_opts = (const pk_rsassa_pss_options *) sig_opts; md_info = md_info_from_type( md_alg ); - mgf_md_info = md_info_from_type( mgf_md ); + mgf_md_info = md_info_from_type( pss_opts->mgf1_hash_id ); ret = snprintf( p, n, " (%s, MGF1-%s, 0x%02X)", md_info ? md_info->name : "???", mgf_md_info ? mgf_md_info->name : "???", - salt_len ); + pss_opts->expected_salt_len ); SAFE_SNPRINTF(); } #else ((void) pk_alg); - ((void) sig_params); + ((void) md_alg); + ((void) sig_opts); #endif /* POLARSSL_RSASSA_PSS_CERTIFICATES */ return( (int) size - n ); diff --git a/library/x509_crl.c b/library/x509_crl.c index 2d6b50d1d..f532c0cbe 100644 --- a/library/x509_crl.c +++ b/library/x509_crl.c @@ -634,9 +634,9 @@ int x509_crl_info( char *buf, size_t size, const char *prefix, char *p; const x509_crl_entry *entry; #if defined(POLARSSL_RSASSA_PSS_CERTIFICATES) - const x509_buf *sig_params = &crl->sig_params; + const void *sig_opts = crl->sig_opts; #else - const x509_buf *sig_params = NULL; + const void *sig_opts = NULL; #endif p = buf; @@ -693,7 +693,8 @@ int x509_crl_info( char *buf, size_t size, const char *prefix, ret = snprintf( p, n, "\n%ssigned using : ", prefix ); SAFE_SNPRINTF(); - ret = x509_sig_alg_gets( p, n, &crl->sig_oid1, crl->sig_pk, sig_params ); + ret = x509_sig_alg_gets( p, n, &crl->sig_oid1, crl->sig_pk, crl->sig_md, + sig_opts ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n" ); diff --git a/library/x509_crt.c b/library/x509_crt.c index 7e5de1d67..617b733af 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1261,9 +1261,9 @@ int x509_crt_info( char *buf, size_t size, const char *prefix, char *p; char key_size_str[BEFORE_COLON]; #if defined(POLARSSL_RSASSA_PSS_CERTIFICATES) - const x509_buf *sig_params = &crt->sig_params; + const void *sig_opts = crt->sig_opts; #else - const x509_buf *sig_params = NULL; + const void *sig_opts = NULL; #endif p = buf; @@ -1306,7 +1306,8 @@ int x509_crt_info( char *buf, size_t size, const char *prefix, ret = snprintf( p, n, "\n%ssigned using : ", prefix ); SAFE_SNPRINTF(); - ret = x509_sig_alg_gets( p, n, &crt->sig_oid1, crt->sig_pk, sig_params ); + ret = x509_sig_alg_gets( p, n, &crt->sig_oid1, crt->sig_pk, + crt->sig_md, sig_opts ); SAFE_SNPRINTF(); /* Key size */ diff --git a/library/x509_csr.c b/library/x509_csr.c index 4dd623a6a..b71bc0b9d 100644 --- a/library/x509_csr.c +++ b/library/x509_csr.c @@ -369,9 +369,9 @@ int x509_csr_info( char *buf, size_t size, const char *prefix, char *p; char key_size_str[BEFORE_COLON]; #if defined(POLARSSL_RSASSA_PSS_CERTIFICATES) - const x509_buf *sig_params = &csr->sig_params; + const void *sig_opts = csr->sig_opts; #else - const x509_buf *sig_params = NULL; + const void *sig_opts = NULL; #endif p = buf; @@ -389,7 +389,8 @@ int x509_csr_info( char *buf, size_t size, const char *prefix, ret = snprintf( p, n, "\n%ssigned using : ", prefix ); SAFE_SNPRINTF(); - ret = x509_sig_alg_gets( p, n, &csr->sig_oid, csr->sig_pk, sig_params ); + ret = x509_sig_alg_gets( p, n, &csr->sig_oid, csr->sig_pk, csr->sig_md, + sig_opts ); SAFE_SNPRINTF(); if( ( ret = x509_key_size_helper( key_size_str, BEFORE_COLON,