diff --git a/openpgp-card-sequoia/src/lib.rs b/openpgp-card-sequoia/src/lib.rs index 1dab6e2..a13f239 100644 --- a/openpgp-card-sequoia/src/lib.rs +++ b/openpgp-card-sequoia/src/lib.rs @@ -172,6 +172,7 @@ pub fn public_key_material_to_key( panic!("unexpected algo {:?}", algo); } } + _ => unimplemented!("Unexpected PublicKeyMaterial type"), } } diff --git a/openpgp-card/src/crypto_data.rs b/openpgp-card/src/crypto_data.rs index 4b2d3bd..793adc3 100644 --- a/openpgp-card/src/crypto_data.rs +++ b/openpgp-card/src/crypto_data.rs @@ -12,6 +12,7 @@ use crate::card_do::{Fingerprint, KeyGenerationTime}; use crate::errors::OpenpgpCardError; /// A hash value that can be signed by the card. +#[non_exhaustive] pub enum Hash<'a> { SHA256([u8; 0x20]), SHA384([u8; 0x30]), @@ -49,6 +50,7 @@ impl Hash<'_> { } /// Data that can be decrypted on the card. +#[non_exhaustive] pub enum Cryptogram<'a> { // message/ciphertext RSA(&'a [u8]), @@ -74,6 +76,7 @@ pub trait CardUploadableKey { /// Algorithm-independent container for private key material to upload to /// an OpenPGP card +#[non_exhaustive] pub enum PrivateKeyMaterial { R(Box), E(Box), @@ -99,6 +102,7 @@ pub trait EccKey { /// Algorithm-independent container for public key material retrieved from /// an OpenPGP card #[derive(Debug)] +#[non_exhaustive] pub enum PublicKeyMaterial { R(RSAPub), E(EccPub), @@ -106,6 +110,7 @@ pub enum PublicKeyMaterial { /// RSA-specific container for public key material from an OpenPGP card. #[derive(Debug)] +#[non_exhaustive] pub struct RSAPub { /// Modulus (a number denoted as n coded on x bytes) n: Vec, @@ -130,6 +135,7 @@ impl RSAPub { /// ECC-specific container for public key material from an OpenPGP card. #[derive(Debug)] +#[non_exhaustive] pub struct EccPub { data: Vec, algo: Algo, @@ -151,6 +157,7 @@ impl EccPub { /// A marker to distinguish between elliptic curve algorithms (ECDH, ECDSA, /// EdDSA) #[derive(PartialEq, Eq, Debug, Clone, Copy)] +#[non_exhaustive] pub enum EccType { ECDH, ECDSA, diff --git a/openpgp-card/src/errors.rs b/openpgp-card/src/errors.rs index 34cb972..d699dd2 100644 --- a/openpgp-card/src/errors.rs +++ b/openpgp-card/src/errors.rs @@ -14,6 +14,7 @@ use thiserror::Error; /// Enum that wraps the different error types that this crate can return #[derive(Error, Debug)] +#[non_exhaustive] pub enum OpenpgpCardError { #[error("Error interacting with smartcard: {0}")] Smartcard(SmartcardError), @@ -45,6 +46,7 @@ impl From for OpenpgpCardError { /// OpenPGP card "Status Byte" errors #[derive(Error, Debug, PartialEq)] +#[non_exhaustive] pub enum OcErrorStatus { #[error("Selected file or DO in termination state")] TerminationState, @@ -150,6 +152,7 @@ impl From<(u8, u8)> for OcErrorStatus { /// Errors on the smartcard/reader layer #[derive(Error, Debug)] +#[non_exhaustive] pub enum SmartcardError { #[error("Failed to create a pcsc smartcard context {0}")] ContextError(String),