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

Return 6285 for SELECT in termination state #155

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ SPDX-License-Identifier: CC0-1.0

## Unreleased

### Bugfixes

- Return status 6285 if SELECT is called in termination state ([#154][])

[#154]: https://github.com/Nitrokey/opcard-rs/issues/154

## [v1.0.0][] (2023-04-27)

- Add support for larger storage for certificates and private use data objects ([#150][])
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ log-warn = []
log-error = []

[patch.crates-io]
iso7816 = { git = "https://github.com/Nitrokey/iso7816.git", tag = "v0.1.1-nitrokey.1" }
p256-cortex-m4 = { git = "https://github.com/Nitrokey/p256-cortex-m4", tag = "v0.1.0-alpha.6-nitrokey-1" }
trussed = { git = "https://github.com/trussed-dev/trussed" , rev = "55ea391367fce4bf5093ff2d3c79041d7aef0485" }
trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth.git", tag = "v0.2.2"}
Expand Down
14 changes: 8 additions & 6 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,16 @@ impl Command {
&self,
mut ctx: Context<'_, R, T>,
) -> Result<(), Status> {
if !self.can_lifecycle_run(State::lifecycle(
ctx.backend.client_mut(),
ctx.options.storage,
)) {
let lifecycle = State::lifecycle(ctx.backend.client_mut(), ctx.options.storage);
if !self.can_lifecycle_run(lifecycle) {
warn!(
"Command {self:?} called in lifecycle {:?}",
State::lifecycle(ctx.backend.client_mut(), ctx.options.storage)
);
return Err(Status::ConditionsOfUseNotSatisfied);
}
match self {
Self::Select => select(ctx),
Self::Select => select(ctx, lifecycle),
Self::GetData(mode, tag) => data::get_data(ctx, *mode, *tag),
Self::GetNextData(tag) => data::get_next_data(ctx, *tag),
Self::PutData(mode, tag) => data::put_data(ctx, *mode, *tag),
Expand Down Expand Up @@ -338,11 +336,15 @@ impl TryFrom<u8> for ManageSecurityEnvironmentMode {
// § 7.2.1
fn select<const R: usize, T: crate::card::Client>(
context: Context<'_, R, T>,
lifecycle: LifeCycle,
) -> Result<(), Status> {
if context.data.starts_with(&RID) {
context.state.volatile.cur_do = None;
context.state.volatile.keyrefs = Default::default();
Ok(())
match lifecycle {
LifeCycle::Operational => Ok(()),
LifeCycle::Initialization => Err(Status::SelectedFileInTerminationState),
}
} else {
info!("Selected application {:x?} not found", context.data);
Err(Status::NotFound)
Expand Down