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

/** @cond */
interface IHash {
/** @endcond */

  /** @cond */
  const int32 PARAM_MODE  = 0;
  const int32 PARAM_HMAC_KEY  = 1;
  const int32 PARAM_SEQ  = 2;
  const int32 PARAM_SET_N_STR = 3;
  const int32 PARAM_SET_S_STR = 4;
  const int32 PARAM_INVALID = -1;

  const int32 MODE_HASH = 0;
  const int32 MODE_HMAC = 1;
  const int32 MODE_INVALID = -1;

  const int32 SEQ_MODE_FIRST = 0;
  const int32 SEQ_MODE_LAST = 1;
  const int32 SEQ_MODE_INVALID = -1;

  const int32 SIZE_SHA1 = 20;
  const int32 SIZE_SHA256 = 32;
  const int32 SIZE_SHA384 = 48;
  const int32 SIZE_SHA512 = 64;
  const int32 SIZE_SM3 = 32;
  const int32 SIZE_INVALID = 0;
  const int32 SIZE_SHA3_224 = 28;
  const int32 SIZE_SHA3_256 = 32;
  const int32 SIZE_SHA3_384 = 48;
  const int32 SIZE_SHA3_512 = 64;

  /** Errors */
  error NOT_SUPPORTED;   /** Returned when HW does not support the feature being requested */

  /** @endcond */

  /**
   * @addtogroup IHash
   * @{
   */

  /**
    Hashes data into the hash context.

    @param[in] plain  Plain text message to hash.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method update(in buffer plain);

  /**
    Computes the digest hash value.

    @param[out] digest Message digest hash.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method final(out buffer digest);

  /**
    Modifies the 32-bit unsigned int parameter value for a given hash operation.

    @param[in] paramID     Parameter to modify.
    @param[in] param       Parameter value to set.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method setParamAsU32(in int32 paramID, in uint32 param);

  /**
    Modifies parameter value for a given hash operation.

    @param[in] paramID     Parameter to modify.
    @param[in] param       Parameter value to set.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method setParamAsData(in int32 paramID, in buffer param);

  /**
    Performs a simultaneous hash/cipher encrypt operation.

    @param[in]  cipher_obj Cipher context (object).
    @param[in]  plain      Input plaintext buffer.
    @param[out] cipher     Output ciphertext buffer.
    @param[out] digest     Digest to store.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method encrypt(in interface cipher_obj, in buffer plain, out buffer cipher, out buffer digest);

  /**
    Performs a simultaneous hash/cipher decrypt operation.

    @param[in] cipher_obj   Cipher context (object).
    @param[in]  cipher      Input ciphertext buffer.
    @param[out]  plain      Output plaintext buffer.
    @param[out] digest      Digest to store.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method decrypt(in interface cipher_obj, in buffer cipher, out buffer plain, out buffer digest);

  /**
    Resets hash context; does not reset the key.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method reset();

  /**
    Computes the digest hash value with the input data.

    @param[in] plain    Plain text message to hash.
    @param[out] digest  Message hash digest.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method hash(in buffer plain, out buffer digest);

  /**
    Computes the digest hash value.

    @param[out] digest Message digest hash.

    @return
    Object_OK -- Successful. \n
    Object_ERROR -- Any error encountered.
  */
  method squeeze(out buffer digest);

  /** @} */ /* end_addtogroup IHash */
};
