The RSA Encryption API enables encrypting data using the RSA encryption algorithm with SHA1 hash, OAEP padding and MGF1 mask generation. The keys used for encryption and decryption are generated based on the user-defined parameters, which enable selecting the format of the keys (either DER or PEM) and the strength of the encryption process. The encryption methods use the encryption key to transform either string data or binary data into Base-64 encoded strings.
The RSA encryption/decryption methods operate on data blocks. The size of input/output blocks is calculated according to the formulas given below.
Encryption input/decryption output block size:
size (in bytes) = key_size/8 - padding (e.g. 1024/8 - 41 = 87 bytes)
Decryption input/encryption output block size:
size (in bytes) = key_size/8 (e.g. 1024/8 = 128 bytes)
For details on certificate encoding standards, please refer to the SSL Knowledgebase.
The encryption strength is defined by setting the size of the keys, expressed in bits.
The RSA encryption API module is called via the
window.launchbox.encryption.RSA
reference.
The following constants may be used during the key generation process:
Name | Description |
---|---|
DER_FORMAT | Denotes that the DER (Base-64 encoded) format should be used while generating the encryption keys. |
PEM_FORMAT | Denotes that the PEM format should be used while generating the encryption keys. |
The RSA encryption API object uses the following five methods.
Name | Description | Return type |
---|---|---|
Generates the RSA encryption keys. This method is a prerequisite for the remaining methods. |
|
|
Accepts string data to return a Base-64 encoded string containing encrypted data. |
|
|
Accepts binary data to return a Base-64 encoded string containing encrypted data. |
|
|
Accepts a Base-64 encoded string containing encrypted data to return decrypted string data. |
|
|
Accepts a Base-64 encoded string containing encrypted data to return decrypted binary data. |
|