# Public ciphers

PublicCipher

The `PublicCipher` class is an abstract class that is used to implement an asymmetric cipher. An asymmetric cipher or public key cipher is designed to operate with a public key and a secret key. Depending on the use model, the public key might be used to crypt the data, and the secret key to decrypt. The basic assumption around a public cipher is that the secret key cannot be derived from the public key.

public-cipher-p
Cipher
get-message-size
Integer
none

The `get-message-size` method returns the cipher message size.

get-crypted-size
Integer
none

The `get-crypted-size` method returns the cipher crypted block size.

Rsa

The `Rsa` class is a public cipher class that implements the RSA algorithm as described by PKCS 2.1, RFC 2437 and ISO 18033-2. The class implements also some padding mechanism described in PKCS 1.5, 2.1 and ISO 18033-2. The RSA algorithm is a public cryptographic cipher based on a secret and public keys. The class operates in crypting mode by default and uses the public key to do the encryption while the secret key is used in reverse (decryption) mode. By default, the PKCS 1.5 type 2 padding is used. The ISO RSA-REM1 padding with a key derivation function (KDF1) is equivalent to PKCS 2.1 padding with the mask generation function (MGF1). The ISO RSA-REM1 padding with KDF2 is not described in the PKCS 2.1.

rsa-p
PublicCipher
Rsa
none

The `Rsa` constructor creates a default RSA public cipher by binding a 1024 bits random key.

Rsa
Key

The `Rsa` constructor creates a RSA public cipher by binding the key argument.

Rsa
Key Boolean

The `Rsa` constructor creates a RSA public cipher by binding the key argument and the reverse flag. The first argument is the key to bind. The second argument is the reverse flag to set.

Rsa
Key Hasher String

The `Rsa` constructor creates a RSA public cipher by binding the key argument and OAEP padding objects. The first argument is the key to bind. The second argument is hasher object to use with the OAEP padding mode. The third argument is an optional label to be used by the KDF object.

PAD-PKCS-11

The `PAD-PKCS-11` constant indicates that the PKCS 1.5 type 1 block should be used to pad the message.

PAD-PKCS-12

The `PAD-PKCS-12` constant indicates that the PKCS 1.5 type 3 block should be used to pad the message.

PAD-OAEP-K1

The `PAD-OAEP-K1` constant indicates that the ISO/IEC 18033-2 OAEP with KDF1 should be used to pad the message.

PAD-OAEP-K2

The `PAD-OAEP-K2` constant indicates that the ISO/IEC 18033-2 OAEP with KDF2 should be used to pad the message.

get-hasher
Hasher
none

The `get-hasher` method returns the hasher object used by the OAEP padding mode.

set-hasher
none
Hasher

The `set-hasher` method sets the hasher object used by the OAEP padding mode.

get-padding-mode
Item
none

The `get-padding-mode` method returns the cipher padding mode.

set-padding-mode
none
Item

The `set-padding-mode` method sets the cipher padding mode.

get-padding-label
String
none

The `get-padding-label` method returns the cipher padding label.

set-padding-label
none
String

The `set-padding-mode` method sets the cipher padding label.

get-padding-seed
String
none

The `get-padding-seed` method returns the cipher padding seed.

set-padding-seed
none
String

The `set-padding-seed` method sets the cipher padding seed.

pkcs-primitive
Relatif
Integer|Relatif

The `pkcs-primitive` method compute a relatif value from a relatif argument by either crypting or decrypting the argument. seed.