silk.crypto.aria.
Encrypt with the ARIA block cipher (RFC 5794, KS X 1213).
When to use#
Use Aria when a format names ARIA, such as aria-128-cbc in OpenSSL or Node.js. Run it in a
mode from silk.crypto.block_cipher, such as Cbc<Aria>.
Details#
The key is 16, 24, or 32 bytes and the block is 16 bytes, with 12, 14, or 16 rounds. Aria
conforms to BlockCipher. Nothing allocates.
Gotchas#
The S-boxes are table lookups, so the time of a block can depend on the key and the data through the cache, as in OpenSSL's portable code. The value holds key material and is not erased when it is dropped.
Examples#
Encrypt one block#
import silk.crypto.block_cipher { BlockCipher, BlockCipherError }
import silk.crypto.aria { Aria }
import silk.core.result { Result }
pub fn main() -> i32 {
// RFC 5794 appendix A.1: key 000102...0f, plaintext 00112233...ff.
let key: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
let cipher = match Aria.make(&key) {
Result<Aria, BlockCipherError>.Success { value } => move value
Result<Aria, BlockCipherError>.Failure { error: _ } => {
return 1
}
}
let mut block: [u8; 16] = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]
cipher.encryptBlock(&mut block)
if block[0] != 0xd7 || block[1] != 0x18 || block[15] != 0x78 {
return 1
}
cipher.decryptBlock(&mut block)
if block[0] != 0x00 || block[15] != 0xff {
return 1
}
return 0
}Import as Aria with import silk.crypto.aria { Aria }.
Public declarations: 1.
Aria#
pub struct AriaAn ARIA key schedule.
Details#
Make one with Aria.make and run it in a mode from silk.crypto.block_cipher, or call
encryptBlock and decryptBlock of BlockCipher on one 16-byte block.
Implementation Aria#
impl AriaAssociated function make#
pub fn make(key: &[u8]) -> Result<Aria, BlockCipherError>Returns the key schedule of key, which is 16, 24, or 32 bytes.
Errors#
InvalidKeyLengthifkeyis not 16, 24, or 32 bytes.
Implementation BlockCipher for Aria#
impl BlockCipher for AriaOperation blockLength#
fn blockLength(self: &Self) -> usizeReturns 16.
Operation encryptBlock#
fn encryptBlock(self: &Self, block: &mut [u8; 16]) -> ()Encrypts the 16 bytes of block in place.
Operation decryptBlock#
fn decryptBlock(self: &Self, block: &mut [u8; 16]) -> ()Decrypts the 16 bytes of block in place.
Category: Cryptography.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.