toysp: Toy Substitution-Permutation block cipher

Description Usage Arguments Value Examples

View source: R/toysp.R

Description

Block cipher with substitution permutation and a xor key.

Usage

1
toysp(block, key, rounds, s, p)

Arguments

block

Block as bit stream.

key

Key as bit stream.

rounds

Rounds.

s

Substitution box n·n, as an array with numbers between 0 and 2^n-1.

p

Permuation, as an array with numbers between 1 and block size.

Value

Encrypted block as bit stream.

Examples

1
2
3
4
5
6
s <- c(2,3,1,13,4,5,6,7,15,10,8,9,0,12,14,11)
p <- seq(0,5*127,5)%%128+1
key <- sample(c(0,1),128,TRUE)
rounds <- 4
block1 <- sample(c(0,1),128,TRUE)
toysp(block1,key,rounds,s,p)

JorgeRiescoDavila/somecrypto documentation built on Jan. 10, 2022, 1:49 a.m.