/*
 * Copyright (c) Qualcomm Technologies, Inc.
 * All Rights Reserved.
 * Confidential and Proprietary - Qualcomm Technologies, Inc.
 */

/**
 * @section IPFM_Overview IPFM Overview
 * IPFM is the interface to the Platform Feature Manager (PFM),
 * which provides access to a managed collection of feature licenses.
 * PFM also refers to an ASCII-encoded license format based on PEM.
 * A complete description of feature licenses is beyond the scope of
 * this document.  From a high level, a feature license is an X.509
 * certificate with extensions that define what features are enabled
 * and under what conditions.  The extensions provide a blacklist.
 * If a value specified by any extension does not match either the query or
 * the state of the device, license validation will fail, with an error
 * code that indicates the first extension where a mismatch was detected.
 * Technically, a Feature ID or FID is an integer that identifies a feature.
 * However, the terms feature, Feature ID, and FID are used somewhat
 * interchangeably in the rest of this document.
 *
 * @subsection IPFM_CBOR CBOR
 * Many of the IPFM methods use CBOR to encode inputs or outputs.  A full
 * description of CBOR is beyond the scope of this document.  One
 * reason it is used in the API is so responses can include additional
 * data in the future without requiring changes to client code or the .idl.
 * With that in mind, client code should not depend on the exact order
 * of items in a CBOR map in a response, or the exact number of items in
 * a CBOR structure/array.  Clients should skip unexpected trailing items in
 * arrays and unknown keys in maps, and should only fail if any expected
 * fields are NOT present.
 *
 * CBOR inputs and outputs are described using both CDDL and a CBOR diagnostic
 * format, which a JSON-like text version of the CBOR data.  Square braces
 * indicate a CBOR array, which may be heterogeneous.  Curly braces
 * indicate a CBOR map.  CBOR maps used by IPFM always use text strings as
 * map key values.
 *
 * @note CBOR permits both definite- and indefinite-length arrays and maps,
 * but IPFM methods only accept and produce definite-length arrays and maps.
 * Depending on the CBOR library used by the client, client code may have to
 * provide additional options to generate definite-length arrays and maps.
 *
 * @subsection IPFM_Distinguished_Names Distinguished Names
 * The normal purpose of an X.509 certificate is for a certificate Issuer
 * to assert that a public key is owned by a Subject.  The Issuer and Subject
 * are identified by Distinguished Names.  A Distingushed Name (DN) is a series
 * of well-known attribute types (keys) and values.  Most key / value pairs are
 * optional.  Several IPFM methods return
 * the Issuer and Subject DNs in a CBOR map.  The values in the CBOR map
 * have been converted from the raw DER encoding into a CBOR map.  Both the
 * keys and values in the map are TSTR values.  The following key values are
 * supported at a minimum.
 * @li @c "O" - Organization
 * @li @c "OU" - Organizational Unit
 * @li @c "CN" - Common Name
 *
 * @subsection IPFM_Validation_Error_Codes Common Validation Error Codes
 * A number of IPFM methods return errors that indicate which restriction
 * failed to match, as described above, or a more general problem with the
 * X.509 certificate structure.  These error codes all include _CERT in
 * their names and are listed here.
 *
 * @par Restriction Mismatch Errors
 * @li @ref ERROR_CERT_PKHASH
 * @li @ref ERROR_CERT_FEATUREID
 * @li @ref ERROR_CERT_EXPIRED
 * @li @ref ERROR_CERT_OEM
 * @li @ref ERROR_CERT_HWVERSION
 * @li @ref ERROR_CERT_LICENSEE_HASH
 * @li @ref ERROR_CERT_DEVICEID
 * @li @ref ERROR_CERT_NOTYETVALID
 * @li @ref ERROR_CERT_PRODUCTID
 *
 * @par Errors for corrupted or incorrectly generated licenses
 * @li @ref ERROR_INVALID_CERT
 * @li @ref ERROR_CERT_NOT_TRUSTED
 * @li @ref ERROR_CERT_GENERAL_ERR
 * @li @ref ERROR_CERT_LEAF_IS_CA
 *
 * @subsection IPFM_Common_Error_Codes Other Common Error Codes
 * @par Object_ERROR_SIZE_OUT
 * Many IPFM methods return variable-length data in CBOR format.  If the output
 * buffer provided by the client is not large enough to hold the data,
 * Object_ERROR_SIZE_OUT will be returned, and the output buffer length will
 * be set to a value large enough to contain the data.  Note that this is
 * an upper bound on the data length, and not necessarily the exact data length.
 * If the client allocates a new buffer of this length and calls the method again
 * with the new buffer, it will succeed, and the buffer length will be set to
 * the exact data size.
 *
 * @par Object_ERROR
 * Object_ERROR can be returned from most methods.  This indicates an
 * internal error of some kind.  It may indicate a system misconfiguration.
 * For example, it can be returned if PFM can not find the persistent storage
 * for licenses. The circumstances under which the error occurred and the
 * qsee_log should be reported to the maintainers of PFM.
 *
 * @par Other error codes
 * Note that while every effort is made to correctly list the errors that
 * each method can return, the list should not be considered exhaustive.
 * A method may return error codes in addition to those listed, either now
 * or in the future.
 */
include "IDeviceAttestation.idl"
include "IProvisioning.idl"
include "IPFMCallback.idl"

struct EnforceHWFeatureId_t {
    uint32 featureID;
    uint32 HWFeatureStatus;
};

/** @cond */
interface IPFMUpdater {
/** @endcond */

  /**
   * @addtogroup IPFMUpdater
   * @{
   */

    /**
    @brief Collects all the licenses for a transaction

    @param[in] PFMLicense - Feature license in PFM or DER format.

    @return Object_OK on success

    */
    method Update(in buffer PFMLicense);

     /**
    @brief Finalizes the transaction.

    @param[out] TransactionInfo. If the licenses don't contain Transaction Extension, the response
    CBOR array will be empty

    @par CDDL for TransactionInfo
    @verbatim
    TransactionInfo CBOR Response:
    [
        +{
            ?"TransactionID":tstr,
            ?"InstalledLicenses":[+bstr],
            ?"RevokedLicenses":[+bstr],
            ?"Status":uint64_t
        }
    ]
    @endverbatim

    @par TransactionInfo Example
    @verbatim

    TransactionInfo:
    [
        {
            "TransactionID": "b02f096b-ecd4-47af-b5bd-38ce798846a3",
            "InstalledLicenses": [h'4535DFC452A36B57794EC60EE15661F0'],
            "RevokedLicenses": [h'688FF7B4A0FB0DAA1D8C7D798E1F665F'],
            "Status": 0
        },
        {
            "TransactionID": "f1c5111f-4d46-4d7e-a6ab-a113af77ca70",
            "InstalledLicenses": [h'4FBB16D936B909F1A2E525DA1B5AA540'],
            "RevokedLicenses": [h'191068B7BBD82C83C5ACCB9FC71D9FA9'],
            "Status": 0
        }
    ]
    @endverbatim

    @par TransactionInfo CBOR value descriptions
    @li TransactionID - Unique identifier for a given transaction for a bundle of licenses.
    @li InstalledLicenses - Serial numbers of licenses installed for this transaction.
    @li RevokedLicenses - Serial numbers of licenses revoked for this transaction.
    @li Status - 0 for transaction success, 1 for transaction incomplete, 3 for transaction failure.

    @return Object_OK on success

    */
    method Finalize(out buffer TransactionInfo);

  /* @} */ /* end_addtogroup IPFM */
};

/** @cond */
interface IPFM  {
/** @endcond */

  /**
   * @addtogroup IPFM
   * @{
   */

    const uint64 OPT_NO_OEMID_CHECK                        = 0x00000001;    /* Deprecated */
    const uint64 OPT_NO_HWVERSION_CHECK                    = 0x00000002;    /* Deprecated */
    const uint64 OPT_NO_FEATUREID_CHECK                    = 0x00000004;    /* Deprecated */
    const uint64 OPT_NO_TIME_CHECK                         = 0x00000008;    /* Deprecated */
    const uint64 OPT_CLOCK_NOT_SET_OK                      = 0x00000010;    /* Deprecated */
    const uint64 OPT_SELECT_TEST_ROOT                      = 0x00000020;    /* Test and Development Use Only */
    const uint64 OPT_USAGE_ENCRYPT                         = 0x00000040;    /* Internal and Test Use Only */
    const uint64 OPT_NO_PKHASH_CHECK                       = 0x00000080;    /* Deprecated */
    const uint64 OPT_NO_DEVICE_ID_CHECK                    = 0x00000100;    /* Test Use Only */
    const uint64 OPT_NO_START_LICENSE_DATE_CHECK           = 0x00000200;    /* Deprecated */
    const uint64 OPT_TRUST_INSECURE_CLK                    = 0x00000400;    /* Deprecated */
    const uint64 OPT_NO_PRODUCTID_CHECK                    = 0x00000800;    /* Deprecated */
    const uint64 OPT_CONSUME_GRACE_COUNT                   = 0x00001000;    /* Deprecated */
    const uint64 OPT_DO_NOT_USE_GRACE_COUNT_FEATURE        = 0x00002000;    /* Deprecated */
    const uint64 OPT_SELECT_TEST_LICENSEE_HASH             = 0x00004000;    /* Test Use Only */
    const uint64 OPT_CLIENT_IS_LICENSEE                    = 0x00008000;    /* Deprecated */

    const uint64 LICENSE_HAS_OEMID                         = 0x00000001;    /**< OEM ID must match license */
    const uint64 LICENSE_HAS_HWVERSION                     = 0x00000002;    /**< Hardware Version must match license */
    const uint64 LICENSE_HAS_DEVICEID                      = 0x00000004;    /**< Device ID must match license */
    const uint64 LICENSE_HAS_PKHASH                        = 0x00000008;    /**< Device PKHash must match license */
    const uint64 LICENSE_HAS_LICENSEEHASH                  = 0x00000010;    /**< client ISV Hash must match license */
    const uint64 LICENSE_HAS_VALIDTIME                     = 0x00000020;    /**< Current time must match license */
    const uint64 LICENSE_HAS_PRODUCTID                     = 0x00000040;    /**< Product ID must match license */
    const uint64 LICENSE_HAS_GRACE_PERIOD                  = 0x00000080;    /**< VALIDTIME may be affected by grace period */

    const uint64 CAPS_ATOMIC_LICENSE_OP                    = 0x00000001;    /**< TA supports Atomic license operations */

    /* Response codes for Check() APIs & Notifications */
    const uint64 FEATURE_STATUS_ALLOWED                    = 0x00000000;    /**< The feature is allowed. */
    const uint64 FEATURE_STATUS_NOT_ALLOWED                = 0x00000001;    /**< The feature is not allowed. */
    const uint64 FEATURE_STATUS_PROCESSING_ERROR           = 0x00000003;    /**< Failure occurs while processing a potentially matching license. */
    const uint64 FEATURE_STATUS_NO_LICENSES                = 0x00000004;    /**< No licenses are in the store. */
    const uint64 FEATURE_STATUS_GRACE_ACTIVATION_NEEDED    = 0x00000005;    /**< Grace activation is required. */

    /* Status for transaction information */
    const uint64 TRANSACTION_STATUS_SUCCESS                = 0x00000000;    /**< Transaction success. */
    const uint64 TRANSACTION_STATUS_INCOMPLETE             = 0x00000001;    /**< Transaction is incomplete. */
    const uint64 TRANSACTION_STATUS_FAIL                   = 0x00000002;    /**< Transaction fail. */

    /* Types of events to register for notifications */
    const uint64 EVENT_TYPE_STATE_CHANGE                   = 0x00000000;    /**< Event change such as install, transaction, expiry, and remove. */

    /* Platform Feature Manager Error Codes */
    error ERROR_NOMEM;                            /**< Memory allocation failed.  Retry may succeed. */
    error ERROR_INVALID_PFM_EXTENSION;            /* Deprecated.  Should not occur. */
    error ERROR_CBOR_ENCODE_ERR;                  /**< Internal error. */
    error ERROR_CERT_PKHASH;                      /**< The device's PKHash does not match the license. */
    error ERROR_INVALID_CERT;                     /**< License cannot be parsed or is corrupt. */
    error ERROR_CERT_FEATUREID;                   /**< The requested Feature ID does not match the license. */
    error ERROR_CERT_EXPIRED;                     /**< The license certificate is expired. */
    error ERROR_CERT_OEM;                         /**< The device's OEM ID does not match the license. */
    error ERROR_CERT_HWVERSION;                   /**< The device's CHIP ID (chip family) does not match the license. */
    error ERROR_CERT_LICENSEE_HASH;               /**< The requested Licensee Hash does not match the license. */
    error ERROR_PFMFILER_FAILED;                  /**< License data store is unavailable.  Retry later. */
    error ERROR_HASH_GENERATION;                  /**< The signing hash used by the license has the wrong length or the hash operation failed. */
    error ERROR_CERT_NOT_TRUSTED;                 /**< The license is not signed with a recognized root CA. */
    error ERROR_CERT_GENERAL_ERR;                 /**< Error while verifying the cert chain. */
    error ERROR_CBOR_DECODE_ERR;                  /**< Client CBOR input parameter is invalid. */
    error ERROR_CBOR_DECODE_DATATYPE_ERR;         /**< Data type is incorrect in client CBOR input parameter. */
    error ERROR_PFMFILER_FILE_REMOVE_FAILED;      /* Deprecated.  Should not occur. */
    error ERROR_PFMCACHE_REMOVE_FAILED;           /* Deprecated.  Should not occur. */
    error ERROR_RPMB_ERR;                         /* Deprecated.  Should not occur. */
    error ERROR_FILE_NOT_FOUND;                   /**< No managed license matches the client request. */
    error ERROR_PFMFILER_GETFILECONTENTS_FAILED;  /**< Managed license exists but could not be read. */
    error ERROR_LICENSE_TOO_BIG;                  /**< License data is too large. */
    error ERROR_PRIVILEGE_ERR;                    /**< ISV client is not the owner of the license. */
    error ERROR_LICENSE_STORE_FULL;               /**< No space is available to install a license. */
    error ERROR_CERT_FIELD_TOO_BIG;               /* Deprecated.  Should not occur. */
    error ERROR_INVALID_CURRENT_TIME;             /**< Time-based operation can not be completed because current time is unknown, or trust level is too low */
    error ERROR_FID_LIST_TRUNCATED;               /* Deprecated.  Should not occur. */
    error ERROR_BLOB_ENCAP_FAILED;                /**< Generation of encrypted response failed. */
    error ERROR_BLOB_DECAP_FAILED;                /**< Decryption of encrypted request failed. */
    error ERROR_CERT_DEVICEID;                    /**< The device's Device ID does not match the license. */
    error ERROR_SFS_ERR;                          /* Deprecated.  Should not occur. */
    error ERROR_CERT_NOTYETVALID;                 /**< The license certificate is not yet valid. */
    error ERROR_OPTS_NOT_SUPPORTED;               /**< SetOptions is not allowed for the current client. */
    error ERROR_OVERFLOW;                         /**< Request would cause an overflow in an internal calculation. */
    error ERROR_NOT_GRACE_BOUND;                  /**< License does not have a grace period extension. */
    error ERROR_CERT_PRODUCTID;                   /**< The device's Product/Model ID does not match the license. */
    error ERROR_CERT_LEAF_IS_CA;                  /**< Leaf certificate in the license is marked as a CA. */
    error ERROR_NO_FEATURE_CONFIG;                /**< Feature Configs are not defined for this chipset */
    error ERROR_DUPLICATE;                        /**< The license can not be installed because it has the same serial number as a managed license. */
    error ERROR_NO_LICENSES;                      /**< Get or Check failed because no licenses are available.  */
    error ERROR_INCORRECT_LICENSEE_HASH;          /**< Licensee field did not match client, and client is an APK */
    error ERROR_ACTIVATION_NOT_NEEDED;            /**< License is currently active so grace period activation is not needed */
    error ERROR_QWESSTORE_MEMORY_FULL;            /**< Not able to store the key because of QWESStore memory is full. */
    error ERROR_REVOCATION_LIST;                  /**< Error while accessing revocation list */
    error ERROR_UNSUPPORTED_REVOCATION_FID;       /**< This happens if Revocation License file contains FeatureIDs that are not related to revocation feature */
    error ERROR_REVOCATION_UNSUPPORTED;           /**< Device does not either support RPMB or it isn't properly provisioned/configured */
    error ERROR_REVOCATION_LIST_FULL;             /**< Revocation List data is full */
    error ERROR_REV_LIC_ALREADY_PROCESSED;        /**< License with the revocation details is already processed */
    error ERROR_LICENSE_ALREADY_REVOKED;          /**< License which is requested to be revoked is already revoked */
    error ERROR_INVALID_TRANSACTION_COUNT;        /**< Revocation License has invalid TransactionID count to perform license revocation */
    error ERROR_REVOCATION_FID_UNAVAILABLE;       /**< License with Revocation extension requires revocaiton FID */
    error ERROR_REVOKE_LICENSE;                   /**< Failed to update revocation data */
    error ERROR_FLUSH;                            /**< Error writing data to RPMB */
    error ERROR_PFM_SUBMOD_REVOCATION_SERIAL;     /**< Error in adding revocation and/or revoked license to PFM Submod report */
    error ERROR_PFM_REPORT_REVOCATION_LICENSE;    /**< Error in adding revocation/revoked licenses in PFM Submod report */
    error ERROR_INVALID_PARAM;                    /**< Error due to passed incorrect input/output params. */
    error ERROR_GPBTTA_GRACE_EXPIRED;             /**< Error due to Allowed Grace Period have been expired */
    error ERROR_GRACE_COUNT_EXHAUSTED;            /**< Error due to Allowed Boot Count for Grace have been Exhauted */
    error ERROR_CALLBACK_STORE_FULL;              /**< No space is available to store a new callback */

    /**
    @brief Install a new license

    Installation will fail if device-based license restrictions do not match the device.
    Installation ignores licensee ID, feature ID, and expiration restrictions.  Output
    buffers will only be set on success.

    @par CDDL for FeatureIDsCBOR
    @verbatim
    FeatureIDsCBOR = {
        FIDs: [*uint32],
        FIDRanges: [*[uint32, uint32]]
    }
    @endverbatim

    @par FeatureIDsCBOR Format
    @verbatim
    FeatureIDsCBOR = {
        "FIDs" : [1,22,43],
        "FIDRanges" : [[10,20],[30,40]]
    }
    @endverbatim

    @par CBOR Value Descriptions
    @li FIDs - FIDs provided by the license
    @li FIDRanges - FID Ranges provided by the license

    @param[in] PFMLicense - Feature license in PFM or DER format
    @param[out] LicenseSerialNumber - Serial number of the license
    @param[out] FeatureIDsCBOR - Features provided by the license
    @param[out] LicenseRestrictions - Bitmask of license restrictions.  Some combination of LICENSE_HAS_XXX values.

    @return Object_OK on success
    @return @ref IPFM_Validation_Error_Codes
    @return @ref ERROR_CBOR_ENCODE_ERR
    @return @ref ERROR_LICENSE_TOO_BIG
    @return @ref ERROR_LICENSE_STORE_FULL
    @return @ref ERROR_DUPLICATE
    @return Object_ERROR_SIZE_OUT
    */
    method InstallLicense(in buffer PFMLicense, out buffer LicenseSerialNumber, out buffer FeatureIDsCBOR, out uint64 LicenseRestrictions);

    /**
    @brief Find a license that currently supports the given feature ID for the given licensee.
    If no managed licenses exist for the given licensee and feature ID,
    or validation of the licenses fails, ERROR_FILE_NOT_FOUND will be returned.
    If no managed licenses exist, ERROR_NO_LICENSES will be returned.

    @param[in] FeatureID - Feature ID to check
    @param[in] LicenseeHash - ISV Hash of the client requesting the feature.  This is only needed
        when the feature is in a license with a licensee hash extension.
    @param[out] LicenseSerialNumber - Serial Number of the license on success

    @return Object_OK on success
    @return Object_ERROR_SIZE_OUT
    @return @ref ERROR_FILE_NOT_FOUND
    @return @ref ERROR_NO_LICENSES
    */
    method CheckInstalledLicense(in uint32 FeatureID, in buffer LicenseeHash, out buffer LicenseSerialNumber);

    /**
    Fetch license information for the given License Serial Number.
    The information is encoded in a CBOR structure described below.

    @par CDDL Format for LicenseInfoCBOR
    @verbatim
    LicenseInfoCBOR = {
        "FileName" : string
        "SerialNumber" : BSTR
        "Issuer" : CBOR Map
        "SubjectKeyID" : BSTR
        "SubjectDN" : CBOR Map
        "Expiration" : BSTR
        "LicenseeHashes" : BSTR
        "FIDs" : [*uint32]
        "FIDRanges" : [*[uint32, uint32]]
        "LicenseRestrictions" : uint64
        "ExtraData" : BSTR
        "Flag" : uint64_t
        "IssueDate" : uint64_t
    }

    @endverbatim
    @par LicenseInfoCBOR Example
    @verbatim
    LicenseInfoCBOR = {
        "FileName" : ""
        "SerialNumber" : 22df4e681bc159922749d591219bc3ec
        "Issuer" : { "OU": "Issuer Org Unit", "O" : "Issuer Organization" }
        "SubjectKeyID" : 878e26b6d2b292e10ecd0cc085454118682c734f
        "SubjectDN" : { "OU": "Subject Org Unit", "CN": "Subject Common Name" }
        "Expiration" : 010000001234567833445566
        "LicenseeHashes" : ""
        "FIDs" : [1,22,43]
        "FIDRanges" : [[5,8], [10,15]]
        "LicenseRestrictions" : 1
        "ExtraData" : 81828384
        "Flag" : 8
        "IssueDate" : 51b07516
    }

    @endverbatim
    @par CBOR value descriptions
    @li FileName - Empty string, No longer used.
    @li SerialNumber - Should match LicenseSerialNumber
    @li Issuer - Distinguished Name of the Issuer.  Refer to the description of Distinguished Names above.
    @li SubjectKeyID - Subject-specific Public Key Identifier.  Normally 20 bytes.
    @li SubjectDN - Distinguished Name of the Subject.  Refer to the description of Distinguished Names above.
    @li Expiration - Valid time range of the license.  12 bytes for time-bound licenses.
    @li LicenseeHashes - Accepted Client ISV Hashes for this license.  32-bit count followed by concatenated hashes.
    @li FIDs - FIDs provided by the license
    @li FIDRanges - FID Ranges provided by the license
    @li LicenseRestrictions - Bitmask of license Restrictions.  Some combination of LICENSE_HAS_XXX values.
    @li Flag - OPT_NO_TIME_CHECK if license validation ignored expiration.  0 otherwise.
    @li IssueDate - License creation date & time details.

    @param[in] LicenseSerialNumber Serial number to search for
    @param[out] LicenseInfoCBOR CBOR structure as described above

    @return Object_OK on success
    @return Object_ERROR_SIZE_OUT
    @return @ref IPFM_Validation_Error_Codes
    @return @ref ERROR_FILE_NOT_FOUND
    @return @ref ERROR_NO_LICENSES
    @return @ref ERROR_PFMFILER_GETFILECONTENTS_FAILED
    */
    method GetInstalledLicenseInfo(in buffer LicenseSerialNumber, out buffer LicenseInfoCBOR);

    /**
    @brief Check whether the given license provides the given feature to the given licensee.

    @par CDDL Format for LicenseInfoCBOR
    @verbatim
    LicenseInfoCBOR = {
        "SerialNumber" : BSTR
        "Issuer" : CBOR Map
        "SubjectKeyID" : BSTR
        "SubjectDN" : CBOR Map
        "Expiration" : BSTR
        "LicenseeHashes" : BSTR
        "FIDs" : [*uint32]
        "FIDRanges" : [*[uint32, uint32]]
        "LicenseRestrictions" : uint64
        "ExtraData" : BSTR
        "Flag" : uint64_t
        "IssueDate" : uint64_t
        "SFEHandle" : BSTR
    }

    @endverbatim
    @par LicenseInfoCBOR Example
    @verbatim
    LicenseInfoCBOR = {
        "SerialNumber" : 22df4e681bc159922749d591219bc3ec
        "Issuer" : { "OU": "Issuer Org Unit", "O" : "Issuer Organization" }
        "SubjectKeyID" : 878e26b6d2b292e10ecd0cc085454118682c734f
        "SubjectDN" : { "OU": "Subject Org Unit", "CN": "Subject Common Name" }
        "Expiration" : 010000001234567833445566
        "LicenseeHashes" : ""
        "FIDs" : [1,22,43]
        "FIDRanges" : [[5,8], [10,15]]
        "LicenseRestrictions" : 1
        "Flag" : 8
        "IssueDate" : 51b07516
        "SFEHandle" : A301185F0250461FF490E8ACA4BC7132EED9439894BA0358205033B84E870622
                      9DD745425AED470DDFA700E88B812D5FEA50A6BBCA7987AE51
    }

    @endverbatim
    @par CBOR Value Descriptions
    @li SerialNumber - Should match LicenseSerialNumber
    @li Issuer - Distinguished Name of the Issuer.  Refer to the description of Distinguished Names above.
    @li SubjectKeyID - Subject-specific Public Key Identifier.  Normally 20 bytes.
    @li SubjectDN - Distinguished Name of the Subject.  Refer to the description of Distinguished Names above.
    @li Expiration - Valid time range of the license.  12 bytes for time-bound licenses.
    @li LicenseeHashes - Accepted Client ISV Hashes for this license.  32-bit count followed by concatenated hashes.
    @li FIDs - FIDs provided by the license
    @li FIDRanges - FID Ranges provided by the license
    @li LicenseRestrictions - Bitmask of license Restrictions.  Some combination of LICENSE_HAS_XXX values.
    @li ExtraData - Extra Data extension from the license, or Zero-length BSTR if the license does not have the extension.
    @li Flag - OPT_NO_TIME_CHECK if license validation ignored expiration.  0 otherwise.
    @li IssueDate - License creation date & time details. If IssueDate extension is not present in the license then it's value will be zero.
    @li SFEHandle - Valid only for SFE feature. If SFE extension is not present in the license then it's value will be Zero-length BSTR.

    @param[in] PFMLicense - Feature license in PFM or DER format
    @param[in] FeatureID - The feature ID to check
    @param[in] LicenseeHash - ISV Hash of the client requesting the feature.  This is only needed
        when the license has a licensee hash extension.
    @param[out] LicenseBufferCBOR

    @return Object_OK on success
    @return Object_ERROR_SIZE_OUT
    @return @ref IPFM_Validation_Error_Codes
    @return @ref ERROR_LICENSE_TOO_BIG
    */
    method CheckLicenseBuffer(in buffer PFMLicense, in uint32 FeatureID, in buffer LicenseeHash, out buffer LicenseBufferCBOR);

    /**
    @brief Securely check feature IDs.

    This API is similar to CheckFeatureIds except that it does not support the
    LicenseeHash option.  Most client applications will not use this API.  It is
    currently used by clients in the modem to securely check features via QMI.
    This requires an apps/HLOS QMI service to relay the request and response to
    this API.

    See @ref CheckFeatureIds for request and response details.
    @param[in] SecuredRequest - Encrypted CBOR request.
    @param[out] SecuredResponse - Encrypted CBOR response

    @return Object_OK on success
    @return Object_ERROR_SIZE_OUT
    @return @ref ERROR_CBOR_ENCODE_ERR
    @return @ref ERROR_CBOR_DECODE_ERR
    @return @ref ERROR_CBOR_DECODE_DATATYPE_ERR
    @return @ref ERROR_BLOB_ENCAP_FAILED
    @return @ref ERROR_BLOB_DECAP_FAILED
    @return @ref ERROR_OVERFLOW
    @return @ref ERROR_LICENSE_TOO_BIG
    */
    method CheckSecured(in buffer SecuredRequest, out buffer SecuredResponse);

    /**
    @brief Get list of installed feature IDs

    This API examines and verifies every managed license, and returns an
    aggregate list of currently supported featured IDs.

    @par CDDL for FeatureIDsCBOR
    @verbatim
    FeatureIDsCBOR = {
        FIDs: [*uint32],
        FIDRanges: [*[uint32, uint32]]
    }

    @endverbatim
    @par FeatureIDsCBOR Example
    @verbatim
    FeatureIDsCBOR = {
        "FIDs" : [1,22,43],
        "FIDRanges" : [[10,20],[30,40]]
    }

    @endverbatim

    @par CBOR Value Descriptions
    @li FIDs - FIDs provided by currently valid licenses
    @li FIDRanges - FID Ranges provided by currently valid licenses

    @param[out] FeatureIDsCBOR - CBOR formatted data out for FIDs and FIDRanges
    @return Object_OK on success
    @return Object_ERROR_SIZE_OUT
    @return @ref ERROR_NO_LICENSES
    */
    method GetAllInstalledFeatureIDs(out buffer FeatureIDsCBOR);

    /**
    @brief Get the serial numbers for all installed licenses.

    This method iterates over all the licenses in the license store and gives
    the caller a list of serial numbers, one for each license.
    The client can use this information to report the list of licenses present,
    to get the details of the licenses, to
    know which license to remove, etc...

    @par CDDL for SerialNumbersCBOR
    @verbatim
    SerialNumbersCBOR = [
        *BSTR
    ]

    @endverbatim
    @par SerialNumbersCBOR Example
    @verbatim
    SerialNumbersCBOR = [
        1234561,
        3af4e0d8,
        567456
    ]
    @endverbatim

    @param[out] SerialNumbersCBOR - List of installed serial numbers

    @return Object_OK on success
    @return @ref ERROR_NO_LICENSES
    */
    method GetAllInstalledSerialNumbers(out buffer SerialNumbersCBOR);

    /**
    @brief Check for licensing of multiple features.

    Given a CBOR list of Feature IDs / licensee hash pairs, return a
    CBOR list of structures of license information.  For each entry in the
    request list, there will be a corresponding entry at the same position
    in the response list.

    @par CDDL for RequestCBOR
    @verbatim
    RequestCBOR = {
        blobVersion : uint32,
        FeatureIDs  : [
            *[uint32, BSTR]
        ]
    }

    @endverbatim
    @par RequestCBOR Example
    @verbatim
    RequestCBOR = {
        "blobVersion" : 2,
        "FeatureIDs" : [
            [1, 12fc331f2c],
            [2, cadfae1900],
            [3, 1502005678]
        ]
    }

    @endverbatim
    @par ResponseCBOR Format for version 1
    @verbatim
    ResponseCBOR = [
        *[uint32, BSTR, BSTR, uint32, BSTR, uint64_t]
    ]

    ResponseCBOR = [
        *[FeatureID, LicenseeHash, SerialNumber, ResponseCode, ExtraData, Flag]
    ]

    @endverbatim
    @par ResponseCBOR Format for version 2
    @verbatim
    ResponseCBOR = [
        *[uint32, BSTR, BSTR, uint32, BSTR, uint64_t, uint64_t, BSTR, BSTR]
    ]

    ResponseCBOR = [
        *[FeatureID, LicenseeHash, SerialNumber, ResponseCode, ExtraData, Flag, IssueDate,
          SFEHandle, GPBeforeTTimeAvailable]
    ]

    @endverbatim
    @par CBOR value descriptions
    @li FeatureID - Feature ID from the request
    @li LicenseeHash - Licensee Hash from the request
    @li SerialNumber - Serial Number of a license enabling the feature for the licensee.  Zero-length BSTR if no matching license was found.
    @li ResponseCode - 0 for allowed, 1 for not allowed, 3 for processing error.
        Normally this value will be 0 if any licenses are listed in Result, and 1 if Result is empty.
        If a failure occurs while processing a potentially matching license, ResponseCode will be 3.
        If no licenses are in the store, ResponseCode will be 4.
    @li ExtraData - Version 1 onwards.  Extra Data extension from the license.  Zero-length BSTR if no matching license was found.
    @li Flag - Version 1 onwards.  OPT_NO_TIME_CHECK if license validation ignored expiration.  0 otherwise.
    @li IssueDate - Version 2 onwards. License creation date & time details. If IssueDate extension is not present in the license then it's value will be zero.
    @li SFEHandle - Version 2 onwards. Valid only for SFE feature. If SFE extension is not present in the license then it's value will be Zero-length BSTR.
    @li GPBeforeTTimeAvailable - Version 2 onwards. It having GracePeriod and GraceCount from GPBeforeTTimeAvailable extension as a BSTR. If GPBeforeTTimeAvailable
        extension is not present then it's value will be Zero-length BSTR.

    @par ResponseCBOR example for version 1
    @verbatim
    ResponseCBOR = [
        [800, "", 22df4e681bc159922749d591219bc3ec, 0, "", 0],
        [900, "", "", 4, "", 0]
    ]
    @endverbatim
    @par ResponseCBOR example for version 2
    @verbatim
    ResponseCBOR = [
        [800, "", 22df4e681bc159922749d591219bc3ec, 0, "", 0, 51b07516, A301185F0250461FF490E8ACA4BC7132EED9439894BA0358205033B84E870622
        9DD745425AED470DDFA700E88B812D5FEA50A6BBCA7987AE51, A26B4772616365506572696F64183C6A4772616365436F756E740A],
        [900, "", 413235710e56a9dd91a2b98210fe0c2a, 0, "", 0, 62E1D3E2, A301185F0250413235710E56A9DD91A2B98210FE0C2A0358201A219DBE5D2704
        8C2957851F63DC8598607728035E7F5FB657B02DF8D271D62A, A26B4772616365506572696F6418786A4772616365436F756E7405]
    ]
    @endverbatim
    @note The ResponseCBOR format for version 0 is the same, except that ExtraData, Flag, Issue Date, SFEHandle
    and GPBeforeTTimeAvailable are not present.

    @param[in] RequestCBOR - CBOR formatted list of FeatureIDs and LicenseeHashes
    @param[out] ResponseCBOR - Gives out all the serial numbers in CBOR format and the error codes correspong to the feature ID

    @return Object_OK on success
    @return Object_ERROR_SIZE_OUT
    @return @ref ERROR_CBOR_ENCODE_ERR
    @return @ref ERROR_CBOR_DECODE_ERR
    @return @ref ERROR_CBOR_DECODE_DATATYPE_ERR
    */
    method CheckFeatureIds(in buffer RequestCBOR, out buffer ResponseCBOR);

    /**
    @brief Get all license information for a list of features

    For reach FID / Licensee pair in the request, the response will contain an
    entry that reports information for all of the licenses that provide the
    given feature for the given licensee.

    @par CDDL for RequestCBOR
    @verbatim
    RequestCBOR = {
        blobVersion : uint32,
        FeatureIDs  : [
            *[uint32, BSTR]
            ]
    }

    @endverbatim
    @par RequestCBOR Example
    @verbatim
    RequestCBOR = {
        "blobVersion" : 2,
        "FeatureIDs" : [
            [1,12fc331f2c],
            [2,cadfae1900],
            [3,1502005678]
        ]
    }

    @endverbatim
    @par CDDL for ResponseCBOR for version 1
    @note Version 0 is the same, except ExtraData and Flag are not present
    @verbatim
    ResponseCBOR = [
        *{
            "FID": uint32
            "LicenseeHash": BSTR
            "Result": [
              * {
                    "SerialNum": BSTR
                    "LicenseRestrictions": uint64
                    "ExtraData": BSTR
                }
            ]
            "ResponseCode": uint32
            "Flag": uint64
        }
    ]

    @endverbatim

    @verbatim
    ResponseCBOR = [
        {
            "FID" : 100
            "LicenseeHash" : ""
            "Result" : [
                {
                    "SerialNum" : 23456,
                    "LicenseRestrictions" : 1F,
                    "ExtraData" : ""
                },
                {
                    "SerialNum" : 234534,
                    "LicenseRestrictions" : 0C,
                    "ExtraData" : "Hello"
                }
            ]
            "ResponseCode" : 0
            "Flag" : 8
        },

        {
            "FID" : 200
            "LicenseeHash" : 234568
            "Result" : [
                {
                    "SerialNum" : 23454,
                    "LicenseRestrictions" : 03,
                    "ExtraData" : ""
                },
                {
                    "SerialNum" : 234123
                    "LicenseRestrictions" : 02,
                    "ExtraData" : ""
                }
            ]
            "ResponseCode" : 0
            "Flag" : 8
        }
    ]

    @endverbatim
    @par CDDL for ResponseCBOR for version 2
    @note Version 1 is the same, except IssueDate, SFEHandle and GPBeforeTTimeAvailable are not present
    @verbatim
    ResponseCBOR = [
        *{
            "FID": uint32
            "LicenseeHash": BSTR
            "Result": [
              * {
                    "SerialNum": BSTR
                    "LicenseRestrictions": uint64
                    "ExtraData": BSTR
                    "IssueDate": uint64_t
                    "SFEHandle": BSTR
                    "GPBeforeTTimeAvailable": {
                                                  "GracePeriod": uint64_t,
                                                  "GraceCount": uint32_t
                                              }
                }
            ]
            "ResponseCode": uint32
            "Flag": uint64
        }
    ]

    @endverbatim

    @verbatim
    ResponseCBOR = [
        {
            "FID" : 100
            "LicenseeHash" : ""
            "Result" : [
                {
                    "SerialNum" : 234567,
                    "LicenseRestrictions" : 1F,
                    "ExtraData" : "",
                    "IssueDate" : 51b07516,
                    "SFEHandle" : A301185F0250461FF490E8ACA4BC7132EED9439894BA0358205033B84E870622
                                  9DD745425AED470DDFA700E88B812D5FEA50A6BBCA7987AE51,
                    "GPBeforeTTimeAvailable": {
                                                  "GracePeriod": 60,
                                                  "GraceCount": 10
                                              }
                },
                {
                    "SerialNum" : 234534,
                    "LicenseRestrictions" : 0C,
                    "ExtraData" : "Hello",
                    "IssueDate" : 59b6c4c5,
                    "SFEHandle" : A301185F0250461FF490E8ACA4BC7132EED9439894BA0358205033B84E870622
                                  9DD745425AED470DDFA700E88B812D5FEA50A6BBCA7987AE51,
                    "GPBeforeTTimeAvailable": {
                                                  "GracePeriod": 120,
                                                  "GraceCount": 5
                                              }
                }
            ]
            "ResponseCode" : 0
            "Flag" : 8
        }
    ]

    @endverbatim

    @par CBOR value descriptions
    @li FID - Feature ID from the request
    @li LicenseeHash - Licensee Hash from the request
    @li Result - CBOR Array of license information, one entry per matching license.
    @li SerialNum - Serial Number of a license enabling the feature for the licensee.
    @li LicenseRestrictions - Bitmask of license Restrictions.  Some combination of LICENSE_HAS_XXX values.
    @li ResponseCode - 0 for allowed, 1 for not allowed, 3 for processing error.
        Normally this value will be 0 if any licenses are listed in Result, and 1 if Result is empty.
        If a failure occurs while processing a potentially matching license, ResponseCode will be 3.
        If no licenses are in the store, ResponseCode will be 4.
    @li ExtraData - Version 1 onwards.  Extra Data extension from the license.  May be empty.
    @li Flag - OPT_NO_TIME_CHECK if license validation ignored expiration.  0 otherwise.
    @li IssueDate - Version 2 onwards. License creation date & time details. If IssueDate extension is not present in the license then it's value will be zero.
    @li SFEHandle - Version 2 onwards. Valid only for SFE feature. If SFE extension is not present in the license then it's value will be Zero-length BSTR.
    @li GraceCount - Version 2 onwards. GraceCount from GPBeforeTTimeAvailable extension. If GPBeforeTTimeAvailable extension is not present then GraceCount will not present in the Response.
    @li GracePeriod - Version 2 onwards. GracePeriod Duration from GPBeforeTTimeAvailable extension. If GPBeforeTTimeAvailable extension is not present then GracePeriod will not present in the Response.

    @param[in] RequestCBOR - CBOR list of FeatureID and LicenseeHash pairs
    @param[out] ResponseCBOR - CBOR list as described above.

    @return Object_OK on success
    */
    method CheckFIDAndGetAllSerialNums(in buffer RequestCBOR, out buffer ResponseCBOR);


    /**
    @brief Disable license validation checks.

    @note This API is for internal testing only

    @param[in] uOpts Option bitmask

    @return Object_OK on success
    @return @ref ERROR_OPTS_NOT_SUPPORTED
    */
    method SetOptions(in uint64 uOpts);

    /**
    @brief Remove an installed license.

    @param[in] LicenseSerialNumber - Serial number of the license to remove.

    @return Object_OK on success
    @return @ref ERROR_FILE_NOT_FOUND
    @return @ref ERROR_NO_LICENSES
    @return @ref ERROR_PFMFILER_GETFILECONTENTS_FAILED
    @return @ref ERROR_PRIVILEGE_ERR ISV client is not the owner of the license
    */
    method RemoveLicense(in buffer LicenseSerialNumber);

    /**
    @brief Remove expired licenses.

    This API removes any installed licenses that have an expiration date before
    the current date.  Licenses will only be removed if the trust level of the
    current date is MEDIUM.

    @note If this method is called by an ISV/APK client, it will only remove
          licenses that were installed by the client.

    @return Object_OK on success
    @return @ref ERROR_INVALID_CURRENT_TIME
    */
    method RemoveLicenseExpired();

    /**
    @brief Return an installed license in PFM format

    @param[in] LicenseSerialNumber - Serial Number of the license
    @param[out] PFMLicense - License Info in PFM format

    @return Object_OK on success
    @return @ref ERROR_FILE_NOT_FOUND
    @return @ref ERROR_NO_LICENSES
    @return @ref ERROR_PFMFILER_GETFILECONTENTS_FAILED
    */
    method GetLicenseCertPFM(in buffer LicenseSerialNumber, out buffer PFMLicense);

    /**
    @brief Get the status of fuses used to request licenses

    On success, fuses is set to a bitmask indicating which sync-request fuses
    have been blown.

    @param[out] fuses - Bitmask indicating fuse status.  Zero if no fuses blown.

    @return Object_OK on success
    @return @ref ERROR_NOMEM
    */
    method GetFeatureConfig(out uint64 fuses);

    /**
    @brief Update internal time with the latest trusted time value

    @note This method can only be called by trusted clients.

    @return Object_OK on success
    @return @ref ERROR_OPTS_NOT_SUPPORTED - Client is not allowed to set trusted time.
    */
    method SetTrustedTime(in uint64 time, in uint32 trust_level);

    /**
    @brief Get the expiration time for the next expiring license(s)

    @param[out] expiration - Epoch time when the next license(s) will expire

    @return Object_OK on success
    @return @ref ERROR_INVALID_CURRENT_TIME
    @return @ref ERROR_NO_LICENSES
    */
    method GetNextExpiration(out uint64 expiration);

    /**
    @brief Get all license information, including activatable licenses, for a list of features

    For reach FID / Licensee pair in the request, the response will contain an
    entry that reports information for all of the licenses that provide the
    given feature for the given licensee.

    @par CDDL for RequestCBOR
    @verbatim
    RequestCBOR = {
        blobVersion : uint32,
        FeatureIDs  : [
            *[uint32, BSTR]
            ]
    }

    @endverbatim
    @par RequestCBOR Example
    @verbatim
    RequestCBOR = {
        "blobVersion" : 1,
        "FeatureIDs" : [
            [1,12fc331f2c],
            [2,cadfae1900],
            [3,1502005678]
        ]
    }

    @endverbatim
    @par CDDL for ResponseCBOR for version 1
    @note Version 0 is the same, except ExtraData and Flag are not present
    @verbatim
    ResponseCBOR = [
        *{
            "FID": uint32
            "LicenseeHash": BSTR
            "Result": [
              * {
                    "SerialNum": BSTR
                    "LicenseRestrictions": uint64
                    "ResponseCode": uint32
                    "ExtraData": BSTR
                }
            ]
            "Flag": uint64
        }
    ]

    @endverbatim

    @verbatim
    ResponseCBOR = [
        {
            "FID" : 100
            "LicenseeHash" : ""
            "Result" : [
                {
                    "SerialNum" : 23456,
                    "LicenseRestrictions" : 1F,
                    "ResponseCode" : 0
                    "ExtraData" : ""
                },
                {
                    "SerialNum" : 234534,
                    "LicenseRestrictions" : 0C,
                    "ResponseCode" : 5
                    "ExtraData" : "Hello"
                }
            ]
            "Flag" : 8
        },

        {
            "FID" : 200
            "LicenseeHash" : 234568
            "Result" : [
                {
                    "SerialNum" : 23454,
                    "LicenseRestrictions" : 03,
                    "ResponseCode" : 0
                    "ExtraData" : ""
                },
                {
                    "SerialNum" : 234123
                    "LicenseRestrictions" : 02,
                    "ResponseCode" : 3
                    "ExtraData" : ""
                }
            ]
            "Flag" : 8
        }
    ]

    @endverbatim
    @par CDDL for ResponseCBOR for version 2
    @note Version 1 is the same, except IssueDate is not present
    @verbatim
    ResponseCBOR = [
        *{
            "FID": uint32
            "LicenseeHash": BSTR
            "Result": [
              * {
                    "SerialNum": BSTR
                    "LicenseRestrictions": uint64
                    "ExtraData": BSTR
                    "IssueDate": uint64_t
                }
            ]
            "ResponseCode": uint32
            "Flag": uint64
        }
    ]

    @endverbatim

    @verbatim
    ResponseCBOR = [
        {
            "FID" : 100
            "LicenseeHash" : ""
            "Result" : [
                {
                    "SerialNum" : 23456,
                    "LicenseRestrictions" : 1F,
                    "ExtraData" : "",
                    "IssueDate" : 51b07516
                },
                {
                    "SerialNum" : 234534,
                    "LicenseRestrictions" : 0C,
                    "ExtraData" : "Hello",
                    "IssueDate" : 59b6c4c5
                }
            ]
            "ResponseCode" : 0
            "Flag" : 8
        }
    ]

    @endverbatim

    @par CBOR value descriptions
    @li FID - Feature ID from the request
    @li LicenseeHash - Licensee Hash from the request
    @li Result - CBOR Array of license information, one entry per matching license.
    @li SerialNum - Serial Number of a license enabling the feature for the licensee.
    @li LicenseRestrictions - Bitmask of license Restrictions.  Some combination of LICENSE_HAS_XXX values.
    @li Response - 0 for allowed, 3 for processing error, and 5 if grace activation is required.
        Normally this value will be 0.  If the value is 5 for the license that the client
        wants to use, the client code must successfully call @ref ActivateGracePeriod
        before enabling the feature.
    @li ExtraData - Version 1 only.  Extra Data extension from the license.  May be empty.
    @li Flag - OPT_NO_TIME_CHECK if license validation ignored expiration.  0 otherwise.
    @li IssueDate - Version 2 onwards. License creation date & time details.

    @param[in] RequestCBOR - CBOR list of FeatureID and LicenseeHash pairs
    @param[out] ResponseCBOR - CBOR list as described above.

    @return Object_OK on success
    */
    method CheckFIDAndGetAllWithGrace(in buffer RequestCBOR, out buffer ResponseCBOR);

    /**
    @brief Activate a grace period for the given license

    @note ISV / APK clients can only activate grace periods for licenses that
    were installed by the client, or are bound to the client's ISV/Licensee Hash.

    @param[in] LicenseSerialNumber - Serial Number of the license to activate

    @return Object_OK on success
    @return @ref ERROR_FILE_NOT_FOUND No license with the given serial number was found
    @return @ref ERROR_NOT_GRACE_BOUND The license does not have a grace period extension
    @return @ref ERROR_CERT_EXPIRED No more grace periods are available
    @return @ref ERROR_PRIVILEGE_ERR ISV client is not the owner of the license
    @return @ref ERROR_NO_ACTIVATION_NEEDED if the license has not expired
    */
    method ActivateGracePeriod(in buffer LicenseSerialNumber);

    /**
    @brief Generating PFM report for attestation service. Currently including only
    installed license serials.

    @param[in] license - buffer containing token_cert license.
    @param[in] options - options to control what info need to add in PFM report.
    @param[out] attestationBuilder - \link IAttestationBuilder \endlink object to construct an attestation.

    @return Object_OK on success
    @return @ref ERROR_CBOR_DECODE_ERR if unable to decode CBOR response of GetAllInstalledSerialNumbers
    @return @ref ERROR_CBOR_ENCODE_ERR if unable to encode PFM report.
    */
    method GeneratePFMReport(in buffer license, in uint32 options, out IAttestationBuilder attestation_builder);

    /**
    @brief Create an IProvisioning object.

    @param[out] Provisioning - \link IProvisioning \endlink object

    @return Object_OK on success
    */
    method CreateProvisioning(out IProvisioning Provisioning);

    /**
    @brief Begins an atomic transaction and copies the credentials

    @param[out] Returns a new object of type IPFMUpdater.

    @return Object_OK on success
    */
    method BeginUpdate(out IPFMUpdater Updater);

    /**
    @brief Get QWES Trused appplication (TA) capabilities. It will return the
    capabilities of TA like whether TA supports Atomic License operations etc.

    @param[out] caps - Returns bitmaks that will correspond to each capability
                       like Atomic license operation etc.

    @return Object_OK on success
    */
    method GetAppCapabilities(out uint64 caps);

    /**
    @brief Registers a callback with fid for smart notifications.

    @return Object_OK on success

    @param[in] callback - An object of type IPFMCallback to get notified of
                          changes to the status of FIDs.
    @param[in] fidsCBOR - A list of FIDs encoded as CBOR. Callee will be notified
                          if the status of these FIDs change.
    @param[out] responseCBOR   - An output CBOR buffer that contains event type
                                 and reponseCode for each affected FIDs.
    @param[out] callbackHandle - An opaque object that must be held by the
                                 callee for the lifetime of the callback. When
                                 done with the callback, the callee must call
                                 Object_release on this object.
    */
    method RegisterCallback(in IPFMCallback Callback, in buffer FidsCBOR, out buffer ResponseCBOR, out interface CallbackHandle);

    /** QoT */
    const uint64 QOT_UNTRUSTED    = 0x00;
    const uint64 QOT_LOW_TRUST    = 0x01;
    const uint64 QOT_MEDIUM_TRUST = 0x02;
    const uint64 QOT_HIGH_TRUST   = 0x03;

    /** Feature Status */
    const uint64 FEATURE_STATUS_ACTIVE      = 0x00;
    const uint64 FEATURE_STATUS_NOTACTIVE   = 0x01;
    const uint64 FEATURE_STATUS_NOTPRESENT  = 0x02;
    const uint64 FEATURE_STATUS_DISABLED    = 0x03;

    /** CheckLicenseBuffer2 labels */
    const uint64 VERSION                = 1;
    const uint64 FEATUREIDS             = 2;
    const uint64 FEATURE_ENCODING_TYPE  = 3;
    const uint64 NONCE                  = 4;
    const uint64 LICENSEE_HASH          = 5;
    const uint64 TIMEINFO               = 6;
    const uint64 QOT                    = 7;
    const uint64 CURRENTTIME            = 8;
    const uint64 FEATUREINFO            = 9;
    const uint64 FEATUREID              = 10;
    const uint64 FEATURESTATUS          = 11;
    const uint64 ISTIMEBOUND            = 12;
    const uint64 VALIDAFTER             = 13;
    const uint64 VALIDUNTIL             = 14;
    const uint64 GRACEUNTIL             = 15;
    const uint64 FEATUREVALUE           = 16;
    const uint64 METADATA               = 17;
    const uint64 BINDINGS               = 18;
    const uint64 ANTIREPLAYCOUNTER      = 19;
    const uint64 SERIALNUMBER           = 20;

    /**
    Fetch license information for the given License buffer.
    The information is encoded in a CBOR structure described below.

    Only supported IPFM_VERSION is '1'.

    @par CDDL Format for LicenseInfoCBOR
    @verbatim
    RequestCBOR = {
        IPFM_VERSION : uint32
        ?IPFM_FEATUREIDS : [+uint32]
        ?IPFM_FEATURE_ENCODING_TYPE : [+int64]
        ?IPFM_NONCE : bstr
        ?IPFM_LICENSEE_HASH : bstr
    }

    @endverbatim

    @verbatim
    TimeInfoMap = {
        IPFM_QOT : QoTType
        ?IPFM_CURRENTTIME : uint64
    }

    QoTType = &(QOT_UNTRUSTED,
                QOT_LOW_TRUST,
                QOT_MEDIUM_TRUST,
                QOT_HIGH_TRUST)

    QOT_UNTRUSTED = 0
    QOT_LOW_TRUST = 1
    QOT_MEDIUM_TRUST = 2
    QOT_HIGH_TRUST = 3
    @endverbatim

    @verbatim
    FeatureInfoMap = {
        IPFM_FEATUREID : uint32
        IPFM_FEATURESTATUS : FeatureStatusType
        IPFM_TIMEBOUND : bool
        ?IPFM_VALIDAFTER : uint64
        ?IPFM_VALIDUNTIL : uint64
        ?IPFM_GRACEUNTIL : uint64
        ?IPFM_FEATUREVALUE : FeatureValueType
        ?IPFM_METADATA : bstr
        IPFM_BINDINGS : uint64
        IPFM_ANTIREPLAYCOUNTER : uint64
    }

    FeatureStatusType = &(FEATURE_STATUS_ACTIVE,
                          FEATURE_STATUS_NOTACTIVE,
                          FEATURE_STATUS_NOTPRESENT,
                          FEATURE_STATUS_DISABLED)

    FEATURE_STATUS_ACTIVE = 0
    FEATURE_STATUS_NOTACTIVE = 1
    FEATURE_STATUS_NOTPRESENT = 2
    FEATURE_STATUS_DISABLED = 3
    @endverbatim

    @par ResponseCBOR
    @verbatim
    ResponseCBOR = {
        IPFM_VERSION : uint32
        ?IPFM_NONCE : bstr
        ?IPFM_LICENSEEHASH : bstr
        IPFM_TIMEINFO : TimeInfoMap
        IPFM_FEATUREINFO : [+FeatureInfoMap]
        IPFM_SERIALNUMBER : bstr
    }
    @endverbatim
    */
    method CheckLicenseBuffer2(in buffer License, in buffer RequestCBOR, out buffer ResponseCBOR);

    /**
    @brief Enforce HW features based on license configuration.

    @return Object_OK on success

    @param[in] featureIDs - Array of featureIDs
    @param[out] HWRegisterInterfaceVersion - HW register interface version (applicable only for TME Lite).
    @param[out] HWFeatureStatus - HW feature status for provided featureIDs
    */
    method EnforceHWFeatures(in uint32[] featureIDs, out uint32 HWRegisterInterfaceVersion, out EnforceHWFeatureId_t[] HWFeatureStatus);

  /* @} */ /* end_addtogroup IPFM */
};
