use crate::{
algorithm::Algorithm,
command::{Command, CommandCode},
object::ObjectId,
response::Response,
};
pub const RSA_PSS_MAX_MESSAGE_SIZE: usize = 0xFFFF;
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct SignPssCommand {
pub key_id: ObjectId,
pub mgf1_hash_alg: Algorithm,
pub salt_len: u16,
pub digest: Vec<u8>,
}
impl Command for SignPssCommand {
type ResponseType = RsaPssSignature;
}
#[derive(Serialize, Deserialize, Debug)]
pub struct RsaPssSignature(pub Vec<u8>);
impl Response for RsaPssSignature {
const COMMAND_CODE: CommandCode = CommandCode::SignPss;
}
#[allow(clippy::len_without_is_empty)]
impl RsaPssSignature {
pub fn into_vec(self) -> Vec<u8> {
self.into()
}
pub fn len(&self) -> usize {
self.0.len()
}
pub fn as_slice(&self) -> &[u8] {
self.as_ref()
}
}
impl AsRef<[u8]> for RsaPssSignature {
fn as_ref(&self) -> &[u8] {
self.0.as_ref()
}
}
impl Into<Vec<u8>> for RsaPssSignature {
fn into(self) -> Vec<u8> {
self.0
}
}