ci: add ci
Some checks are pending
CI / build-and-test (push) Waiting to run

This commit is contained in:
Kristofers Solo 2026-01-12 21:15:42 +02:00
parent 9c14b01e68
commit 4f90912a4d
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED
9 changed files with 3269 additions and 9 deletions

34
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rustfmt
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-nextest
- name: Run Clippy
run: cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
- name: Run formatting
run: cargo fmt --all --check
- name: Run Tests
run: |
cargo nextest run --all-features --all-targets
cargo test --locked --workspace --all-features --doc
- name: Check Documentation
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps

91
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,91 @@
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g., v1.0.0)"
required: true
type: string
env:
CARGO_TERM_COLOR: always
BINARY_NAME: crypt
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --locked -p crypt --target ${{ matrix.target }}
- name: Prepare artifacts (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip ${{ env.BINARY_NAME }} || true
tar -czvf ../../../${{ env.BINARY_NAME }}-${{ matrix.target }}.${{ matrix.archive }} ${{ env.BINARY_NAME }}
- name: Prepare artifacts (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path "${{ env.BINARY_NAME }}.exe" -DestinationPath "../../../${{ env.BINARY_NAME }}-${{ matrix.target }}.${{ matrix.archive }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}-${{ matrix.target }}
path: ${{ env.BINARY_NAME }}-${{ matrix.target }}.${{ matrix.archive }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Get version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
generate_release_notes: true
files: artifacts/*

4
.gitignore vendored
View File

@ -8,10 +8,6 @@
debug/ debug/
target/ target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk

3139
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
use crate::Block128; use crate::Block128;
/// Mixes each column using matrix multiplication in GF(2^8) ([`MixColumns`] step). /// Mixes each column using matrix multiplication in GF(2^8) (`MixColumns` step).
/// ///
/// Each column is treated as a polynomial and multiplied by a fixed polynomial /// Each column is treated as a polynomial and multiplied by a fixed polynomial
/// modulo x^4 + 1. This provides diffusion across the rows. /// modulo x^4 + 1. This provides diffusion across the rows.

View File

@ -1,6 +1,6 @@
use crate::{Block128, key::Subkey}; use crate::{Block128, key::Subkey};
/// XORs the state with a round key ([`AddRoundKey`] step). /// XORs the state with a round key (`AddRoundKey` step).
/// ///
/// Each round of AES combines the current state with a derived subkey /// Each round of AES combines the current state with a derived subkey
/// using bitwise XOR. This operation is its own inverse. /// using bitwise XOR. This operation is its own inverse.

View File

@ -1,6 +1,6 @@
use crate::Block128; use crate::Block128;
/// Cyclically shifts rows of the state matrix ([`ShiftRows`] step). /// Cyclically shifts rows of the state matrix (`ShiftRows` step).
/// ///
/// Row 0: no shift, Row 1: shift left 1, Row 2: shift left 2, Row 3: shift left 3. /// Row 0: no shift, Row 1: shift left 1, Row 2: shift left 2, Row 3: shift left 3.
/// This provides diffusion across the columns. /// This provides diffusion across the columns.

View File

@ -1,6 +1,6 @@
use crate::{Block128, sbox::SboxLookup}; use crate::{Block128, sbox::SboxLookup};
/// Substitutes each byte using the AES S-box ([`SubBytes`] step). /// Substitutes each byte using the AES S-box (`SubBytes` step).
/// ///
/// Provides non-linearity by replacing each byte with its S-box lookup value. /// Provides non-linearity by replacing each byte with its S-box lookup value.
/// The S-box is derived from the multiplicative inverse in GF(2^8). /// The S-box is derived from the multiplicative inverse in GF(2^8).

View File

@ -8,7 +8,7 @@
/// - `input_bits` - Number of meaningful bits in the input (1-64) /// - `input_bits` - Number of meaningful bits in the input (1-64)
/// - `output_bits` - Number of bits in the output (1-64) /// - `output_bits` - Number of bits in the output (1-64)
/// - `position_table` - Table of 1-based positions (1 to `input_bits`) where each output bit comes from. /// - `position_table` - Table of 1-based positions (1 to `input_bits`) where each output bit comes from.
/// The table should have `output_bits` entries. For each entry i (0-based), `position_table`[i] indicates /// The table should have `output_bits` entries. For each entry i (0-based), `position_table\[i\]` indicates
/// which input bit (1-based) should go to the i-th output bit position (from MSB to LSB). /// which input bit (1-based) should go to the i-th output bit position (from MSB to LSB).
#[must_use] #[must_use]
pub fn permutate( pub fn permutate(