1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef PKA_DEFS_H 8 #define PKA_DEFS_H 9 10 #include "cc_sram_map.h" 11 #include "cc_pal_types.h" 12 #include "cc_pka_hw_plat_defs.h" 13 14 15 /* minimal and maximal allowed size of PKA data memory registers in bits */ 16 #define PKA_MIN_OPERATION_SIZE_BITS CC_BITS_IN_32BIT_WORD 17 #ifdef CC_CONFIG_SUPPORT_HK 18 #define PKA_MAX_OPERATION_SIZE_BITS (CC_SRP_MAX_MODULUS_SIZE_IN_BITS+CC_PKA_WORD_SIZE_IN_BITS) 19 #else 20 #define PKA_MAX_OPERATION_SIZE_BITS (CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS+CC_PKA_WORD_SIZE_IN_BITS) 21 #endif 22 23 24 #define CC_SRAM_PKA_SIZE_IN_BYTES (CC_PKA_SRAM_SIZE_IN_KBYTES*CC_1K_SIZE_IN_BYTES) 25 #define CC_SRAM_PKA_MAX_SIZE CC_SRAM_PKA_SIZE_IN_BYTES 26 27 /* PKA word size in bits/32bit words */ 28 #define PKA_WORD_SIZE_IN_BYTES (CC_PKA_WORD_SIZE_IN_BITS/CC_BITS_IN_BYTE) 29 #define PKA_WORD_SIZE_IN_32BIT_WORDS (CC_PKA_WORD_SIZE_IN_BITS/CC_BITS_IN_32BIT_WORD) 30 31 /* maximal size of extended register in "big PKA words" and in 32-bit words: * 32 the size defined according to RSA as more large, and used to define some * 33 * auxiliary buffers sizes */ 34 #define PKA_MAX_REGISTER_SIZE_IN_PKA_WORDS ((PKA_MAX_OPERATION_SIZE_BITS+PKA_EXTRA_BITS+CC_PKA_WORD_SIZE_IN_BITS-1)/CC_PKA_WORD_SIZE_IN_BITS) 35 #define PKA_MAX_REGISTER_SIZE_IN_32BIT_WORDS (PKA_MAX_REGISTER_SIZE_IN_PKA_WORDS*PKA_WORD_SIZE_IN_32BIT_WORDS) 36 37 38 /* Full register (operation) size including extra PKA-word (128/64-bit). Op size * 39 * must include extra bits if needed in the algorithm 40 // Adding 1 for operation with carry/additional bits */ 41 #define GET_FULL_OP_SIZE_PKA_WORDS(opSizeInBits) (((opSizeInBits)/CC_PKA_WORD_SIZE_IN_BITS + (((opSizeInBits) & (CC_PKA_WORD_SIZE_IN_BITS-1)) > 0)) + 1) 42 #define GET_FULL_OP_SIZE_BITS(opSizeInBits) (CC_PKA_WORD_SIZE_IN_BITS*GET_FULL_OP_SIZE_PKA_WORDS((opSizeInBits))) 43 #define GET_FULL_OP_SIZE_32BIT_WORDS(opSizeInBits) (GET_FULL_OP_SIZE_BITS((opSizeInBits)) / CC_BITS_IN_32BIT_WORD) 44 45 46 /* The maximal count of allowed sizes of PKA operands or register-variables */ 47 #define PKA_NUM_OF_PKA_LEN_IDS_REGS 8 48 49 /* enumerator, defining ID-s of PKA registers sizes, inserted in PKA sizes * 50 * table */ 51 typedef enum { 52 LEN_ID_N_BITS = 0, // 0 - for modulus size (RSA, EC) 53 LEN_ID_N_PKA_REG_BITS, // 1 - for operation size (RSA, EC) 54 LEN_ID_PQ_BITS, // 2 - for P, Q size (RSA) 55 LEN_ID_PQ_PKA_REG_BITS, // 3 - for operations on P, Q size (RSA) 56 LEN_ID_AUX_PRIME_BITS, // 4 - for P1,P2,Q1,Q2 101 bit size (RSA) 57 LEN_ID_AUX_PRIME_PKA_REG_BITS, // 5 - for operations on P1,P2,Q1,Q2 101 bit size (RSA) 58 LEN_ID_NP_BITS, // 6 - for calculating Np (RSA, EC) 59 LEN_ID_MAX_BITS , // 7 - size of PKA registers (RSA: CC_RSA_MAX_KEY_GENERATION_SIZE_BITS; EC: reg.size) 60 LEN_ID_MAX, // 8 - not allowed, indicates out of range (RSA, EC) 61 }LenIdTypes_t; 62 63 64 #endif // PKA_GEN_DEFS_H 65