# Security

## Encryption Methodology:

Request data is encrypted using AES encryption which uses the following parameters:

<table data-header-hidden><thead><tr><th width="165.5"></th><th></th></tr></thead><tbody><tr><td>Algorithm</td><td>AES 256</td></tr><tr><td>Key Size</td><td>256 Bits</td></tr><tr><td>Block Size</td><td>128 Bits</td></tr><tr><td>Padding</td><td>PKCS7</td></tr><tr><td>Mode / Cipher</td><td>CBC</td></tr><tr><td>IV</td><td>16 bytes of IV value will be provided by CAMS in a base64 string format</td></tr><tr><td>Key</td><td>32 bytes of Key value will be provided by CAMS in a base64 string format</td></tr></tbody></table>

To ensure integrity of data, a SHA-256 hash of the data is sent in an encrypted format along with the encrypted data.

### Steps for Encryption:

To encrypt and send data, the sender must follow the steps below:

1. Construct the request JSON data as per the format provided.
2. Using the Initialization Vector and AES Key as provided by CAMS, perform AES-256 encryption of the data (use parameters as mentioned in the “Encryption Methodology” section) and convert the same as a base64 string. This will give "Data".
3. Compute the SHA-256 hash of the plain request data and convert it as a hexadecimal string.
4. Using the Initialization Vector and AES Key as provided by CAMS, perform AES-256 encryption of the hash (use parameters as mentioned in the “Encryption Methodology” section) and convert the same into base64 string. This will give "Hash". Concatenate both DATA and HASH value with "." separator, and the final result will be as DATA.HASH

## Decryption Methodology:

CAMS will send the response data to client in an encrypted manner.

Response data is decrypted using AES decryption which uses the following parameters:

<table data-header-hidden><thead><tr><th width="190.5"></th><th></th></tr></thead><tbody><tr><td>Algorithm</td><td>AES 256</td></tr><tr><td>Key Size</td><td>256 Bits</td></tr><tr><td>Block Size</td><td>128 Bits</td></tr><tr><td>Padding</td><td>PKCS7</td></tr><tr><td>Mode / Cipher</td><td>CBC</td></tr><tr><td>IV</td><td>16 bytes of IV value will be provided by CAMS in a base64 string format</td></tr><tr><td>Key</td><td>32 bytes of Key value will be provided by CAMS in a base64 string format</td></tr></tbody></table>

#### Steps for Decryption:

The process of decryption of an AES ciphertext is similar to the encryption process in the reverse order. So, when encrypted data is received, the receiver must use the following steps to decrypt the response data.

1. Perform base64 decoding of response data and use the Initialization Vector and AES Key as provided by CAMS to perform AES-256 decryption of the data (use parameters as mentioned in the “Decryption Methodology” section). This will give the actual data for use.
