LCOV - code coverage report
Current view: top level - drivers/common/qat/qat_adf - qat_pke.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 62 0.0 %
Date: 2024-02-14 00:53:57 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 102 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2021-2022 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _QAT_PKE_FUNCTIONALITY_ARRAYS_H_
       6                 :            : #define _QAT_PKE_FUNCTIONALITY_ARRAYS_H_
       7                 :            : 
       8                 :            : #include "icp_qat_fw_mmp_ids.h"
       9                 :            : 
      10                 :            : /*
      11                 :            :  * Modular exponentiation functionality IDs
      12                 :            :  */
      13                 :            : 
      14                 :            : struct qat_asym_function {
      15                 :            :         uint32_t func_id;
      16                 :            :         uint32_t bytesize;
      17                 :            : };
      18                 :            : 
      19                 :            : static struct qat_asym_function
      20                 :          0 : get_modexp_function2(uint32_t bytesize)
      21                 :            : {
      22                 :            :         struct qat_asym_function qat_function = { };
      23                 :            : 
      24         [ #  # ]:          0 :         if (bytesize <= 64) {
      25                 :            :                 qat_function.func_id = MATHS_MODEXP_L512;
      26                 :            :                 qat_function.bytesize = 64;
      27         [ #  # ]:          0 :         } else if (bytesize <= 128) {
      28                 :            :                 qat_function.func_id = MATHS_MODEXP_L1024;
      29                 :            :                 qat_function.bytesize = 128;
      30         [ #  # ]:          0 :         } else if (bytesize <= 192) {
      31                 :            :                 qat_function.func_id = MATHS_MODEXP_L1536;
      32                 :            :                 qat_function.bytesize = 192;
      33         [ #  # ]:          0 :         } else if (bytesize <= 256) {
      34                 :            :                 qat_function.func_id = MATHS_MODEXP_L2048;
      35                 :            :                 qat_function.bytesize = 256;
      36         [ #  # ]:          0 :         } else if (bytesize <= 320) {
      37                 :            :                 qat_function.func_id = MATHS_MODEXP_L2560;
      38                 :            :                 qat_function.bytesize = 320;
      39         [ #  # ]:          0 :         } else if (bytesize <= 384) {
      40                 :            :                 qat_function.func_id = MATHS_MODEXP_L3072;
      41                 :            :                 qat_function.bytesize = 384;
      42         [ #  # ]:          0 :         } else if (bytesize <= 448) {
      43                 :            :                 qat_function.func_id = MATHS_MODEXP_L3584;
      44                 :            :                 qat_function.bytesize = 448;
      45         [ #  # ]:          0 :         } else if (bytesize <= 512) {
      46                 :            :                 qat_function.func_id = MATHS_MODEXP_L4096;
      47                 :            :                 qat_function.bytesize = 512;
      48                 :            :         }
      49                 :          0 :         return qat_function;
      50                 :            : }
      51                 :            : 
      52                 :            : static struct qat_asym_function
      53                 :            : get_modexp_function(const struct rte_crypto_asym_xform *xform)
      54                 :            : {
      55                 :          0 :         return get_modexp_function2(xform->modex.modulus.length);
      56                 :            : }
      57                 :            : 
      58                 :            : static struct qat_asym_function
      59                 :          0 : get_modinv_function(const struct rte_crypto_asym_xform *xform)
      60                 :            : {
      61                 :            :         struct qat_asym_function qat_function = { };
      62                 :            : 
      63                 :          0 :         if (xform->modinv.modulus.data[
      64         [ #  # ]:          0 :                 xform->modinv.modulus.length - 1] & 0x01) {
      65         [ #  # ]:          0 :                 if (xform->modex.modulus.length <= 16) {
      66                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L128;
      67                 :            :                         qat_function.bytesize = 16;
      68         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 24) {
      69                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L192;
      70                 :            :                         qat_function.bytesize = 24;
      71         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 32) {
      72                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L256;
      73                 :            :                         qat_function.bytesize = 32;
      74         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 48) {
      75                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L384;
      76                 :            :                         qat_function.bytesize = 48;
      77         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 64) {
      78                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L512;
      79                 :            :                         qat_function.bytesize = 64;
      80         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 96) {
      81                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L768;
      82                 :            :                         qat_function.bytesize = 96;
      83         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 128) {
      84                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L1024;
      85                 :            :                         qat_function.bytesize = 128;
      86         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 192) {
      87                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L1536;
      88                 :            :                         qat_function.bytesize = 192;
      89         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 256) {
      90                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L2048;
      91                 :            :                         qat_function.bytesize = 256;
      92         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 384) {
      93                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L3072;
      94                 :            :                         qat_function.bytesize = 384;
      95         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 512) {
      96                 :            :                         qat_function.func_id = MATHS_MODINV_ODD_L4096;
      97                 :            :                         qat_function.bytesize = 512;
      98                 :            :                 }
      99                 :            :         } else {
     100         [ #  # ]:          0 :                 if (xform->modex.modulus.length <= 16) {
     101                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L128;
     102                 :            :                         qat_function.bytesize = 16;
     103         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 24) {
     104                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L192;
     105                 :            :                         qat_function.bytesize = 24;
     106         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 32) {
     107                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L256;
     108                 :            :                         qat_function.bytesize = 32;
     109         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 48) {
     110                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L384;
     111                 :            :                         qat_function.bytesize = 48;
     112         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 64) {
     113                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L512;
     114                 :            :                         qat_function.bytesize = 64;
     115         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 96) {
     116                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L768;
     117                 :            :                         qat_function.bytesize = 96;
     118         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 128) {
     119                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L1024;
     120                 :            :                         qat_function.bytesize = 128;
     121         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 192) {
     122                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L1536;
     123                 :            :                         qat_function.bytesize = 192;
     124         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 256) {
     125                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L2048;
     126                 :            :                         qat_function.bytesize = 256;
     127         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 384) {
     128                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L3072;
     129                 :            :                         qat_function.bytesize = 384;
     130         [ #  # ]:          0 :                 } else if (xform->modex.modulus.length <= 512) {
     131                 :            :                         qat_function.func_id = MATHS_MODINV_EVEN_L4096;
     132                 :            :                         qat_function.bytesize = 512;
     133                 :            :                 }
     134                 :            :         }
     135                 :            : 
     136                 :          0 :         return qat_function;
     137                 :            : }
     138                 :            : 
     139                 :            : static struct qat_asym_function
     140                 :            : get_rsa_enc_function(const struct rte_crypto_asym_xform *xform)
     141                 :            : {
     142                 :            :         struct qat_asym_function qat_function = { };
     143                 :            : 
     144         [ #  # ]:          0 :         if (xform->rsa.n.length <= 64) {
     145                 :            :                 qat_function.func_id = PKE_RSA_EP_512;
     146                 :            :                 qat_function.bytesize = 64;
     147         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 128) {
     148                 :            :                 qat_function.func_id = PKE_RSA_EP_1024;
     149                 :            :                 qat_function.bytesize = 128;
     150         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 192) {
     151                 :            :                 qat_function.func_id = PKE_RSA_EP_1536;
     152                 :            :                 qat_function.bytesize = 192;
     153         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 256) {
     154                 :            :                 qat_function.func_id = PKE_RSA_EP_2048;
     155                 :            :                 qat_function.bytesize = 256;
     156         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 384) {
     157                 :            :                 qat_function.func_id = PKE_RSA_EP_3072;
     158                 :            :                 qat_function.bytesize = 384;
     159         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 512) {
     160                 :            :                 qat_function.func_id = PKE_RSA_EP_4096;
     161                 :            :                 qat_function.bytesize = 512;
     162                 :            :         }
     163                 :            :         return qat_function;
     164                 :            : }
     165                 :            : 
     166                 :            : static struct qat_asym_function
     167                 :            : get_rsa_dec_function(const struct rte_crypto_asym_xform *xform)
     168                 :            : {
     169                 :            :         struct qat_asym_function qat_function = { };
     170                 :            : 
     171         [ #  # ]:          0 :         if (xform->rsa.n.length <= 64) {
     172                 :            :                 qat_function.func_id = PKE_RSA_DP1_512;
     173                 :            :                 qat_function.bytesize = 64;
     174         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 128) {
     175                 :            :                 qat_function.func_id = PKE_RSA_DP1_1024;
     176                 :            :                 qat_function.bytesize = 128;
     177         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 192) {
     178                 :            :                 qat_function.func_id = PKE_RSA_DP1_1536;
     179                 :            :                 qat_function.bytesize = 192;
     180         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 256) {
     181                 :            :                 qat_function.func_id = PKE_RSA_DP1_2048;
     182                 :            :                 qat_function.bytesize = 256;
     183         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 384) {
     184                 :            :                 qat_function.func_id = PKE_RSA_DP1_3072;
     185                 :            :                 qat_function.bytesize = 384;
     186         [ #  # ]:          0 :         } else if (xform->rsa.n.length <= 512) {
     187                 :            :                 qat_function.func_id = PKE_RSA_DP1_4096;
     188                 :            :                 qat_function.bytesize = 512;
     189                 :            :         }
     190                 :            :         return qat_function;
     191                 :            : }
     192                 :            : 
     193                 :            : static struct qat_asym_function
     194                 :            : get_rsa_crt_function(const struct rte_crypto_asym_xform *xform)
     195                 :            : {
     196                 :            :         struct qat_asym_function qat_function = { };
     197                 :          0 :         int nlen = xform->rsa.qt.p.length * 2;
     198                 :            : 
     199         [ #  # ]:          0 :         if (nlen <= 64) {
     200                 :            :                 qat_function.func_id = PKE_RSA_DP2_512;
     201                 :            :                 qat_function.bytesize = 64;
     202         [ #  # ]:          0 :         } else if (nlen <= 128) {
     203                 :            :                 qat_function.func_id = PKE_RSA_DP2_1024;
     204                 :            :                 qat_function.bytesize = 128;
     205         [ #  # ]:          0 :         } else if (nlen <= 192) {
     206                 :            :                 qat_function.func_id = PKE_RSA_DP2_1536;
     207                 :            :                 qat_function.bytesize = 192;
     208         [ #  # ]:          0 :         } else if (nlen <= 256) {
     209                 :            :                 qat_function.func_id = PKE_RSA_DP2_2048;
     210                 :            :                 qat_function.bytesize = 256;
     211         [ #  # ]:          0 :         } else if (nlen <= 384) {
     212                 :            :                 qat_function.func_id = PKE_RSA_DP2_3072;
     213                 :            :                 qat_function.bytesize = 384;
     214         [ #  # ]:          0 :         } else if (nlen <= 512) {
     215                 :            :                 qat_function.func_id = PKE_RSA_DP2_4096;
     216                 :            :                 qat_function.bytesize = 512;
     217                 :            :         }
     218                 :            :         return qat_function;
     219                 :            : }
     220                 :            : 
     221                 :            : static struct qat_asym_function
     222                 :          0 : get_ecdsa_verify_function(const struct rte_crypto_asym_xform *xform)
     223                 :            : {
     224                 :            :         struct qat_asym_function qat_function;
     225                 :            : 
     226         [ #  # ]:          0 :         switch (xform->ec.curve_id) {
     227                 :            :         case RTE_CRYPTO_EC_GROUP_SECP256R1:
     228                 :            :                 qat_function.func_id = PKE_ECDSA_VERIFY_GFP_L256;
     229                 :            :                 qat_function.bytesize = 32;
     230                 :            :                 break;
     231                 :            :         case RTE_CRYPTO_EC_GROUP_SECP384R1:
     232                 :            :                 qat_function.func_id = PKE_ECDSA_VERIFY_GFP_L512;
     233                 :            :                 qat_function.bytesize = 64;
     234                 :            :                 break;
     235                 :            :         case RTE_CRYPTO_EC_GROUP_SECP521R1:
     236                 :            :                 qat_function.func_id = PKE_ECDSA_VERIFY_GFP_521;
     237                 :            :                 qat_function.bytesize = 66;
     238                 :            :                 break;
     239                 :            :         default:
     240                 :            :                 qat_function.func_id = 0;
     241                 :            :         }
     242                 :          0 :         return qat_function;
     243                 :            : }
     244                 :            : 
     245                 :            : static struct qat_asym_function
     246                 :          0 : get_ecdsa_function(const struct rte_crypto_asym_xform *xform)
     247                 :            : {
     248                 :            :         struct qat_asym_function qat_function;
     249                 :            : 
     250         [ #  # ]:          0 :         switch (xform->ec.curve_id) {
     251                 :            :         case RTE_CRYPTO_EC_GROUP_SECP256R1:
     252                 :            :                 qat_function.func_id = PKE_ECDSA_SIGN_RS_GFP_L256;
     253                 :            :                 qat_function.bytesize = 32;
     254                 :            :                 break;
     255                 :            :         case RTE_CRYPTO_EC_GROUP_SECP384R1:
     256                 :            :                 qat_function.func_id = PKE_ECDSA_SIGN_RS_GFP_L512;
     257                 :            :                 qat_function.bytesize = 64;
     258                 :            :                 break;
     259                 :            :         case RTE_CRYPTO_EC_GROUP_SECP521R1:
     260                 :            :                 qat_function.func_id = PKE_ECDSA_SIGN_RS_GFP_521;
     261                 :            :                 qat_function.bytesize = 66;
     262                 :            :                 break;
     263                 :            :         default:
     264                 :            :                 qat_function.func_id = 0;
     265                 :            :         }
     266                 :          0 :         return qat_function;
     267                 :            : }
     268                 :            : 
     269                 :            : static struct qat_asym_function
     270                 :            : get_ecpm_function(const struct rte_crypto_asym_xform *xform)
     271                 :            : {
     272                 :            :         struct qat_asym_function qat_function;
     273                 :            : 
     274                 :            :         switch (xform->ec.curve_id) {
     275                 :            :         case RTE_CRYPTO_EC_GROUP_SECP256R1:
     276                 :            :                 qat_function.func_id = MATHS_POINT_MULTIPLICATION_GFP_L256;
     277                 :            :                 qat_function.bytesize = 32;
     278                 :            :                 break;
     279                 :            :         case RTE_CRYPTO_EC_GROUP_SECP384R1:
     280                 :            :                 qat_function.func_id = MATHS_POINT_MULTIPLICATION_GFP_L512;
     281                 :            :                 qat_function.bytesize = 64;
     282                 :            :                 break;
     283                 :            :         case RTE_CRYPTO_EC_GROUP_SECP521R1:
     284                 :            :                 qat_function.func_id = MATHS_POINT_MULTIPLICATION_GFP_521;
     285                 :            :                 qat_function.bytesize = 66;
     286                 :            :                 break;
     287                 :            :         default:
     288                 :            :                 qat_function.func_id = 0;
     289                 :            :         }
     290                 :            :         return qat_function;
     291                 :            : }
     292                 :            : 
     293                 :            : static struct qat_asym_function
     294                 :            : get_ec_verify_function(const struct rte_crypto_asym_xform *xform)
     295                 :            : {
     296                 :            :         struct qat_asym_function qat_function;
     297                 :            : 
     298                 :            :         switch (xform->ec.curve_id) {
     299                 :            :         case RTE_CRYPTO_EC_GROUP_SECP256R1:
     300                 :            :                 qat_function.func_id = MATHS_POINT_VERIFY_GFP_L256;
     301                 :            :                 qat_function.bytesize = 32;
     302                 :            :                 break;
     303                 :            :         case RTE_CRYPTO_EC_GROUP_SECP384R1:
     304                 :            :                 qat_function.func_id = MATHS_POINT_VERIFY_GFP_L512;
     305                 :            :                 qat_function.bytesize = 64;
     306                 :            :                 break;
     307                 :            :         case RTE_CRYPTO_EC_GROUP_SECP521R1:
     308                 :            :                 qat_function.func_id = MATHS_POINT_VERIFY_GFP_521;
     309                 :            :                 qat_function.bytesize = 66;
     310                 :            :                 break;
     311                 :            :         default:
     312                 :            :                 qat_function.func_id = 0;
     313                 :            :         }
     314                 :            :         return qat_function;
     315                 :            : }
     316                 :            : 
     317                 :            : static struct qat_asym_function
     318                 :            : get_sm2_ecdsa_sign_function(void)
     319                 :            : {
     320                 :            :         struct qat_asym_function qat_function = {
     321                 :            :                 PKE_ECSM2_SIGN_RS, 32
     322                 :            :         };
     323                 :            : 
     324                 :            :         return qat_function;
     325                 :            : }
     326                 :            : 
     327                 :            : static struct qat_asym_function
     328                 :            : get_sm2_ecdsa_verify_function(void)
     329                 :            : {
     330                 :            :         struct qat_asym_function qat_function = {
     331                 :            :                 PKE_ECSM2_VERIFY, 32
     332                 :            :         };
     333                 :            : 
     334                 :            :         return qat_function;
     335                 :            : }
     336                 :            : 
     337                 :            : #endif

Generated by: LCOV version 1.14