| Crates.io | cosmian_kmip |
| lib.rs | cosmian_kmip |
| version | 5.15.0 |
| created_at | 2025-05-09 02:38:22.256082+00 |
| updated_at | 2026-01-22 11:04:22.790407+00 |
| description | Cosmian KMIP library |
| homepage | |
| repository | https://github.com/Cosmian/kms |
| max_upload_size | |
| id | 1666099 |
| size | 37,740,548 |
The KMIP crate provides a comprehensive implementation of the Key Management Interoperability Protocol (KMIP) standard versions 1.0 through 2.1, including the TTLV (Tag-Type-Length-Value) serialization format.
This crate implements the complete KMIP specification, providing:
openssl feature)The crate provides two types of enumerations:
Enumerations that hold KMIP variant names and values from the specification:
#[allow(non_camel_case_types)]
#[repr(u32)]
#[derive(
KmipEnumSerialize,
Deserialize,
Copy,
Clone,
Debug,
Display,
Eq,
PartialEq,
EnumIter,
strum::IntoStaticStr,
)]
pub enum CryptographicAlgorithm {
DES = 0x0000_0001,
THREE_DES = 0x0000_0002,
AES = 0x0000_0003,
RSA = 0x0000_0004,
DSA = 0x0000_0005,
ECDSA = 0x0000_0006,
// ... more algorithms
}
Requirements for KMIP enumerations:
KmipEnumSerialize trait#[repr(u32)]Copy and strum::IntoStaticStr#[allow(non_camel_case_types)] for KMIP namingEnumerations that offer multiple representations of the same value:
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
#[serde(untagged)]
pub enum LinkedObjectIdentifier {
/// Unique Identifier of a Managed Object
TextString(String),
/// Unique Identifier Enumeration
Enumeration(UniqueIdentifierEnumeration),
/// Zero-based nth Unique Identifier in the response
Index(i64),
}
These enumerations:
#[serde(untagged)] for automatic variant selectionuse cosmian_kmip::kmip_2_1::{
requests::CreateRequest,
objects::ObjectType,
attributes::TemplateAttribute,
};
let request = CreateRequest {
object_type: ObjectType::SymmetricKey,
template_attribute: TemplateAttribute::default(),
};
use cosmian_kmip::ttlv::{TTLV, TTLVType};
// Serialize to TTLV binary format
let ttlv_bytes = request.to_ttlv()?;
// Serialize to JSON
let json_string = serde_json::to_string_pretty(&request)?;
#[cfg(feature = "openssl")]
use cosmian_kmip::openssl::convert_key;
// Convert KMIP key to OpenSSL key
let openssl_key = convert_key(&kmip_key)?;
openssl feature)The XML → TTLV helper used in tests now enforces strict KMIP enumeration and
usage mask validation by default. Unknown enumeration tokens, unknown
CryptographicUsageMask textual values, or unknown AttributeReference names
produce errors. The only tolerated deviation (for interoperability with some
public test vectors) is that a missing type="Structure" attribute on a
container element is still accepted and treated as a Structure.
If your custom vectors fail, ensure all textual enumeration and usage mask tokens are valid per the KMIP specification.
openssl: Enable OpenSSL integration and conversionsnon-fips: Enable non-FIPS cryptographic algorithmsdefault: Includes commonly used features# Basic build
cargo build
# With OpenSSL support
cargo build --features openssl
# With non-FIPS features
cargo build --features non-fips
# All features
cargo build --all-features
# Run all tests
cargo test
# Run with specific features
cargo test --features openssl
# Run with logging
RUST_LOG=debug cargo test
This implementation follows:
The implementation provides:
This crate is part of the Cosmian KMS project and is licensed under the Business Source License 1.1 (BUSL-1.1).