Add #[non_exhaustive] to error and crypto_data enums.
This commit is contained in:
parent
84a7f0060d
commit
f501c09d2f
3 changed files with 11 additions and 0 deletions
|
@ -172,6 +172,7 @@ pub fn public_key_material_to_key(
|
||||||
panic!("unexpected algo {:?}", algo);
|
panic!("unexpected algo {:?}", algo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => unimplemented!("Unexpected PublicKeyMaterial type"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::card_do::{Fingerprint, KeyGenerationTime};
|
||||||
use crate::errors::OpenpgpCardError;
|
use crate::errors::OpenpgpCardError;
|
||||||
|
|
||||||
/// A hash value that can be signed by the card.
|
/// A hash value that can be signed by the card.
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum Hash<'a> {
|
pub enum Hash<'a> {
|
||||||
SHA256([u8; 0x20]),
|
SHA256([u8; 0x20]),
|
||||||
SHA384([u8; 0x30]),
|
SHA384([u8; 0x30]),
|
||||||
|
@ -49,6 +50,7 @@ impl Hash<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data that can be decrypted on the card.
|
/// Data that can be decrypted on the card.
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum Cryptogram<'a> {
|
pub enum Cryptogram<'a> {
|
||||||
// message/ciphertext
|
// message/ciphertext
|
||||||
RSA(&'a [u8]),
|
RSA(&'a [u8]),
|
||||||
|
@ -74,6 +76,7 @@ pub trait CardUploadableKey {
|
||||||
|
|
||||||
/// Algorithm-independent container for private key material to upload to
|
/// Algorithm-independent container for private key material to upload to
|
||||||
/// an OpenPGP card
|
/// an OpenPGP card
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum PrivateKeyMaterial {
|
pub enum PrivateKeyMaterial {
|
||||||
R(Box<dyn RSAKey>),
|
R(Box<dyn RSAKey>),
|
||||||
E(Box<dyn EccKey>),
|
E(Box<dyn EccKey>),
|
||||||
|
@ -99,6 +102,7 @@ pub trait EccKey {
|
||||||
/// Algorithm-independent container for public key material retrieved from
|
/// Algorithm-independent container for public key material retrieved from
|
||||||
/// an OpenPGP card
|
/// an OpenPGP card
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum PublicKeyMaterial {
|
pub enum PublicKeyMaterial {
|
||||||
R(RSAPub),
|
R(RSAPub),
|
||||||
E(EccPub),
|
E(EccPub),
|
||||||
|
@ -106,6 +110,7 @@ pub enum PublicKeyMaterial {
|
||||||
|
|
||||||
/// RSA-specific container for public key material from an OpenPGP card.
|
/// RSA-specific container for public key material from an OpenPGP card.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct RSAPub {
|
pub struct RSAPub {
|
||||||
/// Modulus (a number denoted as n coded on x bytes)
|
/// Modulus (a number denoted as n coded on x bytes)
|
||||||
n: Vec<u8>,
|
n: Vec<u8>,
|
||||||
|
@ -130,6 +135,7 @@ impl RSAPub {
|
||||||
|
|
||||||
/// ECC-specific container for public key material from an OpenPGP card.
|
/// ECC-specific container for public key material from an OpenPGP card.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct EccPub {
|
pub struct EccPub {
|
||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
algo: Algo,
|
algo: Algo,
|
||||||
|
@ -151,6 +157,7 @@ impl EccPub {
|
||||||
/// A marker to distinguish between elliptic curve algorithms (ECDH, ECDSA,
|
/// A marker to distinguish between elliptic curve algorithms (ECDH, ECDSA,
|
||||||
/// EdDSA)
|
/// EdDSA)
|
||||||
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum EccType {
|
pub enum EccType {
|
||||||
ECDH,
|
ECDH,
|
||||||
ECDSA,
|
ECDSA,
|
||||||
|
|
|
@ -14,6 +14,7 @@ use thiserror::Error;
|
||||||
|
|
||||||
/// Enum that wraps the different error types that this crate can return
|
/// Enum that wraps the different error types that this crate can return
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum OpenpgpCardError {
|
pub enum OpenpgpCardError {
|
||||||
#[error("Error interacting with smartcard: {0}")]
|
#[error("Error interacting with smartcard: {0}")]
|
||||||
Smartcard(SmartcardError),
|
Smartcard(SmartcardError),
|
||||||
|
@ -45,6 +46,7 @@ impl From<anyhow::Error> for OpenpgpCardError {
|
||||||
|
|
||||||
/// OpenPGP card "Status Byte" errors
|
/// OpenPGP card "Status Byte" errors
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum OcErrorStatus {
|
pub enum OcErrorStatus {
|
||||||
#[error("Selected file or DO in termination state")]
|
#[error("Selected file or DO in termination state")]
|
||||||
TerminationState,
|
TerminationState,
|
||||||
|
@ -150,6 +152,7 @@ impl From<(u8, u8)> for OcErrorStatus {
|
||||||
|
|
||||||
/// Errors on the smartcard/reader layer
|
/// Errors on the smartcard/reader layer
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum SmartcardError {
|
pub enum SmartcardError {
|
||||||
#[error("Failed to create a pcsc smartcard context {0}")]
|
#[error("Failed to create a pcsc smartcard context {0}")]
|
||||||
ContextError(String),
|
ContextError(String),
|
||||||
|
|
Loading…
Reference in a new issue