Skip to main content

Crate uselesskey_core_negative

Crate uselesskey_core_negative 

Source
Expand description

Compatibility façade for negative fixture primitives.

This crate keeps existing uselesskey_core_negative paths stable while delegating to focused microcrates:

§Examples

Corrupt a PEM string with a specific strategy:

use uselesskey_core_negative::{corrupt_pem, CorruptPem};

let pem = "-----BEGIN PUBLIC KEY-----\nABC=\n-----END PUBLIC KEY-----\n";
let bad = corrupt_pem(pem, CorruptPem::BadHeader);
assert!(bad.starts_with("-----BEGIN CORRUPTED KEY-----"));

Deterministic DER corruption from a variant string:

use uselesskey_core_negative::corrupt_der_deterministic;

let der = vec![0x30, 0x82, 0x01, 0x22, 0x10, 0x20];
let a = corrupt_der_deterministic(&der, "corrupt:test-v1");
let b = corrupt_der_deterministic(&der, "corrupt:test-v1");
assert_eq!(a, b); // same variant ⇒ same corruption

Enums§

CorruptPem
Strategies for corrupting PEM-encoded data.

Functions§

corrupt_der_deterministic
Choose a corruption strategy deterministically from variant and apply it to der.
corrupt_pem
Apply a specific CorruptPem corruption strategy to the given PEM string.
corrupt_pem_deterministic
Choose a corruption strategy deterministically from variant and apply it to pem.
flip_byte
XOR the byte at offset with 0x01, returning the original if offset is out of range.
truncate_der
Truncate der to at most len bytes, returning the original if already shorter.