Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General authenticate - challenge response #3

Merged
merged 60 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b9c6ce4
Run cargo fmt
sosthene-nitrokey Oct 24, 2022
53076d7
Update dependencies
sosthene-nitrokey Oct 24, 2022
ce939ee
Fix clippy warnings
sosthene-nitrokey Oct 24, 2022
1a65eb8
Use latest trussed commit
sosthene-nitrokey Oct 24, 2022
65fd2b4
Use trussed's virt module
sosthene-nitrokey Oct 24, 2022
89d8410
Add vsmartcard example
sosthene-nitrokey Oct 25, 2022
3b42f0b
Use recent method for macro import
sosthene-nitrokey Oct 25, 2022
c9a6249
Add infrastructure for command-response tests (taken from opcard-rs)
sosthene-nitrokey Oct 25, 2022
4bb20fe
Log commands
sosthene-nitrokey Oct 25, 2022
98fa36f
Add test with default PIN
sosthene-nitrokey Oct 25, 2022
cc989dc
Add select command support and test
sosthene-nitrokey Oct 26, 2022
3e8fc3e
Fix fasc-n encoding
sosthene-nitrokey Oct 26, 2022
e076633
Add convinience make targets
sosthene-nitrokey Oct 31, 2022
fd23a9f
Remove the unused apdu from the select command
sosthene-nitrokey Oct 31, 2022
0ac5cc5
Improve documentation of default FASC_N
sosthene-nitrokey Oct 31, 2022
34a9629
Fix pivy-tool list
sosthene-nitrokey Oct 31, 2022
aab5302
Fix remaining warnings
sosthene-nitrokey Oct 31, 2022
0dc602c
Remove command chaining
sosthene-nitrokey Oct 31, 2022
d1fac72
Use full names for cryptosystems
sosthene-nitrokey Oct 31, 2022
04d8ea1
Return FunctionNotSupported rather than NotFound for unimplemeted Get…
sosthene-nitrokey Oct 31, 2022
d4c68e7
Remove outdated comments
sosthene-nitrokey Oct 31, 2022
8477aa1
Add yubico commands
sosthene-nitrokey Nov 1, 2022
b9164b5
Add gitlab ci
sosthene-nitrokey Nov 3, 2022
253b0e4
Use hex! for constants
sosthene-nitrokey Nov 3, 2022
ce76bcc
test ci
Nov 4, 2022
53b0e71
test ci
Nov 4, 2022
46267de
test webhook
Nov 4, 2022
0f1aa82
set initial-refacto as main branch for the ci
Nov 4, 2022
ec6fd21
Merge branch 'initial-refacto' into ci
Nov 4, 2022
f325e14
move the checkmark call to the top of the after_script section
Nov 4, 2022
9ffff5c
Fix boilerplate for GENERAL AUTHENTICATE
sosthene-nitrokey Nov 3, 2022
3f93ae1
Remove trussed from the persistent state
sosthene-nitrokey Nov 4, 2022
f06a746
Fix clippy warning
sosthene-nitrokey Nov 4, 2022
42c1e73
Remove const generic in state
sosthene-nitrokey Nov 4, 2022
0bc75ec
Use macros to have one source of KeyReferences
sosthene-nitrokey Nov 4, 2022
7818fe6
Remove the iso command from yubico handler
sosthene-nitrokey Nov 4, 2022
573808a
Remove the need for const generics in the respond implementations
sosthene-nitrokey Nov 4, 2022
5341fc1
Remove opcard's tlv impl and use the existing derp module
sosthene-nitrokey Nov 4, 2022
f6eeff7
Add Nitrokey to authors
sosthene-nitrokey Nov 4, 2022
2d2de43
Fix opcard -> piv-authenticator
sosthene-nitrokey Nov 4, 2022
36b09af
Differenciate loading errors from empty filesystem
sosthene-nitrokey Nov 4, 2022
9640780
Make the use of persistent state easier
sosthene-nitrokey Nov 4, 2022
c5098fd
Fix warnings
sosthene-nitrokey Nov 4, 2022
622fb5a
Relicense to LGPL and comply with reuse
sosthene-nitrokey Nov 8, 2022
043094f
Add README
sosthene-nitrokey Nov 8, 2022
5473ccc
Fix initial parsing of GENERAL AUTHENTICATE
sosthene-nitrokey Nov 9, 2022
3ab233b
Implement request for challenge
sosthene-nitrokey Nov 10, 2022
2e62982
Implemet GENERAL AUTHENTICATE get response support
sosthene-nitrokey Nov 10, 2022
124d334
Check that command algorithm corresponds with state
sosthene-nitrokey Nov 10, 2022
050da53
Add test for admin auth
sosthene-nitrokey Nov 10, 2022
d21a04d
Fix set management key to accept any length
sosthene-nitrokey Nov 15, 2022
38b7a5a
Add support for Aes key management in tests
sosthene-nitrokey Nov 15, 2022
af7340b
Set the management algorithm with the key
sosthene-nitrokey Nov 16, 2022
0e6dbe5
Add support for AES keys in SET MANAGEMENT KEY and test AES keys for …
sosthene-nitrokey Nov 21, 2022
c036f5c
Add basic pivy test
sosthene-nitrokey Nov 21, 2022
1c9a505
Fix reuse compliance
sosthene-nitrokey Nov 22, 2022
ec5e758
Add pivy to CI docker image
sosthene-nitrokey Dec 16, 2022
ce366b6
Use Nitrokey trussed tag
sosthene-nitrokey Dec 16, 2022
22a6011
Fix clippy warning
sosthene-nitrokey Dec 16, 2022
d7d1a17
Fix documentation compilation
sosthene-nitrokey Dec 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Copyright (C) 2022 Nicolas Stalder
# SPDX-License-Identifier: Apache-2.0 OR MIT

[net]
git-fetch-with-cli = true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Copyright (C) 2022 Nicolas Stalder AND Nitrokey GmbH
# SPDX-License-Identifier: Apache-2.0 OR MIT

/target
Cargo.lock
tarpaulin-report.html
cobertura.xml
50 changes: 50 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2022 Nitrokey GmbH
# SPDX-License-Identifier: CC0-1.0

include: 'https://raw.githubusercontent.com/Nitrokey/common-ci-jobs/master/common_jobs.yml'

stages:
- pull-github
- build
- deploy

variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
GIT_SUBMODULE_STRATEGY: recursive
REPO_NAME: piv-authenticator
MAIN_BRANCH: initial-refacto
COMMON_PULL: "true"
COMMON_UPLOAD_NIGHTLY: "false"
COMMON_GITHUB_RELEASE: "false"
COMMON_UPLOAD_FILES: "false"

build:
image: registry.git.nitrokey.com/nitrokey/piv-authenticator/piv-authenticator-build:latest
rules:
- if: '$CI_PIPELINE_SHOULD_NOT_BUILD == "true"'
when: never
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
tags:
- docker
stage: build
before_script:
- cargo --version
script:
- make ci
after_script:
- wget $icon_server/checkmark/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHA/$CI_JOB_NAME/$CI_JOB_STATUS/${CI_JOB_URL#*/*/*/}
- cp /app/.cache/scdaemon.log scdaemon.log
coverage: '/^\d+.\d+% coverage/'
artifacts:
when: always
paths:
- "scdaemon.log"
- "cobertura.xml"
- "tarpaulin-report.html"
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml
47 changes: 36 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,63 @@
# Copyright (C) 2022 Nicolas Stalder AND Nitrokey GmbH
# SPDX-License-Identifier: Apache-2.0 OR MIT

[package]
name = "piv-authenticator"
version = "0.0.0-unreleased"
authors = ["Nicolas Stalder <[email protected]>"]
edition = "2018"
license = "Apache-2.0 OR MIT"
authors = ["Nicolas Stalder <[email protected]>", "Nitrokey GmbH"]
edition = "2021"
license = "LGPL-3.0-only"
repository = "https://github.com/solokeys/piv-authenticator"
documentation = "https://docs.rs/piv-authenticator"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[example]]
name = "virtual"
required-features = ["virtual"]

[dependencies]
apdu-dispatch = { version = "0.1", optional = true }
delog = "0.1.0"
delog = { version = "0.1.5", optional = true }
flexiber = { version = "0.1", features = ["derive", "heapless"] }
heapless = "0.7"
hex-literal = "0.3"
interchange = "0.2.0"
interchange = "0.2.2"
iso7816 = "0.1"
serde = { version = "1", default-features = false }
trussed = { git = "https://github.com/trussed-dev/trussed" }
# trussed = { path = "../../../trussed" }
untrusted = "0.7"
serde = { version = "1", default-features = false, features = ["derive"] }
trussed = "0.1"
untrusted = "0.9"
vpicc = { version = "0.1.0", optional = true }
log = "0.4"
heapless-bytes = "0.3.0"
subtle = "2"

[dev-dependencies]
littlefs2 = "0.3.1"
littlefs2 = "0.3.2"
rand_core = { version = "0.6", features = ["getrandom"] }
trussed = { version = "0.1.0", features = ["virt"] }
env_logger = "0.9"
serde = { version = "1", features = ["derive"] }
serde_cbor = { version = "0.11", features = ["std"] }
hex = "0.4"
test-log = "0.2"
ron = "0.8"
des = "0.8"
aes = "0.8.2"
stoppable_thread = "0.2.1"
expectrl = "0.6.0"


[features]
default = []
strict-pin = []
std = []
virtual = ["std", "vpicc","trussed/virt"]

log-all = []
log-none = []
log-info = []
log-debug = []
log-warn = []
log-error = []

[patch.crates-io]
trussed = { git = "https://github.com/Nitrokey/trussed", tag = "v0.1.0-nitrokey-3"}
File renamed without changes.
121 changes: 121 additions & 0 deletions LICENSES/CC0-1.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
Loading