remove the util function dump_hex() in favor of dump_data()
This commit is contained in:
@@ -218,10 +218,6 @@ void dump_data(const unsigned char *buf, unsigned int len, FILE *output, bool sp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_hex(const unsigned char *buf, unsigned int len, FILE *output, bool space) {
|
|
||||||
dump_data(buf, len, output, space, format_arg_hex);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_length(const unsigned char *buffer, int *len) {
|
int get_length(const unsigned char *buffer, int *len) {
|
||||||
if(buffer[0] < 0x81) {
|
if(buffer[0] < 0x81) {
|
||||||
*len = buffer[0];
|
*len = buffer[0];
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
size_t read_data(unsigned char*, size_t, FILE*, enum enum_format);
|
size_t read_data(unsigned char*, size_t, FILE*, enum enum_format);
|
||||||
void dump_data(unsigned const char*, unsigned int, FILE*, bool, enum enum_format);
|
void dump_data(unsigned const char*, unsigned int, FILE*, bool, enum enum_format);
|
||||||
void dump_hex(unsigned const char*, unsigned int, FILE*, bool);
|
|
||||||
int set_length(unsigned char*, int);
|
int set_length(unsigned char*, int);
|
||||||
int get_length(const unsigned char*, int*);
|
int get_length(const unsigned char*, int*);
|
||||||
X509_NAME *parse_name(const char*);
|
X509_NAME *parse_name(const char*);
|
||||||
|
|||||||
+10
-10
@@ -631,7 +631,7 @@ static bool set_dataobject(ykpiv_state *state, int verbose, int type) {
|
|||||||
}
|
}
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
fprintf(stderr, "Setting the %s to: ", type == CHUID ? "CHUID" : "CCC");
|
fprintf(stderr, "Setting the %s to: ", type == CHUID ? "CHUID" : "CCC");
|
||||||
dump_hex(obj, len, stderr, true);
|
dump_data(obj, len, stderr, true, format_arg_hex);
|
||||||
}
|
}
|
||||||
if((res = ykpiv_save_object(state, id, obj, len)) != YKPIV_OK) {
|
if((res = ykpiv_save_object(state, id, obj, len)) != YKPIV_OK) {
|
||||||
fprintf(stderr, "Failed communicating with device: %s\n", ykpiv_strerror(res));
|
fprintf(stderr, "Failed communicating with device: %s\n", ykpiv_strerror(res));
|
||||||
@@ -1157,7 +1157,7 @@ static bool sign_file(ykpiv_state *state, const char *input, const char *output,
|
|||||||
|
|
||||||
if(verbosity) {
|
if(verbosity) {
|
||||||
fprintf(stderr, "file hashed as: ");
|
fprintf(stderr, "file hashed as: ");
|
||||||
dump_hex(hashed, hash_len, stderr, true);
|
dump_data(hashed, hash_len, stderr, true, format_arg_hex);
|
||||||
}
|
}
|
||||||
EVP_MD_CTX_destroy(mdctx);
|
EVP_MD_CTX_destroy(mdctx);
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1176,7 @@ static bool sign_file(ykpiv_state *state, const char *input, const char *output,
|
|||||||
|
|
||||||
if(verbosity) {
|
if(verbosity) {
|
||||||
fprintf(stderr, "file signed as: ");
|
fprintf(stderr, "file signed as: ");
|
||||||
dump_hex(buf, len, stderr, true);
|
dump_data(buf, len, stderr, true, format_arg_hex);
|
||||||
}
|
}
|
||||||
fwrite(buf, 1, len, output_file);
|
fwrite(buf, 1, len, output_file);
|
||||||
ret = true;
|
ret = true;
|
||||||
@@ -1276,7 +1276,7 @@ static void print_cert_info(ykpiv_state *state, enum enum_slot slot, const EVP_M
|
|||||||
fprintf(output, "\n");
|
fprintf(output, "\n");
|
||||||
X509_digest(x509, md, data, &md_len);
|
X509_digest(x509, md, data, &md_len);
|
||||||
fprintf(output, "\tFingerprint:\t");
|
fprintf(output, "\tFingerprint:\t");
|
||||||
dump_hex(data, md_len, output, false);
|
dump_data(data, md_len, output, false, format_arg_hex);
|
||||||
|
|
||||||
bio = BIO_new_fp(output, BIO_NOCLOSE | BIO_FP_TEXT);
|
bio = BIO_new_fp(output, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||||
not_before = X509_get_notBefore(x509);
|
not_before = X509_get_notBefore(x509);
|
||||||
@@ -1325,7 +1325,7 @@ static bool status(ykpiv_state *state, enum enum_hash hash,
|
|||||||
if(ykpiv_fetch_object(state, YKPIV_OBJ_CHUID, chuid, &len) != YKPIV_OK) {
|
if(ykpiv_fetch_object(state, YKPIV_OBJ_CHUID, chuid, &len) != YKPIV_OK) {
|
||||||
fprintf(output_file, "No data available\n");
|
fprintf(output_file, "No data available\n");
|
||||||
} else {
|
} else {
|
||||||
dump_hex(chuid, len, output_file, false);
|
dump_data(chuid, len, output_file, false, format_arg_hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot == slot__NULL)
|
if (slot == slot__NULL)
|
||||||
@@ -1405,7 +1405,7 @@ static bool test_signature(ykpiv_state *state, enum enum_slot slot,
|
|||||||
EVP_DigestFinal_ex(mdctx, data, &data_len);
|
EVP_DigestFinal_ex(mdctx, data, &data_len);
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
fprintf(stderr, "Test data hashes as: ");
|
fprintf(stderr, "Test data hashes as: ");
|
||||||
dump_hex(data, data_len, stderr, true);
|
dump_data(data, data_len, stderr, true, format_arg_hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1561,9 +1561,9 @@ static bool test_decipher(ykpiv_state *state, enum enum_slot slot,
|
|||||||
if(len == sizeof(secret)) {
|
if(len == sizeof(secret)) {
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
fprintf(stderr, "Generated nonce: ");
|
fprintf(stderr, "Generated nonce: ");
|
||||||
dump_hex(secret, sizeof(secret), stderr, true);
|
dump_data(secret, sizeof(secret), stderr, true, format_arg_hex);
|
||||||
fprintf(stderr, "Decrypted nonce: ");
|
fprintf(stderr, "Decrypted nonce: ");
|
||||||
dump_hex(secret2, sizeof(secret2), stderr, true);
|
dump_data(secret2, sizeof(secret2), stderr, true, format_arg_hex);
|
||||||
}
|
}
|
||||||
if(memcmp(secret, secret2, sizeof(secret)) == 0) {
|
if(memcmp(secret, secret2, sizeof(secret)) == 0) {
|
||||||
fprintf(stderr, "Successfully performed RSA decryption!\n");
|
fprintf(stderr, "Successfully performed RSA decryption!\n");
|
||||||
@@ -1603,9 +1603,9 @@ static bool test_decipher(ykpiv_state *state, enum enum_slot slot,
|
|||||||
}
|
}
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
fprintf(stderr, "ECDH host generated: ");
|
fprintf(stderr, "ECDH host generated: ");
|
||||||
dump_hex(secret, len, stderr, true);
|
dump_data(secret, len, stderr, true, format_arg_hex);
|
||||||
fprintf(stderr, "ECDH card generated: ");
|
fprintf(stderr, "ECDH card generated: ");
|
||||||
dump_hex(secret2, len, stderr, true);
|
dump_data(secret2, len, stderr, true, format_arg_hex);
|
||||||
}
|
}
|
||||||
if(memcmp(secret, secret2, key_len) == 0) {
|
if(memcmp(secret, secret2, key_len) == 0) {
|
||||||
fprintf(stderr, "Successfully performed ECDH exchange with card.\n");
|
fprintf(stderr, "Successfully performed ECDH exchange with card.\n");
|
||||||
|
|||||||
+4
-4
@@ -1840,7 +1840,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
|
|||||||
|
|
||||||
DBG("Sending %lu bytes to sign", ulDataLen);
|
DBG("Sending %lu bytes to sign", ulDataLen);
|
||||||
#if YKCS11_DBG == 1
|
#if YKCS11_DBG == 1
|
||||||
dump_hex(pData, ulDataLen, stderr, CK_TRUE);
|
dump_data(pData, ulDataLen, stderr, CK_TRUE, format_arg_hex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (is_hashed_mechanism(op_info.mechanism.mechanism) == CK_TRUE) {
|
if (is_hashed_mechanism(op_info.mechanism.mechanism) == CK_TRUE) {
|
||||||
@@ -1882,7 +1882,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
|
|||||||
DBG("Using key %lx", op_info.op.sign.key_id);
|
DBG("Using key %lx", op_info.op.sign.key_id);
|
||||||
DBG("After padding and transformation there are %lu bytes", op_info.buf_len);
|
DBG("After padding and transformation there are %lu bytes", op_info.buf_len);
|
||||||
#if YKCS11_DBG == 1
|
#if YKCS11_DBG == 1
|
||||||
dump_hex(op_info.buf, op_info.buf_len, stderr, CK_TRUE);
|
dump_data(op_info.buf, op_info.buf_len, stderr, CK_TRUE, format_arg_hex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*pulSignatureLen = sizeof(op_info.buf);
|
*pulSignatureLen = sizeof(op_info.buf);
|
||||||
@@ -1903,7 +1903,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
|
|||||||
|
|
||||||
DBG("Got %lu bytes back", *pulSignatureLen);
|
DBG("Got %lu bytes back", *pulSignatureLen);
|
||||||
#if YKCS11_DBG == 1
|
#if YKCS11_DBG == 1
|
||||||
dump_hex(pSignature, *pulSignatureLen, stderr, CK_TRUE);
|
dump_data(pSignature, *pulSignatureLen, stderr, CK_TRUE, format_arg_hex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!is_RSA_mechanism(op_info.mechanism.mechanism)) {
|
if (!is_RSA_mechanism(op_info.mechanism.mechanism)) {
|
||||||
@@ -1913,7 +1913,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
|
|||||||
|
|
||||||
DBG("After removing DER encoding %lu", *pulSignatureLen);
|
DBG("After removing DER encoding %lu", *pulSignatureLen);
|
||||||
#if YKCS11_DBG == 1
|
#if YKCS11_DBG == 1
|
||||||
dump_hex(pSignature, *pulSignatureLen, stderr, CK_TRUE);
|
dump_data(pSignature, *pulSignatureLen, stderr, CK_TRUE, format_arg_hex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user