public inbox for tpm2@lists.linux.dev
 help / color / mirror / Atom feed
From: Petr Gotthard <petr.gotthard at centrum.cz>
To: tpm2@lists.01.org
Subject: [tpm2] Re: {External} Re: OpenSSL 3 and tpm2 provider... / openssl cms
Date: Tue, 26 Apr 2022 22:22:33 +0200	[thread overview]
Message-ID: <20220426222233.E2A0DF7A@centrum.cz> (raw)
In-Reply-To: DS7PR03MB5576DBEE0181A7DBD38E9C259AFB9@ds7pr03mb5576.namprd03.prod.outlook.com

[-- Attachment #1: Type: text/plain, Size: 3268 bytes --]

Thank you, James.

Debugging openssl is tricky when it fails without any error message. :-/ This happens especially when the provider does not supply openssl with something that the default provider usually supplies-- in this case the MD algorithm.

The command
> openssl cms -sign -provider tpm2 -provider default -in file.txt -inkey handle:0x81800002 -signer handle:0x01000013
was failing because the key had no mandatory digest and there was no digest specified via the command line.

Adding "-md sha256" fixed the issue for me. If you create e.g. a RSA-PSS key restricted to a specific hash-algorithm you shouldn't need this extra argument, because openssl will ask the key for the digest algorithm.

Based on the commands you sent I made a new test for 'openssl cms'. Have a look here:
https://github.com/tpm2-software/tpm2-openssl/blob/master/test/rsa_genpkey_x509_cms.sh
This should show a full test scenario for CMS. I can add more if you think something is missing, or when you encounter another weird behaviour.


Regards,
Petr
______________________________________________________________
> Od: "Sievert, James" <james.sievert(a)bsci.com>
> Komu: "tpm2(a)lists.01.org" <tpm2(a)lists.01.org>
> Datum: 26.04.2022 16:24
> Předmět: [tpm2] Re: {External} Re: OpenSSL 3 and tpm2 provider...
>
>> Could you please suggest a sequence of openssl (and other commands) to verify all required CMS functions?
>
>Tell you what, I'll frame the test sequences in terms of the tpm2tss engine commands as I can verify correct syntax and command operation.  I'll assume for the time being that the necessary keys and certs are stored in TPM NVRAM through tpm2_* commands.
>
>The a good start to testing would be something to the effect:
>
>	echo "this is some text" >file.txt
>
>	openssl cms -sign -engine tpm2tss -keyform engine -inkey 0x81800002 -signer signer.pem -in file.txt -binary -nodetach -out file.sig
>
>	(note that although the tpm2tss engine doesn't support it, the signer could also be given as a handle to the tpm2 provider)
>
>	openssl cms -verify -in file.sig -binary -noverify
>
>	(note that you can remove the -noverify and point to a truststore if necessary with -CApath /somewhere/truststore)
>
>	openssl cms -encrypt -recip signer.pem -in file.txt -out file.enc
>
>	(note that although the tpm2tss engine doesn't support it, the recip could also be given as a handle to the tpm2 provider)
>
>	openssl cms -decrypt -engine tpm2tss -keyform engine -inkey 0x81800002 -in file.enc -recip signer.pem
>
>	(note that this command doesn't work with the tpm2tss engine.  See:  https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1962549.)
>
>	openssl cms  -encrypt  -sign...
>
>	(the cms command can encrypt, sign, and bundle everything into an output with a single command -- the syntax is a combination of what's above)
>
>	openssl cms -verify -decrypt ...
>
>	(the cms command can verify and decrypt an input with a single command -- the syntax is a combination of what's above)
>
>	 
>_______________________________________________
>tpm2 mailing list -- tpm2(a)lists.01.org
>To unsubscribe send an email to tpm2-leave(a)lists.01.org
>%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
>
>

             reply	other threads:[~2022-04-26 20:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 20:22 Petr Gotthard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-04-26 21:43 [tpm2] Re: {External} Re: OpenSSL 3 and tpm2 provider... / openssl cms Sievert, James
2022-04-26 21:54 Petr Gotthard
2022-04-27 14:46 Petr Gotthard
2022-04-27 15:20 Sievert, James
2022-04-27 17:37 Petr Gotthard
2022-04-28 14:42 Sievert, James
2022-04-28 15:07 Sievert, James
2022-04-28 15:10 Petr Gotthard
2022-04-28 15:46 Sievert, James
2022-04-28 16:26 Petr Gotthard
2022-04-28 16:33 Sievert, James
2022-04-28 17:39 Petr Gotthard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220426222233.E2A0DF7A@centrum.cz \
    --to=tpm2@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox