Package: prim_cipher_pkg
- File: prim_cipher_pkg.sv
Description
Copyright lowRISC contributors.
Licensed under the Apache License, Version 2.0, see LICENSE for details.
SPDX-License-Identifier: Apache-2.0
This package holds common constants and functions for PRESENT- and
PRINCE-based scrambling devices.
See also: prim_present, prim_prince
References: - https://en.wikipedia.org/wiki/PRESENT
- https://en.wikipedia.org/wiki/Prince_(cipher)
- http://www.lightweightcrypto.org/present/present_ches2007.pdf
- https://eprint.iacr.org/2012/529.pdf
- https://eprint.iacr.org/2015/372.pdf
- https://eprint.iacr.org/2014/656.pdf
Signals
Name | Type | Description |
---|---|---|
prim_cipher_pkg | endpackage |
Constants
Name | Type | Value | Description |
---|---|---|---|
PRINCE_SBOX4 | logic [15:0][3:0] | { 4'h4, 4'hD, 4'h5, 4'hE, |
|
PRINCE_SBOX4_INV | logic [15:0][3:0] | { 4'h1, 4'hC, 4'hE, 4'h5, |
|
PRINCE_SHIFT_ROWS64 | logic [15:0][3:0] | undefined | nibble permutations |
PRINCE_SHIFT_ROWS64_INV | logic [15:0][3:0] | logic [11:0][63:0] | |
PRINCE_ALPHA_CONST | logic [63:0] | 64'hC0AC29B7C97C50DD | tweak constant for key modification between enc/dec modes |
PRINCE_SHIFT_ROWS_CONST0 | logic [15:0] | 16'h7BDE | masking constants for shift rows function below |
PRINCE_SHIFT_ROWS_CONST1 | logic [15:0] | 16'hBDE7 | |
PRINCE_SHIFT_ROWS_CONST2 | logic [15:0] | 16'hDE7B | |
PRINCE_SHIFT_ROWS_CONST3 | logic [15:0] | 16'hE7BD | |
PRESENT_SBOX4 | logic [15:0][3:0] | { 4'h2, 4'h1, 4'h7, 4'h4, |
////////////////// PRESENT Cipher // ////////////////// this is the sbox from the present cipher |
PRESENT_SBOX4_INV | logic [15:0][3:0] | { 4'hA, 4'h9, 4'h7, 4'h0, |
|
PRESENT_PERM32 | logic [31:0][4:0] | { 5'd31, 5'd23, 5'd15, 5'd07, |
these are modified permutation indices for a 32bit version that follow the same pattern as for the 64bit version |
PRESENT_PERM32_INV | logic [31:0][4:0] | { 5'd31, 5'd27, 5'd23, 5'd19, |
|
PRESENT_PERM64 | logic [63:0][5:0] | { 6'd63, 6'd47, 6'd31, 6'd15, |
these are the permutation indices of the present cipher |
PRESENT_PERM64_INV | logic [63:0][5:0] | { 6'd63, 6'd59, 6'd55, 6'd51, |
Functions
- prince_shiftrows_32bit (logic [31:0] state_) return (logic [31:0])
Description
nibble shifts
- prince_shiftrows_64bit (logic [63:0] state_) return (logic [63:0])
- prince_nibble_red16 (logic [15:0]) return (logic [3:0])
Description
XOR reduction of four nibbles in a 16bit subvector
- prince_mult_prime_32bit (logic [31:0] state_in) return (logic [31:0])
Description
M prime multiplication
- prince_mult_prime_64bit (logic [63:0] state_in) return (logic [63:0])
Description
M prime multiplication
- present_update_key64 (logic [63:0] key_in,
) return (logic [63:0])
Description
forward key schedule
- present_update_key80 (logic [79:0] key_in,
) return (logic [79:0])
- present_update_key128 (logic [127:0] key_in,
) return (logic [127:0])
- present_inv_update_key64 (logic [63:0] key_in,
) return (logic [63:0])
Description
inverse key schedule
- present_inv_update_key80 (logic [79:0] key_in,
) return (logic [79:0])
- present_inv_update_key128 (logic [127:0] key_in,
) return (logic [127:0])
- present_get_dec_key64 (logic [63:0] key_in,
) return (logic [63:0])
Description
these functions can be used to derive the DEC key from the ENC key by
stepping the key by the correct number of rounds using the keyschedule functions above.
- present_get_dec_key80 (logic [79:0] key_in,
) return (logic [79:0])
- present_get_dec_key128 (logic [127:0] key_in,
) return (logic [127:0])
- sbox4_8bit (logic [7:0] state_in,
logic [15:0][3:0]) return (logic [7:0])
Description
///////////////////////
Common Subfunctions //
///////////////////////
- sbox4_16bit (logic [15:0] state_in,
logic [15:0][3:0]) return (logic [15:0])
- sbox4_32bit (logic [31:0] state_in,
logic [15:0][3:0]) return (logic [31:0])
- sbox4_64bit (logic [63:0] state_in,
logic [15:0][3:0]) return (logic [63:0])
- perm_8bit (logic [7:0] state_in,
logic [7:0][2:0]) return (logic [7:0])
- perm_16bit (logic [15:0] state_in,
logic [15:0][3:0]) return (logic [15:0])
- perm_32bit (logic [31:0] state_in,
logic [31:0][4:0]) return (logic [31:0])
- perm_64bit (logic [63:0] state_in,
logic [63:0][5:0]) return (logic [63:0])