From 86ea532504310dfac51e06500a45a73f848df4b1 Mon Sep 17 00:00:00 2001 From: Nikita Tikhonov Date: Tue, 25 Jun 2024 21:22:17 +0300 Subject: [PATCH] Initial commit. --- .editorconfig | 17 +++++ .gitattributes | 2 + .github/CODEOWNERS | 1 + .github/dependabot.yml | 28 +++++++ .github/workflows/release.yml | 106 ++++++++++++++++++++++++++ .github/workflows/test.yml | 31 ++++++++ .gitignore | 7 ++ CHANGELOG.md | 3 + CODE_OF_CONDUCT.md | 137 ++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 0 Cargo.toml | 12 +++ LICENSE | 21 ++++++ README.md | 76 +++++++++++++++++++ SECURITY.md | 112 +++++++++++++++++++++++++++ changelogging.toml | 8 ++ changes/.gitignore | 1 + src/in_place.rs | 11 +++ src/lib.rs | 6 ++ 18 files changed, 579 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 changelogging.toml create mode 100644 changes/.gitignore create mode 100644 src/in_place.rs create mode 100644 src/lib.rs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..43ebb20 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +indent_style = space +indent_size = 4 + +charset = utf-8 + +[*.yaml] +indent_size = 2 + +[*.yml] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6e8b6ff --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# automatically detect text files and perform LF normalization +* text=auto diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f9a6f67 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @nekitdev diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..eb7a69c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,28 @@ +version: 2 + +updates: + - package-ecosystem: github-actions + directory: "/" + + labels: + - A-dependencies + - P-normal + - S-triage + + schedule: + interval: daily + + open-pull-requests-limit: 10 + + - package-ecosystem: cargo + directory: "/" + + labels: + - A-dependencies + - P-normal + - S-triage + + schedule: + interval: daily + + open-pull-requests-limit: 10 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ba6d6b4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,106 @@ +name: release + +on: + workflow_dispatch: + inputs: + version: + description: The version to release, without the leading `v`. + type: string + required: true + +env: + bot-name: nekit[bot] + bot-email: bot@nekit.dev + changelog: CHANGELOG-${{ inputs.version }}.md + +jobs: + changelog: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install changelogging + run: cargo install changelogging + + - name: Build changelog ${{ inputs.version }} + run: changelogging preview > ${{ env.changelog }} + + - name: Upload changelog ${{ inputs.version }} + uses: actions/upload-artifact@v4 + with: + name: changelog + path: ${{ env.changelog }} + + - name: Build changelog + run: changelogging build --stage --remove + + - name: Setup bot user + run: | + git config --local user.name ${{ env.bot-name }} + git config --local user.email ${{ env.bot-email }} + + - name: Commit and push + run: | + git commit -m "Add ${{ inputs.version }} to the changelog." + git push + + tag: + runs-on: ubuntu-latest + needs: changelog + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup bot user + run: | + git config --local user.name ${{ env.bot-name }} + git config --local user.email ${{ env.bot-email }} + + - name: Tag and push + run: | + git tag v${{ inputs.version }} + git push --tags + + publish: + runs-on: ubuntu-latest + needs: tag + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Publish + run: cargo publish --token ${{ secrets.CARGO_TOKEN }} + + release: + runs-on: ubuntu-latest + needs: publish + + steps: + - name: Download changelog + uses: actions/download-artifact@v4 + with: + pattern: changelog + merge-multiple: true + + - name: Publish to GitHub + uses: softprops/action-gh-release@v2 + with: + body_path: ${{ env.changelog }} + tag_name: v${{ inputs.version }} + token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6dfdb38 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: test + +on: + push: + branches: + - main + + pull_request: + branches: + - "**" + +jobs: + test: + strategy: + matrix: + os: [ubuntu, macos, windows] + + runs-on: ${{ matrix.os }}-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Run clippy + run: cargo clippy + + - name: Run tests + run: cargo test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f88253 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# build artifacts + +target/ + +# remove if lock file should be included + +Cargo.lock diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b3c7888 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + + diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..948d71d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,137 @@ +# Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement to +[conduct@xor-cipher.org][Email]. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][Home], +version 2.1, available at +[https://contributor-covenant.org/version/2/1/code_of_conduct][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's Code of Conduct enforcement ladder][Mozilla Code of Conduct]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://contributor-covenant.org/faq][FAQ]. Translations are available at +[https://contributor-covenant.org/translations][Translations]. + +[Email]: mailto:conduct@xor-cipher.org + +[Home]: https://contributor-covenant.org/ +[v2.1]: https://contributor-covenant.org/version/2/1/code_of_conduct + +[Mozilla Code of Conduct]: https://github.com/mozilla/diversity + +[FAQ]: https://contributor-covenant.org/faq +[Translations]: https://contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e69de29 diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..74a66b1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "xor-cipher" +version = "1.0.0" +authors = ["nekitdev "] +edition = "2021" +description = "Simple, reusable and optimized XOR ciphers in Rust." +documentation = "https://docs.rs/xor-cipher" +readme = "README.md" +homepage = "https://xor-cipher.org/" +repository = "https://github.com/xor-cipher/xor-cipher" +license = "MIT" +keywords = ["xor", "cipher"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f860d10 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present, Nikita Tikhonov (nekitdev) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c89912 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# `xor-cipher` + +[![License][License Badge]][License] +[![Version][Version Badge]][Crate] +[![Downloads][Downloads Badge]][Crate] +[![Test][Test Badge]][Actions] + +> *Simple, reusable and optimized XOR ciphers in Rust.* + +## Installation + +### `cargo` + +You can add `xor-cipher` as a dependency with the following command: + +```console +$ cargo add xor-cipher +``` + +Or by directly specifying it in the configuration like so: + +```toml +[dependencies] +xor-cipher = "1.0.0" +``` + +Alternatively, you can add it directly from the source: + +```toml +[dependencies.xor-cipher] +git = "https://github.com/xor-cipher/xor-cipher-crate.git" +``` + +## Documentation + +You can find the documentation [here][Documentation]. + +## Support + +If you need support with the library, you can send an [email][Email]. + +## Changelog + +You can find the changelog [here][Changelog]. + +## Security Policy + +You can find the Security Policy of `xor-cipher` [here][Security]. + +## Contributing + +If you are interested in contributing to `xor-cipher`, make sure to take a look at the +[Contributing Guide][Contributing Guide], as well as the [Code of Conduct][Code of Conduct]. + +## License + +`xor-cipher` is licensed under the MIT License terms. See [License][License] for details. + +[Email]: mailto:support@xor-cipher.org + +[Actions]: https://github.com/xor-cipher/xor-cipher-crate/actions + +[Changelog]: https://github.com/xor-cipher/xor-cipher-crate/blob/main/CHANGELOG.md +[Code of Conduct]: https://github.com/xor-cipher/xor-cipher-crate/blob/main/CODE_OF_CONDUCT.md +[Contributing Guide]: https://github.com/xor-cipher/xor-cipher-crate/blob/main/CONTRIBUTING.md +[Security]: https://github.com/xor-cipher/xor-cipher-crate/blob/main/SECURITY.md + +[License]: https://github.com/xor-cipher/xor-cipher-crate/blob/main/LICENSE + +[Crate]: https://crates.io/crates/xor-cipher +[Documentation]: https://docs.rs/xor-cipher + +[License Badge]: https://img.shields.io/crates/l/xor-cipher +[Version Badge]: https://img.shields.io/crates/v/xor-cipher +[Downloads Badge]: https://img.shields.io/crates/dr/xor-cipher +[Test Badge]: https://github.com/xor-cipher/xor-cipher-crate/workflows/test/badge.svg diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..5c5de1b --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,112 @@ +# Security Policy + +## Reporting + +Thank you for taking the time to responsibly disclose any problems you find. + +**Do not file public issues as they are open for everyone to see!** + +All security vulnerabilities in `xor-cipher` should be reported by email +to [security@xor-cipher.org][Security Email]. +Your report will be acknowledged within 24 hours, and you will receive a more +detailed response within 48 hours indicating the next steps in handling your report. + +You can encrypt your report using our public key: +[`FF8BC4BD3679FEC28A1CF79ED063CCAB4A83E040`][Security Key]. +This key is also available on [MIT's Key Server][MIT Key Server] +and [reproduced below](#security-key). + +After the initial reply to your report, the core team will try to keep you +informed of the progress being made towards a fix and official announcement. +These updates will be sent at least every five days. In reality, this is +more likely to be every 24-48 hours. + +## Disclosure Policy + +`xor-cipher` has a 5-step disclosure process: + +1. The security report is received and is assigned a primary handler. + This person will coordinate the fix and release process. + +2. The problem is confirmed and a list of all affected versions is determined. + +3. Code is audited to find any potential similar problems. + +4. Fixes are prepared for all releases which are still under maintenance. + These fixes are not committed to the public repository but rather + held locally pending the announcement. + +5. On the embargo date, the changes are pushed to the public repository + and new builds are deployed. + +This process can take some time, especially when coordination is required +with maintainers of other projects. Every effort will be made to handle +the issue in as timely a manner as possible, however it is important that +we follow the release process above to ensure that the disclosure is handled +in a consistent manner. + +## Security Key + +```text +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBGWlKxoBEADQyivM64TFCWYBjcOT0RusKqNIU95DYWNmKD/FQhfh+qtRMDTj +lWUSMepk1GNkYIf2SmfEwwZYXk0IURyQOwFg49A/CiYVyZWdZGSa3K2a358D8pnw +d42IwEnhwdrTf2EM+KzpfnLtofS9IGP66wmBcfHiDGVnpciwfQELI3UXu1e7parX +CYaTV+vpft7VzfQDLTQmkAt363YYY1/6x5NxGooSyVKr81sCZmlH3Ww5aA5sI6kZ +1WfFm6vseFZebkoNdQESDB/poRT60VCBmme2UorpmrikhtHimBbt6DgAVKnwjqvb +eRnAz4CRkwXao2uQMzeaCCiG60O4QRpKKAptu9Njq8CCHM6V0SAYcPaQJgA6yJMR +1XfGivsrNAKODHmcoid7azMn92KF4mWh4FF4Mk995RBzfTsF1FPNEyj5ofHRc05y +3UWsgM1hgiZuBnz5eN3kaXfX87baHvaXrKUzIlRXUK/R5ixW+BLVZmIZNWn3Bwbq +S9HnnQPDi06EYFuQEIYTILOvbDvIub+q8nb/XeduLQVVeh0yNsbo6qSq0oUNstQE +N6f+Cx2rgS3UrJYKI45Q//3C95MzcouV4WXfFvmmdMsfxeQw+Rb4RWWnc1tmODf4 +IDM0HRfzn+O7+NLBBEnCqbMv/9NvC5uxewihduDPmb51W2DIzXLXZScllQARAQAB +tC9YT1IgQ2lwaGVyIChzZWN1cml0eSkgPHNlY3VyaXR5QHhvci1jaXBoZXIub3Jn +PokCTgQTAQoAOBYhBP+LxL02ef7Cihz3ntBjzKtKg+BABQJlpSsaAhsDBQsJCAcC +BhUKCQgLAgQWAgMBAh4BAheAAAoJENBjzKtKg+BAzOoP/R1VjjvZi7E4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c2qRjtnlvsXol+Y= +=uSs5 +-----END PGP PUBLIC KEY BLOCK----- +``` + +## Attribution + +This Security Policy is adapted from [Rust's Security Policy][Rust Security Policy]. + +[Security Email]: mailto:security@xor-cipher.org +[Security Key]: https://xor-cipher.org/keys/security +[MIT Key Server]: https://pgp.mit.edu/pks/lookup?op=index&search=0xFF8BC4BD3679FEC28A1CF79ED063CCAB4A83E040 +[Rust Security Policy]: https://rust-lang.org/policies/security diff --git a/changelogging.toml b/changelogging.toml new file mode 100644 index 0000000..0360ca4 --- /dev/null +++ b/changelogging.toml @@ -0,0 +1,8 @@ +[context] +name = "xor-cipher" +version = "1.0.0" +url = "https://github.com/xor-cipher/xor-cipher-crate" + +[formats] +title = "[{{version}}]({{url}}/tree/v{{version}}) ({{date}})" +fragment = "{{content}} ([#{{id}}]({{url}}/pull/{{id}}))" diff --git a/changes/.gitignore b/changes/.gitignore new file mode 100644 index 0000000..f935021 --- /dev/null +++ b/changes/.gitignore @@ -0,0 +1 @@ +!.gitignore diff --git a/src/in_place.rs b/src/in_place.rs new file mode 100644 index 0000000..59b3ab8 --- /dev/null +++ b/src/in_place.rs @@ -0,0 +1,11 @@ +#[inline] +pub fn xor_in_place(data: &mut [u8], key: u8) { + data.iter_mut().for_each(|byte| *byte ^= key); +} + +#[inline] +pub fn cyclic_xor_in_place(data: &mut [u8], key: &[u8]) { + data.iter_mut() + .zip(key.iter().cycle()) + .for_each(|(byte, key_byte)| *byte ^= key_byte); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..bd408da --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,6 @@ +#![forbid(unsafe_code)] +#![warn(missing_docs)] + +#![cfg_attr(not(feature = "std"), no_std)] + +pub mod in_place;