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

/** @file IQWESKeyStore.idl */

/** @cond */
interface IQWESKeyStore {
/** @endcond */

  /**
    @addtogroup IQWESKeyStore
    @{
   */

  /* QWES Key Store Error Codes. */
  error ERROR_NO_MEMORY;           /**< Failure during memory allocation. */
  error ERROR_INVALID_ARGUMENT;    /**< Invalid arguments. */
  error ERROR_INVALID_KEY_BLOB;    /**< Invalid key blob. */
  error ERROR_KEY_STORE_FULL;      /**< Available/allowed key storage capacity is reached. */
  error ERROR_DUPLICATE_ALIAS;     /**< Alias passed to saveKey is already used. */

  /**
    Saves a key in secure storage (SFS).

    @param[in] keyBlob     Buffer containing the key material.
    @param[in] keyAlias    Alias name for the input key.

    @return
    Object_OK on success.
  */
  method saveKey(in buffer keyBlob, in buffer keyAlias);

  /**
    Loads key blob identified by keyAlias from secure storage.

    @param[in]  keyAlias    Alias name for the input key.
    @param[out] keyValue    Buffer containing the key material.

    @return
    Object_OK on success.
  */
  method loadKey(in buffer keyAlias, out buffer keyValue);

  /**
    Removes the key and any cert associated with the key identified by keyAlias.

    @param[in] keyAlias    Alias name for the input key.

    @return
    Object_OK on success.
  */
  method removeKey(in buffer keyAlias);

  /**
    Save either a key blob or x509 certificate given by valueBytes and associates them with the key identified by keyAlias.

    @param[in] keyAlias      Alias name for the input key.
    @param[in] valueBytes    Buffer containing either key blob or x509 certificate.

    @return
    Object_OK on success.
  */
  method saveValue(in buffer keyAlias, in buffer valueBytes);

  /**
    Loads type and value of the data or certificate saved and associated with key identified by keyAlias.

    @param[in]  keyAlias      Alias name for the input key.
    @param[out] valueBytes    Buffer containing either key blob or x509 certificate.

    @return
    Object_OK on success.
  */
  method loadValue(in buffer keyAlias, out buffer valueBytes);

  /**
    Clears the data or cert that is saved and associated with the key identified by keyAlias.

    @param[in] keyAlias    Alias name for the input key.

    @return
    Object_OK on success.
  */
  method clearValue(in buffer keyAlias);

  /** @} */ /* end_addtogroup IQWESKeyStore */
};
