Skip to content

Commit

Permalink
Release of version 1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mbracht-ifx committed Nov 29, 2024
1 parent 8b253be commit 66e1a4a
Show file tree
Hide file tree
Showing 30 changed files with 117 additions and 254 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
[submodule "extras/optiga-trust-m/external/optiga"]
path = extras/optiga-trust-m/external/optiga
url = https://github.com/Infineon/optiga-trust-m.git
[submodule "extras/optiga-trust-m/external/libusb"]
path = extras/optiga-trust-m/external/libusb
url = https://github.com/libusb/libusb.git
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.4.3 (2024-11-29)

### Changed
- Updated optiga-trust-m module to v5.3.0
- Fixed sample preparation config
- Improve permission handling for libusb on Linux
- Improved the description and metadata of the Python package

## 1.4.2 (2024-08-29)

### Fixed
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ To install this Python module from pip, run the following command
$ python -m pip install optigatrust
```

### libusb: Allow access to USB device (USB-to-UART-interface)

If you want to use the `optigatrust` Python package with libusb and a USB-to-UART-interface from user space, the access has to be permitted with a udev rule.

#### Manual installation of the udev rule

When using the OPTIGA™ Trust M Perso2Go board, add the predefined [udev rule](./src/optigatrust/rules/90-optigatrust.rules) as follows (root permission needed).

```bash
$ sudo cp ./src/optigatrust/rules/90-optigatrust.rules /etc/udev/rules.d/
```
#### Automatic installation of the udev rule (root permission needed)

Alternatively, you can also run the installation with root permissions which will install the udev rule for the OPTIGA™ Trust M Perso2Go board automatically.

```bash
$ sudo python -m pip install optigatrust
```

## Building from sources

### Building the OPTIGA™ Trust Host Library for C as library
Expand Down
28 changes: 0 additions & 28 deletions extras/optiga-trust-m/download_libusb_windows.bat

This file was deleted.

1 change: 1 addition & 0 deletions extras/optiga-trust-m/external/libusb
Submodule libusb added at d52e35
1 change: 1 addition & 0 deletions extras/optiga-trust-m/linux_i2c.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if(UNIX)
${TRUSTM_HOST_LIBRARY_PATH}/extras/pal/linux/pal_os_lock.c
${TRUSTM_HOST_LIBRARY_PATH}/extras/pal/linux/pal_os_timer.c
${TRUSTM_HOST_LIBRARY_PATH}/extras/pal/linux/pal_os_memory.c
${TRUSTM_HOST_LIBRARY_PATH}/extras/pal/linux/pal_shared_mutex.c
${TRUSTM_HOST_LIBRARY_PATH}/src/comms/optiga_comms_ifx_i2c.c
${TRUSTM_HOST_LIBRARY_PATH}/src/comms/ifx_i2c/ifx_i2c.c
${TRUSTM_HOST_LIBRARY_PATH}/src/comms/ifx_i2c/ifx_i2c_config.c
Expand Down
18 changes: 8 additions & 10 deletions extras/optiga-trust-m/optiga-trust-m-libusb.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ SPDX-License-Identifier: MIT
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\include;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\libusb;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\VS2019\MS32\static\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\build\v142\Win32\Release\lib;$(SolutionDir)external\libusb\build\v143\Win32\Release\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libusb-1.0.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
Expand All @@ -126,7 +126,7 @@ SPDX-License-Identifier: MIT
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\include;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\libusb;$(SolutionDir)external\libusb\include;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
Expand All @@ -136,7 +136,7 @@ SPDX-License-Identifier: MIT
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\VS2019\MS32\static\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\build\v142\Win32\Release\lib;$(SolutionDir)external\libusb\build\v143\Win32\Release\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libusb-1.0.lib;legacy_stdio_definitions.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
Expand All @@ -149,20 +149,18 @@ SPDX-License-Identifier: MIT
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\include;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\libusb;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>OPTIGA_LIB_EXPORTS;OPTIGA_LIB_EXTERNAL="optiga_lib_config_m_v3_python.h";IFX_I2C_FRAME_SIZE=55;WIN32;__WIN32__;_WINDLL</PreprocessorDefinitions>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\VS2019\MS64\static\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libusb-1.0.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>LIBCMT</IgnoreSpecificDefaultLibraries>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\build\v142\x64\Release\lib;$(SolutionDir)external\libusb\build\v143\x64\Release\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
Expand All @@ -173,14 +171,14 @@ SPDX-License-Identifier: MIT
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\include;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)config;$(SolutionDir)include;$(SolutionDir)external\libusb\libusb;$(SolutionDir)external\optiga\extras\pal\libusb\include;$(SolutionDir)external\optiga\include;$(SolutionDir)external\optiga\include\cmd;$(SolutionDir)external\optiga\include\common;$(SolutionDir)external\optiga\include\comms;$(SolutionDir)external\optiga\include\ifx_i2c;$(SolutionDir)external\optiga\include\pal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>OPTIGA_LIB_EXPORTS;OPTIGA_LIB_EXTERNAL="optiga_lib_config_m_v3_python.h";IFX_I2C_FRAME_SIZE=55;WIN32;__WIN32__;_WINDLL</PreprocessorDefinitions>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\VS2019\MS64\static\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)external\libusb\build\v142\x64\Release\lib;$(SolutionDir)external\libusb\build\v143\x64\Release\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libusb-1.0.lib;legacy_stdio_definitions.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
Expand Down
2 changes: 0 additions & 2 deletions extras/optiga-trust-m/optiga-trust-m-uart.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ SPDX-License-Identifier: MIT
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
Expand Down
109 changes: 54 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import os
import shutil

def read(rel_path):

def _read_relative(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
with codecs.open(os.path.join(here, rel_path), "r") as fp:
return fp.read()

def __copy_rules(target):
rules = 'rules/90-optigatrust.rules'

def _copy_rules(target):
rules = "src/optigatrust/rules/90-optigatrust.rules"

if not os.path.exists(target):
raise FileNotFoundError
Expand All @@ -25,83 +27,77 @@ def __copy_rules(target):


def _install_rules():
if sys.platform.startswith('linux'):
if sys.platform.startswith("linux"):
try:
__copy_rules('/etc/udev/rules.d')
except PermissionError:
print('Install udev rules failed, install as sudo or manually')
except:
print('Install udev rules failed')
_copy_rules("/etc/udev/rules.d")
except PermissionError as e:
print("Error: Installation of udev rules failed! Install as sudo or manually.")
print(e)
except Exception as e:
print("Error: Installation of udev rules failed!")
print(e)


class _install(install):
def run(self):
# Installation
install.run(self)
# Post-install steps
_install_rules()


def __description():
description_file = os.path.join("src" , "optigatrust", "DESCRIPTION.md")
with open(description_file, 'r', encoding='utf-8') as f:
description_file = os.path.join("src", "optigatrust", "DESCRIPTION.md")
with open(description_file, "r", encoding="utf-8") as f:
readme = f.read()

return readme


def __get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
for line in _read_relative(rel_path).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")

class OptigaTrustInstall(install):
def run(self):
self.do_egg_install()
_install_rules()


__name = 'optigatrust'
__desc = 'A ctypes based Python wrapper for the OPTIGA™ Trust M Host Library for C'
__url = 'https://github.com/infineon/python-optiga-trust'
__author = 'Infineon Technologies AG'
__author_email = 'DSSTechnicalSupport@infineon.com'
__license = 'MIT'
__keywords = 'ECDHE ECDSA RSA ECC X509 NISTP256 NIST384 OPTIGA TRUST TRUSTX TRUSTM'
__name = "optigatrust"
__desc = "A ctypes based Python wrapper for the OPTIGA™ Trust M Host Library for C"
__url = "https://github.com/infineon/python-optiga-trust"
__author = "Infineon Technologies AG"
__author_email = "dsi-host-software@infineon.com"
__license = "MIT"
__keywords = "ECDHE ECDSA RSA ECC X509 NISTP256 NIST384 OPTIGA TRUST TRUSTX TRUSTM"
__classifiers = [
'Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 3.7',
'Operating System :: Microsoft :: Windows',
'Operating System :: Microsoft :: Windows :: Windows 8',
'Operating System :: Microsoft :: Windows :: Windows 8.1',
'Operating System :: Microsoft :: Windows :: Windows 10',
'Operating System :: POSIX :: Linux'
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Framework :: Pytest"
]

# Parameters for setup
__packages = [
'optigatrust',
'optigatrust.enums',
'optigatrust.rules',
'optigatrust.lib'
]
__packages = ["optigatrust", "optigatrust.enums", "optigatrust.rules", "optigatrust.lib"]

__package_data = {
'optigatrust': ['*.md'],
'optigatrust.lib': ['*.dll', '*.so', '*.ini'],
'optigatrust.enums': ['*.xml'],
'optigatrust.rules': ['*.rules']
}
__package_data = {"optigatrust": ["*.md"], "optigatrust.lib": ["*.dll", "*.so", "*.ini"], "optigatrust.enums": ["*.xml"], "optigatrust.rules": ["*.rules"]}

__package_root_dir = "src/" + __name

__package_dir = {
"optigatrust": __package_root_dir,
}

if __name__ == '__main__':
if __name__ == "__main__":
setup(
name=__name,
version=__get_version("src/optigatrust/version.py"),
description=__desc,
long_description=__description(),
long_description_content_type='text/markdown',
long_description_content_type="text/markdown",
url=__url,
author=__author,
author_email=__author_email,
Expand All @@ -112,12 +108,15 @@ def run(self):
packages=__packages,
package_dir=__package_dir,
package_data=__package_data,
setup_requires=['setuptools>=40', 'wheel'],
install_requires=['optigatrust', 'asn1crypto', 'jinja2', 'cryptography', 'pyserial', 'click'],
python_requires='>=3.5',
setup_requires=["setuptools>=40", "wheel"],
install_requires=["optigatrust", "asn1crypto", "jinja2", "cryptography", "pyserial", "click"],
python_requires=">=3.5",
entry_points={
'console_scripts': [
'optigatrust = optigatrust.clidriver:main',
"console_scripts": [
"optigatrust = optigatrust.clidriver:main",
],
},
cmdclass={
"install": _install,
},
)
Loading

0 comments on commit 66e1a4a

Please sign in to comment.