Mastercard / pkcs11-tools

A set of tools to manage objects on PKCS#11 cryptographic tokens. Compatible with many PKCS#11 library, including major HSM brands, NSS and softoken.
Other
142 stars 29 forks source link

p11keygen ignores some of unknown argument #35

Closed wiwiwa closed 1 year ago

wiwiwa commented 1 year ago

Describe the bug p11keygen simply ignores unknown argument if argument starts with unicode characters

To Reproduce Steps to reproduce the behavior:

  1. run p11keygen -i test_key -k rsa WRAP £UNWRAP, success to generate key
  2. run p11ls prvk/test_key outputs prvk/test_key tok,prv,r/w,loc,sen,ase,nxt,rsa(2048). Nounw attribute found

Expected behavior run p11keygen -i test_key -k rsa WRAP £UNWRAP should fail with error message

Operating System (please complete the following information):

keldonin commented 1 year ago

Thanks @wiwiwa , The issue is indeed confirmed.

It seems that all subsequent arguments following £ character are ignored.

I suspect the issue to be caused by the character itelf: £ is not ASCII. Its Unicode representation is 0x00 0xa3; it is likely that the parser stops string interpretation when the first 0x00 is encountered.

keldonin commented 1 year ago

The issue is happening at the parser & lexer level. Unless there is an imperative reason to fix it, I'll leave this one as is.