AFIT/Source/builtin/ciphers.ml

75 lines
2.0 KiB
OCaml

(** Ciphers
Built-in integer based ciphers.
*)
open Builtin
open Basic_arithmetics
open Power
(********** Cesar Cipher **********)
(** Cesar's cipher encryption
@param k is an integer corresponding to key
@param m word to cipher.
@param b base ; for ASCII codes should be set to 255.
*)
let encrypt_cesar k m b = []
(** Cesar's cipher decryption
@param k is an integer corresponding to key
@param m encrypted word.
@param b base ; for ASCII code should be set to 255.
*)
let decrypt_cesar k m b = []
(********** RSA Cipher **********)
(** Generate an RSA ciphering keys.
Involved prime numbers need to be distinct. Output is a couple
of public, private keys.
@param p prime number
@param q prime number
*)
let generate_keys_rsa p q = ((0,0), (0,0))
(** Encryption using RSA cryptosystem.
@param m integer hash of message
@param pub_key a tuple (n, e) composing public key of RSA cryptosystem.
*)
let encrypt_rsa m (n, e) = 0
(** Decryption using RSA cryptosystem.
@param m integer hash of encrypter message.
@param pub_key a tuple (n, d) composing private key of RSA cryptosystem.
*)
let decrypt_rsa m (n , d) = 0
;;
(********** ElGamal Cipher **********)
(** Generate ElGamal public data. Generates a couple (g, p)
where p is prime and g having high enough order modulo p.
@param p is prime having form 2*q + 1 for prime q.
*)
let rec public_data_g p = (0, 0)
(** Generate ElGamal public data.
@param pub_data a tuple (g, p) of public data for ElGamal cryptosystem.
*)
let generate_keys_g (g, p) = (0, 0)
(** ElGamal encryption process.
@param msg message to be encrypted.
@param pub_data a tuple (g, p) of ElGamal public data.
@param kA ElGamal public key.
*)
let encrypt_g msg (g, p) kA = (0, 0)
(** ElGamal decryption process.
@param msg a tuple (msgA, msgB) forming an encrypted ElGamal message.
@param a private key
@param pub_data a tuple (g, p) of public data for ElGamal cryptosystem.
*)
let decrypt_g (msgA, msgB) a (g, p) = 0