Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pkcs11-tool: allow mechanism to be specified in hexadecimal
To support vendor mechanisms, let -m accept hexadecimal strings,
e.g., -m 0x80001234
  • Loading branch information
aalba6675 authored and frankmorgner committed Mar 31, 2018
1 parent 45ad44e commit 74885fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/tools/pkcs11-tool.1.xml
Expand Up @@ -231,7 +231,8 @@
</term>
<listitem><para>Use the specified <replaceable>mechanism</replaceable>
for token operations. See <option>-M</option> for a list
of mechanisms supported by your token.</para></listitem>
of mechanisms supported by your token. The mechanism can also be specified in
hexadecimal, e.g., <replaceable>0x80001234</replaceable>.</para></listitem>
</varlistentry>

<varlistentry>
Expand Down
5 changes: 4 additions & 1 deletion src/tools/pkcs11-tool.c
Expand Up @@ -234,7 +234,7 @@ static const char *option_help[] = {
"Hash some data",
"Derive a secret key using another key and some data",
"Derive ECDHpass DER encoded pubkey for compatibility with some PKCS#11 implementations",
"Specify mechanism (use -M for a list of supported mechanisms)",
"Specify mechanism (use -M for a list of supported mechanisms), or by hexadecimal, e.g., 0x80001234",
"Specify hash algorithm used with RSA-PKCS-PSS signature and RSA-PKCS-OAEP decryption",
"Specify MGF (Message Generation Function) used for RSA-PSS signature and RSA-OAEP decryption (possible values are MGF1-SHA1 to MGF1-SHA512)",
"Specify how many bytes should be used for salt in RSA-PSS signatures (default is digest size)",
Expand Down Expand Up @@ -6076,6 +6076,9 @@ static CK_MECHANISM_TYPE p11_name_to_mechanism(const char *name)
{
struct mech_info *mi;

if (strncasecmp("0x", name, 2) == 0) {
return strtoul(name, NULL, 0);
}
for (mi = p11_mechanisms; mi->name; mi++) {
if (!strcasecmp(mi->name, name)
|| (mi->short_name && !strcasecmp(mi->short_name, name)))
Expand Down

0 comments on commit 74885fb

Please sign in to comment.