pub enum ArtifactValue {
BackendKey {
backend_name: String,
key_id: KeyId,
algorithm: KeyAlgorithm,
public_key: Option<PublicKeyDer>,
},
WrappedKey {
data: Vec<u8>,
algorithm: WrapAlgorithm,
},
PublicKey(PublicKeyDer),
Bytes(Vec<u8>),
Text(String),
Certificate(CertificateDer),
}Expand description
Runtime representation of an artifact.
Variants§
BackendKey
Cryptographic key managed by a backend (software, HSM, YubiKey).
The private key never leaves the backend - only references are stored.
Fields
algorithm: KeyAlgorithmAlgorithm for type checking and evidence.
public_key: Option<PublicKeyDer>Public key (None for non-exportable HSM keys).
WrappedKey
Wrapped key (CMS EnvelopedData, AES Key Wrap, or RSA-OAEP).
Fields
algorithm: WrapAlgorithmWrapping algorithm used.
PublicKey(PublicKeyDer)
Exported public key.
Bytes(Vec<u8>)
Binary content from files or inline data (documents, crypto materials). Used for hashing, cryptographic operations, and verification.
Text(String)
Display text for physical item references (USB drives, tamper bags, etc.). Used in messages and prompts when referencing physical objects.
Certificate(CertificateDer)
X.509 certificate. Stored as DER; displayed and serialized as PEM.
Implementations§
Source§impl ArtifactValue
impl ArtifactValue
Sourcepub fn serialize(
&self,
format: Option<&str>,
) -> Result<SerializedArtifact, String>
pub fn serialize( &self, format: Option<&str>, ) -> Result<SerializedArtifact, String>
Serialize artifact to bytes with metadata.
Returns a SerializedArtifact containing both the serialized bytes
and metadata (MIME type, file extension) appropriate for the format.
Applies sensible defaults if format is None, then validates strictly.
Supported formats by artifact type:
WrappedKey: “der” (default), “pem”PublicKey: “pem” (default), “der”, “base64”RsaKeypair: “pem” (default), “der” (private key in PKCS#8)- Other artifacts: text representation (format ignored)
MIME type references:
- application/pkcs7-mime: CMS/PKCS#7 (RFC 5273)
- application/pkcs8: PKCS#8 private keys (RFC 5958)
- application/x-pem-file: PEM-encoded files
- application/x-x509-ca-cert: X.509 certificates (Netscape)
- text/plain: Text artifacts
Returns an error if an unsupported format is specified.