Encryption Service
Overview
Encryption Service is used to secure sensitive data that is being stored in the database. The encryption services uses envelope encryption.
Pre-requisites
Before you proceed with the documentation, make sure the following pre-requisites are met -
Java 17.
Kafka server is up and running.
Key Functionalities
Encryption Service offers following features :
Encrypt - The service will encrypt the data based on given input parameters and data to be encrypted. The encrypted data will be mandatorily of type string.
Decrypt - The decryption will happen solely based on the input data (any extra parameters are not required). The encrypted data will have identity of the key used at the time of encryption, the same key will be used for decryption.
Sign - Encryption Service can hash and sign the data which can be used as unique identifier of the data. This can also be used for searching gicen value from a datastore.
Verify - Based on the input sign and the claim, it can verify if the the given sign is correct for the provided claim.
Rotate Key - Encryption Service supports changing the key used for encryption. The old key will still remain with the service which will be used to decrypt old data. All the new data will be encrypted by the new key.
Configuration Details
Following are the properties in application.properties file in egov-enc-service which are configurable.
Property | Default Value | Remarks |
---|---|---|
| asd@#$@$!132123 | Master password for encryption/ decryption. It can be any string. |
| qweasdzx | A salt is random data that is used as an additional input to a one-way function that hashes data, a password or passphrase. It needs to be an alphanumeric string of length 8. |
| qweasdzxqwea | An initialization vector is a fixed-size input to a cryptographic primitive. It needs to be an alphanumeric string of length 12. |
| 256 | Default size of Symmetric key. |
| 1024 | Default size of Asymmetric key. |
| 12 | Default size of Initial vector. |
| software | Name of the implementation to be used for encrypting DEKs |
NA | AWS access key to access the KMS service (Note: this field is required only if | |
NA | AWS secret to access the KMS service (Note: this field is required only if | |
NA | AWS region to access the KMS service (Note: this field is required only if | |
NA | Id of the KMS key to be used for encrypting the DEK (Note: this field is required only if |
Deployment Details
Deploy the latest version of Encryption Service
Note: This video will give you an idea of how to deploy any Digit-service. Further you can find the latest builds for each service in out latest release document here.
Add Role-Action mapping for API’s.
Integration
Integration Scope
The Encryption service is used to encrypt sensitive data that needs to be stored in the database. For each tenant, a different data encryption key (DEK) is used. The DEK is encrypted using Key Encryption Keys (KEK). Currently, there are two implementations of encrypting the data encryption keys available. The first one is using AWS KMS service and the second one is using a master password. For any custom implementation, the MasterKeyProvider interface in the service should be extended. Based on the master.password.provider flag in appication.properties you can enable which implementation of MasterKeyProvider interface to use
Integration Benefits
Can perform encryption without having to re-write encryption logic every time in every service.
Steps to Integration
To integrate, the host of encryption-services module should be overwritten in the helm chart.
/crypto/v1/_encrypt
should be added as an endpoint for encrypting input data in the system/crypto/v1/_decrypt
should be added as the decryption endpoint./crypto/v1/_sign
should be added as the endpoint for providing a signature for a given value./crypto/v1/_verify
should be added as the endpoint for verifying whether the signature for the provided value is correct./crypto/v1/_rotatekey
should be added as an endpoint to deactivate the keys and generate new keys for a given tenant.
Reference Docs
Doc Links
Title | Link |
---|---|
API Swagger Documentation |
API List
a) POST /crypto/v1/_encrypt
Encrypts the given input value/s OR values of the object.
b) POST /crypto/v1/_decrypt
Decrypts the given input value/s OR values of the object.
c) /crypto/v1/_sign
Provide signature for a given value.
d) POST /crypto/v1/_verify
Check if the signature is correct for the provided value.
e) POST /crypto/v1/_rotatekey
Deactivate the keys for the given tenant and generate new keys. It will deactivate both symmetric and asymmetric keys for the provided tenant.
Play around with the APIs : DIGIT-Playground
Last updated