All of lore.kernel.org
 help / color / mirror / Atom feed
* U-Boot FIT Signature Verification
@ 2020-09-11 17:26 Andrii Voloshyn
  2020-09-15 23:19 ` Heinrich Schuchardt
  0 siblings, 1 reply; 14+ messages in thread
From: Andrii Voloshyn @ 2020-09-11 17:26 UTC (permalink / raw)
  To: u-boot

Hi there,

    Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file? 

Cheers,
Andy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-11 17:26 U-Boot FIT Signature Verification Andrii Voloshyn
@ 2020-09-15 23:19 ` Heinrich Schuchardt
  2020-09-16  8:13   ` AKASHI Takahiro
  2020-09-16 20:01   ` Philippe REYNES
  0 siblings, 2 replies; 14+ messages in thread
From: Heinrich Schuchardt @ 2020-09-15 23:19 UTC (permalink / raw)
  To: u-boot

On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> Hi there,
>
>     Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
>
> Cheers,
> Andy
>

Hello Philippe,

looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
find a comparison of the date on which an image was signed with the
expiry date of the certificate. Shouldn't there be a check? Or did I
simply look into the wrong function?

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-15 23:19 ` Heinrich Schuchardt
@ 2020-09-16  8:13   ` AKASHI Takahiro
  2020-09-16 11:14     ` Heinrich Schuchardt
  2020-09-16 20:01   ` Philippe REYNES
  1 sibling, 1 reply; 14+ messages in thread
From: AKASHI Takahiro @ 2020-09-16  8:13 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> > Hi there,
> >
> >     Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> >
> > Cheers,
> > Andy
> >
> 
> Hello Philippe,
> 
> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> find a comparison of the date on which an image was signed with the
> expiry date of the certificate. Shouldn't there be a check? Or did I
> simply look into the wrong function?

I think Simon is the right person to answer this question, but

as far as I know, we don't have any device tree property for the expiration
date of a public key. See doc/uImage.FIT/signature.txt.

-Takahiro Akashi

> Best regards
> 
> Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16  8:13   ` AKASHI Takahiro
@ 2020-09-16 11:14     ` Heinrich Schuchardt
  2020-09-16 11:40       ` Joakim Tjernlund
  2020-09-17  5:26       ` AKASHI Takahiro
  0 siblings, 2 replies; 14+ messages in thread
From: Heinrich Schuchardt @ 2020-09-16 11:14 UTC (permalink / raw)
  To: u-boot

On 16.09.20 10:13, AKASHI Takahiro wrote:
> On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
>> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
>>> Hi there,
>>>
>>>     Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
>>>
>>> Cheers,
>>> Andy
>>>
>>
>> Hello Philippe,
>>
>> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
>> find a comparison of the date on which an image was signed with the
>> expiry date of the certificate. Shouldn't there be a check? Or did I
>> simply look into the wrong function?
>
> I think Simon is the right person to answer this question, but
>
> as far as I know, we don't have any device tree property for the expiration
> date of a public key. See doc/uImage.FIT/signature.txt.

Yes, the problem starts with mkimage not writing the dates available in
the X509 certificate into the device tree.

The dates are accessible via the X509_get0_notBefore() and
X509_get0_notAfter() functions of the OpenSSL library.


Takahiro, could you, please, also look at the UEFI secure boot
implementation in U-Boot. EDK2 validates the dates via the embedded
OpenSSL library in
CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
verify_chain(). We should not do less.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 11:14     ` Heinrich Schuchardt
@ 2020-09-16 11:40       ` Joakim Tjernlund
  2020-09-16 11:55         ` Heinrich Schuchardt
  2020-09-17  5:57         ` takahiro.akashi at linaro.org
  2020-09-17  5:26       ` AKASHI Takahiro
  1 sibling, 2 replies; 14+ messages in thread
From: Joakim Tjernlund @ 2020-09-16 11:40 UTC (permalink / raw)
  To: u-boot

On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> On 16.09.20 10:13, AKASHI Takahiro wrote:
> > On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> > > On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> > > > Hi there,
> > > > 
> > > > ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> > > > 
> > > > Cheers,
> > > > Andy
> > > > 
> > > 
> > > Hello Philippe,
> > > 
> > > looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> > > find a comparison of the date on which an image was signed with the
> > > expiry date of the certificate. Shouldn't there be a check? Or did I
> > > simply look into the wrong function?
> > 
> > I think Simon is the right person to answer this question, but
> > 
> > as far as I know, we don't have any device tree property for the expiration
> > date of a public key. See doc/uImage.FIT/signature.txt.
> 
> Yes, the problem starts with mkimage not writing the dates available in
> the X509 certificate into the device tree.
> 
> The dates are accessible via the X509_get0_notBefore() and
> X509_get0_notAfter() functions of the OpenSSL library.
> 
> 
> Takahiro, could you, please, also look at the UEFI secure boot
> implementation in U-Boot. EDK2 validates the dates via the embedded
> OpenSSL library in
> CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
> verify_chain(). We should not do less.

Does that mean that verified boot stops/fails when the date expires ?
How do you guarantee that the device has the correct time ?

   Jocke

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 11:40       ` Joakim Tjernlund
@ 2020-09-16 11:55         ` Heinrich Schuchardt
  2020-09-16 12:05           ` Joakim Tjernlund
  2020-09-17  5:57         ` takahiro.akashi at linaro.org
  1 sibling, 1 reply; 14+ messages in thread
From: Heinrich Schuchardt @ 2020-09-16 11:55 UTC (permalink / raw)
  To: u-boot

On 16.09.20 13:40, Joakim Tjernlund wrote:
> On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
>> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>>
>>
>> On 16.09.20 10:13, AKASHI Takahiro wrote:
>>> On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
>>>> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
>>>>> Hi there,
>>>>>
>>>>> ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
>>>>>
>>>>> Cheers,
>>>>> Andy
>>>>>
>>>>
>>>> Hello Philippe,
>>>>
>>>> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
>>>> find a comparison of the date on which an image was signed with the
>>>> expiry date of the certificate. Shouldn't there be a check? Or did I
>>>> simply look into the wrong function?
>>>
>>> I think Simon is the right person to answer this question, but
>>>
>>> as far as I know, we don't have any device tree property for the expiration
>>> date of a public key. See doc/uImage.FIT/signature.txt.
>>
>> Yes, the problem starts with mkimage not writing the dates available in
>> the X509 certificate into the device tree.
>>
>> The dates are accessible via the X509_get0_notBefore() and
>> X509_get0_notAfter() functions of the OpenSSL library.
>>
>>
>> Takahiro, could you, please, also look at the UEFI secure boot
>> implementation in U-Boot. EDK2 validates the dates via the embedded
>> OpenSSL library in
>> CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
>> verify_chain(). We should not do less.
>
> Does that mean that verified boot stops/fails when the date expires ?
> How do you guarantee that the device has the correct time ?
>
>    Jocke
>

We talking of the validity time range of the public key and the date of
signature of the intermediate certificates and the loaded image. No RTC
time is involved.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 11:55         ` Heinrich Schuchardt
@ 2020-09-16 12:05           ` Joakim Tjernlund
  2020-09-16 12:44             ` Heinrich Schuchardt
  0 siblings, 1 reply; 14+ messages in thread
From: Joakim Tjernlund @ 2020-09-16 12:05 UTC (permalink / raw)
  To: u-boot

On Wed, 2020-09-16 at 13:55 +0200, Heinrich Schuchardt wrote:
> On 16.09.20 13:40, Joakim Tjernlund wrote:
> > On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
> > > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> > > 
> > > 
> > > On 16.09.20 10:13, AKASHI Takahiro wrote:
> > > > On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> > > > > On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> > > > > > Hi there,
> > > > > > 
> > > > > > ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> > > > > > 
> > > > > > Cheers,
> > > > > > Andy
> > > > > > 
> > > > > 
> > > > > Hello Philippe,
> > > > > 
> > > > > looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> > > > > find a comparison of the date on which an image was signed with the
> > > > > expiry date of the certificate. Shouldn't there be a check? Or did I
> > > > > simply look into the wrong function?
> > > > 
> > > > I think Simon is the right person to answer this question, but
> > > > 
> > > > as far as I know, we don't have any device tree property for the expiration
> > > > date of a public key. See doc/uImage.FIT/signature.txt.
> > > 
> > > Yes, the problem starts with mkimage not writing the dates available in
> > > the X509 certificate into the device tree.
> > > 
> > > The dates are accessible via the X509_get0_notBefore() and
> > > X509_get0_notAfter() functions of the OpenSSL library.
> > > 
> > > 
> > > Takahiro, could you, please, also look at the UEFI secure boot
> > > implementation in U-Boot. EDK2 validates the dates via the embedded
> > > OpenSSL library in
> > > CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
> > > verify_chain(). We should not do less.
> > 
> > Does that mean that verified boot stops/fails when the date expires ?
> > How do you guarantee that the device has the correct time ?
> > 
> > ???Jocke
> > 
> 
> We talking of the validity time range of the public key and the date of
> signature of the intermediate certificates and the loaded image. No RTC

OK, but still: will an invalid time range then stop booting ?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 12:05           ` Joakim Tjernlund
@ 2020-09-16 12:44             ` Heinrich Schuchardt
  2020-09-16 19:54               ` Tom Rini
  2020-09-17  5:33               ` takahiro.akashi at linaro.org
  0 siblings, 2 replies; 14+ messages in thread
From: Heinrich Schuchardt @ 2020-09-16 12:44 UTC (permalink / raw)
  To: u-boot

On 16.09.20 14:05, Joakim Tjernlund wrote:
> On Wed, 2020-09-16 at 13:55 +0200, Heinrich Schuchardt wrote:
>> On 16.09.20 13:40, Joakim Tjernlund wrote:
>>> On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
>>>> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>>>>
>>>>
>>>> On 16.09.20 10:13, AKASHI Takahiro wrote:
>>>>> On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
>>>>>> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
>>>>>>> Hi there,
>>>>>>>
>>>>>>> ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Andy
>>>>>>>
>>>>>>
>>>>>> Hello Philippe,
>>>>>>
>>>>>> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
>>>>>> find a comparison of the date on which an image was signed with the
>>>>>> expiry date of the certificate. Shouldn't there be a check? Or did I
>>>>>> simply look into the wrong function?
>>>>>
>>>>> I think Simon is the right person to answer this question, but
>>>>>
>>>>> as far as I know, we don't have any device tree property for the expiration
>>>>> date of a public key. See doc/uImage.FIT/signature.txt.
>>>>
>>>> Yes, the problem starts with mkimage not writing the dates available in
>>>> the X509 certificate into the device tree.
>>>>
>>>> The dates are accessible via the X509_get0_notBefore() and
>>>> X509_get0_notAfter() functions of the OpenSSL library.
>>>>
>>>>
>>>> Takahiro, could you, please, also look at the UEFI secure boot
>>>> implementation in U-Boot. EDK2 validates the dates via the embedded
>>>> OpenSSL library in
>>>> CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
>>>> verify_chain(). We should not do less.
>>>
>>> Does that mean that verified boot stops/fails when the date expires ?
>>> How do you guarantee that the device has the correct time ?
>>>
>>> ???Jocke
>>>
>>
>> We talking of the validity time range of the public key and the date of
>> signature of the intermediate certificates and the loaded image. No RTC
>
> OK, but still: will an invalid time range then stop booting ?
>
>

If you use a certificate that is valid until 2019 to sign an image or an
intermediate certificate in 2020, the image must not be loaded.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 12:44             ` Heinrich Schuchardt
@ 2020-09-16 19:54               ` Tom Rini
  2020-09-17  5:33               ` takahiro.akashi at linaro.org
  1 sibling, 0 replies; 14+ messages in thread
From: Tom Rini @ 2020-09-16 19:54 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 16, 2020 at 02:44:45PM +0200, Heinrich Schuchardt wrote:
> On 16.09.20 14:05, Joakim Tjernlund wrote:
> > On Wed, 2020-09-16 at 13:55 +0200, Heinrich Schuchardt wrote:
> >> On 16.09.20 13:40, Joakim Tjernlund wrote:
> >>> On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
> >>>> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> >>>>
> >>>>
> >>>> On 16.09.20 10:13, AKASHI Takahiro wrote:
> >>>>> On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> >>>>>> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> >>>>>>> Hi there,
> >>>>>>>
> >>>>>>> ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> >>>>>>>
> >>>>>>> Cheers,
> >>>>>>> Andy
> >>>>>>>
> >>>>>>
> >>>>>> Hello Philippe,
> >>>>>>
> >>>>>> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> >>>>>> find a comparison of the date on which an image was signed with the
> >>>>>> expiry date of the certificate. Shouldn't there be a check? Or did I
> >>>>>> simply look into the wrong function?
> >>>>>
> >>>>> I think Simon is the right person to answer this question, but
> >>>>>
> >>>>> as far as I know, we don't have any device tree property for the expiration
> >>>>> date of a public key. See doc/uImage.FIT/signature.txt.
> >>>>
> >>>> Yes, the problem starts with mkimage not writing the dates available in
> >>>> the X509 certificate into the device tree.
> >>>>
> >>>> The dates are accessible via the X509_get0_notBefore() and
> >>>> X509_get0_notAfter() functions of the OpenSSL library.
> >>>>
> >>>>
> >>>> Takahiro, could you, please, also look at the UEFI secure boot
> >>>> implementation in U-Boot. EDK2 validates the dates via the embedded
> >>>> OpenSSL library in
> >>>> CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
> >>>> verify_chain(). We should not do less.
> >>>
> >>> Does that mean that verified boot stops/fails when the date expires ?
> >>> How do you guarantee that the device has the correct time ?
> >>>
> >>> ???Jocke
> >>>
> >>
> >> We talking of the validity time range of the public key and the date of
> >> signature of the intermediate certificates and the loaded image. No RTC
> >
> > OK, but still: will an invalid time range then stop booting ?
> >
> >
> 
> If you use a certificate that is valid until 2019 to sign an image or an
> intermediate certificate in 2020, the image must not be loaded.

Right.  And to be clear, the case of using a valid until 2021 cert to
sign everything in 2020 will be seen as valid in 2022.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200916/31301554/attachment.sig>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-15 23:19 ` Heinrich Schuchardt
  2020-09-16  8:13   ` AKASHI Takahiro
@ 2020-09-16 20:01   ` Philippe REYNES
  1 sibling, 0 replies; 14+ messages in thread
From: Philippe REYNES @ 2020-09-16 20:01 UTC (permalink / raw)
  To: u-boot

Hi Heinrich,

> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
>> Hi there,
>> 
>> Does U-boot take into account certificate expiration date when verifying signed
>> images in FIT? In other words, is date stored along with the public key in DTB
>> file?
>> 
>> Cheers,
>> Andy
>> 
> 
> Hello Philippe,
> 
> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> find a comparison of the date on which an image was signed with the
> expiry date of the certificate. Shouldn't there be a check? Or did I
> simply look into the wrong function?

This function only check the padding using the algorithm pkcs-1.5 as
defined here : https://tools.ietf.org/html/rfc3447#section-9.2
It doesn't check the certificate validity.

I don't remember to have see a date checked in the signature process.
If all informations are (or may be) available at runtime, we may
add it.

> Best regards
> 
> Heinrich

Best regards,
Philippe

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 11:14     ` Heinrich Schuchardt
  2020-09-16 11:40       ` Joakim Tjernlund
@ 2020-09-17  5:26       ` AKASHI Takahiro
  1 sibling, 0 replies; 14+ messages in thread
From: AKASHI Takahiro @ 2020-09-17  5:26 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 16, 2020 at 01:14:56PM +0200, Heinrich Schuchardt wrote:
> On 16.09.20 10:13, AKASHI Takahiro wrote:
> > On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> >> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> >>> Hi there,
> >>>
> >>>     Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> >>>
> >>> Cheers,
> >>> Andy
> >>>
> >>
> >> Hello Philippe,
> >>
> >> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> >> find a comparison of the date on which an image was signed with the
> >> expiry date of the certificate. Shouldn't there be a check? Or did I
> >> simply look into the wrong function?
> >
> > I think Simon is the right person to answer this question, but
> >
> > as far as I know, we don't have any device tree property for the expiration
> > date of a public key. See doc/uImage.FIT/signature.txt.
> 
> Yes, the problem starts with mkimage not writing the dates available in
> the X509 certificate into the device tree.
> 
> The dates are accessible via the X509_get0_notBefore() and
> X509_get0_notAfter() functions of the OpenSSL library.
> 
> 
> Takahiro, could you, please, also look at the UEFI secure boot
> implementation in U-Boot. EDK2 validates the dates via the embedded
> OpenSSL library in
> CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
> verify_chain(). We should not do less.

Yes, we do the check. See pkcs7_verify_one() in lib/crypto/pkcs7_verify.c.

-Takahiro Akashi


> Best regards
> 
> Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 12:44             ` Heinrich Schuchardt
  2020-09-16 19:54               ` Tom Rini
@ 2020-09-17  5:33               ` takahiro.akashi at linaro.org
  1 sibling, 0 replies; 14+ messages in thread
From: takahiro.akashi at linaro.org @ 2020-09-17  5:33 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 16, 2020 at 02:44:45PM +0200, Heinrich Schuchardt wrote:
> On 16.09.20 14:05, Joakim Tjernlund wrote:
> > On Wed, 2020-09-16 at 13:55 +0200, Heinrich Schuchardt wrote:
> >> On 16.09.20 13:40, Joakim Tjernlund wrote:
> >>> On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
> >>>> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> >>>>
> >>>>
> >>>> On 16.09.20 10:13, AKASHI Takahiro wrote:
> >>>>> On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> >>>>>> On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> >>>>>>> Hi there,
> >>>>>>>
> >>>>>>> ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> >>>>>>>
> >>>>>>> Cheers,
> >>>>>>> Andy
> >>>>>>>
> >>>>>>
> >>>>>> Hello Philippe,
> >>>>>>
> >>>>>> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> >>>>>> find a comparison of the date on which an image was signed with the
> >>>>>> expiry date of the certificate. Shouldn't there be a check? Or did I
> >>>>>> simply look into the wrong function?
> >>>>>
> >>>>> I think Simon is the right person to answer this question, but
> >>>>>
> >>>>> as far as I know, we don't have any device tree property for the expiration
> >>>>> date of a public key. See doc/uImage.FIT/signature.txt.
> >>>>
> >>>> Yes, the problem starts with mkimage not writing the dates available in
> >>>> the X509 certificate into the device tree.
> >>>>
> >>>> The dates are accessible via the X509_get0_notBefore() and
> >>>> X509_get0_notAfter() functions of the OpenSSL library.
> >>>>
> >>>>
> >>>> Takahiro, could you, please, also look at the UEFI secure boot
> >>>> implementation in U-Boot. EDK2 validates the dates via the embedded
> >>>> OpenSSL library in
> >>>> CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
> >>>> verify_chain(). We should not do less.
> >>>
> >>> Does that mean that verified boot stops/fails when the date expires ?
> >>> How do you guarantee that the device has the correct time ?
> >>>
> >>> ???Jocke
> >>>
> >>
> >> We talking of the validity time range of the public key and the date of
> >> signature of the intermediate certificates and the loaded image. No RTC
> >
> > OK, but still: will an invalid time range then stop booting ?
> >
> >
> 
> If you use a certificate that is valid until 2019 to sign an image or an
> intermediate certificate in 2020, the image must not be loaded.

Well, I'm not confident that pckcs7_verify_one() does this.
(Probably not.)

-Takahiro Akashi

> 
> Best regards
> 
> Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
  2020-09-16 11:40       ` Joakim Tjernlund
  2020-09-16 11:55         ` Heinrich Schuchardt
@ 2020-09-17  5:57         ` takahiro.akashi at linaro.org
  1 sibling, 0 replies; 14+ messages in thread
From: takahiro.akashi at linaro.org @ 2020-09-17  5:57 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 16, 2020 at 11:40:08AM +0000, Joakim Tjernlund wrote:
> On Wed, 2020-09-16 at 13:14 +0200, Heinrich Schuchardt wrote:
> > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> > 
> > 
> > On 16.09.20 10:13, AKASHI Takahiro wrote:
> > > On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:
> > > > On 9/11/20 7:26 PM, Andrii Voloshyn wrote:
> > > > > Hi there,
> > > > > 
> > > > > ????Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?
> > > > > 
> > > > > Cheers,
> > > > > Andy
> > > > > 
> > > > 
> > > > Hello Philippe,
> > > > 
> > > > looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot
> > > > find a comparison of the date on which an image was signed with the
> > > > expiry date of the certificate. Shouldn't there be a check? Or did I
> > > > simply look into the wrong function?
> > > 
> > > I think Simon is the right person to answer this question, but
> > > 
> > > as far as I know, we don't have any device tree property for the expiration
> > > date of a public key. See doc/uImage.FIT/signature.txt.
> > 
> > Yes, the problem starts with mkimage not writing the dates available in
> > the X509 certificate into the device tree.
> > 
> > The dates are accessible via the X509_get0_notBefore() and
> > X509_get0_notAfter() functions of the OpenSSL library.
> > 
> > 
> > Takahiro, could you, please, also look at the UEFI secure boot
> > implementation in U-Boot. EDK2 validates the dates via the embedded
> > OpenSSL library in
> > CryptoPkg/Library/OpensslLib/openssl/crypto/x509/x509_vfy.c, function
> > verify_chain(). We should not do less.
> 
> Does that mean that verified boot stops/fails when the date expires ?
> How do you guarantee that the device has the correct time ?

Good point. Reither had a similar comment.

For trusted timestamps, we need to support RFC3161 timestamp protocol
when signing an image.
During the image verification, the "signed" timestamp of the image will also
be verified with a certificate in "dbt" database.

Well, this is in UEFI world, not FIT signature verification.

(I have a prototype of timestamp revocation implementation as part of
UEFI secure boot on U-Boot, but never made it public yet.)

-Takahiro Akashi



>    Jocke

^ permalink raw reply	[flat|nested] 14+ messages in thread

* U-Boot FIT Signature Verification
@ 2020-09-16 15:31 REITHER Robert - Contractor
  0 siblings, 0 replies; 14+ messages in thread
From: REITHER Robert - Contractor @ 2020-09-16 15:31 UTC (permalink / raw)
  To: u-boot

Hi there



I don't think it would make sense to check for expiration (even in case we would have full certificates like PKCS#7 verifiy)

At our point of the boot process we normally do not have access to a trusted time/date, so any check could be simply spoofed or even worse fails, because wall clock is not initialized properly.



I think even the EFI boot-process (or shim) does not check expiration date of their certificates!





What could make sense is a check for an expired certificate/key at signing time (including intermed certs), but not sure if this would be a too hard restriction (at least for developing/testing). I think a hint for the signer should be enough!



Regards

Robert



On Wed, Sep 16, 2020 at 01:19:03AM +0200, Heinrich Schuchardt wrote:

>

On 9/11/20 7:26 PM, Andrii Voloshyn wrote:

> > Hi there,

> >

> >     Does U-boot take into account certificate expiration date when verifying signed images in FIT? In other words, is date stored along with the public key in DTB file?

> >

> > Cheers,

> > Andy

> >

>

> Hello Philippe,

>

> looking at padding_pkcs_15_verify() in lib/rsa/rsa-verify.c I cannot

> find a comparison of the date on which an image was signed with the

> expiry date of the certificate. Shouldn't there be a check? Or did I

> simply look into the wrong function?



I think Simon is the right person to answer this question, but



as far as I know, we don't have any device tree property for the expiration date of a public key. See doc/uImage.FIT/signature.txt.



-Takahiro Akashi



> Best regards

>

> Heinrich

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-09-17  5:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 17:26 U-Boot FIT Signature Verification Andrii Voloshyn
2020-09-15 23:19 ` Heinrich Schuchardt
2020-09-16  8:13   ` AKASHI Takahiro
2020-09-16 11:14     ` Heinrich Schuchardt
2020-09-16 11:40       ` Joakim Tjernlund
2020-09-16 11:55         ` Heinrich Schuchardt
2020-09-16 12:05           ` Joakim Tjernlund
2020-09-16 12:44             ` Heinrich Schuchardt
2020-09-16 19:54               ` Tom Rini
2020-09-17  5:33               ` takahiro.akashi at linaro.org
2020-09-17  5:57         ` takahiro.akashi at linaro.org
2020-09-17  5:26       ` AKASHI Takahiro
2020-09-16 20:01   ` Philippe REYNES
2020-09-16 15:31 REITHER Robert - Contractor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.