Skip to content

lancealt/libcperm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libcperm

Create secure permutations from cryptologic ciphers.

libcperm is a library for creating permutations from cryptologic block ciphers. A block cipher is by definition a permutation over the set of possible inputs. Most block ciphers have limited number of block sizes, which are typically powers of two. Often times, permutations with much smaller ranges are needed, limiting the effectiveness of the using a block cipher directly.

libcperm creates a pseudo-random permutation over an arbitrary finite domain. Permutations are created using either the Prefix Cipher or the Cycle-walking Cipher algorithms described in the paper "Ciphers with Arbitrary Finite Domains" by John Black and Phillip Rogaway. As shown in the paper, the permutations generated by libcperm are no less secure as the cipher used to generate them.

Advantages of libcperm

  • Permutations are as secure as the cipher used to generate them (RC5, speck).
  • Simple, easy to use API.
  • Can handle any size domain up to 2^32.
  • Each value will only be seen once unlike a random number generator which may generate the same value twice.
  • Small, compact, pure-C library that will compile anywhere.
  • Permutations can be seeded, allowing repeated generation of the same permutation.

Installation

git clone https://github.com/lancealt/libcperm
cd libcperm
./autogen.sh
./configure; make
sudo make install

Example

Below is a simple C program that creates a permutation with 100 objects and prints out the each of the objects in the permuted order.

#include <stdio.h>
#include "cperm.h"

#define SIZE 100
#define KEYLEN 16

int main() {
  uint8_t key[KEYLEN] = { 0 };
  struct cperm_t* perm = cperm_create(SIZE, PERM_MODE_PREFIX, PERM_CIPHER_RC5, key, KEYLEN);
  uint32_t value, count = 0;

  while(PERM_END != cperm_next(perm, &value)) {
    printf("perm[%u] = %u\n", count, value);
    count++;
  }

  cperm_destroy(perm);

  return 0;
}

About

Permutation Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages