# JsDoc Reference - Ciform.ciphers.RSAEncoder

Class Index | File Index

## Classes

- _global_
- Ciform
- Ciform.Cipher
- Ciform.ciphers
- Ciform.ciphers.ChainEncoder
- Ciform.ciphers.CiformPacketizer
- Ciform.ciphers.Encoder
- Ciform.ciphers.RSAEncoder
- Ciform.ciphers.RSAPublicKey
- Ciform.ciphers.SHA1Encoder
- Ciform.Field
- Ciform.protocol

# Class Ciform.ciphers.RSAEncoder

This encoder can encrypt a message given a public key. The ciphertext may be decrypted only with the corresponding private key.
Defined in: ciform.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Ciform.ciphers.RSAEncoder(options)

Field Summary
Field Attributes | Field Name and Description
--- | ---
| noPadding If true, does not check that the padding scheme is correct (does not apply if salt is added).
| preamble If true, meta-data will be prepended to the result of encryption.
| pubKey The public key used for asymmetric encryption.
| salt If true, a random string will be prepended to the text before encryption, in order to make the ciphertext different every time, even with the same original text.
| SALT_MAX
| SALT_MIN

Method Summary
Method Attributes | Method Name and Description
--- | ---
<private> | _getMPI()
<private> | _getSalt()
| encode(message)
| maxLength() Computes the maximum length the message should be to prevent attacks against RSA without padding.

Class Detail
Ciform.ciphers.RSAEncoder(options)

Parameters:
{Object} options
  Overrides the fields of this object. Must contain at least 'pubKey'.

Throws:
  TypeError if the public key was not given or is not correct

See:
  http://en.wikipedia.org/wiki/RSA.

Field Detail
{boolean} noPadding

If true, does not check that the padding scheme is correct (does not apply if salt is added).

DEFAULT : false : do check that the padding scheme is correct (does not apply if salt is added).

{boolean} preamble

If true, meta-data will be prepended to the result of encryption.

DEFAULT : false : don't add meta-data in the beginning of the ciphertext.

{Ciform.ciphers.RSAPublicKey} pubKey

The public key used for asymmetric encryption.

REQUIRED (no default value)

{boolean} salt

If true, a random string will be prepended to the text before encryption, in order to make the ciphertext different every time, even with the same original text.
E.g. "1234:my message" : "1234:" is the salt

DEFAULT : false : don't add salt in the beginning of the ciphertext

WARNING : without salt, the same message encoded with the same key will always give the same ciphertext (this could be a security issue).

SALT_MAX

SALT_MIN
Method Detail
<private> {Array[Number]} _getMPI()

<private> {Number} _getSalt()

Returns:
  a random number between this.SALT_MIN and this.SALT_MAX

encode(message)

Parameters:
message

Throws:
  RangeError if the message is too long to be secure for the current public key (ignored if either 'salt' or 'nopadding' is true)

Returns:
  the ciphertext of the message, encoded with the public RSA key of this encoder, with meta-data about the encoding if this.options['preamble'] is true

See:
  Ciform.ciphers.Encoder#encode

{Number} maxLength()
Computes the maximum length the message should be to prevent attacks against RSA without padding.

Returns:
  the max. length for a message to be encoded. In case salt is added to the ciphertext, the real max. length might be longer, because the salt has a variable length

See:
  http://en.wikipedia.org/wiki/RSA#Padding_schemes.
  Ciform.ciphers.RSAEncoder#_getSalt

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 06 2012 00:12:49 GMT+0100 (CET)