Skip to content

Commit

Permalink
to be removed, cmp_kem.c:add debug message
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeev-0 committed Mar 25, 2024
1 parent 36505aa commit 4b14d3d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crypto/cmp/cmp_kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@

#define RSAKEM_KEYLENGTH 32

static void print_buf(const char *title, const unsigned char *buf,
size_t buf_len)
{
size_t i = 0;

fprintf(stdout, "%s , len %ld\n", title, buf_len);
for (i = 0; i < buf_len; ++i)
fprintf(stdout, "%02X%s", buf[i],
(i + 1) % 16 == 0 ? "\r\n" : " ");

}

/* TODO: look for existing OpenSSL solution */
static int x509_algor_from_nid_with_md(int nid, X509_ALGOR **palg,
const EVP_MD *md)
Expand Down Expand Up @@ -228,6 +240,8 @@ static int kem_decapsulation(OSSL_CMP_CTX *ctx, EVP_PKEY *pkey, int is_EC,
OPENSSL_free(*secret);
goto err;
}
print_buf("\nct", ct, ct_len);
print_buf("\nsecret", *secret, *secret_len);
ret = 1;
err:
EVP_PKEY_CTX_free(kem_decaps_ctx);
Expand Down Expand Up @@ -313,6 +327,9 @@ int ossl_cmp_kem_derivessk(OSSL_CMP_CTX *ctx,
derive_ssk_HKDF(ctx, secret, secret_len,
salt, sizeof(salt), info, info_len,
out, len);
print_buf("\nsecret", secret, secret_len);
print_buf("\ninfo", info, info_len);
print_buf("\nssk", *out, *len);

OPENSSL_clear_free(info, info_len);
OPENSSL_free(salt);
Expand Down Expand Up @@ -425,7 +442,8 @@ static int kem_encapsulation(OSSL_CMP_CTX *ctx,
OPENSSL_free(*secret);
goto err;
}

print_buf("\nct", *ct, *ct_len);
print_buf("\nsecret", *secret, *secret_len);
ret = 1;
err:
EVP_PKEY_CTX_free(kem_encaps_ctx);
Expand Down

0 comments on commit 4b14d3d

Please sign in to comment.