|
|
92e350 |
From 74885fb1c174468cc0a505cd7404e228d465efd8 Mon Sep 17 00:00:00 2001
|
|
|
92e350 |
From: AnthonyA <ascanio.alba7@gmail.com>
|
|
|
92e350 |
Date: Tue, 27 Mar 2018 00:48:05 +0000
|
|
|
92e350 |
Subject: [PATCH] pkcs11-tool: allow mechanism to be specified in hexadecimal
|
|
|
92e350 |
|
|
|
92e350 |
To support vendor mechanisms, let -m accept hexadecimal strings,
|
|
|
92e350 |
e.g., -m 0x80001234
|
|
|
92e350 |
---
|
|
|
92e350 |
doc/tools/pkcs11-tool.1.xml | 3 ++-
|
|
|
92e350 |
src/tools/pkcs11-tool.c | 5 ++++-
|
|
|
92e350 |
2 files changed, 6 insertions(+), 2 deletions(-)
|
|
|
92e350 |
|
|
|
92e350 |
diff --git a/doc/tools/pkcs11-tool.1.xml b/doc/tools/pkcs11-tool.1.xml
|
|
|
92e350 |
index f8d638b45..e78570b10 100644
|
|
|
92e350 |
--- a/doc/tools/pkcs11-tool.1.xml
|
|
|
92e350 |
+++ b/doc/tools/pkcs11-tool.1.xml
|
|
|
92e350 |
@@ -231,7 +231,8 @@
|
|
|
92e350 |
</term>
|
|
|
92e350 |
<listitem><para>Use the specified <replaceable>mechanism</replaceable>
|
|
|
92e350 |
for token operations. See <option>-M</option> for a list
|
|
|
92e350 |
- of mechanisms supported by your token.</para></listitem>
|
|
|
92e350 |
+ of mechanisms supported by your token. The mechanism can also be specified in
|
|
|
92e350 |
+ hexadecimal, e.g., <replaceable>0x80001234</replaceable>.</para></listitem>
|
|
|
92e350 |
</varlistentry>
|
|
|
92e350 |
|
|
|
92e350 |
<varlistentry>
|
|
|
92e350 |
diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
|
|
|
92e350 |
index 63e5c5f7f..484c019d8 100644
|
|
|
92e350 |
--- a/src/tools/pkcs11-tool.c
|
|
|
92e350 |
+++ b/src/tools/pkcs11-tool.c
|
|
|
92e350 |
@@ -234,7 +234,7 @@ static const char *option_help[] = {
|
|
|
92e350 |
"Hash some data",
|
|
|
92e350 |
"Derive a secret key using another key and some data",
|
|
|
92e350 |
"Derive ECDHpass DER encoded pubkey for compatibility with some PKCS#11 implementations",
|
|
|
92e350 |
- "Specify mechanism (use -M for a list of supported mechanisms)",
|
|
|
92e350 |
+ "Specify mechanism (use -M for a list of supported mechanisms), or by hexadecimal, e.g., 0x80001234",
|
|
|
92e350 |
|
|
|
92e350 |
"Log into the token first",
|
|
|
92e350 |
"Specify login type ('so', 'user', 'context-specific'; default:'user')",
|
|
|
92e350 |
@@ -6076,6 +6076,9 @@ static CK_MECHANISM_TYPE p11_name_to_mechanism(const char *name)
|
|
|
92e350 |
{
|
|
|
92e350 |
struct mech_info *mi;
|
|
|
92e350 |
|
|
|
92e350 |
+ if (strncasecmp("0x", name, 2) == 0) {
|
|
|
92e350 |
+ return strtoul(name, NULL, 0);
|
|
|
92e350 |
+ }
|
|
|
92e350 |
for (mi = p11_mechanisms; mi->name; mi++) {
|
|
|
92e350 |
if (!strcasecmp(mi->name, name)
|
|
|
92e350 |
|| (mi->short_name && !strcasecmp(mi->short_name, name)))
|
|
|
92e350 |
|