Package: prim_cipher_pkg

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

Description
nibble shifts

Description
XOR reduction of four nibbles in a 16bit subvector

Description
M prime multiplication

Description
M prime multiplication

Description
forward key schedule

Description
inverse key schedule

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.

Description
///////////////////////
Common Subfunctions //
///////////////////////