File: psa_test_wrapper.py

package info (click to toggle)
mbedtls 3.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 50,424 kB
  • sloc: ansic: 164,526; sh: 25,295; python: 14,825; makefile: 2,761; perl: 1,043; tcl: 4
file content (39 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Generate wrapper functions for PSA function calls.
"""

# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

import argparse
import itertools
import os
from typing import Iterator, List, Collection, Optional, Tuple

from .. import build_tree
from .. import c_parsing_helper
from .. import c_wrapper_generator
from .. import typing_util

from .psa_buffer import BufferParameter
from .psa_wrapper import PSAWrapper, PSALoggingWrapper, PSAWrapperConfiguration

class PSATestWrapper(PSAWrapper):
    """Generate a C source file containing wrapper functions for PSA Crypto API calls."""

    _WRAPPER_NAME_PREFIX = 'mbedtls_test_wrap_'
    _WRAPPER_NAME_SUFFIX = ''

    _PSA_WRAPPER_INCLUDES = ['<psa/crypto.h>',
                             '<test/memory.h>',
                             '<test/psa_crypto_helpers.h>',
                             '<test/psa_test_wrappers.h>']

class PSALoggingTestWrapper(PSATestWrapper, PSALoggingWrapper):
    """Generate a C source file containing wrapper functions that log PSA Crypto API calls."""

    def __init__(self, out_h_f: str,
                       out_c_f: str,
                       stream: str,
                       in_headers: Optional[List[str]] = None) -> None:
        super().__init__(out_h_f, out_c_f, stream, in_headers)