Skip to main content

unprotect

Function unprotect 

Source
pub fn unprotect(
    ctx: &mut SecurityContext,
    apdu: &[u8],
) -> Result<(u8, Vec<u8>), CipherError>
Expand description

Removes protection from a ciphered APDU, returning (ciphered_tag, plaintext).

The invocation counter carried in the header is written into ctx so the same context can decipher a following APDU with the peer’s counter. Per IEC 62056-5-3 the IC must increase monotonically per peer; a received IC that does not exceed the last one accepted from this peer is rejected as a replay before any decryption is attempted, and ctx is left unchanged.