LCOV - code coverage report
Current view: top level - externals/mbedtls/library - psa_crypto_client.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 23 0.0 %
Date: 2024-09-16 20:15:30 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  *  PSA crypto client code
       3                 :            :  */
       4                 :            : /*
       5                 :            :  *  Copyright The Mbed TLS Contributors
       6                 :            :  *  SPDX-License-Identifier: Apache-2.0
       7                 :            :  *
       8                 :            :  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
       9                 :            :  *  not use this file except in compliance with the License.
      10                 :            :  *  You may obtain a copy of the License at
      11                 :            :  *
      12                 :            :  *  http://www.apache.org/licenses/LICENSE-2.0
      13                 :            :  *
      14                 :            :  *  Unless required by applicable law or agreed to in writing, software
      15                 :            :  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
      16                 :            :  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      17                 :            :  *  See the License for the specific language governing permissions and
      18                 :            :  *  limitations under the License.
      19                 :            :  */
      20                 :            : 
      21                 :            : #include "common.h"
      22                 :            : #include "psa/crypto.h"
      23                 :            : 
      24                 :            : #if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
      25                 :            : 
      26                 :            : #include <string.h>
      27                 :            : #include "mbedtls/platform.h"
      28                 :            : #if !defined(MBEDTLS_PLATFORM_C)
      29                 :            : #define mbedtls_calloc calloc
      30                 :            : #define mbedtls_free   free
      31                 :            : #endif
      32                 :            : 
      33                 :          0 : void psa_reset_key_attributes( psa_key_attributes_t *attributes )
      34                 :            : {
      35                 :          0 :     mbedtls_free( attributes->domain_parameters );
      36                 :          0 :     memset( attributes, 0, sizeof( *attributes ) );
      37                 :          0 : }
      38                 :            : 
      39                 :          0 : psa_status_t psa_set_key_domain_parameters( psa_key_attributes_t *attributes,
      40                 :            :                                             psa_key_type_t type,
      41                 :            :                                             const uint8_t *data,
      42                 :            :                                             size_t data_length )
      43                 :            : {
      44                 :          0 :     uint8_t *copy = NULL;
      45                 :            : 
      46         [ #  # ]:          0 :     if( data_length != 0 )
      47                 :            :     {
      48                 :          0 :         copy = mbedtls_calloc( 1, data_length );
      49         [ #  # ]:          0 :         if( copy == NULL )
      50                 :            :             return( PSA_ERROR_INSUFFICIENT_MEMORY );
      51                 :          0 :         memcpy( copy, data, data_length );
      52                 :            :     }
      53                 :            :     /* After this point, this function is guaranteed to succeed, so it
      54                 :            :      * can start modifying `*attributes`. */
      55                 :            : 
      56         [ #  # ]:          0 :     if( attributes->domain_parameters != NULL )
      57                 :            :     {
      58                 :          0 :         mbedtls_free( attributes->domain_parameters );
      59                 :          0 :         attributes->domain_parameters = NULL;
      60                 :          0 :         attributes->domain_parameters_size = 0;
      61                 :            :     }
      62                 :            : 
      63                 :          0 :     attributes->domain_parameters = copy;
      64                 :          0 :     attributes->domain_parameters_size = data_length;
      65                 :          0 :     attributes->core.type = type;
      66                 :          0 :     return( PSA_SUCCESS );
      67                 :            : }
      68                 :            : 
      69                 :          0 : psa_status_t psa_get_key_domain_parameters(
      70                 :            :     const psa_key_attributes_t *attributes,
      71                 :            :     uint8_t *data, size_t data_size, size_t *data_length )
      72                 :            : {
      73         [ #  # ]:          0 :     if( attributes->domain_parameters_size > data_size )
      74                 :            :         return( PSA_ERROR_BUFFER_TOO_SMALL );
      75                 :          0 :     *data_length = attributes->domain_parameters_size;
      76         [ #  # ]:          0 :     if( attributes->domain_parameters_size != 0 )
      77                 :          0 :         memcpy( data, attributes->domain_parameters,
      78                 :            :                 attributes->domain_parameters_size );
      79                 :            :     return( PSA_SUCCESS );
      80                 :            : }
      81                 :            : 
      82                 :            : #endif /* MBEDTLS_PSA_CRYPTO_CLIENT */

Generated by: LCOV version 1.14