Skip to content

Commit

Permalink
Fix coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
ashman-p committed Aug 13, 2024
1 parent a2fc480 commit f781668
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
7 changes: 4 additions & 3 deletions oqsprov/oqs_encode_key2any.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions oqsprov/oqs_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
17 changes: 9 additions & 8 deletions oqsprov/oqsprov_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f781668

Please sign in to comment.