// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// key manager package
//

package keymgr_pkg;

  parameter int KeyWidth = 256;
  parameter int DigestWidth = 128;     // uses truncated hash
  parameter int KmacDataIfWidth = 64;  // KMAC interface data width
  parameter int KeyMgrStages = 3;      // Number of key manager stages (creator, ownerInt, owner)
  parameter int RomExtDescWidth = 128; // Size of rom_ext hash, truncated
  parameter int LfsrWidth = 64;
  parameter int Shares = 2; // number of key shares

  // These should be defined in another module's package
  parameter int HealthStateWidth = 128;
  parameter int DevIdWidth = 256;

  // These should eventually reference top_pkg so that they can be easily managed per
  // device
  parameter logic[KeyWidth-1:0] RevisionSecret      = 256'hAAAA5555;
  parameter logic[KeyWidth-1:0] CreatorIdentityKey  = 256'hDEADBEEF;
  parameter logic[KeyWidth-1:0] OwnerIntIdentityKey = 256'hDEADBEEF;
  parameter logic[KeyWidth-1:0] OwnerIdentityKey    = 256'hDEADBEEF;
  parameter logic[KeyWidth-1:0] SoftOutputKey       = 256'hDEADBEEF;
  parameter logic[KeyWidth-1:0] HardOutputKey       = 256'hDEADBEEE;

  // Width calculations
  // These are the largest calculations in use across all stages
  parameter int AdvDataWidth = RomExtDescWidth + 2*KeyWidth + DevIdWidth + HealthStateWidth;
  parameter int IdDataWidth = KeyWidth;
  // key version + salt + key ID + constant
  parameter int GenDataWidth = 32 + 128 + KeyWidth;
  parameter int StageWidth = $clog2(KeyMgrStages);

  // Max Payload Width to derivation function
  // This should be decomposed to 1600 - security_strength*2
  // see security strength description https://keccak.team/keccak.html
  parameter int KDFMaxWidth = 1088;

  // Enumeration for operations
  typedef enum logic [2:0] {
    Creator   = 0,
    OwnerInt  = 1,
    Owner     = 2,
    Disable   = 3
  } keymgr_stage_e;

  // Enumeration for sideload sel
  typedef enum logic [1:0] {
    None   = 0,
    Aes    = 1,
    Hmac   = 2,
    Kmac   = 3
  } keymgr_key_dest_e;

  // Enumeration for key select
  typedef enum logic {
    HwKey = 0,
    SwKey = 1
  } keymgr_gen_out_e;

  // Enumeration for operation
  typedef enum logic [2:0] {
    OpAdvance = 0,
    OpGenId = 1,
    OpGenSwOut = 2,
    OpGenHwOut = 3,
    OpDisable = 4
  } keymgr_ops_e;

  // Enumeration for working state
  typedef enum logic [2:0] {
    StReset = 0,
    StRandom = 1,
    StInit = 2,
    StCreatorRootKey = 3,
    StOwnerIntKey = 4,
    StOwnerKey = 5,
    StWipe = 6,
    StDisabled = 7
  } keymgr_working_state_e;

  // Enumeration for operation status
  typedef enum logic [1:0] {
    OpIdle = 0,
    OpWip = 1,
    OpDoneSuccess = 2,
    OpDoneFail = 3
  } keymgr_op_status_e;

  // Bit position of error code
  // Error is encoded as 1 error per bit
  typedef enum logic [2:0] {
    ErrInvalidOp,
    ErrInvalidCmd,
    ErrInvalidIn,
    ErrInvalidOut,
    ErrLastPos
  } keymgr_err_pos_e;

  // Key connection to various modules
  typedef struct packed {
    logic valid;
    logic [KeyWidth-1:0] key_share0;
    logic [KeyWidth-1:0] key_share1;
  } hw_key_req_t;

  parameter hw_key_req_t HW_KEY_REQ_DEFAULT = '{
    valid: 1'b0,
    key_share0: KeyWidth'(32'hDEADBEEF),
    key_share1: KeyWidth'(32'hFACEBEEF)
  };

  typedef struct packed {
    logic valid;
    logic [KmacDataIfWidth-1:0] data;
    logic [KmacDataIfWidth/8-1:0] strb;
    // last indicates the last beat of the data. strb can be partial only with
    // last.
    logic last;
  } kmac_data_req_t;

  typedef struct packed {
    logic ready;
    logic done;
    logic [KeyWidth-1:0] digest_share0;
    logic [KeyWidth-1:0] digest_share1;
    // Error is valid when done is high. If any error occurs during KDF, KMAC
    // returns the garbage digest data with error. The KeyMgr discards the
    // digest and may re-initiate the process.
    logic error;
  } kmac_data_rsp_t;

  parameter kmac_data_req_t KMAC_DATA_REQ_DEFAULT = '{
    valid: 1'b 0,
    data: '0,
    strb: '0,
    last: 1'b 0
  };
  parameter kmac_data_rsp_t KMAC_DATA_RSP_DEFAULT = '{
    ready: 1'b1,
    done:  1'b1,
    digest_share0: KeyWidth'(32'hDEADBEEF),
    digest_share1: KeyWidth'(32'hFACEBEEF),
    error: 1'b1
  };

  // The following structs should be sourced from other modules
  // defined here temporarily
  typedef struct packed {
    logic [HealthStateWidth-1:0] health_state;
    logic keymgr_en;
  } lc_data_t;

  parameter lc_data_t LC_DATA_DEFAULT = '{
    health_state: '0,
    keymgr_en:    1'b1
  };

  typedef struct packed {
    logic [DevIdWidth-1:0] devid;
    logic [KeyWidth-1:0] root_key;
  } otp_data_t;

  parameter otp_data_t OTP_DATA_DEFAULT = '{
    devid:    '0,
    root_key: '0
  };

  typedef struct packed {
    logic [KeyWidth-1:0] div_key;
    logic [KeyWidth-1:0] owner_secret;
  } flash_key_t;

  parameter flash_key_t FLASH_KEY_DEFAULT = '{
    div_key:      '0,
    owner_secret: '0
  };
endpackage : keymgr_pkg
