Commit Graph

379 Commits

Author SHA1 Message Date
Julien Cretin
07a28fe611 Inline Helper 2022-07-14 12:50:39 +02:00
Julien Cretin
b28f8f6d33 Merge branch 'develop' into attestation_store 2022-07-14 12:37:11 +02:00
hcyang
4736cc63c4 Add CBOR credential ID type (#512)
* Add CBOR credential ID type

Update the format of the credential ID we generated to extend the
encrypted portion from only private_key + rp_id_hash to a flexible CBOR
map. This way we can persist more data into the key handle in the future
without need of a new version.

We add credProtectPolicy to the persisted data in this commit too, so we
can correctly check the credProtectPolicy for non-discoverable
credentials in follow-up commits.

* Fixed some style problems.

* Fix cargo clippy warning

* Check credProtectPolicy for non-discoverable credentials.

* Remove support of old v1, v2 key handles

- And changed some style problems

* Style changes

* Add missing `alloc` use
2022-07-14 14:17:12 +08:00
Julien Cretin
f528567ce1 Expose the get and set helper implementation 2022-07-12 16:58:29 +02:00
Julien Cretin
bc354d8abb Fix attestation priority 2022-07-11 11:16:58 +02:00
Julien Cretin
0bbc8663c2 Remove unused variable 2022-07-07 17:28:33 +02:00
Julien Cretin
25c884c070 Address comments 2022-07-07 17:23:24 +02:00
Julien Cretin
80a6b82ed7 Abstract attestation support 2022-07-05 16:26:07 +02:00
Julien Cretin
c8dc1dd0e8 Rename STORE_KEY 2022-07-01 13:59:09 +02:00
Julien Cretin
ecb98b0f58 Return Result instead of Option 2022-07-01 13:30:27 +02:00
Julien Cretin
30a3205fa7 Address comments 2022-07-01 10:58:56 +02:00
Julien Cretin
ff6c700cd9 Use indirection to implement the default KeyStore 2022-06-30 15:03:38 +02:00
Julien Cretin
2256c739cd Fix ed25519 test 2022-06-30 12:04:46 +02:00
Julien Cretin
2f9e82696d Fix ctap1 tests 2022-06-30 11:53:44 +02:00
Julien Cretin
87a4dc725f Fix doc 2022-06-30 11:43:11 +02:00
Julien Cretin
fcdf617a2e Rename kh_ to key_handle_ 2022-06-30 11:38:03 +02:00
Julien Cretin
9a7760f362 Actually use ECDSA seed mechanism 2022-06-30 11:35:42 +02:00
Julien Cretin
d793a992d3 Add a key store to avoid storing secrets in the store 2022-06-29 12:51:57 +02:00
Julien Cretin
55a856fd88 Add missing copyright notice 2022-06-28 11:06:04 +02:00
egor-duda
41780e9e33 Move protocol-specific user presence checking code from Env to CTAP library (#501)
* Common duration type for ctap library independent of TockOS

* Implement Env-specific ctap-hid channels for I/O
Common I/O Status, Error and Result types

* Move common user presence checking code to ctap library

* Move CtapHidChannel and UserPresence traits, with their accompanying
types to separate API mods. Remove Default implementations of methods
in these traits, to keep all implementation details inside of concrete
Env types.

Rename methods in UserPresence trait, for better readability.

Remove duplicate code for finding appropriate HID channel for given
transport.

Rework check_user_presence() function so that there's no more need for
quick_check() method in UserPresence trait. To short-circuit user
presence check, Env implementation may use wait_with_timeout() method.

* Fix button press wait with zero timeout for TockEnv

* Fix formatting

* Remove type for duration, use embedded_time::duration::Milliseconds
directly, for better readability.

Treat any unconfirmed result of user presence check as an error, which
maps more naturally to CTAP spec status codes.

Remove unneeded underscores in trait definition.

Store usb endpoint directly, in TockEnv channels, to avoid unneeded
conversions.

* No need for separate error type for send_keepalive_up_needed()

* Document UserPresence trait and types.

Remove unused parameters in UserPresence trait's methods.

Add conversion function from UserPresence errors to Ctap2 status codes.

Do not check button status when tock user presence wait is called with
zero timeout.

* Make test environment always report success sending data

* Rename CtapHidChannel to HidConnection, rename *_hid_channel ->
*_hid_connection, for clarity. Use "Channel" to refer to the logical
connection from authenticator to one client, and use "Connection" to
refer to physical connection of authenticator to platform, on which
clients run.

Remove channel parameter from user presence API, it's not needed.

* Remove duplicate comments.

Co-authored-by: kaczmarczyck <43844792+kaczmarczyck@users.noreply.github.com>
2022-06-23 16:34:27 +02:00
kaczmarczyck
1d53f3c921 Adapts libtock drivers for vendor HID (#500)
* adapts libtock drivers for vendor HID

* status with timeout
2022-06-16 17:56:44 +02:00
kaczmarczyck
95aa02f932 allows passing in capabilities to CtapHid (#496) 2022-06-10 14:31:33 +02:00
Julien Cretin
f57126634b Allow read_slice to return a Vec 2022-06-03 11:16:43 +02:00
hcyang
85fe9cd29d Add sturctured get assertion and client pin fuzzers (#482) 2022-05-27 10:34:38 +08:00
egor-duda
9a9d68ec41 Merge branch 'develop' into ed25519 2022-05-19 22:58:02 +03:00
Egor Duda
5aac730f93 Delete spurious file 2022-05-19 08:50:47 +03:00
Egor Duda
1277b97018 Remove obsolete comment 2022-05-18 20:51:28 +03:00
Egor Duda
e4d3262623 Reserve version IDs to avoid accidental reuse with other options 2022-05-18 20:50:56 +03:00
Julien Cretin
07424c3123 Only derive PartialEq and Eq for PrivateKey for tests
We shouldn't compare private keys in prod for side-channel resilience. Ideally
we shouldn't clone too. We currently do for storage. Fixing this would probably
require to serialize the private key in the credential struct.
2022-05-17 22:59:18 +02:00
Egor Duda
25d538cde6 fix formatting 2022-05-17 23:03:22 +03:00
Egor Duda
42bfd7860d whitespace cleanup 2022-05-17 19:53:45 +03:00
Egor Duda
b9c48b480a Common setting for unsupported CredentialId version 2022-05-17 19:49:25 +03:00
Egor Duda
dc7311a3bd Shorter idiomatic expression for finding preferred crypto algorithm 2022-05-17 17:33:21 +03:00
Egor Duda
06230d15e1 Fix compile warning 2022-05-17 17:15:47 +03:00
Egor Duda
55056b721c Use ed25519-compact crate instead of ed25519-dalek
ed25519-dalek does not implement Clone and Eq for secret keys, and
relevant PR in its repository wait for merge from long time ago, leading
to potential problems with maintainability
2022-05-16 21:48:43 +03:00
Egor Duda
0ef0bb23f4 Remove unneeded code (covered by default branch) 2022-05-16 18:15:03 +03:00
Egor Duda
7f6ff31dd1 Static allocation for list of supported algorithms 2022-05-16 18:12:15 +03:00
Egor Duda
3b8884c088 Separate test for reading ed25519 key from bad cbor 2022-05-13 22:06:10 +03:00
Egor Duda
e473af7118 Cleaner assignment syntax 2022-05-13 21:55:18 +03:00
Egor Duda
f24445b325 with_ed25519 -> ed25519 ("with_*" naming is discouraged) 2022-05-13 20:43:09 +03:00
Egor Duda
983bc5c5b2 Add support for ed25519 keys (#335) 2022-05-12 22:56:33 +03:00
kaczmarczyck
f95ae1f5ab Make private keys extensible (#476)
* adds PrivateKey to handle different algorithms

* fixes input check problem of decrypt_credential_source

* addresses comments

* version number not encrypted

* version number test

* adds a credential size test

* removes the algorithm from credential encoding
2022-05-10 14:31:29 +02:00
hcyang
3a39c4dff1 Add test_helpers (#474)
* Add set_enterprise_attestation in TestEnv

* Add test_helpers for Test Unification

* Used it in structured fuzzer and enterprise attestation unittests

* Restructure test_helpers

* Rename setup_enterprise_attestation to enable_
2022-05-10 18:50:18 +08:00
kaczmarczyck
8979af6ca4 adds Eq to PartialEq (#477) 2022-05-05 15:50:28 +02:00
hcyang
a0e11bd5aa Move remaining customizations to new file (#473) 2022-04-28 13:33:34 +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
kaczmarczyck
360efa4eaf replaces ThreadRng with env RNG (#469) 2022-04-27 15:49:45 +02:00
kaczmarczyck
8dc6dab450 Enterprise attestation testing (#465)
* fix enterprise attestation check

* returns storage errors
2022-04-26 12:24:43 +02:00
hcyang
2b6424360c Move enterprise mode related customizations to new file (#463)
* Move enterprise mode related customizations to new file

* Fix cargo clippy error

* Add is_enterpris_rp_id API to avoid cloning

* Only expose enterprise_rp_id_list API in std
2022-04-25 09:45:59 +08:00
hcyang
aca1f35170 Make rng in TestEnv deterministic and seedable (#461)
* Move three dependent customizations into new file

* default_min_pin_length(_rp_ids) and max_rp_ids_length

* Did some backing store tricks to make the list configurable in
  TestCustomization.

* Add testing for TestCustomization

* Change assert comparison to assert_eq

* Separate tests

* Move 3 pure constants to new file

* Return Vec<String> for rp_ids()

* Make rng in TestEnv deterministic and seedable

* Move seed method to TestRng256

* Change some constant name in comments to snake case

* Move seed rng of env to the start

* Fix unused warning

* Make rng in TestEnv deterministic and seedable

* Move seed method to TestRng256

* Move seed rng of env to the start

* Fix unused warning

* Seed rng in all fuzz targets

* Fix error introduced when merging

Co-authored-by: Julien Cretin <cretin@google.com>
2022-04-20 15:49:17 +08:00