tmlat 0.5.1__cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tmlat might be problematic. Click here for more details.

mla/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .mla import *
2
+
3
+ __doc__ = mla.__doc__
4
+ if hasattr(mla, "__all__"):
5
+ __all__ = mla.__all__
mla/__init__.pyi ADDED
@@ -0,0 +1,136 @@
1
+ from typing import Optional, Union, Any, BinaryIO, List, Dict, final
2
+ import os
3
+
4
+ __all__ = [
5
+ "EntryName", "FileMetadata", "MLAWriter", "MLAReader",
6
+ "WriterConfig", "ReaderConfig", "SignatureConfig",
7
+ "PublicKeys", "PrivateKeys", "DEFAULT_COMPRESSION_LEVEL",
8
+ # Exceptions
9
+ "MLAError", "WrongMagic", "UnsupportedVersion", "InvalidKeyFormat",
10
+ "WrongBlockSubFileType", "UTF8ConversionError", "EntryNameTooLong",
11
+ "WrongArchiveWriterState", "WrongReaderState", "WrongWriterState",
12
+ "RandError", "PrivateKeyNeeded", "DeserializationError", "SerializationError",
13
+ "MissingMetadata", "BadAPIArgument", "EndOfStream", "ConfigError",
14
+ "DuplicateEntryName", "AuthenticatedDecryptionWrongTag", "HKDFInvalidKeyLength",
15
+ "HPKEError", "InvalidLastTag", "WrongEndMagic", "NoValidSignatureFound",
16
+ "SignatureVerificationAskedButNoSignatureLayerFound",
17
+ "MissingEndOfEncryptedInnerLayerMagic", "TruncatedTag", "UnknownTagPosition",
18
+ "MLAOther"
19
+ ]
20
+
21
+ @final
22
+ class EntryName:
23
+ def __new__(cls, str_path: str) -> "EntryName": ...
24
+ @staticmethod
25
+ def from_path(path: os.PathLike[str]) -> "EntryName": ...
26
+ @staticmethod
27
+ def from_arbitrary_bytes(bytes: bytes) -> "EntryName": ...
28
+ @property
29
+ def arbitrary_bytes(self) -> bytes: ...
30
+ def raw_content_to_escaped_string(self) -> str: ...
31
+ def to_pathbuf(self) -> str: ...
32
+ def to_pathbuf_escaped_string(self) -> str: ...
33
+ def __hash__(self) -> int: ...
34
+ def __eq__(self, other: object) -> bool: ...
35
+ def __ne__(self, other: object) -> bool: ...
36
+ def __repr__(self) -> str: ...
37
+
38
+ @final
39
+ class FileMetadata:
40
+ size: Optional[int]
41
+ hash: Optional[bytes]
42
+
43
+ @final
44
+ class MLAWriter:
45
+ def __new__(cls, path: str, config: "WriterConfig") -> "MLAWriter": ...
46
+ def __repr__(self) -> str: ...
47
+ def __setitem__(self, key: EntryName, value: bytes) -> None: ...
48
+ def finalize(self) -> None: ...
49
+ _buffered_type: Any
50
+ def add_entry_from(self, key: EntryName, src: Union[str, BinaryIO], chunk_size: int = 4194304) -> None: ...
51
+ def __enter__(self) -> "MLAWriter": ...
52
+ def __exit__(self, exc_type: Optional[type] = ..., _exc_value: Optional[BaseException] = ..., _traceback: Optional[Any] = ...) -> bool: ...
53
+
54
+ @final
55
+ class MLAReader:
56
+ def __new__(cls, path: str, config: "ReaderConfig") -> "MLAReader": ...
57
+ def __repr__(self) -> str: ...
58
+ def __getitem__(self, key: EntryName) -> bytes: ...
59
+ def __contains__(self, key: EntryName) -> bool: ...
60
+ def __len__(self) -> int: ...
61
+ def keys(self) -> List[EntryName]: ...
62
+ def list_entries(self, include_size: bool = False, include_hash: bool = False) -> Union[List[EntryName], Dict[EntryName, FileMetadata]]: ...
63
+ def write_entry_to(self, key: EntryName, dest: Union[str, BinaryIO], chunk_size: int = 4194304) -> None: ...
64
+ def __enter__(self) -> "MLAReader": ...
65
+ def __exit__(self, _exc_type: Optional[type] = ..., _exc_value: Optional[BaseException] = ..., _traceback: Optional[Any] = ...) -> bool: ...
66
+
67
+ @final
68
+ class WriterConfig:
69
+ def __new__(cls, private_keys: "PrivateKeys", public_keys: "PublicKeys") -> "WriterConfig": ...
70
+ @classmethod
71
+ def without_encryption_without_signature(cls) -> "WriterConfig": ...
72
+ @classmethod
73
+ def with_encryption_without_signature(cls, public_keys: "PublicKeys") -> "WriterConfig": ...
74
+ @classmethod
75
+ def without_encryption_with_signature(cls, private_keys: "PrivateKeys") -> "WriterConfig": ...
76
+ def with_compression_level(self, compression_level: int) -> "WriterConfig": ...
77
+ def without_compression(self) -> "WriterConfig": ...
78
+
79
+ @final
80
+ class ReaderConfig:
81
+ def __new__(cls, private_keys: Optional["PrivateKeys"], signature_config: "SignatureConfig") -> "ReaderConfig": ...
82
+ @classmethod
83
+ def without_encryption(cls, signature_config: "SignatureConfig") -> "ReaderConfig": ...
84
+ @classmethod
85
+ def with_private_keys_accept_unencrypted(cls, private_keys: "PrivateKeys", signature_config: "SignatureConfig") -> "ReaderConfig": ...
86
+
87
+ @final
88
+ class SignatureConfig:
89
+ def __new__(cls, public_keys: "PublicKeys") -> "SignatureConfig": ...
90
+ @classmethod
91
+ def without_signature_verification(cls) -> "SignatureConfig": ...
92
+
93
+ @final
94
+ class PublicKeys:
95
+ def __new__(cls, *keys: Union[bytes, str]) -> "PublicKeys": ...
96
+ keys: List[str]
97
+
98
+ @final
99
+ class PrivateKeys:
100
+ def __new__(cls, *keys: Union[bytes, str]) -> "PrivateKeys": ...
101
+ keys: List[str]
102
+
103
+ # Constants
104
+ DEFAULT_COMPRESSION_LEVEL: int
105
+
106
+ # Exceptions
107
+ class MLAError(Exception): ...
108
+ class WrongMagic(MLAError): ...
109
+ class UnsupportedVersion(MLAError): ...
110
+ class InvalidKeyFormat(MLAError): ...
111
+ class WrongBlockSubFileType(MLAError): ...
112
+ class UTF8ConversionError(MLAError): ...
113
+ class EntryNameTooLong(MLAError): ...
114
+ class WrongArchiveWriterState(MLAError): ...
115
+ class WrongReaderState(MLAError): ...
116
+ class WrongWriterState(MLAError): ...
117
+ class RandError(MLAError): ...
118
+ class PrivateKeyNeeded(MLAError): ...
119
+ class DeserializationError(MLAError): ...
120
+ class SerializationError(MLAError): ...
121
+ class MissingMetadata(MLAError): ...
122
+ class BadAPIArgument(MLAError): ...
123
+ class EndOfStream(MLAError): ...
124
+ class ConfigError(MLAError): ...
125
+ class DuplicateEntryName(MLAError): ...
126
+ class AuthenticatedDecryptionWrongTag(MLAError): ...
127
+ class HKDFInvalidKeyLength(MLAError): ...
128
+ class HPKEError(MLAError): ...
129
+ class InvalidLastTag(MLAError): ...
130
+ class WrongEndMagic(MLAError): ...
131
+ class NoValidSignatureFound(MLAError): ...
132
+ class SignatureVerificationAskedButNoSignatureLayerFound(MLAError): ...
133
+ class MissingEndOfEncryptedInnerLayerMagic(MLAError): ...
134
+ class TruncatedTag(MLAError): ...
135
+ class UnknownTagPosition(MLAError): ...
136
+ class MLAOther(MLAError): ...
Binary file
mla/py.typed ADDED
File without changes
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: tmlat
3
+ Version: 0.5.1
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ License-File: LICENSE.md
8
+ Summary: Bindings for MLA Archive manipulation
9
+ Keywords: rust,compression,encryption,signature,pqc
10
+ Home-Page: https://github.com/ANSSI-FR/MLA
11
+ Author-email: ANSSI <opensource@ssi.gouv.fr>
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+ Project-URL: documentation, https://github.com/ANSSI-FR/MLA
15
+ Project-URL: repository, https://github.com/ANSSI-FR/MLA
16
+
17
+ # MLA Python Bindings
18
+
19
+ Python bindings for the MLA (Multi-Layer Archive) format, enabling secure, compressed, and signed archives from Python.
20
+
21
+ ## Installation
22
+
23
+ Install from PyPI:
24
+
25
+ ```sh
26
+ pipx install mla-archive
27
+ ```
28
+
29
+ Or build from source:
30
+
31
+ **Install maturin:**
32
+ `maturin` is a tool for building and publishing Rust-based Python packages.
33
+ You can install it via pipx:
34
+
35
+ ```sh
36
+ pipx install maturin
37
+ ```
38
+
39
+ **Build the Python wheel:**
40
+
41
+ ```sh
42
+ maturin build --release
43
+ ```
44
+
45
+ This creates a `.whl` file in the `target/wheels/` directory.
46
+
47
+ **(Alternative) Install directly into a Python virtual environment:**
48
+
49
+ ```sh
50
+ python -m venv .venv
51
+ source .venv/bin/activate
52
+ maturin develop
53
+ ```
54
+
55
+ This builds and installs the package for development.
56
+
57
+ ## Usage Example
58
+
59
+ ```python
60
+ import mla
61
+
62
+ def main() -> None:
63
+ # --- Writing ---
64
+ config: mla.WriterConfig = mla.WriterConfig.without_encryption_without_signature()
65
+ with mla.MLAWriter("example.mla", config) as archive:
66
+ archive[mla.EntryName("hello.txt")] = b"Hello, MLA!"
67
+ archive[mla.EntryName("data.bin")] = b"\x00\x01\x02"
68
+ print("Archive written: example.mla")
69
+
70
+ # --- Reading ---
71
+ sig_cfg: mla.SignatureConfig = mla.SignatureConfig.without_signature_verification()
72
+ config: mla.ReaderConfig = mla.ReaderConfig.without_encryption(sig_cfg)
73
+ with mla.MLAReader("example.mla", config) as archive:
74
+ for name in archive.keys():
75
+ # name is of type EntryName
76
+ print(f"{name.raw_content_to_escaped_string()}: {archive[name].decode('utf-8')}")
77
+
78
+ if __name__ == "__main__":
79
+ main()
80
+ ```
81
+
82
+ ## Features
83
+
84
+ - Create and extract MLA archives from Python
85
+ - Support for compression, encryption, and signatures (if enabled in the archive)
86
+ - Simple dictionary-like API for file access
87
+ - Compatible with archives created by the Rust `mlar` CLI
88
+
89
+ ## API
90
+
91
+ - `mla.MLAReader(path, config)` — Open an archive for reading
92
+ - `mla.MLAWriter(path, config)` — Open an archive for writing
93
+ - `archive[name] = data` — Add a file (write mode)
94
+ - `archive[name]` — Read a file (read mode)
95
+ - `archive.finalize()` — Finalize and close the archive (write mode)
96
+ - Iteration: `for name in archive: ...`
97
+
98
+ See [tests](tests) for more usage examples.
99
+
100
+ ## Type stub files
101
+
102
+ The MLA Python bindings include type stub files (`.pyi`) to provide static type information for tools like `mypy`, IDEs, and linters.
103
+
104
+ - The bindings expose a native extension module `mla.mla` along with the top-level `mla` package.
105
+ - To support static analysis, there are stub files both for the top-level package (`mla/__init__.pyi`) and the native submodule (`mla/mla.pyi`).
106
+ - These stubs allow type checkers to understand the full API surface, since compiled native modules lack introspectable Python signatures.
107
+ - When developing or modifying the bindings, ensure all `.pyi` files are kept alongside their respective Python or compiled modules so tools can locate them.
108
+ - To verify your stubs correctly match the runtime API (with `mypy` as an example), use:
109
+
110
+ ```sh
111
+ python3 -m mypy.stubtest mla
112
+ ```
113
+
114
+ ## Testing
115
+
116
+ Run the test suite with:
117
+
118
+ ```sh
119
+ pytest
120
+ ```
@@ -0,0 +1,8 @@
1
+ mla/__init__.py,sha256=btya5Hbk_481g6E8z0xi35pavTbBBAE8TXbnmukm_UA,95
2
+ mla/__init__.pyi,sha256=m-Yvq6lItHzzlw_iC2h16ba09bHrHPNsC7-G70SzYgA,5671
3
+ mla/mla.cpython-314-i386-linux-gnu.so,sha256=Tmc45ooFNizBhbMBk76YDfUrqtCjhINTWLslzbXLHMg,2858448
4
+ mla/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ tmlat-0.5.1.dist-info/METADATA,sha256=9BwrRqETUiZ2pTZ27siObCaCgScR8AxCMOaBZ5N7qGs,3752
6
+ tmlat-0.5.1.dist-info/WHEEL,sha256=SVj-mRhc8RTrK4UpVRzxX8JD-f_LshAVh79WuN6tVL8,139
7
+ tmlat-0.5.1.dist-info/licenses/LICENSE.md,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
8
+ tmlat-0.5.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.5)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-manylinux_2_5_i686
5
+ Tag: cp314-cp314-manylinux1_i686
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.