Skip to content

Commit ca65902

Browse files
authored
CTAP library move (#602)
* Moves all CTAP logic into its own library * workflows fix test * more coveralls workflow tests
1 parent 03031e6 commit ca65902

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+412
-2000
lines changed

.github/workflows/cargo_fmt.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
submodules: "true"
2323
- name: Install Rust toolchain
2424
run: rustup show
25+
- name: Install nightly toolchain
26+
run: rustup toolchain install nightly
27+
- name: Install nightly cargo fmt
28+
run: rustup component add rustfmt --toolchain nightly
2529
- uses: actions/setup-python@v1
2630
with:
2731
python-version: 3.7
@@ -34,46 +38,59 @@ jobs:
3438
uses: actions-rs/cargo@v1
3539
with:
3640
command: fmt
37-
args: --all -- --check
41+
args: -- --check
3842

39-
- name: Cargo format fuzz/
43+
- name: Cargo format libraries/opensk
4044
uses: actions-rs/cargo@v1
4145
with:
46+
toolchain: nightly
4247
command: fmt
43-
args: --manifest-path fuzz/Cargo.toml --all -- --check
48+
args: --manifest-path libraries/opensk/Cargo.toml -- --check
49+
50+
- name: Cargo format libraries/opensk/fuzz
51+
uses: actions-rs/cargo@v1
52+
with:
53+
toolchain: nightly
54+
command: fmt
55+
args: --manifest-path libraries/opensk/fuzz/Cargo.toml -- --check
4456

4557
- name: Cargo format libraries/cbor
4658
uses: actions-rs/cargo@v1
4759
with:
60+
toolchain: nightly
4861
command: fmt
49-
args: --manifest-path libraries/cbor/Cargo.toml --all -- --check
62+
args: --manifest-path libraries/cbor/Cargo.toml -- --check
5063

5164
- name: Cargo format libraries/cbor/fuzz
5265
uses: actions-rs/cargo@v1
5366
with:
67+
toolchain: nightly
5468
command: fmt
55-
args: --manifest-path libraries/cbor/fuzz/Cargo.toml --all -- --check
69+
args: --manifest-path libraries/cbor/fuzz/Cargo.toml -- --check
5670

5771
- name: Cargo format libraries/crypto
5872
uses: actions-rs/cargo@v1
5973
with:
74+
toolchain: nightly
6075
command: fmt
61-
args: --manifest-path libraries/crypto/Cargo.toml --all -- --check
76+
args: --manifest-path libraries/crypto/Cargo.toml -- --check
6277

6378
- name: Cargo format libraries/persistent_store
6479
uses: actions-rs/cargo@v1
6580
with:
81+
toolchain: nightly
6682
command: fmt
67-
args: --manifest-path libraries/persistent_store/Cargo.toml --all -- --check
83+
args: --manifest-path libraries/persistent_store/Cargo.toml -- --check
6884

6985
- name: Cargo format tools/heapviz
7086
uses: actions-rs/cargo@v1
7187
with:
88+
toolchain: nightly
7289
command: fmt
73-
args: --manifest-path tools/heapviz/Cargo.toml --all -- --check
90+
args: --manifest-path tools/heapviz/Cargo.toml -- --check
7491

7592
- name: Cargo format bootloader
7693
uses: actions-rs/cargo@v1
7794
with:
7895
command: fmt
79-
args: --manifest-path bootloader/Cargo.toml --all -- --check
96+
args: --manifest-path bootloader/Cargo.toml -- --check

.github/workflows/cargo_fuzz.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:
14+
toolchain: nightly
1415
submodules: "true"
1516
- name: Install Rust toolchain
1617
run: rustup show
@@ -25,8 +26,8 @@ jobs:
2526
run: ./fuzzing_setup.sh
2627

2728
- name: Cargo fuzz build
28-
run: cargo fuzz build
29+
run: cd libraries/opensk && cargo +nightly fuzz build
2930
- name: Cargo fuzz build (libraries/cbor)
30-
run: cd libraries/cbor && cargo fuzz build && cd ../..
31+
run: cd libraries/cbor && cargo +nightly fuzz build
3132
- name: Cargo fuzz build (libraries/persistent_store)
32-
run: cd libraries/persistent_store && cargo fuzz build && cd ../..
33+
run: cd libraries/persistent_store && cargo +nightly fuzz build

.github/workflows/coveralls.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: OpenSK code coverage report
33
on:
44
push:
55
paths:
6-
- 'src/**/*.rs'
76
- 'libraries/**/*.rs'
87
pull_request:
98
types: [opened, synchronize, reopened]
@@ -27,22 +26,24 @@ jobs:
2726
- name: Set up OpenSK
2827
run: ./setup.sh
2928
- name: Install llvm tools
30-
run: rustup component add llvm-tools-preview
29+
run: rustup +nightly component add llvm-tools-preview
3130

3231
- name: Install grcov
3332
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo +stable install grcov; fi
3433
- uses: actions-rs/cargo@v1
3534
with:
35+
toolchain: nightly
3636
command: test
37-
args: --features "with_ctap1,vendor_hid,ed25519,with_nfc,std" --no-fail-fast
37+
args: --manifest-path libraries/opensk/Cargo.toml --features "std,with_ctap1,vendor_hid,ed25519" --no-fail-fast
3838
env:
39-
RUSTFLAGS: "-Zinstrument-coverage"
39+
RUSTFLAGS: "-Cinstrument-coverage"
4040
LLVM_PROFILE_FILE: "opensk-%p-%m.profraw"
4141
- name: Run grcov
42-
run: grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --ignore-not-existing ---output-path ./lcov.info --ignore "/*" --ignore "examples/*" --ignore "third_party/*"
42+
run: RUSTUP_TOOLCHAIN=nightly grcov . --binary-path ./libraries/opensk/target/debug/ --source-dir libraries/opensk/ --output-type lcov --ignore-not-existing ---output-path ./lcov.info --ignore "/*" --ignore "examples/*" --ignore "third_party/*"
4343
- uses: coverallsapp/[email protected]
4444
name: upload report to coveralls
4545
with:
4646
github-token: ${{ secrets.GITHUB_TOKEN }}
4747
path-to-lcov: "./lcov.info"
48+
base-path: "libraries/opensk"
4849

.github/workflows/crypto_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ jobs:
3131
- name: Unit testing of crypto library (release mode)
3232
uses: actions-rs/cargo@v1
3333
with:
34+
toolchain: nightly
3435
command: test
3536
args: --manifest-path libraries/crypto/Cargo.toml --release --features std
3637

3738
- name: Unit testing of crypto library (debug mode)
3839
uses: actions-rs/cargo@v1
3940
with:
41+
toolchain: nightly
4042
command: test
4143
args: --manifest-path libraries/crypto/Cargo.toml --features std

.github/workflows/opensk_test.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,28 @@ jobs:
2929
- name: Unit testing of CTAP2 (release mode)
3030
uses: actions-rs/cargo@v1
3131
with:
32+
toolchain: nightly
3233
command: test
33-
args: --release --features std
34+
args: --manifest-path libraries/opensk/Cargo.toml --release --features std
3435

3536
- name: Unit testing of CTAP2 (debug mode)
3637
uses: actions-rs/cargo@v1
3738
with:
39+
toolchain: nightly
3840
command: test
39-
args: --features std
41+
args: --manifest-path libraries/opensk/Cargo.toml --features std
4042

41-
- name: Unit testing of CTAP2 (release mode + CTAP1)
43+
- name: Unit testing of CTAP2 (release mode + all features)
4244
uses: actions-rs/cargo@v1
4345
with:
46+
toolchain: nightly
4447
command: test
45-
args: --release --features std,with_ctap1
48+
args: --manifest-path libraries/opensk/Cargo.toml --release --features std,debug_ctap,with_ctap1,vendor_hid,ed25519
4649

47-
- name: Unit testing of CTAP2 (debug mode + CTAP1)
50+
- name: Unit testing of CTAP2 (debug mode + all features)
4851
uses: actions-rs/cargo@v1
4952
with:
53+
toolchain: nightly
5054
command: test
51-
args: --features std,with_ctap1
55+
args: --manifest-path libraries/opensk/Cargo.toml --features std,debug_ctap,with_ctap1,vendor_hid,ed25519
5256

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
fuzz/artifacts
2-
fuzz/corpus
3-
fuzz/coverage
1+
libraries/**/Cargo.lock
42
target/
53

64
# Local installation of elf2tab.

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ edition = "2018"
1414
libtock_core = { path = "third_party/libtock-rs/core" }
1515
libtock_drivers = { path = "third_party/libtock-drivers" }
1616
lang_items = { path = "third_party/lang-items" }
17+
opensk = { path = "libraries/opensk" }
1718
sk-cbor = { path = "libraries/cbor" }
1819
crypto = { path = "libraries/crypto" }
1920
rng256 = { path = "libraries/rng256" }
@@ -27,15 +28,14 @@ ed25519-compact = { version = "1", default-features = false, optional = true }
2728

2829
[features]
2930
debug_allocations = ["lang_items/debug_allocations"]
30-
debug_ctap = ["libtock_drivers/debug_ctap"]
31+
debug_ctap = ["libtock_drivers/debug_ctap", "opensk/debug_ctap"]
3132
panic_console = ["lang_items/panic_console"]
32-
std = ["crypto/std", "lang_items/std", "persistent_store/std", "rng256/std", "rand"]
33+
std = ["crypto/std", "lang_items/std", "persistent_store/std", "rng256/std", "rand", "opensk/std"]
3334
verbose = ["debug_ctap", "libtock_drivers/verbose_usb"]
34-
with_ctap1 = ["crypto/with_ctap1"]
35+
with_ctap1 = ["crypto/with_ctap1", "opensk/with_ctap1"]
3536
with_nfc = ["libtock_drivers/with_nfc"]
36-
vendor_hid = []
37-
fuzz = ["arbitrary", "std"]
38-
ed25519 = ["ed25519-compact"]
37+
vendor_hid = ["opensk/vendor_hid"]
38+
ed25519 = ["ed25519-compact", "opensk/ed25519"]
3939

4040
[dev-dependencies]
4141
enum-iterator = "0.6.0"

0 commit comments

Comments
 (0)