Skip to content

Commit

Permalink
Merge pull request #15 from Nitrokey/debug-partialeq
Browse files Browse the repository at this point in the history
Implement Debug, PartialEq, Eq, Clone and Copy on all relevant structs and prepare release 0.1.5
  • Loading branch information
sosthene-nitrokey authored Jun 6, 2024
2 parents 3ab25a9 + a3da638 commit 2e1adc4
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 136 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ SPDX-License-Identifier: CC0-1.0

# Changelog

## [v0.1.5][] (2025-06-06)

- Implement Debug, PartialEq, Eq, Clone and Copy on all relevant structs ([#15][])

[#15]: https://github.com/Nitrokey/se03x/pull/15
[v0.1.5]: https://github.com/Nitrokey/se05x/releases/tag/v0.1.5

## [v0.1.4][] (2024-05-27)

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "se05x"
version = "0.1.4"
version = "0.1.5"
authors = ["Nitrokey GmbH <info@nitrokey.com>"]

edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions generate_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def flatten(items):
response_lifetime = "<'data>"


outfile.write("#[derive(Clone, Debug)]\n")
outfile.write("#[derive(Clone, Debug, PartialEq, Eq)]\n")
outfile.write("#[cfg_attr(feature = \"builder\", derive(typed_builder::TypedBuilder))]\n")
outfile.write(f'pub struct {name}{payload_lifetime} {{\n')

Expand Down Expand Up @@ -236,7 +236,7 @@ def flatten(items):
outfile.write("}\n")

if "response" in v:
outfile.write("#[derive(Clone, Debug)]\n")
outfile.write("#[derive(Clone, Debug, PartialEq, Eq)]\n")
outfile.write(f'pub struct {name}Response{response_lifetime} {{\n')

for arg_name, arg in v["response"].items():
Expand Down
24 changes: 12 additions & 12 deletions src/se05x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct Se05X<Twi, D> {

pub const MAX_APDU_PAYLOAD_LENGTH: usize = 889;

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
Unknown,
Line(u32),
Expand Down Expand Up @@ -371,7 +371,7 @@ impl<Twi: I2CForT1, D: DelayUs<u32>> Se05X<Twi, D> {
}

bitflags! {
#[derive(Debug,Clone,Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AppletConfig: u16 {
const ECDAA = 0x0001;
const ECDSA_ECDH_ECDHE = 0x0002;
Expand All @@ -394,7 +394,7 @@ bitflags! {
}

pub struct Select;
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Atr {
pub major: u8,
pub minor: u8,
Expand Down Expand Up @@ -440,7 +440,7 @@ impl<'a> TryFrom<&'a [u8]> for Atr {

pub type VersionInfo = Atr;

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ObjectAttributes {
identifier: ObjectId,
class: SecureObjectType,
Expand Down Expand Up @@ -583,7 +583,7 @@ impl<W: Writer, C: Se05XCommand<W>> Se05XCommand<W> for ProcessSessionCmd<C> {
type Response<'a> = C::Response<'a>;
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Se05xChallenge {
pub key_diversification_data: [u8; 10],
pub key_information: [u8; 3],
Expand Down Expand Up @@ -1090,7 +1090,7 @@ pub const SCP_REQUIRED: u8 = 0x01;
pub const SCP_NOT_REQUIRED: u8 = 0x02;

/// Big-endian encoded integer
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Be<I>(pub I);

impl<I> From<I> for Be<I> {
Expand Down Expand Up @@ -1262,15 +1262,15 @@ macro_rules! enum_data {
}

enum_data!(
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum TransientIndicator {
Transient = TRANSIENT_LOCK,
Persistent = PERSISTENT_LOCK,
}
);

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LockState {
Locked,
Unlocked,
Expand Down Expand Up @@ -1320,7 +1320,7 @@ impl<W: Writer> DataStream<W> for LockState {
}

enum_data!(
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum P1KeyType {
Na = P1_DEFAULT,
Expand All @@ -1331,7 +1331,7 @@ enum_data!(
);

enum_data!(
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum RsaFormat {
Crt = P2_DEFAULT,
Expand All @@ -1340,7 +1340,7 @@ enum_data!(
);

enum_data!(
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum EcCurve {
NistP192 = NIST_P192,
Expand All @@ -1366,7 +1366,7 @@ enum_data!(
);

enum_data!(
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum EcCurveParam {
ParamA = CURVE_PARAM_A,
Expand Down
Loading

0 comments on commit 2e1adc4

Please sign in to comment.