From f7816681c354559c4d0de422f351bb343be8a80c Mon Sep 17 00:00:00 2001 From: Norman Ashley Date: Tue, 13 Aug 2024 17:05:39 -0400 Subject: [PATCH] Fix coding style --- oqsprov/oqs_encode_key2any.c | 7 ++++--- oqsprov/oqs_sig.c | 14 ++++++++------ oqsprov/oqsprov_keys.c | 17 +++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/oqsprov/oqs_encode_key2any.c b/oqsprov/oqs_encode_key2any.c index 71253d13..a1395325 100644 --- a/oqsprov/oqs_encode_key2any.c +++ b/oqsprov/oqs_encode_key2any.c @@ -703,8 +703,8 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { nid = oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->keytype; if (nid == EVP_PKEY_RSA) { // get the RSA real key size - unsigned char *enc_len = - (unsigned char *)OPENSSL_strndup(oqsxkey->comp_privkey[i], 4); + unsigned char *enc_len = (unsigned char *)OPENSSL_strndup( + oqsxkey->comp_privkey[i], 4); OPENSSL_cleanse(enc_len, 2); DECODE_UINT32(buflen, enc_len); buflen += 4; @@ -1684,7 +1684,8 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { ->keytype == EVP_PKEY_RSA) { // get the RSA real key size unsigned char *enc_len = - (unsigned char *)OPENSSL_strndup(okey->comp_privkey[i], 4); + (unsigned char *)OPENSSL_strndup( + okey->comp_privkey[i], 4); OPENSSL_cleanse(enc_len, 2); DECODE_UINT32(privlen, enc_len); privlen += 4; diff --git a/oqsprov/oqs_sig.c b/oqsprov/oqs_sig.c index 4960f95d..83305bb2 100644 --- a/oqsprov/oqs_sig.c +++ b/oqsprov/oqs_sig.c @@ -517,8 +517,8 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, oqs_sig_len = oqsxkey->oqsx_provider_ctx.oqsx_qs_ctx.sig ->length_signature; buf = OPENSSL_malloc(oqs_sig_len); - if (OQS_SIG_sign(oqs_key, buf, &oqs_sig_len, (const unsigned char *)final_tbs, - final_tbslen, + if (OQS_SIG_sign(oqs_key, buf, &oqs_sig_len, + (const unsigned char *)final_tbs, final_tbslen, oqsxkey->comp_privkey[i]) != OQS_SUCCESS) { ERR_raise(ERR_LIB_USER, OQSPROV_R_SIGNING_FAILED); CompositeSignature_free(compsig); @@ -541,7 +541,8 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *evp_ctx = EVP_MD_CTX_new(); if ((EVP_DigestSignInit(evp_ctx, NULL, NULL, NULL, oqs_key_classic) <= 0) || - (EVP_DigestSign(evp_ctx, buf, &oqs_sig_len, (const unsigned char *)final_tbs, + (EVP_DigestSign(evp_ctx, buf, &oqs_sig_len, + (const unsigned char *)final_tbs, final_tbslen) <= 0)) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); CompositeSignature_free(compsig); @@ -877,8 +878,8 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, } if (get_oqsname_fromtls(name)) { - if (OQS_SIG_verify(oqs_key, (const unsigned char *)final_tbs, final_tbslen, buf, - buf_len, + if (OQS_SIG_verify(oqs_key, (const unsigned char *)final_tbs, + final_tbslen, buf, buf_len, oqsxkey->comp_pubkey[i]) != OQS_SUCCESS) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); OPENSSL_free(name); @@ -897,7 +898,8 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, EVP_MD_CTX *evp_ctx = EVP_MD_CTX_new(); if ((EVP_DigestVerifyInit(evp_ctx, NULL, NULL, NULL, oqsxkey->classical_pkey) <= 0) || - (EVP_DigestVerify(evp_ctx, buf, buf_len, (const unsigned char *)final_tbs, + (EVP_DigestVerify(evp_ctx, buf, buf_len, + (const unsigned char *)final_tbs, final_tbslen) <= 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); OPENSSL_free(name); diff --git a/oqsprov/oqsprov_keys.c b/oqsprov/oqsprov_keys.c index 04613ec8..d711ff56 100644 --- a/oqsprov/oqsprov_keys.c +++ b/oqsprov/oqsprov_keys.c @@ -397,11 +397,10 @@ EVP_PKEY *setECParams(EVP_PKEY *eck, int nid) { 0x04, 0x00, 0x22}; const unsigned char p521params[] = {0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x23}; - const unsigned char bp256params[] = {0x06, 0x09, 0x2b, 0x24, 0x03, - 0x03, 0x02, 0x08, 0x01, 0x01, - 0x07}; - const unsigned char bp384params[] = {0x06, 0x09, 0x2b, 0x24, 0x03, - 0x03, 0x02, 0x08, 0x01, 0x01, 0x0b}; + const unsigned char bp256params[] = {0x06, 0x09, 0x2b, 0x24, 0x03, 0x03, + 0x02, 0x08, 0x01, 0x01, 0x07}; + const unsigned char bp384params[] = {0x06, 0x09, 0x2b, 0x24, 0x03, 0x03, + 0x02, 0x08, 0x01, 0x01, 0x0b}; const unsigned char *params; switch (nid) { @@ -703,9 +702,11 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } - unsigned char *enc_len = - (unsigned char *)OPENSSL_strndup((const char *) - (p + previous_privlen + previous_publen), 4); + unsigned char *enc_len = + (unsigned char *)OPENSSL_strndup( + (const char *)(p + previous_privlen + + previous_publen), + 4); OPENSSL_cleanse(enc_len, 2); DECODE_UINT32(privlen, enc_len); privlen += 4;