[pkg-opensc-commit] [opensc] 275/295: pkcs15init: handle secret key in generic helper functions
Eric Dorland
eric at moszumanska.debian.org
Sat Jun 24 21:11:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository opensc.
commit fe88222ffeb8214de90597ea1927b854c2a1fe60
Author: Timo Teräs <timo.teras at iki.fi>
Date: Wed Apr 12 13:44:51 2017 +0300
pkcs15init: handle secret key in generic helper functions
---
src/pkcs15init/pkcs15-lib.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c
index 9e28278..70a27f1 100644
--- a/src/pkcs15init/pkcs15-lib.c
+++ b/src/pkcs15init/pkcs15-lib.c
@@ -77,6 +77,7 @@
#define DEFAULT_PIN_FLAGS (SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
#define DEFAULT_PRKEY_FLAGS (SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
#define DEFAULT_PUBKEY_FLAGS (SC_PKCS15_CO_FLAG_MODIFIABLE)
+#define DEFAULT_SKEY_FLAGS (SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
#define DEFAULT_CERT_FLAGS (SC_PKCS15_CO_FLAG_MODIFIABLE)
#define DEFAULT_DATA_FLAGS (SC_PKCS15_CO_FLAG_MODIFIABLE)
@@ -2549,6 +2550,8 @@ get_template_name_from_object (struct sc_pkcs15_object *obj)
return "private-key";
case SC_PKCS15_TYPE_PUBKEY:
return "public-key";
+ case SC_PKCS15_TYPE_SKEY:
+ return "secret-key";
case SC_PKCS15_TYPE_CERT:
return "certificate";
case SC_PKCS15_TYPE_DATA_OBJECT:
@@ -2578,6 +2581,9 @@ get_object_path_from_object (struct sc_pkcs15_object *obj,
case SC_PKCS15_TYPE_PUBKEY:
*ret_path = ((struct sc_pkcs15_pubkey_info *)obj->data)->path;
return SC_SUCCESS;
+ case SC_PKCS15_TYPE_SKEY:
+ *ret_path = ((struct sc_pkcs15_skey_info *)obj->data)->path;
+ return SC_SUCCESS;
case SC_PKCS15_TYPE_CERT:
*ret_path = ((struct sc_pkcs15_cert_info *)obj->data)->path;
return SC_SUCCESS;
@@ -2964,6 +2970,10 @@ sc_pkcs15init_new_object(int type, const char *label, struct sc_pkcs15_id *auth_
object->flags = DEFAULT_PRKEY_FLAGS;
data_size = sizeof(struct sc_pkcs15_prkey_info);
break;
+ case SC_PKCS15_TYPE_SKEY:
+ object->flags = DEFAULT_SKEY_FLAGS;
+ data_size = sizeof(struct sc_pkcs15_skey_info);
+ break;
case SC_PKCS15_TYPE_PUBKEY:
object->flags = DEFAULT_PUBKEY_FLAGS;
data_size = sizeof(struct sc_pkcs15_pubkey_info);
@@ -3043,6 +3053,9 @@ sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card, struct sc_profile *p
case SC_PKCS15_PUKDF_TRUSTED:
((struct sc_pkcs15_pubkey_info *) object->data)->id = new_id;
break;
+ case SC_PKCS15_SKDF:
+ ((struct sc_pkcs15_skey_info *) object->data)->id = new_id;
+ break;
case SC_PKCS15_CDF:
case SC_PKCS15_CDF_TRUSTED:
case SC_PKCS15_CDF_USEFUL:
@@ -3093,22 +3106,8 @@ sc_pkcs15init_delete_object(struct sc_pkcs15_card *p15card, struct sc_profile *p
int r = 0, stored_in_ef = 0;
LOG_FUNC_CALLED(ctx);
- switch(obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
- case SC_PKCS15_TYPE_PUBKEY:
- path = ((struct sc_pkcs15_pubkey_info *)obj->data)->path;
- break;
- case SC_PKCS15_TYPE_PRKEY:
- path = ((struct sc_pkcs15_prkey_info *)obj->data)->path;
- break;
- case SC_PKCS15_TYPE_CERT:
- path = ((struct sc_pkcs15_cert_info *)obj->data)->path;
- break;
- case SC_PKCS15_TYPE_DATA_OBJECT:
- path = ((struct sc_pkcs15_data_info *)obj->data)->path;
- break;
- default:
- return SC_ERROR_NOT_SUPPORTED;
- }
+ r = get_object_path_from_object(obj, &path);
+ LOG_TEST_RET(ctx, r, "Failed to get object path");
sc_log(ctx, "delete object(type:%X) with path(type:%X,%s)", obj->type, path.type, sc_print_path(&path));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git
More information about the pkg-opensc-commit
mailing list