{"id":16993618,"url":"https://github.com/unbekanntes-pferd/dco3-crypto","last_synced_at":"2025-08-02T22:05:17.314Z","repository":{"id":64987833,"uuid":"577047785","full_name":"unbekanntes-pferd/dco3-crypto","owner":"unbekanntes-pferd","description":"A Rust crate for cryptography in DRACOON - more info on DRACOON here: https://dracoon.com","archived":false,"fork":false,"pushed_at":"2024-04-23T19:56:38.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T13:25:04.644Z","etag":null,"topics":["cryptography","dracoon","openssl","rust-crate","rust-crypto","rust-lang"],"latest_commit_sha":null,"homepage":"","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/unbekanntes-pferd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-12-11T20:10:01.000Z","updated_at":"2024-04-23T19:56:42.000Z","dependencies_parsed_at":"2024-10-14T03:43:38.432Z","dependency_job_id":"3d37d9ac-840f-4261-89ae-429adaaab204","html_url":"https://github.com/unbekanntes-pferd/dco3-crypto","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"9575ecc255051306c4bbf064d26d8f0ea36d8263"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/unbekanntes-pferd/dco3-crypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbekanntes-pferd%2Fdco3-crypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbekanntes-pferd%2Fdco3-crypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbekanntes-pferd%2Fdco3-crypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbekanntes-pferd%2Fdco3-crypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unbekanntes-pferd","download_url":"https://codeload.github.com/unbekanntes-pferd/dco3-crypto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbekanntes-pferd%2Fdco3-crypto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268464789,"owners_count":24254196,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cryptography","dracoon","openssl","rust-crate","rust-crypto","rust-lang"],"created_at":"2024-10-14T03:43:36.706Z","updated_at":"2025-08-02T22:05:17.212Z","avatar_url":"https://github.com/unbekanntes-pferd.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"  \u003ch1 align=\"center\"\u003edco3-crypto\u003c/h1\u003e\n\n  \u003cp align=\"center\"\u003e\n    DRACOON Crypto utils in Rust\n    \u003cbr /\u003e\n    \u003ca href=\"https://docs.rs/dco3_crypto/latest/dco3_crypto\"\u003e\u003cstrong\u003eDocumentation »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/unbekanntes-pferd/dco3-crypto/issues\"\u003eReport Bug\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n# dco3-crypto\n\n## What is this?\n\nWork in progress Crypto library for DRACOON based on openssl crate.\n\n**Breaking changes** are most likely at this early stage - the library is under heavy development and depends on requirements from `dco3` (currently private API wrapper for DRACOON).\nChanges will be documented in the [release notes](https://github.com/unbekanntes-pferd/dco3-crypto/releases).\n\n### What does work?\n\n- Asymmetric encryption / decryption of file keys (RSA)\n- Keypair generation (RSA)\n- Keypair encryption / decryption (RSA)\n- Symmetric encryption / decryption of messages (AES256 GCM)\n  - on the fly encryption / decryption \n  - chunked encryption / decryption\n\n### What is planned?\n\n- Refactor asymmetric encryption (split keypair generation from other operations)\n- Use other libraries like ring as alternative to openssl bindings\n- Add feature flags to cargo build\n- Add e2e tests using encryption data from other SDKs / libs and ensure compatibility in pipeline\n\n### What is shipped?\nUsing the crate currently binds to the latest openssl version and is compiled in vendored mode (see [openssl](https://crates.io/crates/openssl) for details). \n\n### How to use?\n\nSee [crates.io](https://crates.io/crates/dco3_crypto)\nTL;DR Add the following line to your Cargo.toml file (dependencies):\n```toml\ndco3_crypto = \"0.4.1\"\n```\n\n## Documentation\n\n[Documentation](https://docs.rs/dco3_crypto/latest/dco3_crypto)\nAll detailed documentation is provided via docs on [docs.rs](https://docs.rs/dco3_crypto/latest/dco3_crypto)\n\n## TL; DR usage\n\n### Required imports\n\nThe lib consists of several traits that are all (currently only) implemented by the `DracoonCrypto` struct.\nTherefore, the minimum required import is *always* `DracoonCrypto` and the relevant required trait (`DracoonRSACrypto`, `Encrypt`, `Decrypt`, `ChunkedEncryption`, `Encrypter`, `Decrypter`).\n\n#### Asymmetric encryption\n\nIn order to \n- generate a (plain) user keypair \n- en/decrypt a user keypair\n- decrypt a private only\n- encrypt a file key with a public key (user keypair)\n- decrypt a file key with a private key (user keypair)\n\n\nGenerate a plain user keypair:\n\n```rust\nuse dco3_crypto::{DracoonCrypto, DracoonRSACrypto, UserKeypairVersion};\n\n// RSA2048 is only supported for legacy compatibility \n// always use UserKeypairVersion::RSA4096\nlet new_keypair = DracoonCrypto::create_plain_user_keypair(UserKeyPairVersion::RSA4096).unwrap();\n\n```\n\nEncrypt a plain user keypair:\n\n```rust\nuse dco3_crypto::{DracoonCrypto, DracoonRSACrypto, UserKeypairVersion};\n\nlet new_keypair = DracoonCrypto::create_plain_user_keypair(UserKeyPairVersion::RSA4096).unwrap();\nlet secret =\"VerySecret123!\";\nlet enc_keypair = DracoonCrypto::encrypt_private_key(secret, new_keypair).unwrap();\n\n```\n\nDecrypt a private key only (for public share use):\n\n```rust\nuse dco3_crypto::{DracoonCrypto, DracoonRSACrypto, UserKeypairVersion};\n\nlet new_keypair = DracoonCrypto::create_plain_user_keypair(UserKeyPairVersion::RSA4096).unwrap();\nlet secret =\"VerySecret123!\";\nlet enc_keypair = DracoonCrypto::encrypt_private_key(secret, new_keypair).unwrap();\nlet plain_private_key = DracoonCrypto::decrypt_private_key_only(secret, enc_keypair.private_key_container).unwrap();\n\n```\n\nDecrypt a protected user keypair:\n```rust\nuse dco3_crypto::{DracoonCrypto, DracoonRSACrypto, UserKeypairVersion};\n\nlet new_keypair = DracoonCrypto::create_plain_user_keypair(UserKeyPairVersion::RSA4096).unwrap();\nlet secret =\"VerySecret123!\";\nlet enc_keypair = DracoonCrypto::encrypt_private_key(secret, new_keypair).unwrap();\nlet plain_keypair = DracoonCrypto::decrypt_private_key(secret, enc_keypair).unwrap();\n\n```\n\nEncrypt a file key using either a plain user keypair or a public key container:\n\n```rust\nuse dco3_crypto::{DracoonCrypto, DracoonRSACrypto, UserKeypairVersion, Encrypt};\nlet new_keypair = DracoonCrypto::create_plain_user_keypair(UserKeyPairVersion::RSA4096).unwrap();\n\n// encrypt a message to get a plain file key for demo purposes\nlet message = b\"Secret message\";\nlet (enc_message, plain_file_key) = DracoonCrypto::encrypt(message.to_vec()).unwrap();\n\n// the function also accepts a public key container as argument\nlet enc_file_key = DracoonCrypto::encrypt_file_key(plain_file_key, plain_keypair).unwrap();\n```\n\nDecrypt the file key using a plain user keypair:\n```rust\nuse dco3_crypto::{DracoonCrypto, DracoonRSACrypto, UserKeypairVersion, Encrypt};\nlet new_keypair = DracoonCrypto::create_plain_user_keypair(UserKeyPairVersion::RSA4096).unwrap();\n\n// encrypt a message to get a plain file key for demo purposes\nlet message = b\"Secret message\";\nlet (enc_message, plain_file_key) = DracoonCrypto::encrypt(message.to_vec()).unwrap();\n\n// the function also accepts a public key container as argument\nlet enc_file_key = DracoonCrypto::encrypt_file_key(plain_file_key, plain_keypair).unwrap();\n\n// this code is for demo purposes - plain_keypair is consumed above and needs to be \n// instantiated again\nlet plain_file_key = DracoonCrypto::decrypt_file_key(enc_file_key, plain_keypair).unwrap();\n```\n\n#### Symmetric encryption\n\nSymmetric encryption is represented by the following traits:\n\n- Encrypt: needed for in-memory encryption\n- Decrypt: needed for in-memory decryption\n- Decrypter: needed to build a decrypter capable of chunked decryption\n- Encrypter: needed to build an encrypter capable of chunked encryption\n- ChunkedEncryption: needed for both en- and decryption when using a decrypter / encrypter\n\nEncrypt a message on the fly:\n\n```rust\nuse dco3_crypto::{DracoonCrypto, Encrypt};\n\n// encrypt a message to get a plain file key for demo purposes\nlet message = b\"Secret message\";\nlet (enc_message, plain_file_key) = DracoonCrypto::encrypt(message.to_vec()).unwrap();\n\n// to encrypt the file key, see asymmetric encryption above\n```\n\nDecrypt a message on the fly:\n\n```rust\nuse dco3_crypto::{DracoonCrypto, Encrypt, Decrypt};\n\n// encrypt a message to get a plain file key for demo purposes\nlet message = b\"Secret message\";\nlet (enc_message, plain_file_key) = DracoonCrypto::encrypt(message.to_vec()).unwrap();\n\n// to decrypt / encrypt the file key, see asymmetric encryption above\nlet plain_message = DracoonCrypto::decrypt(\u0026enc_message, plain_file_key);\n```\n\nEncrypt in chunks:\n\n```rust\nuse dco3_crypto::{DracoonCrypto, Encrypter, ChunkedEncryption};\nlet mut message = b\"Encrypt this very long message in chunks and decrypt it\";\nlet buff_len = message.len() + 1;\nlet mut buf = vec![0u8; buff_len];\nlet mut encrypter = DracoonCrypto::encrypter(\u0026mut buf).unwrap();\nlet mut count: usize = 0;\n\n// chunks of 8 bytes\nconst CHUNKSIZE: usize = 8;\nlet mut chunks = message.chunks(CHUNKSIZE);\nwhile let Some(chunk) = chunks.next() {\n  count += encrypter.update(\u0026chunk).unwrap();\n  };\n\ncount += encrypter.finalize().unwrap();\nlet enc_message = encrypter.get_message();\nlet plain_file_key = encrypter.get_plain_file_key();\n\n```\n\n\nDecrypt in chunks:\n\n```rust\n// importing Encrypt is only necessary for the inital message encryption\nuse dco3_crypto::{DracoonCrypto, Encrypt, Decrypter, ChunkedEncryption};\nuse openssl::symm::Cipher;\nlet message = b\"Encrypt this very long message in chunks and decrypt it\";\n    \nlet (message, plain_file_key) = DracoonCrypto::encrypt(message.to_vec()).unwrap();\nlet buff_len = message.len() + 1;\n    \nlet mut chunks = message.chunks(5);\nlet mut buf = vec![0u8; buff_len];\nlet mut decrypter = DracoonCrypto::decrypter(plain_file_key, \u0026mut buf).unwrap();\nlet mut count: usize = 0;\nwhile let Some(chunk) = chunks.next() {\n  count += decrypter.update(\u0026chunk).unwrap();\n  }\n\ncount += decrypter.finalize().unwrap();\n    \nlet plain_message = std::str::from_utf8(decrypter.get_message()).unwrap();\n  \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funbekanntes-pferd%2Fdco3-crypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funbekanntes-pferd%2Fdco3-crypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funbekanntes-pferd%2Fdco3-crypto/lists"}