Data encrypted at rest,
keys under Ranger policies.
Ranger KMS creates and stores the keys of the HDFS encryption zones, and access to them is authorized by Ranger policies and audited. Follow a file in an encryption zone and learn the service architecture and the layered keys.
Ranger KMS is the KMS for transparent encryption in HDFS: it stores the encryption keys of the encryption zones, and access to them is decided by Ranger policies.
In HDFS
One key per zone
Each HDFS encryption zone has a key, stored in the KMS, and each file in the zone also has its own data encryption key.
End to end
Only the client decrypts
HDFS stores only encrypted data and encrypted data encryption keys. The client does the decryption, after obtaining the key from the KMS.
In Ranger
Under policy and audit
Access to the keys is authorized by Ranger policies, and KMS operations are recorded in the audit.
On this page
- See an encrypted file
- Architecture
- The layered keys
- Who decides access
- Why Ranger KMS
- In the TDP editions
See an encrypted file
Press Play or step through. Underlined names lead to the Glossary.
1 One zone, one key
Before any file exists, the administrator creates a key in the KMS and an encryption zone in an HDFS directory, linked to that key. The zone has a single key, and everything written inside it is encrypted.
In the Glossary: NameNode · Zone key · Encryption zone · Encryption key
- One zone, one key. Before any file exists, the administrator creates a key in the KMS and an encryption zone in an HDFS directory, linked to that key. The zone has a single key, and everything written inside it is encrypted.
- The client creates a file in the zone. For the application, nothing changes: the client asks the NameNode to create the file, as in any HDFS directory.
- The NameNode asks the KMS for an EDEK. Each file in the zone has its own data encryption key, the DEK. The NameNode asks the KMS to generate one: the KMS creates a random key, encrypts it with the zone key, and returns only the encrypted version, the EDEK. The NameNode stores it in the file metadata.
- The client receives the EDEK. The NameNode hands the client the file's EDEK and the version of the zone key that encrypted it. HDFS handles only EDEKs: the plaintext DEK never passes through it.
- The KMS checks the permission and decrypts. The client asks the KMS to decrypt the EDEK, and the KMS first checks whether the client has permission on the zone key version. In Ranger KMS, this permission comes from Ranger policies, which the KMS plugin fetches from Ranger Admin and caches. If permission is granted, the KMS returns the DEK to the client.
- The client encrypts and decrypts. The DataNodes only store. With the DEK, the client itself encrypts what it writes and decrypts what it reads. The DataNodes receive and store only encrypted bytes, which is what protects the data at rest and in transit.
- Every operation is recorded. The KMS records the operations on the keys in the Ranger audit, and the destinations of the records, such as Solr and HDFS, are configurable in Ambari.
Architecture
The KMS stores the keys; HDFS only calls it; Ranger decides and records.
What the figure shows:
- The HDFS client encrypts and decrypts the data. It creates and reads files on the NameNode and asks Ranger KMS to decrypt the EDEK.
- The NameNode stores the EDEK of each file and asks Ranger KMS to generate it.
- The DataNodes receive only encrypted bytes.
- The Ranger KMS Server answers through a REST API over HTTP: this is how the NameNode and the HDFS clients talk to the KMS.
- The zone keys are stored in the KMS, one per encryption zone.
- The Ranger plugin in the KMS fetches the key access policies from Ranger Admin and keeps a local copy.
- The master key, from which the encryption keys are created, is stored in the KMS database or, optionally, in an HSM.
- Ranger Admin provides the key access policies.
- Kerberos can authenticate access to the KMS.
- The audit receives the records of the KMS operations, with destinations such as Solr and HDFS.
HDFS points to the KMS through a KeyProvider.
The layered keys
Each key protects the next, from the master key to the file content. Go into a level to see what it holds.
Level 1 of 4
Master key
The key from which the KMS creates the encryption keys. It is stored in the KMS database or, optionally, in an HSM.
- HSMA security device dedicated to storing keys, an alternative to the KMS database for storing the master key.
- Master key. The key from which the KMS creates the encryption keys. It is stored in the KMS database or, optionally, in an HSM.
- HSM. A security device dedicated to storing keys, an alternative to the KMS database for storing the master key.
- Zone key. Each encryption zone has a single key, chosen when the zone is created. The key has a unique name and, when it is rolled over, gets a new version.
- Key version. Each version has its own material. A file's EDEK stays associated with the version that encrypted it.
- Nested zone. Inside a zone it is possible to create others, with different keys. A file's EDEK uses the key of the nearest ancestor zone.
- Data encryption key (DEK). Each file in the zone has its own DEK. The client uses it to encrypt what it writes and decrypt what it reads.
- EDEK. The DEK encrypted with the zone key. The EDEK is what HDFS stores, in the file metadata. The KMS generates and decrypts it.
- File content. What the client writes reaches HDFS encrypted. The DataNodes see only a stream of encrypted bytes.
- DataNode. Stores the encrypted bytes and never has access to plaintext data or data encryption keys.
Who decides access
Access to the data and access to the keys are decided in different places.
Who reads, writes, and lists the data and metadata of an encryption zone is decided by the normal HDFS permissions.
Who uses the zone keys is decided by the KMS, with its own permissions. In Ranger KMS, these permissions are Ranger policies, maintained in Ranger Admin.
Whoever gains access to an HDFS superuser account reaches only the encrypted content and the EDEKs. The keys remain under other permissions, in the KMS and in the key store.
Why Ranger KMS
Transparent
No application changes
Data read from and written to the encryption zones is encrypted and decrypted without changing the application code.
End to end
At rest and in transit
Only the client encrypts and decrypts. HDFS never stores or accesses plaintext data or data encryption keys, and the data stays encrypted on disk and on the network.
Granularity
One key per zone, one per file
Each zone has its own key, each file has its own DEK, and zones can be nested with different keys.
Central administration
Keys and permissions in Ranger
Keys can be created, rolled over, and listed through the Ranger Admin REST API or the hadoop key command line, and the permissions on them are Ranger policies.
Master key
In the database or in an HSM
The master key can be stored in the KMS database or in an HSM, with a utility to migrate it from one to the other.
Availability
One or more servers
The service supports one or more servers, and clients can switch between them or use a load balancer.
HDFS transparent encryption needs a key service in the cluster: the Hadoop KMS, a server based on the Hadoop KeyProvider API that HDFS queries as a client. In TDP Datacenter, Ranger KMS takes this place and is administered by Ranger.
In the TDP editions
| Edition | Version | Documentation |
|---|---|---|
| TDP Datacenter | 2.4.0 | TDP Datacenter components |
In TDP Datacenter
In TDP Datacenter, Ranger KMS is the RANGER_KMS service, installed and managed by Ambari.
RANGER_KMS_SERVER (master, one or more). The RANGER_KMS_SERVER requires HDFS_CLIENT (HDFS). Component category.
The KMS database is configurable in kms-properties (DB_FLAVOR, db_host, db_name, and db_user), and the creation of the database and user by Ambari, in create_db_user (kms-env). In the documented installation, Ranger KMS uses its own PostgreSQL database.
The master key password is configurable in KMS_MASTER_KEY_PASSWD (kms-properties) and in ranger.db.encrypt.key.password (dbks-site). The HSM can be enabled in ranger.ks.hsm.enabled, with the type in ranger.ks.hsm.type, and the Keysecure integration in ranger.kms.keysecure.enabled (dbks-site).
The KMS KeyProvider is configurable in hadoop.kms.key.provider.uri (kms-site). In HDFS, the provider for the encryption zones is set in dfs.encryption.key.provider.uri (hdfs-site) and in hadoop.security.key.provider.path (core-site).
The cache of the KMS keys and metadata can be enabled in hadoop.kms.cache.enable, and the expiration times are configurable in hadoop.kms.cache.timeout.ms and hadoop.kms.current.key.cache.timeout.ms (kms-site).
The KMS authentication type is configurable in hadoop.kms.authentication.type, with the HTTP endpoint principal in hadoop.kms.authentication.kerberos.principal (kms-site) and the service principal and keytab in ranger.ks.kerberos.principal and ranger.ks.kerberos.keytab (dbks-site). See Kerberos.
The Ranger plugin in the KMS fetches the policies from Ranger Admin, in ranger.plugin.kms.policy.rest.url, for the Ranger service set in ranger.plugin.kms.service.name. The polling interval and the local copy directory are configurable in ranger.plugin.kms.policy.pollIntervalMs and ranger.plugin.kms.policy.cache.dir (ranger-kms-security). See Ranger.
The destinations are configurable in ranger-kms-audit, such as Solr (xasecure.audit.destination.solr) and HDFS (xasecure.audit.destination.hdfs), and the window that groups repeated records, in hadoop.kms.audit.aggregation.window.ms (kms-site). See Security in TDP Datacenter.
The user, group, port, maximum memory, and log directory of the service are configurable in kms_user, kms_group, kms_port, ranger_kms_max_heap_size, and kms_log_dir (kms-env).
HDFS uses the KMS in the encryption zones. See Security in TDP Datacenter.
Next steps
TDP Datacenter
TDP Datacenter Architecture
The services of the Ambari-managed cluster and how they relate.
TDP Datacenter
Security in TDP Datacenter
Kerberos, Ranger, Knox, and the encryption keys in the cluster.