Plasma GitLab Archive
Projects Blog Knowledge

Module Netsys_ciphers

module Netsys_ciphers: sig .. end

Symmetric cryptographic ciphers


type padding = [ `CTS | `Length | `None | `_8000 ] 

Padding schemes:

  • `None: no padding. The text to encrypt/decrypt must be a multiple of block_constraint bytes
  • `Length: Pad the last block with n bytes of code n
  • `_8000: Pad with one byte 0x80 and as many zeros as needed to fill the block (this may add one or two blocks)
  • `CTS: Use "Ciphertext Stealing". There is a minimum length of the message to encrypt of two blocks.
class type cipher_ctx = object .. end
class type cipher = object .. end

The following functions use the current crypto module (as retrieved by Netsys_crypto.current_symmetric_crypto), unless the impl argument is passed.

val ciphers : ?impl:(module Netsys_crypto_types.SYMMETRIC_CRYPTO) ->
unit -> cipher list

List of supported ciphers

val find : ?impl:(module Netsys_crypto_types.SYMMETRIC_CRYPTO) ->
string * string -> cipher

find (name,mode): get the cipher name in the passed mode.

The name conventionally follows the <uppercasestring>-<size> format, e.g. "AES-128" or "TWOFISH-128".

Modes are "ECB", "CBC", "OFB", "CTR", "STREAM", "GCM". Not every cipher is available in every mode.

val process_subbytes : (last:bool -> Netsys_types.memory -> Netsys_types.memory -> int * int) ->
Stdlib.Bytes.t -> int -> int -> Stdlib.Bytes.t

process_subbytes p s pos len: If p is encrypt or decrypt from a cipher_ctx, p will be called to submit the data from string s, starting at position pos and length len.

The encrypted or decrypted string is returned.

val process_substring : (last:bool -> Netsys_types.memory -> Netsys_types.memory -> int * int) ->
string -> int -> int -> string

process_substring p s pos len: Same for immutable strings.

val process_bytes : (last:bool -> Netsys_types.memory -> Netsys_types.memory -> int * int) ->
Stdlib.Bytes.t -> Stdlib.Bytes.t

process_bytes p s: If p is encrypt or decrypt from a cipher_ctx, p will be called to submit the data from string s.

The encrypted or decrypted string is returned.

val process_string : (last:bool -> Netsys_types.memory -> Netsys_types.memory -> int * int) ->
string -> string

process_string p s: same for immutable strings.

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml