{"id":20453485,"url":"https://github.com/sheroz/magma","last_synced_at":"2025-04-13T03:33:51.062Z","repository":{"id":178420557,"uuid":"661730581","full_name":"sheroz/magma","owner":"sheroz","description":"Symmetric Key Block Cipher \"Magma\" in Rust","archived":false,"fork":false,"pushed_at":"2023-09-18T12:38:28.000Z","size":2071,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-27T05:03:44.337Z","etag":null,"topics":["28147-89","block-cipher","cryptography","gost","gost-28147-89","gost-r-34-12-2015","magma"],"latest_commit_sha":null,"homepage":"https://sheroz.com/pages/blog/rust-cipher-magma-28147-89.html","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sheroz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-03T14:12:18.000Z","updated_at":"2024-05-28T01:34:34.035Z","dependencies_parsed_at":null,"dependency_job_id":"5c8e1076-2c74-4ce2-9bfb-51afa18b30e2","html_url":"https://github.com/sheroz/magma","commit_stats":null,"previous_names":["sheroz/crypto","sheroz/cipher_magma","sheroz/magma"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheroz%2Fmagma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheroz%2Fmagma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheroz%2Fmagma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheroz%2Fmagma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sheroz","download_url":"https://codeload.github.com/sheroz/magma/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248659856,"owners_count":21141191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["28147-89","block-cipher","cryptography","gost","gost-28147-89","gost-r-34-12-2015","magma"],"created_at":"2024-11-15T11:12:56.273Z","updated_at":"2025-04-13T03:33:51.034Z","avatar_url":"https://github.com/sheroz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symmetric Key Block Cipher \"Magma\" in Rust\n\n[![crates.io](https://img.shields.io/crates/v/cipher_magma)](https://crates.io/crates/cipher_magma)\n[![docs](https://img.shields.io/docsrs/cipher_magma)](https://docs.rs/cipher_magma)\n[![build \u0026 test](https://github.com/sheroz/magma/actions/workflows/ci.yml/badge.svg)](https://github.com/sheroz/magma/actions/workflows/ci.yml)\n[![MIT](https://img.shields.io/github/license/sheroz/cipher_magma)](https://github.com/sheroz/magma/tree/main/cipher_magma/LICENSE.txt)\n\nThe brief description: [https://sheroz.com/pages/blog/rust-cipher-magma-28147-89.html](https://sheroz.com/pages/blog/rust-cipher-magma-28147-89.html)\n\n## Supported Cipher Modes\n\n- **ECB** - Electronic Codebook Mode\n- **CTR** - Counter Encryption Mode\n- **CTR-ACPKM** - Counter Encryption Mode as per [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html)\n- **OFB** - Output Feedback Mode\n- **CBC** - Cipher Block Chaining Mode\n- **CFB** - Cipher Feedback Mode\n- **MAC** - Message Authentication Code Generation Mode\n\n## Implemented and tested according to specifications\n\n- [RFC 8891](https://datatracker.ietf.org/doc/html/rfc8891.html) a.k.a GOST R 34.12-2015: Block Cipher \"Magma\"\n- [RFC 5830](https://datatracker.ietf.org/doc/html/rfc5830) a.k.a GOST 28147-89\n- Block Cipher Modes:\n  - [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)\n  - [CTR-ACPKM, Р 1323565.1.017—2018](https://standartgost.ru/g/%D0%A0_1323565.1.017-2018)\n\nTests are implemented using: [crypto_vectors](https://crates.io/crates/crypto_vectors)\n\n## Tested on platforms\n\n1. Linux Ubuntu 22.04 LTS / Intel® Core™ i7\n2. MacOS Ventura 13.4 / Apple Macbook Pro M1\n\n## Usage\n\nPlease look at [magma_samples](https://github.com/sheroz/magma/tree/main/magma_samples/src)\n\n### Samples\n\n- Block encryption [encrypt_block.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/encrypt_block.rs)\n- Text encryption [encrypt_text.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/encrypt_text.rs)\n- Message Authentication Code (MAC) [calculate_mac.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/calculate_mac.rs)\n- Buffer encryption [encrypt_buffer.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/encrypt_buffer.rs)\n- Buffer encryption by parallel processing [encrypt_buffer_parallel.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/encrypt_buffer_parallel.rs)\n  - On a MacBook M1 Pro with 8+2 cores, the encryption speed increased ~ 8.3 times\n  - On an i7-3770 with 4 cores, running Linux, the encryption speed increased ~ 4.5 times\n- File encryption [encrypt_file.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/encrypt_file.rs)\n- Bitmap file encryption [encrypt_bmp.rs](https://github.com/sheroz/magma/blob/main/magma_samples/src/encrypt_bmp.rs)\n\n## Bitmap file encryption results\n\n### The original bitmap image: Ferris the crab\n\n[![Ferris the crab, the original image](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/ferris.bmp)](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/ferris.bmp)\n\n---\n\n### Encrypted bitmap in Electronic Codebook (ECB) Mode\n\n[![Ferris the crab, encrypted in ECB Mode](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_ecb.ferris.bmp)](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_ecb.ferris.bmp)\n\nPlease note that the ECB mode has weaknesses. It does not hide data patterns well and leaks information about the plaintext. ECB mode [is not recommended](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#ECB-weakness) for use in cryptographic protocols.\n\n---\n\n### Encrypted bitmap in Counter Encryption (CTR) Mode\n\n[![Ferris the crab, encrypted in CTR Mode](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_ctr.ferris.bmp)](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_ctr.ferris.bmp)\n\n---\n\n### Encrypted bitmap in Output Feedback (OFB) Mode\n\n[![Ferris the crab, encrypted in OFB Mode](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_ofb.ferris.bmp)](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_ofb.ferris.bmp)\n\n---\n\n### Encrypted bitmap in Cipher Block Chaining (CBC) Mode\n\n[![Ferris the crab, encrypted in CBC Mode](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_cbc.ferris.bmp)](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_cbc.ferris.bmp)\n\n---\n\n### Encrypted bitmap in Cipher Feedback (CFB) Mode\n\n[![Ferris the crab, encrypted in CFB Mode](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_cfb.ferris.bmp)](https://raw.githubusercontent.com/sheroz/magma/main/magma_samples/tests/out/encrypted_cfb.ferris.bmp)\n\n## Disclaimer\n\nThis project was created for research purposes and is not intended for use in production systems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheroz%2Fmagma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsheroz%2Fmagma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheroz%2Fmagma/lists"}