#![cfg_attr(not(test), no_std)]
extern crate alloc;
use alloc::string::String;
#[cfg(feature = "pem")]
pub use pem_rfc7468::Error as PemError;
pub use rasn::error::DecodeError as RasnDecodeError;
pub use rasn::error::EncodeError as RasnEncodeError;
mod tpmkey;
pub use tpmkey::OID_TPMKEY_IMPORTABLE;
pub use tpmkey::OID_TPMKEY_LOADABLE;
pub use tpmkey::OID_TPMKEY_SEALED;
pub use tpmkey::TPMAuthPolicy;
pub use tpmkey::TPMKey;
pub use tpmkey::TPMKeyType;
pub use tpmkey::TPMPolicy;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Missing a secret")]
MissingSecret,
#[error("Should not have a secret")]
UnexpectedSecret,
#[error("DER decoding error: {0}")]
DerDecodeError(#[from] RasnDecodeError),
#[error("DER encoding error: {0}")]
DerEncodeError(#[from] RasnEncodeError),
#[error("OID is not a TSS2 PRIVATE KEY")]
NoTss2PrivateKey,
#[error("Key has an invalid parent handle: 0x{0}")]
InvalidParentHandle(String),
#[cfg(feature = "pem")]
#[error("PEM decoding error: {0}")]
PemDecodeError(pem_rfc7468::Error),
#[error("PEM data is not a TSS2 PRIVATE KEY")]
PemNoTss2PrivateKey,
}
#[cfg(feature = "pem")]
impl From<PemError> for Error {
fn from(err: PemError) -> Self {
Self::PemDecodeError(err)
}
}