botan-bindings-0.0.1.0: Raw Botan bindings
Copyright(c) Leo D 2023
LicenseBSD-3-Clause
Maintainerleo@apotheca.io
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Botan.Bindings.FPE

Description

Format preserving encryption (FPE) refers to a set of techniques for encrypting data such that the ciphertext has the same format as the plaintext. For instance, you can use FPE to encrypt credit card numbers with valid checksums such that the ciphertext is also an credit card number with a valid checksum, or similarly for bank account numbers, US Social Security numbers, or even more general mappings like English words onto other English words.

The scheme currently implemented in botan is called FE1, and described in the paper Format Preserving Encryption by Mihir Bellare, Thomas Ristenpart, Phillip Rogaway, and Till Stegers. FPE is an area of ongoing standardization and it is likely that other schemes will be included in the future.

To encrypt an arbitrary value using FE1, you need to use a ranking method. Basically, the idea is to assign an integer to every value you might encrypt. For instance, a 16 digit credit card number consists of a 15 digit code plus a 1 digit checksum. So to encrypt a credit card number, you first remove the checksum, encrypt the 15 digit value modulo 1015, and then calculate what the checksum is for the new (ciphertext) number. Or, if you were encrypting words in a dictionary, you could rank the words by their lexicographical order, and choose the modulus to be the number of words in the dictionary.

Synopsis

Documentation

data BotanFPEStruct Source #

Opaque FPE struct

newtype BotanFPE Source #

Botan FPE object

Constructors

MkBotanFPE 

Instances

Instances details
Storable BotanFPE Source # 
Instance details

Defined in Botan.Bindings.FPE

Eq BotanFPE Source # 
Instance details

Defined in Botan.Bindings.FPE

Ord BotanFPE Source # 
Instance details

Defined in Botan.Bindings.FPE

pattern BOTAN_FPE_FLAG_NONE :: (Eq a, Num a) => a Source #

botan_fpe_fe1_init Source #

Arguments

:: Ptr BotanFPE

fpe

-> BotanMP

n

-> ConstPtr Word8

key[]

-> CSize

key_len

-> CSize

rounds

-> Word32

flags

-> IO CInt 

botan_fpe_encrypt Source #

Arguments

:: BotanFPE

fpe

-> BotanMP

x

-> ConstPtr Word8

tweak[]

-> CSize

tweak_len

-> IO CInt 

botan_fpe_decrypt Source #

Arguments

:: BotanFPE

fpe

-> BotanMP

x

-> ConstPtr Word8

tweak[]

-> CSize

tweak_len

-> IO CInt