logo
pub struct Iso7816;
Expand description

Pad block with byte sequence \x80 00...00 00.

use block_padding::{Iso7816, Padding};
use generic_array::{GenericArray, typenum::U8};

let msg = b"test";
let pos = msg.len();
let mut block: GenericArray::<u8, U8> = [0xff; 8].into();
block[..pos].copy_from_slice(msg);
Iso7816::pad(&mut block, pos);
assert_eq!(&block[..], b"test\x80\x00\x00\x00");
let res = Iso7816::unpad(&block).unwrap();
assert_eq!(res, msg);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Padding type

Pads block filled with data up to pos (i.e length of a message stored in the block is equal to pos). Read more

Unpad data in the block. Read more

Unpad data in the blocks. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.