Registers

Summary

NameOffsetLengthDescription
hmac.INTR_STATE0x04Interrupt State Register
hmac.INTR_ENABLE0x44Interrupt Enable Register
hmac.INTR_TEST0x84Interrupt Test Register
hmac.ALERT_TEST0xc4Alert Test Register
hmac.CFG0x104HMAC Configuration register.
hmac.CMD0x144HMAC command register
hmac.STATUS0x184HMAC Status register
hmac.ERR_CODE0x1c4HMAC Error Code
hmac.WIPE_SECRET0x204Clear internal secret registers.
hmac.KEY_00x244HMAC Secret Key
hmac.KEY_10x284HMAC Secret Key
hmac.KEY_20x2c4HMAC Secret Key
hmac.KEY_30x304HMAC Secret Key
hmac.KEY_40x344HMAC Secret Key
hmac.KEY_50x384HMAC Secret Key
hmac.KEY_60x3c4HMAC Secret Key
hmac.KEY_70x404HMAC Secret Key
hmac.KEY_80x444HMAC Secret Key
hmac.KEY_90x484HMAC Secret Key
hmac.KEY_100x4c4HMAC Secret Key
hmac.KEY_110x504HMAC Secret Key
hmac.KEY_120x544HMAC Secret Key
hmac.KEY_130x584HMAC Secret Key
hmac.KEY_140x5c4HMAC Secret Key
hmac.KEY_150x604HMAC Secret Key
hmac.KEY_160x644HMAC Secret Key
hmac.KEY_170x684HMAC Secret Key
hmac.KEY_180x6c4HMAC Secret Key
hmac.KEY_190x704HMAC Secret Key
hmac.KEY_200x744HMAC Secret Key
hmac.KEY_210x784HMAC Secret Key
hmac.KEY_220x7c4HMAC Secret Key
hmac.KEY_230x804HMAC Secret Key
hmac.KEY_240x844HMAC Secret Key
hmac.KEY_250x884HMAC Secret Key
hmac.KEY_260x8c4HMAC Secret Key
hmac.KEY_270x904HMAC Secret Key
hmac.KEY_280x944HMAC Secret Key
hmac.KEY_290x984HMAC Secret Key
hmac.KEY_300x9c4HMAC Secret Key
hmac.KEY_310xa04HMAC Secret Key
hmac.DIGEST_00xa44Digest output.
hmac.DIGEST_10xa84Digest output.
hmac.DIGEST_20xac4Digest output.
hmac.DIGEST_30xb04Digest output.
hmac.DIGEST_40xb44Digest output.
hmac.DIGEST_50xb84Digest output.
hmac.DIGEST_60xbc4Digest output.
hmac.DIGEST_70xc04Digest output.
hmac.DIGEST_80xc44Digest output.
hmac.DIGEST_90xc84Digest output.
hmac.DIGEST_100xcc4Digest output.
hmac.DIGEST_110xd04Digest output.
hmac.DIGEST_120xd44Digest output.
hmac.DIGEST_130xd84Digest output.
hmac.DIGEST_140xdc4Digest output.
hmac.DIGEST_150xe04Digest output.
hmac.MSG_LENGTH_LOWER0xe44Received Message Length calculated by the HMAC in bits [31:0]
hmac.MSG_LENGTH_UPPER0xe84Received Message Length calculated by the HMAC in bits [63:32]
hmac.MSG_FIFO0x10004096Message FIFO. Any write to this window will be appended to the FIFO.

INTR_STATE

Interrupt State Register

  • Offset: 0x0
  • Reset default: 0x0
  • Reset mask: 0x7

Fields

{"reg": [{"name": "hmac_done", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"name": "fifo_empty", "bits": 1, "attr": ["ro"], "rotate": -90}, {"name": "hmac_err", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"bits": 29}], "config": {"lanes": 1, "fontsize": 10, "vspace": 120}}
BitsTypeResetName
31:3Reserved
2rw1c0x0hmac_err
1ro0x0fifo_empty
0rw1c0x0hmac_done

INTR_STATE . hmac_err

HMAC error has occurred. ERR_CODE register shows which error occurred.

INTR_STATE . fifo_empty

The message FIFO is empty. This interrupt is raised only if the message FIFO is actually writable by software, i.e., if all of the following conditions are met: i) The HMAC block is not running in HMAC mode and performing the second round of computing the final hash of the outer key as well as the result of the first round using the inner key. ii) Software has not yet written the Process or Stop command to finish the hashing operation. For the interrupt to be raised, the message FIFO must also have been full previously. Otherwise, the hardware empties the FIFO faster than software can fill it and there is no point in interrupting the software to inform it about the message FIFO being empty.

INTR_STATE . hmac_done

HMAC/SHA-2 has completed.

INTR_ENABLE

Interrupt Enable Register

  • Offset: 0x4
  • Reset default: 0x0
  • Reset mask: 0x7

Fields

{"reg": [{"name": "hmac_done", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "fifo_empty", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "hmac_err", "bits": 1, "attr": ["rw"], "rotate": -90}, {"bits": 29}], "config": {"lanes": 1, "fontsize": 10, "vspace": 120}}
BitsTypeResetNameDescription
31:3Reserved
2rw0x0hmac_errEnable interrupt when INTR_STATE.hmac_err is set.
1rw0x0fifo_emptyEnable interrupt when INTR_STATE.fifo_empty is set.
0rw0x0hmac_doneEnable interrupt when INTR_STATE.hmac_done is set.

INTR_TEST

Interrupt Test Register

  • Offset: 0x8
  • Reset default: 0x0
  • Reset mask: 0x7

Fields

{"reg": [{"name": "hmac_done", "bits": 1, "attr": ["wo"], "rotate": -90}, {"name": "fifo_empty", "bits": 1, "attr": ["wo"], "rotate": -90}, {"name": "hmac_err", "bits": 1, "attr": ["wo"], "rotate": -90}, {"bits": 29}], "config": {"lanes": 1, "fontsize": 10, "vspace": 120}}
BitsTypeResetNameDescription
31:3Reserved
2wo0x0hmac_errWrite 1 to force INTR_STATE.hmac_err to 1.
1wo0x0fifo_emptyWrite 1 to force INTR_STATE.fifo_empty to 1.
0wo0x0hmac_doneWrite 1 to force INTR_STATE.hmac_done to 1.

ALERT_TEST

Alert Test Register

  • Offset: 0xc
  • Reset default: 0x0
  • Reset mask: 0x1

Fields

{"reg": [{"name": "fatal_fault", "bits": 1, "attr": ["wo"], "rotate": -90}, {"bits": 31}], "config": {"lanes": 1, "fontsize": 10, "vspace": 130}}
BitsTypeResetNameDescription
31:1Reserved
0wo0x0fatal_faultWrite 1 to trigger one alert event of this kind.

CFG

HMAC Configuration register.

The register is updated when the engine is in Idle. If the software updates the register while the engine computes the hash, the updated value is discarded.

  • Offset: 0x10
  • Reset default: 0x4100
  • Reset mask: 0x7fff

Fields

{"reg": [{"name": "hmac_en", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "sha_en", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "endian_swap", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "digest_swap", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "key_swap", "bits": 1, "attr": ["rw"], "rotate": -90}, {"name": "digest_size", "bits": 4, "attr": ["rw"], "rotate": -90}, {"name": "key_length", "bits": 6, "attr": ["rw"], "rotate": 0}, {"bits": 17}], "config": {"lanes": 1, "fontsize": 10, "vspace": 130}}
BitsTypeResetName
31:15Reserved
14:9rw0x20key_length
8:5rw0x8digest_size
4rw0x0key_swap
3rw0x0digest_swap
2rw0x0endian_swap
1rwxsha_en
0rwxhmac_en

CFG . key_length

Key length configuration.

This is a 6-bit one-hot encoded field to configure the key length for HMAC.

The HMAC can be programmed with the following key lengths: 128-bit, 256-bit, 384-bit, 512-bit and 1024-bit. But the HMAC supports any arbitrary key length: the software should configure the HMAC with the next largest supported key length and concatenate zeros to reach the programmed key length. The position of these zeros depends on the endianness, thus on the programmed CFG.key_swap. For example, for an 80-bit key, HMAC should be configured with an 128-bit key length, fed with the 80-bit key and with 48 zero-bits.

Note that the key length cannot be greater than the block size: up to 1024-bit for SHA-2 384/512 and up to 512-bit for SHA-2 256. The value of this register is irrelevant when only SHA-2 (not keyed HMAC) is configured. However, for HMAC mode (hmac_en == 1), when HMAC is triggered to start while KEY_LENGTH holds Key_None or KEY_LENGTH holds Key_1024 for DIGEST_SIZE = SHA2_256, starting is blocked and an error is signalled to SW.

ValueNameDescription
0x01Key_1286’b00_0001: 128-bit secret key.
0x02Key_2566’b00_0010: 256-bit secret key.
0x04Key_3846’b00_0100: 384-bit secret key.
0x08Key_5126’b00_1000: 512-bit secret key.
0x10Key_10246’b01_0000: 1024-bit secret key.
0x20Key_None6’b10_0000: Unsupported/invalid values and all-zero values are mapped to Key_None. With this value, when HMAC is triggered to start operation (via hash_start or hash_continue), it will be blocked from starting and an error is signalled to the SW. If only unkeyed SHA-2 is configured (hmac_en == 0), starting is not blocked, since this does not require a key.

Other values are reserved.

CFG . digest_size

Digest size configuration.

This is a 4-bit one-hot encoded field to select digest size for either HMAC or SHA-2. Invalid/unsupported values, i.e., values that don’t correspond to SHA2_256, SHA2_384, or SHA2_512, are mapped to SHA2_None.

ValueNameDescription
0x1SHA2_2564’b0001: SHA-2 256 digest.
0x2SHA2_3844’b0010: SHA-2 384 digest.
0x4SHA2_5124’b0100: SHA-2 512 digest.
0x8SHA2_None4’b1000: Unsupported/invalid values and all-zero values are mapped to SHA2_None. With this value, when HMAC/SHA-2 is triggered to start operation (via hash_start or hash_continue), it will be blocked from starting and an error is signalled to the SW.

Other values are reserved.

CFG . key_swap

Key register byte swap.

If 1 the endianness of each KEY_* register is swapped. Default value (value 0) is big endian representation of the KEY_* CSRs.

CFG . digest_swap

Digest register byte swap.

If 1 the value in each digest output register is converted to big-endian byte order. This setting does not affect the order of the digest output registers, DIGEST_0 still contains the first 4 bytes of the digest.

CFG . endian_swap

Endian swap.

If 0, each value will be added to the message in little-endian byte order. The value is written to MSG_FIFO same to the SW writes. If 1, then each individual multi-byte value, regardless of its alignment, written to MSG_FIFO will be added to the message in big-endian byte order. A message written to MSG_FIFO one byte at a time will not be affected by this setting. From a hardware perspective byte swaps are performed on a TL-UL word granularity.

CFG . sha_en

SHA-2 enable.

If 0, the SHA engine will not initiate compression, this is used to stop operation of the SHA-2 engine until configuration has been done. When the SHA-2 engine is disabled the digest is cleared.

CFG . hmac_en

HMAC datapath enable.

If this bit is 1, HMAC operates when hash_start toggles.

CMD

HMAC command register

  • Offset: 0x14
  • Reset default: 0x0
  • Reset mask: 0xf

Fields

{"reg": [{"name": "hash_start", "bits": 1, "attr": ["r0w1c"], "rotate": -90}, {"name": "hash_process", "bits": 1, "attr": ["r0w1c"], "rotate": -90}, {"name": "hash_stop", "bits": 1, "attr": ["r0w1c"], "rotate": -90}, {"name": "hash_continue", "bits": 1, "attr": ["r0w1c"], "rotate": -90}, {"bits": 28}], "config": {"lanes": 1, "fontsize": 10, "vspace": 150}}
BitsTypeResetName
31:4Reserved
3r0w1cxhash_continue
2r0w1cxhash_stop
1r0w1cxhash_process
0r0w1cxhash_start

CMD . hash_continue

When 1 is written to this field, SHA-2 or HMAC will continue hashing based on the current hash in the digest registers and the message length, which both have to be restored to switch context.

CMD . hash_stop

When 1 is written to this field, SHA-2 or HMAC will afterwards set the hmac_done interrupt as soon as the current block has been hashed. The hash can then be read from the registers DIGEST_0 to DIGEST_15. Together with the message length in MSG_LENGTH_LOWER and MSG_LENGTH_UPPER, this forms the information that has to be saved before switching context.

CMD . hash_process

If 1 is written to this field, SHA-2 or HMAC calculates the digest or signing based on currently received message.

CMD . hash_start

If 1 is written into this field, SHA-2 or HMAC begins its operation. CPU must configure relative information first, such as the digest size, secret key and the key length.

STATUS

HMAC Status register

  • Offset: 0x18
  • Reset default: 0x3
  • Reset mask: 0x3f7

Fields

{"reg": [{"name": "hmac_idle", "bits": 1, "attr": ["ro"], "rotate": -90}, {"name": "fifo_empty", "bits": 1, "attr": ["ro"], "rotate": -90}, {"name": "fifo_full", "bits": 1, "attr": ["ro"], "rotate": -90}, {"bits": 1}, {"name": "fifo_depth", "bits": 6, "attr": ["ro"], "rotate": 0}, {"bits": 22}], "config": {"lanes": 1, "fontsize": 10, "vspace": 120}}
BitsTypeResetNameDescription
31:10Reserved
9:4roxfifo_depthFIFO entry count.
3Reserved
2roxfifo_fullFIFO full. Data written to the FIFO whilst it is full will cause back-pressure on the interconnect
1ro0x1fifo_emptyFIFO empty
0ro0x1hmac_idleHMAC idle status. When IDLE, the DIGEST and the MSG_LENGTH_LOWER/MSG_LENGTH_UPPER can be written to from SW which enables restoring context (to support context switching).

ERR_CODE

HMAC Error Code

  • Offset: 0x1c
  • Reset default: 0x0
  • Reset mask: 0xffffffff

Fields

{"reg": [{"name": "err_code", "bits": 32, "attr": ["ro"], "rotate": 0}], "config": {"lanes": 1, "fontsize": 10, "vspace": 80}}
BitsTypeResetNameDescription
31:0ro0x0err_codeIf an error interrupt occurs, this register has information of error cause. Please take a look at `hw/ip/prim/rtl/prim_sha2_pkg.sv:err_code_e enum type.

WIPE_SECRET

Clear internal secret registers.

If CPU writes a value into the register, the value is used to clear the internal variables such as the secret key, internal state machine, or hash value. The clear secret operation overwrites the internal variables with the provided 32-bit value. For SHA-2 384/512 that work with 64-bit words, the 32-bit value is duplicated and concatenated to generate the 64-bit value. It is recommended to use a value extracted from an entropy source.

  • Offset: 0x20
  • Reset default: 0x0
  • Reset mask: 0xffffffff

Fields

{"reg": [{"name": "secret", "bits": 32, "attr": ["wo"], "rotate": 0}], "config": {"lanes": 1, "fontsize": 10, "vspace": 80}}
BitsTypeResetNameDescription
31:0woxsecretSecret value

KEY

HMAC Secret Key

HMAC using SHA-2 256/384/512 assumes any hashed secret key length up to the block size, thus capped at 1024-bit. key_length determines how many of these registers are relevant for the HMAC operation. Order of the secret key is: key[1023:0] = {KEY0, KEY1, KEY2, … , KEY31};

The registers are allowed to be updated only when the engine is in Idle state. If the engine computes the hash, it discards any attempts to update the secret keys and report an error.

  • Reset default: 0x0
  • Reset mask: 0xffffffff

Instances

NameOffset
KEY_00x24
KEY_10x28
KEY_20x2c
KEY_30x30
KEY_40x34
KEY_50x38
KEY_60x3c
KEY_70x40
KEY_80x44
KEY_90x48
KEY_100x4c
KEY_110x50
KEY_120x54
KEY_130x58
KEY_140x5c
KEY_150x60
KEY_160x64
KEY_170x68
KEY_180x6c
KEY_190x70
KEY_200x74
KEY_210x78
KEY_220x7c
KEY_230x80
KEY_240x84
KEY_250x88
KEY_260x8c
KEY_270x90
KEY_280x94
KEY_290x98
KEY_300x9c
KEY_310xa0

Fields

{"reg": [{"name": "key", "bits": 32, "attr": ["wo"], "rotate": 0}], "config": {"lanes": 1, "fontsize": 10, "vspace": 80}}
BitsTypeResetNameDescription
31:0woxkey32-bit chunk of 1024-bit secret key

DIGEST

Digest output.

If HMAC is disabled, the register shows result of SHA-2 256/384/512. Order of the 512-bit digest[511:0] = {DIGEST0, DIGEST1, DIGEST2, … , DIGEST15}. For SHA-2 256 order of the 256-bit digest[255:0] = {DIGEST0, DIGEST1, DIGEST2, DIGEST3, DIGEST4, DIGEST5, DIGEST6, DIGEST7} and {DIGEST8 - DIGEST15} are irrelevant and should not be read out. For SHA-2 384, {DIGEST12-DIGEST15} are truncated; they are irrelevant and should not be read out.

The digest gets cleared when CFG.sha_en transitions from 1 to 0. When STATUS.hmac_idle is 1, these registers may be written to by software. Outside of this window, writes can cause unpredictable behavior.

  • Reset default: 0x0
  • Reset mask: 0xffffffff

Instances

NameOffset
DIGEST_00xa4
DIGEST_10xa8
DIGEST_20xac
DIGEST_30xb0
DIGEST_40xb4
DIGEST_50xb8
DIGEST_60xbc
DIGEST_70xc0
DIGEST_80xc4
DIGEST_90xc8
DIGEST_100xcc
DIGEST_110xd0
DIGEST_120xd4
DIGEST_130xd8
DIGEST_140xdc
DIGEST_150xe0

Fields

{"reg": [{"name": "digest", "bits": 32, "attr": ["rw"], "rotate": 0}], "config": {"lanes": 1, "fontsize": 10, "vspace": 80}}
BitsTypeResetNameDescription
31:0rwxdigest32-bit chunk of 512-bit digest

MSG_LENGTH_LOWER

Received Message Length calculated by the HMAC in bits [31:0]

Message is byte granularity. Lower 3 bits [2:0] are ignored.

When STATUS.hmac_idle is 1, this register may be written by software. Outside of this window, writes can cause unpredictable behavior.

  • Offset: 0xe4
  • Reset default: 0x0
  • Reset mask: 0xffffffff

Fields

{"reg": [{"name": "v", "bits": 32, "attr": ["rw"], "rotate": 0}], "config": {"lanes": 1, "fontsize": 10, "vspace": 80}}
BitsTypeResetNameDescription
31:0rwxvMessage Length [31:0]

MSG_LENGTH_UPPER

Received Message Length calculated by the HMAC in bits [63:32]

When STATUS.hmac_idle is 1, this register may be written by software. Outside of this window, writes can cause unpredictable behavior. For SHA-2-2 256 computations, message length is 64-bit {MSG_LENGTH_UPPER, MSG_LENGTH_LOWER}.f For SHA-2 384/512 message length is extended to 128-bit in line with [nist-fips-180-4] where the upper 64 bits get zero-padded: {32’b0, 32’b0, MSG_LENGTH_UPPER, MSG_LENGTH_LOWER}.

  • Offset: 0xe8
  • Reset default: 0x0
  • Reset mask: 0xffffffff

Fields

{"reg": [{"name": "v", "bits": 32, "attr": ["rw"], "rotate": 0}], "config": {"lanes": 1, "fontsize": 10, "vspace": 80}}
BitsTypeResetNameDescription
31:0rwxvMessage Length [63:32]

MSG_FIFO

Message FIFO. Any write to this window will be appended to the FIFO. Only the lower [1:0] bits of the address matter to writes within the window (for correctly dealing with non 32-bit writes)

  • Word Aligned Offset Range: 0x1000to0x1ffc
  • Size (words): 1024
  • Access: wo
  • Byte writes are supported.