LCOV - code coverage report
Current view: top level - app/test - test_cryptodev_asym_util.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 12 33 36.4 %
Date: 2026-04-01 20:02:27 Functions: 2 5 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 26 26.9 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Cavium Networks
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef TEST_CRYPTODEV_ASYM_TEST_UTIL_H__
       6                 :            : #define TEST_CRYPTODEV_ASYM_TEST_UTIL_H__
       7                 :            : 
       8                 :            : /* Below Apis compare resulted buffer to original test vector */
       9                 :            : 
      10                 :            : static inline int rsa_verify(struct rsa_test_data *rsa_param,
      11                 :            :                 struct rte_crypto_op *result_op)
      12                 :            : {
      13                 :          2 :         if (memcmp(rsa_param->data,
      14         [ -  + ]:          2 :                                 result_op->asym->rsa.message.data,
      15                 :            :                                 result_op->asym->rsa.message.length))
      16                 :            :                 return -1;
      17                 :            :         return 0;
      18                 :            : }
      19                 :            : 
      20                 :          1 : static inline int verify_modinv(uint8_t *mod_inv,
      21                 :            :                 struct rte_crypto_op *result_op)
      22                 :            : {
      23                 :          1 :         const uint8_t *b = result_op->asym->modinv.result.data;
      24                 :          1 :         size_t b_len = result_op->asym->modinv.result.length;
      25                 :            : 
      26   [ +  -  -  + ]:          1 :         while (b_len > 1 && b[0] == 0) {
      27                 :          0 :                 b++;
      28                 :          0 :                 b_len--;
      29                 :            :         }
      30         [ -  + ]:          1 :         if (memcmp(mod_inv, b, b_len))
      31                 :          0 :                 return -1;
      32                 :            :         return 0;
      33                 :            : }
      34                 :            : 
      35                 :          1 : static inline int verify_modexp(uint8_t *mod_exp,
      36                 :            :                 struct rte_crypto_op *result_op)
      37                 :            : {
      38                 :          1 :         const uint8_t *b = result_op->asym->modex.result.data;
      39                 :          1 :         size_t b_len = result_op->asym->modex.result.length;
      40                 :            : 
      41   [ +  -  -  + ]:          1 :         while (b_len > 1 && b[0] == 0) {
      42                 :          0 :                 b++;
      43                 :          0 :                 b_len--;
      44                 :            :         }
      45         [ -  + ]:          1 :         if (memcmp(mod_exp, b, b_len))
      46                 :          0 :                 return -1;
      47                 :            :         return 0;
      48                 :            : }
      49                 :            : 
      50                 :          0 : static inline int verify_ecdsa_sign(uint8_t *sign_r,
      51                 :            :                 uint8_t *sign_s, struct rte_crypto_op *result_op)
      52                 :            : {
      53         [ #  # ]:          0 :         if (memcmp(sign_r, result_op->asym->ecdsa.r.data,
      54                 :          0 :                    result_op->asym->ecdsa.r.length) ||
      55         [ #  # ]:          0 :                    memcmp(sign_s, result_op->asym->ecdsa.s.data,
      56                 :            :                    result_op->asym->ecdsa.s.length))
      57                 :          0 :                 return -1;
      58                 :            :         return 0;
      59                 :            : }
      60                 :            : 
      61                 :          0 : static inline int verify_ecpm(uint8_t *result_x, uint8_t *result_y,
      62                 :            :                               struct rte_crypto_op *result_op)
      63                 :            : {
      64         [ #  # ]:          0 :         if (memcmp(result_x, result_op->asym->ecpm.r.x.data,
      65                 :          0 :                    result_op->asym->ecpm.r.x.length) ||
      66         [ #  # ]:          0 :                    memcmp(result_y, result_op->asym->ecpm.r.y.data,
      67                 :            :                    result_op->asym->ecpm.r.y.length))
      68                 :          0 :                 return -1;
      69                 :            : 
      70                 :            :         return 0;
      71                 :            : }
      72                 :            : 
      73                 :          0 : static inline int verify_ecdh_secret(uint8_t *result_x, uint8_t *result_y,
      74                 :            :                               struct rte_crypto_op *result_op)
      75                 :            : {
      76         [ #  # ]:          0 :         if (memcmp(result_x, result_op->asym->ecdh.shared_secret.x.data,
      77                 :          0 :                    result_op->asym->ecdh.shared_secret.x.length) ||
      78         [ #  # ]:          0 :                    memcmp(result_y, result_op->asym->ecdh.shared_secret.y.data,
      79                 :            :                    result_op->asym->ecdh.shared_secret.y.length))
      80                 :          0 :                 return -1;
      81                 :            : 
      82                 :            :         return 0;
      83                 :            : }
      84                 :            : #endif /* TEST_CRYPTODEV_ASYM_TEST_UTIL_H__ */

Generated by: LCOV version 1.14