Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Fridrich <[email protected]>
  • Loading branch information
ZoltanFridrich committed Sep 15, 2023
1 parent 938d349 commit fd03086
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions p11-kit/generate-keypair.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
#include <stdlib.h>
#include <string.h>

//TODO
#include <stdio.h>
#include "constants.h"

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(x) dgettext(PACKAGE_NAME, x)
Expand Down Expand Up @@ -323,6 +327,52 @@ generate_keypair (const char *token_str,
}
}

// TODO remove

printf ("session = %lu\n\n", session);

printf ("mechanism.mechanism = %s\n", p11_constant_nick (p11_constant_mechanisms, mechanism.mechanism));
printf ("mechanism.pParameter = %s\n", (char *)mechanism.pParameter);
printf ("mechanism.ulParameterLen = %lu\n\n", mechanism.ulParameterLen);

printf ("pubkey =\n");
CK_ULONG k = p11_attrs_count (pubkey);
for (int i = 0; i < k; ++i) {
printf ("type = %s\n", p11_constant_nick (p11_constant_types, pubkey[i].type));
printf ("pValue = ");
if (pubkey[i].type == CKA_LABEL) {
for (int j = 0; j < pubkey[i].ulValueLen; ++j)
printf ("%c", ((char *)pubkey[i].pValue)[j]);
} else if (pubkey[i].type == CKA_MODULUS_BITS) {
printf ("%lu", *((CK_ULONG *)pubkey[i].pValue));
} else {
for (int j = 0; j < pubkey[i].ulValueLen; ++j)
printf ("%02X ", ((unsigned char *)pubkey[i].pValue)[j]);
}
printf ("\n");
printf ("ulValueLen = %lu\n", pubkey[i].ulValueLen);
}
printf ("\npubkey_len = %lu\n\n", k);

printf ("privkey =\n");
k = p11_attrs_count (privkey);
for (int i = 0; i < k; ++i) {
printf ("type = %s\n", p11_constant_nick (p11_constant_types, privkey[i].type));
printf ("pValue = ");
if (privkey[i].type == CKA_LABEL) {
for (int j = 0; j < privkey[i].ulValueLen; ++j)
printf ("%c", ((char *)privkey[i].pValue)[j]);
} else if (privkey[i].type == CKA_MODULUS_BITS) {
printf ("%lu", *((CK_ULONG *)privkey[i].pValue));
} else {
for (int j = 0; j < privkey[i].ulValueLen; ++j)
printf ("%02X ", ((unsigned char *)privkey[i].pValue)[j]);
}
printf ("\n");
printf ("ulValueLen = %lu\n", privkey[i].ulValueLen);
}
printf ("\nprivkey_len = %lu\n", k);

rv = module->C_GenerateKeyPair (session, &mechanism,
pubkey, p11_attrs_count (pubkey),
privkey, p11_attrs_count (privkey),
Expand Down

0 comments on commit fd03086

Please sign in to comment.