static void print_cert_info(const struct sc_pkcs15_object *obj) { struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) obj->data; struct sc_pkcs15_cert *cert_parsed = NULL; char guid[39]; int rv; printf("X.509 Certificate [%s]\n", obj->label); print_common_flags(obj); printf("\tAuthority : %s\n", cert_info->authority ? "yes" : "no"); printf("\tPath : %s\n", sc_print_path(&cert_info->path)); printf("\tID : %s\n", sc_pkcs15_print_id(&cert_info->id)); rv = sc_pkcs15_get_guid(p15card, obj, guid, sizeof(guid)); if (!rv) printf("\tGUID : %s\n", guid); print_access_rules(obj->access_rules, SC_PKCS15_MAX_ACCESS_RULES); rv = sc_pkcs15_read_certificate(p15card, cert_info, &cert_parsed); if (rv >= 0 && cert_parsed) { printf("\tEncoded serial : %02X %02X ", *(cert_parsed->serial), *(cert_parsed->serial + 1)); util_hex_dump(stdout, cert_parsed->serial + 2, cert_parsed->serial_len - 2, ""); printf("\n"); sc_pkcs15_free_certificate(cert_parsed); } }
static void print_prkey_info(const struct sc_pkcs15_object *obj) { unsigned int i; struct sc_pkcs15_prkey_info *prkey = (struct sc_pkcs15_prkey_info *) obj->data; const char *types[] = { "", "RSA", "DSA", "GOSTR3410", "EC", "", "", "" }; const char *usages[] = { "encrypt", "decrypt", "sign", "signRecover", "wrap", "unwrap", "verify", "verifyRecover", "derive", "nonRepudiation" }; const size_t usage_count = NELEMENTS(usages); const char *access_flags[] = { "sensitive", "extract", "alwaysSensitive", "neverExtract", "local" }; const unsigned int af_count = NELEMENTS(access_flags); char guid[39]; printf("Private %s Key [%s]\n", types[7 & obj->type], obj->label); print_common_flags(obj); printf("\tUsage : [0x%X]", prkey->usage); for (i = 0; i < usage_count; i++) if (prkey->usage & (1 << i)) { printf(", %s", usages[i]); } printf("\n"); printf("\tAccess Flags : [0x%X]", prkey->access_flags); for (i = 0; i < af_count; i++) if (prkey->access_flags & (1 << i)) printf(", %s", access_flags[i]); printf("\n"); print_access_rules(obj->access_rules, SC_PKCS15_MAX_ACCESS_RULES); if (prkey->modulus_length) printf("\tModLength : %lu\n", (unsigned long)prkey->modulus_length); else printf("\tFieldLength : %lu\n", (unsigned long)prkey->field_length); printf("\tKey ref : %d (0x%X)\n", prkey->key_reference, prkey->key_reference); printf("\tNative : %s\n", prkey->native ? "yes" : "no"); if (prkey->path.len || prkey->path.aid.len) printf("\tPath : %s\n", sc_print_path(&prkey->path)); if (obj->auth_id.len != 0) printf("\tAuth ID : %s\n", sc_pkcs15_print_id(&obj->auth_id)); printf("\tID : %s\n", sc_pkcs15_print_id(&prkey->id)); if (!sc_pkcs15_get_guid(p15card, obj, guid, sizeof(guid))) printf("\tGUID : %s\n", guid); }
static void print_pubkey_info(const struct sc_pkcs15_object *obj) { unsigned int i; const struct sc_pkcs15_pubkey_info *pubkey = (const struct sc_pkcs15_pubkey_info *) obj->data; const char *types[] = { "", "RSA", "DSA", "GOSTR3410" }; const char *usages[] = { "encrypt", "decrypt", "sign", "signRecover", "wrap", "unwrap", "verify", "verifyRecover", "derive", "nonRepudiation" }; const unsigned int usage_count = NELEMENTS(usages); const char *access_flags[] = { "sensitive", "extract", "alwaysSensitive", "neverExtract", "local" }; const unsigned int af_count = NELEMENTS(access_flags); printf("Public %s Key [%s]\n", types[3 & obj->type], obj->label); print_common_flags(obj); printf("\tUsage : [0x%X]", pubkey->usage); for (i = 0; i < usage_count; i++) if (pubkey->usage & (1 << i)) { printf(", %s", usages[i]); } printf("\n"); printf("\tAccess Flags : [0x%X]", pubkey->access_flags); for (i = 0; i < af_count; i++) { if (pubkey->access_flags & (1 << i)) { printf(", %s", access_flags[i]); } } print_access_rules(obj->access_rules, SC_PKCS15_MAX_ACCESS_RULES); printf("\n"); printf("\tModLength : %lu\n", (unsigned long)pubkey->modulus_length); printf("\tKey ref : %d\n", pubkey->key_reference); printf("\tNative : %s\n", pubkey->native ? "yes" : "no"); printf("\tPath : %s\n", sc_print_path(&pubkey->path)); if (obj->auth_id.len != 0) printf("\tAuth ID : %s\n", sc_pkcs15_print_id(&obj->auth_id)); printf("\tID : %s\n", sc_pkcs15_print_id(&pubkey->id)); }