use cosmian_kmip::kmip_2_1::{
kmip_attributes::Attributes,
kmip_objects::ObjectType,
kmip_operations::ReKeyKeyPair,
kmip_types::{CryptographicAlgorithm, KeyFormatType, UniqueIdentifier},
};
use super::attributes::{RekeyEditAction, rekey_edit_action_as_vendor_attribute};
use crate::error::CryptoError;
pub fn build_rekey_keypair_request(
vendor_id: &str,
msk_uid: &str,
action: &RekeyEditAction,
) -> Result<ReKeyKeyPair, CryptoError> {
Ok(ReKeyKeyPair {
private_key_unique_identifier: Some(UniqueIdentifier::TextString(msk_uid.to_owned())),
private_key_attributes: Some(Attributes {
object_type: Some(ObjectType::PrivateKey),
cryptographic_algorithm: Some(CryptographicAlgorithm::CoverCrypt),
key_format_type: Some(KeyFormatType::CoverCryptSecretKey),
vendor_attributes: Some(vec![rekey_edit_action_as_vendor_attribute(
vendor_id, action,
)?]),
..Attributes::default()
}),
..ReKeyKeyPair::default()
})
}