Skip to content

Commit

Permalink
Clean up more
Browse files Browse the repository at this point in the history
  • Loading branch information
nickray committed Jul 5, 2023
1 parent f8e42e8 commit 1ec27e9
Show file tree
Hide file tree
Showing 43 changed files with 807 additions and 895 deletions.
3 changes: 0 additions & 3 deletions .envrc

This file was deleted.

27 changes: 12 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
jobs:
test:
# want QEMU >=4
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install build dependencies
Expand All @@ -32,27 +32,23 @@ jobs:
toolchain: stable
override: true

- name: Check that all crates build without warning
run: RUSTFLAGS='--deny warnings' cargo check --all
shell: bash
- uses: actions-rs/toolchain@v1
name: Install Rust stable/thumbv7em-none-eabi
with:
profile: minimal
toolchain: stable
target: thumbv7em-none-eabi

# - name: Check clippy lints
# run: cargo clippy --all-features --all-targets -- --deny warnings
- name: Check that all crates check without warning
run: make check

- name: Check formatting
run: cargo fmt -- --check
- name: Check formatting + lints
run: make lint

- name: Build PC
run: cargo build --release
shell: bash

- uses: actions-rs/toolchain@v1
name: Install Rust stable/thumbv7em-none-eabi
with:
profile: minimal
toolchain: stable
target: thumbv7em-none-eabi
override: true
- name: Build Cortex-M4
run: cargo build --release --target thumbv7em-none-eabi
shell: bash
Expand All @@ -70,6 +66,7 @@ jobs:
toolchain: stable
target: thumbv8m.main-none-eabi
override: true

- name: Run all of the tests, including QEMU tests
run: make test
shell: bash
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/target
**/*.rs.bk
Cargo.lock
/venv
**/*.o
**/*.map
**/.gdb_history
/tests/x25519_test.json
/tests/eddsa_test.json
78 changes: 62 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,77 @@
[package]
name = "salty"
version = "0.2.1"
authors = ["Nicolas Stalder <n@stalder.io>"]
[workspace]
members = [
".",
"c-api",
"qemu-tests",
"wycheproof",
"wycheproof/macros",
"wycheproof/types",
]

[workspace.package]
authors = ["The Salty Engineers"]
edition = "2021"
description = "Small, sweet, swift Ed25519 signatures for microcontrollers"
homepage = "https://salty.rs"
repository = "https://github.com/nickray/salty"
homepage = "https://github.com/ycrypto/salty"
license = "Apache-2.0 OR MIT"
readme = "README.md"
repository = "https://github.com/ycrypto/salty"
version = "0.2.1"

[package]
name = "salty"
description = "Small, sweet, swift Ed25519 signatures for microcontrollers"
keywords = ["no-std", "NaCl", "Ed25519", "cryptography", "signatures"]
version.workspace = true
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true

[dependencies]
cosey = { version = "0.3.0", optional = true }
[workspace.dependencies]
salty = { path = "." }
wycheproof = { path = "wycheproof" }
wycheproof-macros = { path = "wycheproof/macros" }
wycheproof-types = { path = "wycheproof/types" }

cosey = { version = "0.3.0" }
ed25519 = { version = "2.2", default-features = false }
hex = "0.4"
hex-literal = "0.4"
subtle = { version = "2.4.0", default-features = false }
zeroize = { version = "1.2.0", default-features = false }
ed25519 = { version = "2.2", default-features = false, optional = true }

[dependencies]
subtle.workspace = true
zeroize.workspace = true

cosey = { workspace = true, optional = true}
ed25519 = { workspace = true, optional = true}

[dev-dependencies]
hex = "0.4"
hex-literal = "0.4"
wycheproof = { path = "wycheproof" }
wycheproof-gen = { path = "wycheproof/wycheproof-gen" }
hex.workspace = true
hex-literal.workspace = true
wycheproof-macros.workspace = true
wycheproof-types.workspace = true

[features]
default = ["rustcrypto"]
slow-motion = []
cose = ["cosey"]
rustcrypto = ["ed25519"]
# # doubt this will ever finish xD
# very-long-x25519-test = []

[profile.release.package.salty-c-api]
codegen-units = 1
debug = true
# using `lto = true` leads to
# warning: Linking globals named 'salty_public_key': symbol multiply defined!
# error: failed to load bc of "salty.2a057q60-cgu.0": <Paste>
# lto = "thin"
opt-level = "s"

[profile.release.package.qemu-tests]
codegen-units = 1
debug = true
# lto = true
opt-level = "z"
82 changes: 44 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
TARGET ?= thumbv7em-none-eabihf
WYCHEPROOF_EDDSA_TEST_JSON_URL ?= https://raw.githubusercontent.com/google/wycheproof/master/testvectors/eddsa_test.json
WYCHEPROOF_X25519_TEST_JSON_URL ?= https://raw.githubusercontent.com/google/wycheproof/master/testvectors/x25519_test.json

build build-release:
build:
cargo build --release
cargo build --release --target thumbv7em-none-eabi
cargo build --release --features slow-motion --target thumbv7em-none-eabi

build-debug:
cargo build

local-docs:
cargo doc --document-private-items

fmt:
cargo fmt

rustup:
rustup target add $(TARGET)
rustup component add rustfmt

tests/eddsa_test.json:
curl -sSf "$(WYCHEPROOF_EDDSA_TEST_JSON_URL)" -o $@

tests/x25519_test.json:
curl -sSf "$(WYCHEPROOF_X25519_TEST_JSON_URL)" -o $@

test: tests/eddsa_test.json tests/x25519_test.json
test:
# Test on PC
cargo test
# Test on QEMU
make -C qemu-tests test

.PHONY: venv
# re-run as necessary
venv:
python3 -m venv venv
venv/bin/pip install -U pip
venv/bin/pip install -U -r requirements.txt
fmt:
cargo fmt --all

fix: fmt
cargo clippy --fix --workspace --allow-staged

# used in CI
check:
# cargo check --all
cargo check -p salty
cargo check -p salty-c-api --target thumbv7em-none-eabi
cargo check -p qemu-tests
cargo check -p wycheproof
cargo check -p wycheproof-macros
cargo check -p wycheproof-types

# used in CI
lint:
cargo fmt --check --all
# cargo clippy --workspace
cargo clippy -p salty
cargo clippy -p salty-c-api --target thumbv7em-none-eabi
cargo clippy -p qemu-tests
cargo clippy -p wycheproof
cargo clippy -p wycheproof-macros
cargo clippy -p wycheproof-types

watch:
cargo watch -x 'build --release'
local-docs:
cargo doc --document-private-items

clean:
rm -f tests/eddsa_test.json
rm -f tests/x25519_test.json
cargo clean
rustup-targets:
rustup target add thumbv7em-none-eabi
rustup target add thumbv8m.main-none-eabi

WP_VECTOR_SOURCE = https://raw.githubusercontent.com/google/wycheproof/master/testvectors
WP_SCHEMA_SOURCE = https://raw.githubusercontent.com/google/wycheproof/master/schemas
WP_DATA = wycheproof/data
update-wycheproof-data:
curl -sSf $(WP_VECTOR_SOURCE)/eddsa_test.json -o $(WP_DATA)/eddsa_test.json
curl -sSf $(WP_SCHEMA_SOURCE)/eddsa_verify_schema.json -o $(WP_DATA)/eddsa_verify_schema.json
curl -sSf $(WP_VECTOR_SOURCE)/x25519_test.json -o $(WP_DATA)/x25519_test.json
curl -sSf $(WP_SCHEMA_SOURCE)/xdh_comp_schema.json -o $(WP_DATA)/xdh_comp_schema.json
2 changes: 2 additions & 0 deletions c-api/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "thumbv7em-none-eabi"
1 change: 0 additions & 1 deletion c-api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/target
libsalty-debug.a
30 changes: 15 additions & 15 deletions c-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[package]
name = "salty-c-api"
version = "0.2.0"
authors = ["Nicolas Stalder <n@stalder.io>"]
edition = "2021"
description = "Small, sweet, swift Ed25519 signatures for microcontrollers"
repository = "https://github.com/nickray/salty"
license = "Apache-2.0 OR MIT"
readme = "README.md"
keywords = ["no-std", "NaCl", "cryptography", "signatures"]
authors.workspace = true
edition.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
version.workspace = true

[lib]
crate-type = ["staticlib"]

[dependencies]
salty = { path = ".." }
salty.workspace = true
panic-halt = "0.2"

[features]
slow-motion = ["salty/slow-motion"]

[profile.release]
codegen-units = 1
debug = true
# using `lto = true` leads to
# warning: Linking globals named 'salty_public_key': symbol multiply defined!
# error: failed to load bc of "salty.2a057q60-cgu.0": <Paste>
lto = "thin"
opt-level = "s"
# [profile.release]
# codegen-units = 1
# debug = true
# # using `lto = true` leads to
# # warning: Linking globals named 'salty_public_key': symbol multiply defined!
# # error: failed to load bc of "salty.2a057q60-cgu.0": <Paste>
# lto = "thin"
# opt-level = "s"
2 changes: 1 addition & 1 deletion c-api/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGET = thumbv7em-none-eabihf
TARGET = thumbv7em-none-eabi
build:
cargo build --release --target $(TARGET)
cp target/$(TARGET)/release/build/salty-*/out/libsalty-asm.a libsalty-asm.a
Expand Down
Loading

0 comments on commit 1ec27e9

Please sign in to comment.