184 Commits

Author SHA1 Message Date
kaczmarczyck
e5ba9db644 Reworks workflows into script (#661)
* Reworks some workflows to run a script instead

Advantages are:
- Only one set of tests needs maintenance.
- Local results match workflows, no surprises.
- Reduced reliance on GitHub actions.

Fixes #50, #168, #169, #171, #507

* Adds macos to the test matrix
2023-11-08 17:24:15 +01:00
kaczmarczyck
67e3d46291 Cleans up warnings, unused functions and features (#643) 2023-08-14 13:59:54 +02:00
kaczmarczyck
8a53986961 CBOR API changes (#639)
* adds extract_* functions to CBOR library

* hides Value implementation details

* CBOR API fixes

* README adapted to API changes
2023-08-11 17:28:59 +02:00
kaczmarczyck
87f0711284 New key wrapping API (#642)
* New key wrapping API

Allows key wrapping to be different between persistent and server-side
storage.

To accomplish this, the PrivateKey now always stores the fully
reconstructed key, and has different methods to serialize it for the
respective use case.

* Cleans up legacy credential parsing

This is a backwards incompatible change. This PR already introduces
backwards incompatible new credential parsing, and therefore we can also
remove all other legacy parsing.

* Correct credential minimum size

* wider public interface to allow custom PrivateKey construction
2023-08-10 14:20:39 +02:00
Zach Halvorsen
96af5e81a5 Add more transparency into some EC structures. (#641)
This adds the ability to create ECDH keys from raw bytes and export
signatures as raw bytes.
2023-08-09 17:48:05 +02:00
kaczmarczyck
f0e87ee813 resolves old TODO unlocked by new compiler and spec (#634) 2023-06-13 15:31:54 +02:00
kaczmarczyck
e9ea05f888 fixes new clippy lints (#632) 2023-06-12 11:11:00 +02:00
kaczmarczyck
55f7e47423 Only requires enabling EP when the command exists (#630) 2023-05-10 13:27:13 +02:00
kaczmarczyck
fbf07d7476 Fixes credProtect checking in CTAP1 (#629)
We accidentally lost this check in #516. I refactored some of the
filters for better style.

The actual difference in logic is just one line in CTAP1 authenticate,
everything else is style, a test and the order in which we convert and
filter the credentials:

```
let credential_source = filter_listed_credential(credential_source, false)
            .ok_or(Ctap1StatusCode::SW_WRONG_DATA)?;
```
2023-05-09 22:44:29 +02:00
kaczmarczyck
6fb7e194eb Compile flag for AuthenticatorConfig (#628)
* Adds a compile flag for AuthenticatorConfig

The command can be disabled for authenticators that don't want users to
change their configuration.

* adds tool for calling Config

* std now implies config_command

* removes obsolete comment
2023-05-08 15:45:32 +02:00
kaczmarczyck
99f81adc55 RustCrypto in TockEnv (#625)
* Adds a rust_crypto feature to Tock

* -O3 for RustCrypto
2023-05-05 22:38:56 +02:00
kaczmarczyck
cae2088f36 Credential wrapping in Env (#624)
* Moves credential wrapping to Env

* visibility of constants

* moves PrivateKey to api

* fixes docs and imports
2023-05-05 17:09:31 +02:00
kaczmarczyck
f25cdd6acc Tock V2 port - rebased and updated (#620)
* Changes from #580

* fixes USB cancel panic

* style fixes

* Update src/env/tock/storage.rs

Co-authored-by: Zach Halvorsen <zhalvorsen@google.com>

---------

Co-authored-by: Zach Halvorsen <zhalvorsen@google.com>
2023-05-05 09:55:16 +02:00
kaczmarczyck
bcd382e5e9 Moves CTAP secrets to the key store (#617)
The PIN hash can be encrypted and decrypted, and CredRandom is part of
the master secrets.
2023-04-21 16:32:58 +02:00
kaczmarczyck
a88a1b2a22 Adds a hardware failure state for user presence (#616)
Introduced in https://github.com/google/OpenSK/pull/580

The conversion to libtock's ErrorCode has to happen outside of the
library.
2023-04-21 08:03:46 +02:00
kaczmarczyck
5f7eb3177b Cryptographic Secret type (#615)
* Adds a type for cryptographic secrets

* default implementations and zeroize documentation

* removes whitespace
2023-04-19 18:02:48 +02:00
kaczmarczyck
3091b5a29d Moves vendor commands into TockEnv (#614)
This move changes the Env trait: It removes all functionality that is
used only in vendor commands (`FirmwareProtection`, `UpgradeStorage`)
and adds a function to call when parsing CBOR commands.

The abstraction necessary to test these commands is instead realized
through compile flags. The mock upgrade storage is active when compiled
for std for example.
2023-04-17 00:17:37 +02:00
kaczmarczyck
a1d6ed0223 Makes our CredRandom derivation FIPS compliant (#613)
* Makes our CredRandom derivation FIPS compliant

This change breaks existing usage of CredRandom.

* fixes rust_crypto and HKDF test style
2023-04-11 14:48:42 +02:00
kaczmarczyck
be42b47caf Replaces Rng256 with new Rng API (#612)
* Replaces the Rng256 with RngCore from rand_core

The old trait was designed with our software crypto in mind. We should
use a more standard API going forward.

- Removes libraries/rng256/
- Ports libraries/crypto/ to rand_core
- Moves the used RNG trait to api/

* Use StdRng directy in TestEnv
2023-04-11 10:23:38 +02:00
kaczmarczyck
4cc1b4fddf Adds AES256 to the Crypto trait (#611) 2023-04-06 10:27:33 +02:00
kaczmarczyck
d0cdbec5ce Adds HKDF to the Crypto trait (#610) 2023-04-04 17:48:56 +02:00
kaczmarczyck
22192a37d2 SHA and HMAC for the Crypto trait (#609)
* Implements SHA256 into the Crypto trait

* Fixes documentation

* Descriptive documentation
2023-04-04 17:12:05 +02:00
kaczmarczyck
c168141b60 Adds a trait for crypto, porting EC first (#606)
* Adds a trait for crypto, porting EC first

* Moves crypto implementation next to its trait

* Renames constants and types
2023-04-04 13:54:41 +02:00
kaczmarczyck
80b82ffd42 LTO fix and toml cleanup (#608)
* Removes redundant entries from Cargo.toml

This also fixes a compilation problem we have in debug mode with LTO
enabled.

* fix output-path triple dash
2023-04-04 13:40:42 +02:00
kaczmarczyck
6d5ea16f2d CTAP HID Lock (#605)
* Implements the CTAP HID Lock command

This is a direct translation of our internal implementation.

* adds more HID Lock tests
2023-03-17 17:22:36 +01:00
kaczmarczyck
752db8cc90 Fixes new clippy lints on the latest nightly (#603)
* Fixes new clippy lints on the latest nightly

We didn't see these before because of our old Rust toolchain.

* fixes nit
2023-03-09 12:08:34 +01:00
kaczmarczyck
ca65902a8f CTAP library move (#602)
* Moves all CTAP logic into its own library

* workflows fix test

* more coveralls workflow tests
2023-03-07 15:56:46 +01:00
kaczmarczyck
3135c13e6b Moves the TockEnv implementation of RNG to env/ (#599)
This change removes the tock dependencies from non-Tock envs.
2023-03-06 11:21:48 +01:00
Julien Cretin
f6e9e00b87 Add linear view into a storage (#571) 2022-12-07 13:00:41 +01:00
kaczmarczyck
6610a29a67 Fixed proc-macro2 version (#550)
* fixes proc-macro2 in dependencies

* adds missing locked versions, and a verbose print for cargo check

* commits Cargo.lock files

* removes unnecessary Cargo.lock entries

* adds missing Cargo.lock
2022-09-27 10:12:45 +02:00
kaczmarczyck
f2fac83124 Fix once_cell dependency (#548)
* fixed version of once_cell

* fixes comments

* removes unnecessary fuzz dependency
2022-09-21 19:32:09 +02:00
kaczmarczyck
1b360662ee Public Key plain byte encoding (#540)
* public key is encoded in bytes

* ECDSA pubkey in uncompressed format
2022-08-31 15:51:40 +02:00
Julien Cretin
a44d961e7e Fix bumpalo issue 2022-08-23 10:43:44 +02:00
Julien Cretin
e52adf04c7 Add support for concatenated values 2022-08-19 12:47:29 +02:00
Egor Duda
cc1fb2543e Accommodate Store requirements for max_word_writes and max_page_erases 2022-06-07 17:04:18 +03:00
Egor Duda
0158cc846d Use 0xff for consistency 2022-06-07 15:58:08 +03:00
Egor Duda
2708074949 Improve variable names and comments readability 2022-06-06 15:08:42 +03:00
Egor Duda
660b6b76b2 Make FileOptions available to library's users 2022-06-06 15:06:29 +03:00
Egor Duda
4e47968233 Separate options type for FileStorage, remove hardcoded constants 2022-06-05 22:40:59 +03:00
Egor Duda
c0299c3225 No need for specific feature, use std instead 2022-06-05 22:40:32 +03:00
Egor Duda
f2cb2f72e7 Use StorageError::CustomError for implementations-specific (I/O) errors 2022-06-05 22:39:13 +03:00
Egor Duda
1cf7373bfe With new Storage API there's no need to double-buffer file data
read_slice(...) can return Cow::Owned buffer to the caller
2022-06-05 15:16:49 +03:00
Egor Duda
db26f6125b Implement file-backed persistent storage
This allows running ctap2 authenticator application on non-embedded host OS
to implement virtual FIDO2 authenticator for QEMU
2022-06-05 15:08:52 +03:00
Julien Cretin
0f368f0b48 Add justification for Cow usage 2022-06-03 17:03:06 +02:00
Julien Cretin
f57126634b Allow read_slice to return a Vec 2022-06-03 11:16:43 +02:00
Julien Cretin
5685e95b79 Remove useless dependency after rng256 was split out 2022-05-19 15:20:39 +02:00
kaczmarczyck
8979af6ca4 adds Eq to PartialEq (#477) 2022-05-05 15:50:28 +02:00
kaczmarczyck
4782d7e186 Separate RNG library (#470)
* seperates the RNG library

* fixes crypto tests

* adds rng256 workflow

* fixes formatting
2022-04-28 11:36:43 +02:00
Howard Yang
17ecd46b04 Generate valid structure for MakeCredential params
* Add crate arbitrary as ctap's optional dependency, when feature "fuzz"
  is activated.

* Derive Arbitrary for all the necessary types in order to generate the
  concrete types from random bytes.

* Add a fuzz target that transforms the input to valid format for
  MakeCredential.
2022-03-22 19:06:20 +08:00
kaczmarczyck
7e7d5e38a1 enforces Module imports granularity (#445) 2022-03-14 20:44:48 +01:00