Package: sha3_pkg
- File: sha3_pkg.sv
Description
Copyright lowRISC contributors.
Licensed under the Apache License, Version 2.0, see LICENSE for details.
SPDX-License-Identifier: Apache-2.0
sha3_pkg
Signals
Name | Type | Description |
---|---|---|
sha3_pkg | endpackage |
Constants
Name | Type | Value | Description |
---|---|---|---|
StateW | int | 1600 | |
FnWidth | int | 32 | up to 32bit Function Name |
CsWidth | int | 256 | up to 256bit Customization Input |
MaxFnEncodeSize | int | + 8 - 1 | Calculate left_encode(len( X )) bit size. Assume the enc_8(n) is always 1 (up to 255 byte of len(S) size) e.g) 248bit --> two bytes , 256bit --> three bytes round8bit(clog2(X+1))/8 |
MaxCsEncodeSize | int | + 8 - 1 | |
NSRegisterSizePre | int | FnWidth/8 + CsWidth/8 | |
NSRegisterSize | int | 4 | Round up to 32bit word base |
PrefixSize | int | NSRegisterSize + 2 | Prefix represents bytepad(encode_string(N) |
PrefixIndexW | int | $clog2(PrefixSize/64) | index width for N and S |
MsgWidth | int | 64 | Datapath width in KMAC, this also affects the output of MSG_FIFO This is assumed as 64 in KMAC design. If this value is changed, some parts of the KMAC design need to be changed. 1. keccak_round logic datapath. Keccak round logic assumes MsgWidth divides 1600 keccak state Width . Choose the value accordingly. 2. sha3pad module has fixed width mux for funcpad logic. If MsgWidth is changed, the logic also need to be revised. 3. kmac core logic also has fixed size mux for appeding output length. Revise the case statement to fit into revised MsgWidth value. |
MsgStrbW | int | MsgWidth / 8 | |
KeccakRate | int unsigned | undefined | |
MaxBlockSize | int unsigned | KeccakRate[0] | |
KeccakEntries | int unsigned | 1600/MsgWidth | |
KeccakMsgAddrW | int unsigned | $clog2(KeccakEntries) | |
KeccakCountW | int unsigned | $clog2(KeccakEntries+1) |
Types
Name | Type | Description |
---|---|---|
sha3_mode_e | enum logic[1:0] { Sha3 = 2'b 00, Shake = 2'b 10, CShake = 2'b 11 } |
Keccak module supports SHA3, SHAKE, cSHAKE function. This mode determines if the module uses encoded N and S or not. Also it chooses the padding value. mode |
keccak_strength_e | enum logic [2:0] { L128 = 3'b 000, L224 = 3'b 001, L256 = 3'b 010, L384 = 3'b 011, L512 = 3'b 100 } |
keccak_strength_e determines the security strength against collision attack This value decides the rate and capacity of the keccak states. It affects the sha3pad module too. the padding module implements bytepad(X,168) for L128, bytepad(X,136) for L256 in cSHAKE |
sha3_st_e | enum logic [2:0] { StIdle, StAbsorb, StSqueeze, StManualRun, StFlush } |
SHA3 core state. This state value is used in sha3core module and also in KMAC top module and the register interface for sw to track the sha3 status. |
err_code_e | enum logic [7:0] { ErrNone = 8'h 00, ErrSha3SwControl = 8'h 80 } |
//////////////// Error Report // //////////////// |
err_t | struct packed { logic valid; err_code_e code; logic [23:0] info; } |
Functions
- encode_bytepad_len (keccak_strength_e kstrength) return (logic [15:0])
Description
/////////////
Functions //
/////////////
Bytepading function
encode_bytepad_len
represents the first two bytes of bytepad()
It depends on the block size. We can reuse KeccakRate
10000000 || 00010101 // 168
10000000 || 00010001 // 136