shircrypt 1.0.3__tar.gz

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.
@@ -0,0 +1,31 @@
1
+ name: shircrypt CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ rust-and-python:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.11", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: dtolnay/rust-toolchain@stable
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ - name: Run Rust unit tests
23
+ run: cargo test --release
24
+ - name: Build wheel with maturin
25
+ run: |
26
+ python -m pip install --upgrade pip maturin
27
+ maturin build --release --out dist
28
+ - name: Install wheel
29
+ run: python -m pip install --no-index --find-links dist shircrypt
30
+ - name: Run Python test suite
31
+ run: python -m unittest discover -s tests -v
@@ -0,0 +1,104 @@
1
+ name: Build & Release Wheels
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ linux:
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ matrix:
17
+ include:
18
+ - os: ubuntu-latest
19
+ target: x86_64
20
+ - os: ubuntu-24.04-arm
21
+ target: aarch64
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: PyO3/maturin-action@v1
25
+ with:
26
+ target: ${{ matrix.target }}
27
+ args: --release --out dist
28
+ manylinux: auto
29
+ - uses: actions/upload-artifact@v4
30
+ with:
31
+ name: wheels-linux-${{ matrix.target }}
32
+ path: dist
33
+
34
+ windows:
35
+ runs-on: windows-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: PyO3/maturin-action@v1
39
+ with:
40
+ target: x64
41
+ args: --release --out dist
42
+ - uses: actions/upload-artifact@v4
43
+ with:
44
+ name: wheels-windows
45
+ path: dist
46
+
47
+ macos:
48
+ runs-on: macos-latest
49
+ strategy:
50
+ matrix:
51
+ target: [x86_64, aarch64]
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+ - uses: PyO3/maturin-action@v1
55
+ with:
56
+ target: ${{ matrix.target }}
57
+ args: --release --out dist
58
+ - uses: actions/upload-artifact@v4
59
+ with:
60
+ name: wheels-macos-${{ matrix.target }}
61
+ path: dist
62
+
63
+ sdist:
64
+ runs-on: ubuntu-latest
65
+ steps:
66
+ - uses: actions/checkout@v4
67
+ - uses: PyO3/maturin-action@v1
68
+ with:
69
+ command: sdist
70
+ args: --out dist
71
+ - uses: actions/upload-artifact@v4
72
+ with:
73
+ name: sdist
74
+ path: dist
75
+
76
+ github-release:
77
+ if: startsWith(github.ref, 'refs/tags/v')
78
+ needs: [linux, windows, macos, sdist]
79
+ runs-on: ubuntu-latest
80
+ steps:
81
+ - uses: actions/download-artifact@v4
82
+ with:
83
+ path: dist
84
+ merge-multiple: true
85
+ - name: Attach wheels to GitHub Release
86
+ uses: softprops/action-gh-release@v2
87
+ with:
88
+ files: dist/*
89
+ generate_release_notes: true
90
+
91
+ publish-pypi:
92
+ if: startsWith(github.ref, 'refs/tags/v')
93
+ needs: [linux, windows, macos, sdist]
94
+ runs-on: ubuntu-latest
95
+ permissions:
96
+ id-token: write
97
+ continue-on-error: true
98
+ steps:
99
+ - uses: actions/download-artifact@v4
100
+ with:
101
+ path: dist
102
+ merge-multiple: true
103
+ - name: Publish to PyPI
104
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,23 @@
1
+ # Rust / Cargo
2
+ target/
3
+ Cargo.lock
4
+
5
+ # Python
6
+ __pycache__/
7
+ *.py[cod]
8
+ *.so
9
+ *.pyd
10
+ *.egg-info/
11
+ .eggs/
12
+ build/
13
+ dist/
14
+ wheels/
15
+ .venv/
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+ .ruff_cache/
19
+
20
+ # Editors & OS
21
+ .DS_Store
22
+ .vscode/
23
+ .idea/
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes to `shircrypt` are documented in this file.
4
+
5
+ ## [1.0.3] - 2026-11-26
6
+
7
+ ### Added
8
+ - **Rust `abi3-py311` Native Core (`shircrypt._shircrypt`):**
9
+ - `ige256_encrypt` / `ige256_decrypt` with single-allocation `PyBytes::new_bound_with`, `zeroize` key wiping, and automatic GIL release (`>= 4096` bytes).
10
+ - `ctr256_crypt` with byte-granularity `offset` seeking for parallel chunked file transfers.
11
+ - `cbc256_encrypt` / `cbc256_decrypt` for auxiliary MTProto / storage compatibility.
12
+ - `compute_msg_key` and `mtproto2_kdf` implemented natively in Rust (`sha2`).
13
+ - **Automatic Fallback & Typing:**
14
+ - Pure-Python + `cryptography` fallback (`shircrypt._fallback`) with `BACKEND` indicator (`"rust"` or `"cryptography"`).
15
+ - Full PEP 561 type stubs (`__init__.pyi`, `py.typed`).
16
+ - **CI/CD & Benchmarks:**
17
+ - Multi-platform `maturin` wheel builds (`x86_64`, `aarch64`, Windows, macOS) and `cargo test` + `unittest` CI.
18
+ - Benchmark suite in `benches/bench_shircrypt.py`.
@@ -0,0 +1,21 @@
1
+ # Contributing to shircrypt
2
+
3
+ Contributions are welcome! Please keep the core minimal, zero-C-dependency, and memory-safe.
4
+
5
+ ## Local Development
6
+
7
+ ```bash
8
+ git clone https://github.com/Vicious-Cycle/shircrypt.git
9
+ cd shircrypt
10
+ python3 -m pip install -e ".[dev]"
11
+ maturin develop --release
12
+ cargo test --release
13
+ python3 -m unittest discover -s tests -v
14
+ ```
15
+
16
+ ## Guidelines
17
+
18
+ 1. Never introduce C/OpenSSL system dependencies in `Cargo.toml`.
19
+ 2. Ensure all key/IV buffers are wiped via `zeroize`.
20
+ 3. Keep `python/shircrypt/_fallback.py` and `python/shircrypt/__init__.pyi` in sync with `src/lib.rs`.
21
+ 4. Add unit tests in both `src/lib.rs` and `tests/test_shircrypt.py` for any new primitive.
@@ -0,0 +1,335 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "aes"
7
+ version = "0.8.4"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
10
+ dependencies = [
11
+ "cfg-if",
12
+ "cipher",
13
+ "cpufeatures",
14
+ ]
15
+
16
+ [[package]]
17
+ name = "autocfg"
18
+ version = "1.5.1"
19
+ source = "registry+https://github.com/rust-lang/crates.io-index"
20
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
21
+
22
+ [[package]]
23
+ name = "block-buffer"
24
+ version = "0.10.4"
25
+ source = "registry+https://github.com/rust-lang/crates.io-index"
26
+ checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
27
+ dependencies = [
28
+ "generic-array",
29
+ ]
30
+
31
+ [[package]]
32
+ name = "block-padding"
33
+ version = "0.3.3"
34
+ source = "registry+https://github.com/rust-lang/crates.io-index"
35
+ checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
36
+ dependencies = [
37
+ "generic-array",
38
+ ]
39
+
40
+ [[package]]
41
+ name = "cbc"
42
+ version = "0.1.2"
43
+ source = "registry+https://github.com/rust-lang/crates.io-index"
44
+ checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
45
+ dependencies = [
46
+ "cipher",
47
+ ]
48
+
49
+ [[package]]
50
+ name = "cfg-if"
51
+ version = "1.0.5"
52
+ source = "registry+https://github.com/rust-lang/crates.io-index"
53
+ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
54
+
55
+ [[package]]
56
+ name = "cipher"
57
+ version = "0.4.4"
58
+ source = "registry+https://github.com/rust-lang/crates.io-index"
59
+ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
60
+ dependencies = [
61
+ "crypto-common",
62
+ "inout",
63
+ ]
64
+
65
+ [[package]]
66
+ name = "cpufeatures"
67
+ version = "0.2.17"
68
+ source = "registry+https://github.com/rust-lang/crates.io-index"
69
+ checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
70
+ dependencies = [
71
+ "libc",
72
+ ]
73
+
74
+ [[package]]
75
+ name = "crypto-common"
76
+ version = "0.1.7"
77
+ source = "registry+https://github.com/rust-lang/crates.io-index"
78
+ checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
79
+ dependencies = [
80
+ "generic-array",
81
+ "typenum",
82
+ ]
83
+
84
+ [[package]]
85
+ name = "ctr"
86
+ version = "0.9.2"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
89
+ dependencies = [
90
+ "cipher",
91
+ ]
92
+
93
+ [[package]]
94
+ name = "digest"
95
+ version = "0.10.7"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
98
+ dependencies = [
99
+ "block-buffer",
100
+ "crypto-common",
101
+ ]
102
+
103
+ [[package]]
104
+ name = "generic-array"
105
+ version = "0.14.7"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
108
+ dependencies = [
109
+ "typenum",
110
+ "version_check",
111
+ ]
112
+
113
+ [[package]]
114
+ name = "heck"
115
+ version = "0.5.0"
116
+ source = "registry+https://github.com/rust-lang/crates.io-index"
117
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
118
+
119
+ [[package]]
120
+ name = "indoc"
121
+ version = "2.0.8"
122
+ source = "registry+https://github.com/rust-lang/crates.io-index"
123
+ checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
124
+ dependencies = [
125
+ "rustversion",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "inout"
130
+ version = "0.1.4"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
133
+ dependencies = [
134
+ "block-padding",
135
+ "generic-array",
136
+ ]
137
+
138
+ [[package]]
139
+ name = "libc"
140
+ version = "0.2.191"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
143
+
144
+ [[package]]
145
+ name = "memoffset"
146
+ version = "0.9.1"
147
+ source = "registry+https://github.com/rust-lang/crates.io-index"
148
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
149
+ dependencies = [
150
+ "autocfg",
151
+ ]
152
+
153
+ [[package]]
154
+ name = "once_cell"
155
+ version = "1.21.4"
156
+ source = "registry+https://github.com/rust-lang/crates.io-index"
157
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
158
+
159
+ [[package]]
160
+ name = "portable-atomic"
161
+ version = "1.15.0"
162
+ source = "registry+https://github.com/rust-lang/crates.io-index"
163
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
164
+
165
+ [[package]]
166
+ name = "proc-macro2"
167
+ version = "1.0.107"
168
+ source = "registry+https://github.com/rust-lang/crates.io-index"
169
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
170
+ dependencies = [
171
+ "unicode-ident",
172
+ ]
173
+
174
+ [[package]]
175
+ name = "pyo3"
176
+ version = "0.22.6"
177
+ source = "registry+https://github.com/rust-lang/crates.io-index"
178
+ checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
179
+ dependencies = [
180
+ "cfg-if",
181
+ "indoc",
182
+ "libc",
183
+ "memoffset",
184
+ "once_cell",
185
+ "portable-atomic",
186
+ "pyo3-build-config",
187
+ "pyo3-ffi",
188
+ "pyo3-macros",
189
+ "unindent",
190
+ ]
191
+
192
+ [[package]]
193
+ name = "pyo3-build-config"
194
+ version = "0.22.6"
195
+ source = "registry+https://github.com/rust-lang/crates.io-index"
196
+ checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
197
+ dependencies = [
198
+ "once_cell",
199
+ "target-lexicon",
200
+ ]
201
+
202
+ [[package]]
203
+ name = "pyo3-ffi"
204
+ version = "0.22.6"
205
+ source = "registry+https://github.com/rust-lang/crates.io-index"
206
+ checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
207
+ dependencies = [
208
+ "libc",
209
+ "pyo3-build-config",
210
+ ]
211
+
212
+ [[package]]
213
+ name = "pyo3-macros"
214
+ version = "0.22.6"
215
+ source = "registry+https://github.com/rust-lang/crates.io-index"
216
+ checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
217
+ dependencies = [
218
+ "proc-macro2",
219
+ "pyo3-macros-backend",
220
+ "quote",
221
+ "syn",
222
+ ]
223
+
224
+ [[package]]
225
+ name = "pyo3-macros-backend"
226
+ version = "0.22.6"
227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
228
+ checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
229
+ dependencies = [
230
+ "heck",
231
+ "proc-macro2",
232
+ "pyo3-build-config",
233
+ "quote",
234
+ "syn",
235
+ ]
236
+
237
+ [[package]]
238
+ name = "quote"
239
+ version = "1.0.47"
240
+ source = "registry+https://github.com/rust-lang/crates.io-index"
241
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
242
+ dependencies = [
243
+ "proc-macro2",
244
+ ]
245
+
246
+ [[package]]
247
+ name = "rustversion"
248
+ version = "1.0.23"
249
+ source = "registry+https://github.com/rust-lang/crates.io-index"
250
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
251
+
252
+ [[package]]
253
+ name = "sha2"
254
+ version = "0.10.9"
255
+ source = "registry+https://github.com/rust-lang/crates.io-index"
256
+ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
257
+ dependencies = [
258
+ "cfg-if",
259
+ "cpufeatures",
260
+ "digest",
261
+ ]
262
+
263
+ [[package]]
264
+ name = "shircrypt"
265
+ version = "1.0.3"
266
+ dependencies = [
267
+ "aes",
268
+ "cbc",
269
+ "cipher",
270
+ "ctr",
271
+ "pyo3",
272
+ "sha2",
273
+ "zeroize",
274
+ ]
275
+
276
+ [[package]]
277
+ name = "syn"
278
+ version = "2.0.119"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
281
+ dependencies = [
282
+ "proc-macro2",
283
+ "quote",
284
+ "unicode-ident",
285
+ ]
286
+
287
+ [[package]]
288
+ name = "target-lexicon"
289
+ version = "0.12.16"
290
+ source = "registry+https://github.com/rust-lang/crates.io-index"
291
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
292
+
293
+ [[package]]
294
+ name = "typenum"
295
+ version = "1.20.1"
296
+ source = "registry+https://github.com/rust-lang/crates.io-index"
297
+ checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
298
+
299
+ [[package]]
300
+ name = "unicode-ident"
301
+ version = "1.0.27"
302
+ source = "registry+https://github.com/rust-lang/crates.io-index"
303
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
304
+
305
+ [[package]]
306
+ name = "unindent"
307
+ version = "0.2.4"
308
+ source = "registry+https://github.com/rust-lang/crates.io-index"
309
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
310
+
311
+ [[package]]
312
+ name = "version_check"
313
+ version = "0.9.5"
314
+ source = "registry+https://github.com/rust-lang/crates.io-index"
315
+ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
316
+
317
+ [[package]]
318
+ name = "zeroize"
319
+ version = "1.9.2"
320
+ source = "registry+https://github.com/rust-lang/crates.io-index"
321
+ checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa"
322
+ dependencies = [
323
+ "zeroize_derive",
324
+ ]
325
+
326
+ [[package]]
327
+ name = "zeroize_derive"
328
+ version = "1.5.0"
329
+ source = "registry+https://github.com/rust-lang/crates.io-index"
330
+ checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328"
331
+ dependencies = [
332
+ "proc-macro2",
333
+ "quote",
334
+ "syn",
335
+ ]
@@ -0,0 +1,27 @@
1
+ [package]
2
+ name = "shircrypt"
3
+ version = "1.0.3"
4
+ edition = "2021"
5
+ license = "LGPL-3.0-or-later"
6
+ description = "Modern, memory-safe, abi3 Rust cryptographic extension for MTProto 2.0 (AES-256-IGE, CTR, CBC, KDF)."
7
+ readme = "README.md"
8
+ repository = "https://github.com/Vicious-Cycle/shircrypt"
9
+
10
+ [lib]
11
+ name = "_shircrypt"
12
+ crate-type = ["cdylib"]
13
+
14
+ [dependencies]
15
+ pyo3 = { version = "0.22", features = ["extension-module", "abi3-py311"] }
16
+ aes = "0.8"
17
+ cbc = "0.1"
18
+ cipher = "0.4"
19
+ ctr = "0.9"
20
+ sha2 = "0.10"
21
+ zeroize = { version = "1.8", features = ["derive"] }
22
+
23
+ [profile.release]
24
+ lto = "fat"
25
+ codegen-units = 1
26
+ opt-level = 3
27
+ strip = "symbols"
@@ -0,0 +1,12 @@
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
+ This version of the GNU Lesser General Public License incorporates
9
+ the terms and conditions of version 3 of the GNU General Public License,
10
+ supplemented by the additional permissions listed below.
11
+
12
+ Full text: https://www.gnu.org/licenses/lgpl-3.0.txt