ķ
[ö_c           @   s*   d  d l  m Z d e f d     YZ d S(   i˙˙˙˙(   t	   HSMSignert   HSMOEMSignerc           B   s5   e  Z d  Z e d    Z e d    Z d   Z RS(   s+   Class to enable signing via OEM's HSM.
    c         C   s   t  S(   s0  Registers the class with the signer plugin manager. This allows
        the signer to be selected by the user from config/command line.

        Returns:
            is_plugin   (bool): True if the signer should be enabled,
                                False if the signer should be disabled.
        (   t   True(   t   cls(    (    s   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/sectools/plugin/signer/hsm_oem.pyt	   is_plugin   s    	c         C   s   d S(   sĪ   Specifies the unique id of the signer. This is the id that the user
        will use to select the signer from config/command line.

        Returns:
            signer_id   (str): ID of the signer.
        t   hsm_oem(    (   R   (    (    s   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/sectools/plugin/signer/hsm_oem.pyt	   signer_id   s    c         C   s.   d \ } } } } t d   | | | | f S(   sM  Signs the image_hash, generates the attestation certificate using
        the attest_cert_dict and signing_attrs and optionally returns the
        root certificate and the ca certificate.

        Args:
            signing_attrs  (object): An object containing the following signing
                                     attributes:
                                         - key_size: Size of the key for
                                                     attestation key.
                                         - exponent: Exponent for attestation
                                                     key.
            attest_cert_dict (dict): Dictionary containing the parameters to be
                                     put in the attestation certificate.
            image_hash        (str): The image hash binary blob to be signed.

        Returns:
            A tuple containing the root certificate, ca certificate, attestation
            certificate and the signature corresponsding to the image hash.

            root_cert    (str): - Binary blob of the root certificate.
                                - None if root certificate is provided under:
                                    resources/data_prov_assets/Signing/Local
            ca_cert      (str): - Binary blob of the ca certificate.
                                - None if ca certificate is provided under:
                                    resources/data_prov_assets/Signing/Local
            attest_cert  (str): Binary blob of the attestation certificate.
            signature    (str): Binary blob of the signature.
        s   OEM to implement hsm signerN(   NNNN(   t   Nonet   NotImplementedError(   t   selft   signing_attrst   attest_cert_dictt
   image_hasht	   root_certt   ca_certt   attest_certt	   signature(    (    s   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/sectools/plugin/signer/hsm_oem.pyt   sign_req%   s    (   t   __name__t
   __module__t   __doc__t   classmethodR   R   R   (    (    (    s   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/sectools/plugin/signer/hsm_oem.pyR      s   
N(   t   plugin.signerR    R   (    (    (    s   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/sectools/plugin/signer/hsm_oem.pyt   <module>	   s   