Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial rc5 impl #346

Merged
merged 13 commits into from Feb 10, 2023
63 changes: 63 additions & 0 deletions .github/workflows/rc5.yml
@@ -0,0 +1,63 @@
name: rc5
on:
pull_request:
paths:
- "rc5/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: rc5

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v3
- uses: RustCrypto/actions/cargo-cache@master
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- run: cargo build --no-default-features --release --target ${{ matrix.target }}

minimal-versions:
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
with:
working-directory: ${{ github.workflow }}

test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- stable
steps:
- uses: actions/checkout@v3
- uses: RustCrypto/actions/cargo-cache@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
profile: minimal
- run: cargo check --all-features
- run: cargo test --no-default-features
- run: cargo test
- run: cargo test --all-features
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -15,6 +15,7 @@ members = [
"sm4",
"twofish",
"threefish",
"rc5"
]

[profile.dev]
Expand Down
8 changes: 8 additions & 0 deletions rc5/CHANGELOG.md
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1.0 (2022-11-23)
21 changes: 21 additions & 0 deletions rc5/Cargo.toml
@@ -0,0 +1,21 @@
[package]
name = "rc5"
version = "0.1.0"
description = "RC5 block cipher"
authors = ["RustCrypto Developers"]
edition = "2021"
license = "MIT OR Apache-2.0"
rust-version = "1.56"
readme = "README.md"
repository = "https://github.com/RustCrypto/block-ciphers"
keywords = ["crypto", "rc5", "block-cipher"]
categories = ["cryptography"]

[dependencies]
cipher = { version = "0.4.3", features = ["zeroize"] }

[dev-dependencies]
cipher = { version = "0.4.3", features = ["dev"] }

[features]
zeroize = []
13 changes: 13 additions & 0 deletions rc5/LICENSE-APACHE
@@ -0,0 +1,13 @@
Copyright 2022 Antonio Dropulic

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
25 changes: 25 additions & 0 deletions rc5/LICENSE-MIT
@@ -0,0 +1,25 @@
Copyright (c) 2022 Antonio Dropulic

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.
71 changes: 71 additions & 0 deletions rc5/README.md
@@ -0,0 +1,71 @@
# RustCrypto: RC5 Cipher

[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
![Apache2/MIT licensed][license-image]
![Rust Version][rustc-image]
[![Project Chat][chat-image]][chat-link]
[![Build Status][build-image]][build-link]
[![HAZMAT][hazmat-image]][hazmat-link]

Pure Rust implementation of the [RC5 block cipher][1].

[Documentation][docs-link]

## ⚠️ Security Warning: [Hazmat!][hazmat-link]

This crate does not ensure ciphertexts are authentic (i.e. by using a MAC to
verify ciphertext integrity), which can lead to serious vulnerabilities
if used incorrectly!

No security audits of this crate have ever been performed, and it has not been
thoroughly assessed to ensure its operation is constant-time on common CPU
architectures.

USE AT YOUR OWN RISK!

## Minimum Supported Rust Version

Rust **1.56** or higher.

Minimum supported Rust version can be changed in the future, but it will be
done with a minor version bump.

## SemVer Policy

- All on-by-default features of this library are covered by SemVer
- MSRV is considered exempt from SemVer as noted above

## License

Licensed under either of:

* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

[//]: # (badges)

[crate-image]: https://img.shields.io/crates/v/rc5.svg
[crate-link]: https://crates.io/crates/rc5
[docs-image]: https://docs.rs/rc5/badge.svg
[docs-link]: https://docs.rs/rc5/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg
[hazmat-image]: https://img.shields.io/badge/crypto-hazmat%E2%9A%A0-red.svg
[hazmat-link]: https://github.com/RustCrypto/meta/blob/master/HAZMAT.md
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260039-block-ciphers
[build-image]: https://github.com/RustCrypto/block-ciphers/workflows/rc5/badge.svg?branch=master&event=push
[build-link]: https://github.com/RustCrypto/block-ciphers/actions?query=workflow%3Arc5

[//]: # (general links)

[1]: https://en.wikipedia.org/wiki/RC5
27 changes: 27 additions & 0 deletions rc5/benches/mod.rs
@@ -0,0 +1,27 @@
#![feature(test)]
extern crate test;

use cipher::{block_decryptor_bench, block_encryptor_bench};
use rc5::{RC5_32_12_16, RC5_32_16_16};

block_encryptor_bench!(
Key: RC5_32_12_16,
rc5_32_12_16_encrypt_block,
rc5_32_12_16_encrypt_blocks,
);
block_decryptor_bench!(
Key: RC5_32_12_16,
rc5_32_12_16_decrypt_block,
rc5_32_12_16_decrypt_blocks,
);

block_encryptor_bench!(
Key: RC5_32_16_16,
rc5_32_16_16_encrypt_block,
rc5_32_16_16_encrypt_blocks,
);
block_decryptor_bench!(
Key: RC5_32_16_16,
rc5_32_16_16_decrypt_block,
rc5_32_16_16_decrypt_blocks,
);