blob: 3f4f4a6b02e544eb53524602b1145803b2e6640a [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
| Generated by Apache Maven Doxia at 2023-03-15
| Rendered using Apache Maven Stylus Skin 1.5
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Apache Hadoop Amazon Web Services support &#x2013; Working with Encrypted S3 Data</title>
<style type="text/css" media="all">
@import url("../../css/maven-base.css");
@import url("../../css/maven-theme.css");
@import url("../../css/site.css");
</style>
<link rel="stylesheet" href="../../css/print.css" type="text/css" media="print" />
<meta name="Date-Revision-yyyymmdd" content="20230315" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class="composite">
<div id="banner">
<a href="http://hadoop.apache.org/" id="bannerLeft">
<img src="http://hadoop.apache.org/images/hadoop-logo.jpg" alt="" />
</a>
<a href="http://www.apache.org/" id="bannerRight">
<img src="http://www.apache.org/images/asf_logo_wide.png" alt="" />
</a>
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
<a href="http://www.apache.org/" class="externalLink">Apache</a>
&gt;
<a href="http://hadoop.apache.org/" class="externalLink">Hadoop</a>
&gt;
<a href="../../index.html">Apache Hadoop Amazon Web Services support</a>
&gt;
Working with Encrypted S3 Data
</div>
<div class="xright"> <a href="http://wiki.apache.org/hadoop" class="externalLink">Wiki</a>
|
<a href="https://gitbox.apache.org/repos/asf/hadoop.git" class="externalLink">git</a>
&nbsp;| Last Published: 2023-03-15
&nbsp;| Version: 3.3.5
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>General</h5>
<ul>
<li class="none">
<a href="../../../index.html">Overview</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/SingleCluster.html">Single Node Setup</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/ClusterSetup.html">Cluster Setup</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/CommandsManual.html">Commands Reference</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/FileSystemShell.html">FileSystem Shell</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/Compatibility.html">Compatibility Specification</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/DownstreamDev.html">Downstream Developer's Guide</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/AdminCompatibilityGuide.html">Admin Compatibility Guide</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/InterfaceClassification.html">Interface Classification</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/filesystem/index.html">FileSystem Specification</a>
</li>
</ul>
<h5>Common</h5>
<ul>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/CLIMiniCluster.html">CLI Mini Cluster</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/FairCallQueue.html">Fair Call Queue</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/NativeLibraries.html">Native Libraries</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/Superusers.html">Proxy User</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/RackAwareness.html">Rack Awareness</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/SecureMode.html">Secure Mode</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/ServiceLevelAuth.html">Service Level Authorization</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/HttpAuthentication.html">HTTP Authentication</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/CredentialProviderAPI.html">Credential Provider API</a>
</li>
<li class="none">
<a href="../../../hadoop-kms/index.html">Hadoop KMS</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/Tracing.html">Tracing</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/UnixShellGuide.html">Unix Shell Guide</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/registry/index.html">Registry</a>
</li>
</ul>
<h5>HDFS</h5>
<ul>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsDesign.html">Architecture</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsUserGuide.html">User Guide</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HDFSCommands.html">Commands Reference</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HDFSHighAvailabilityWithQJM.html">NameNode HA With QJM</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HDFSHighAvailabilityWithNFS.html">NameNode HA With NFS</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/ObserverNameNode.html">Observer NameNode</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/Federation.html">Federation</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/ViewFs.html">ViewFs</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/ViewFsOverloadScheme.html">ViewFsOverloadScheme</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsSnapshots.html">Snapshots</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsEditsViewer.html">Edits Viewer</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsImageViewer.html">Image Viewer</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsPermissionsGuide.html">Permissions and HDFS</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsQuotaAdminGuide.html">Quotas and HDFS</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/LibHdfs.html">libhdfs (C API)</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/WebHDFS.html">WebHDFS (REST API)</a>
</li>
<li class="none">
<a href="../../../hadoop-hdfs-httpfs/index.html">HttpFS</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/ShortCircuitLocalReads.html">Short Circuit Local Reads</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/CentralizedCacheManagement.html">Centralized Cache Management</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsNfsGateway.html">NFS Gateway</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsRollingUpgrade.html">Rolling Upgrade</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/ExtendedAttributes.html">Extended Attributes</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/TransparentEncryption.html">Transparent Encryption</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsMultihoming.html">Multihoming</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/ArchivalStorage.html">Storage Policies</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/MemoryStorage.html">Memory Storage Support</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/SLGUserGuide.html">Synthetic Load Generator</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HDFSErasureCoding.html">Erasure Coding</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HDFSDiskbalancer.html">Disk Balancer</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsUpgradeDomain.html">Upgrade Domain</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsDataNodeAdminGuide.html">DataNode Admin</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs-rbf/HDFSRouterFederation.html">Router Federation</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/HdfsProvidedStorage.html">Provided Storage</a>
</li>
</ul>
<h5>MapReduce</h5>
<ul>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html">Tutorial</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapredCommands.html">Commands Reference</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduce_Compatibility_Hadoop1_Hadoop2.html">Compatibility with 1.x</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/EncryptedShuffle.html">Encrypted Shuffle</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/PluggableShuffleAndPluggableSort.html">Pluggable Shuffle/Sort</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/DistributedCacheDeploy.html">Distributed Cache Deploy</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/SharedCacheSupport.html">Support for YARN Shared Cache</a>
</li>
</ul>
<h5>MapReduce REST APIs</h5>
<ul>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapredAppMasterRest.html">MR Application Master</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-hs/HistoryServerRest.html">MR History Server</a>
</li>
</ul>
<h5>YARN</h5>
<ul>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/YARN.html">Architecture</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/YarnCommands.html">Commands Reference</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/CapacityScheduler.html">Capacity Scheduler</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/FairScheduler.html">Fair Scheduler</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/ResourceManagerRestart.html">ResourceManager Restart</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html">ResourceManager HA</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/ResourceModel.html">Resource Model</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/NodeLabel.html">Node Labels</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/NodeAttributes.html">Node Attributes</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/WebApplicationProxy.html">Web Application Proxy</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/TimelineServer.html">Timeline Server</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/TimelineServiceV2.html">Timeline Service V.2</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/WritingYarnApplications.html">Writing YARN Applications</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/YarnApplicationSecurity.html">YARN Application Security</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/NodeManager.html">NodeManager</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/DockerContainers.html">Running Applications in Docker Containers</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/RuncContainers.html">Running Applications in runC Containers</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/NodeManagerCgroups.html">Using CGroups</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/SecureContainer.html">Secure Containers</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/ReservationSystem.html">Reservation System</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/GracefulDecommission.html">Graceful Decommission</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/OpportunisticContainers.html">Opportunistic Containers</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/Federation.html">YARN Federation</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/SharedCache.html">Shared Cache</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/UsingGpus.html">Using GPU</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/UsingFPGA.html">Using FPGA</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/PlacementConstraints.html">Placement Constraints</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/YarnUI2.html">YARN UI2</a>
</li>
</ul>
<h5>YARN REST APIs</h5>
<ul>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/WebServicesIntro.html">Introduction</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/ResourceManagerRest.html">Resource Manager</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/NodeManagerRest.html">Node Manager</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/TimelineServer.html#Timeline_Server_REST_API_v1">Timeline Server</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/TimelineServiceV2.html#Timeline_Service_v.2_REST_API">Timeline Service V.2</a>
</li>
</ul>
<h5>YARN Service</h5>
<ul>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/yarn-service/Overview.html">Overview</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/yarn-service/QuickStart.html">QuickStart</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/yarn-service/Concepts.html">Concepts</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/yarn-service/YarnServiceAPI.html">Yarn Service API</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/yarn-service/ServiceDiscovery.html">Service Discovery</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-site/yarn-service/SystemServices.html">System Services</a>
</li>
</ul>
<h5>Hadoop Compatible File Systems</h5>
<ul>
<li class="none">
<a href="../../../hadoop-aliyun/tools/hadoop-aliyun/index.html">Aliyun OSS</a>
</li>
<li class="none">
<a href="../../../hadoop-aws/tools/hadoop-aws/index.html">Amazon S3</a>
</li>
<li class="none">
<a href="../../../hadoop-azure/index.html">Azure Blob Storage</a>
</li>
<li class="none">
<a href="../../../hadoop-azure-datalake/index.html">Azure Data Lake Storage</a>
</li>
<li class="none">
<a href="../../../hadoop-cos/cloud-storage/index.html">Tencent COS</a>
</li>
</ul>
<h5>Auth</h5>
<ul>
<li class="none">
<a href="../../../hadoop-auth/index.html">Overview</a>
</li>
<li class="none">
<a href="../../../hadoop-auth/Examples.html">Examples</a>
</li>
<li class="none">
<a href="../../../hadoop-auth/Configuration.html">Configuration</a>
</li>
<li class="none">
<a href="../../../hadoop-auth/BuildingIt.html">Building</a>
</li>
</ul>
<h5>Tools</h5>
<ul>
<li class="none">
<a href="../../../hadoop-streaming/HadoopStreaming.html">Hadoop Streaming</a>
</li>
<li class="none">
<a href="../../../hadoop-archives/HadoopArchives.html">Hadoop Archives</a>
</li>
<li class="none">
<a href="../../../hadoop-archive-logs/HadoopArchiveLogs.html">Hadoop Archive Logs</a>
</li>
<li class="none">
<a href="../../../hadoop-distcp/DistCp.html">DistCp</a>
</li>
<li class="none">
<a href="../../../hadoop-gridmix/GridMix.html">GridMix</a>
</li>
<li class="none">
<a href="../../../hadoop-rumen/Rumen.html">Rumen</a>
</li>
<li class="none">
<a href="../../../hadoop-resourceestimator/ResourceEstimator.html">Resource Estimator Service</a>
</li>
<li class="none">
<a href="../../../hadoop-sls/SchedulerLoadSimulator.html">Scheduler Load Simulator</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/Benchmarking.html">Hadoop Benchmarking</a>
</li>
<li class="none">
<a href="../../../hadoop-dynamometer/Dynamometer.html">Dynamometer</a>
</li>
</ul>
<h5>Reference</h5>
<ul>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/release/">Changelog and Release Notes</a>
</li>
<li class="none">
<a href="../../../api/index.html">Java API docs</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/UnixShellAPI.html">Unix Shell API</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/Metrics.html">Metrics</a>
</li>
</ul>
<h5>Configuration</h5>
<ul>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/core-default.xml">core-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs/hdfs-default.xml">hdfs-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-hdfs-rbf/hdfs-rbf-default.xml">hdfs-rbf-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xml">mapred-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-yarn/hadoop-yarn-common/yarn-default.xml">yarn-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-kms/kms-default.html">kms-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-hdfs-httpfs/httpfs-default.html">httpfs-default.xml</a>
</li>
<li class="none">
<a href="../../../hadoop-project-dist/hadoop-common/DeprecatedProperties.html">Deprecated Properties</a>
</li>
</ul>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img alt="Built by Maven" src="../../images/logos/maven-feather.png"/>
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<!---
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<h1>Working with Encrypted S3 Data</h1>
<ul>
<li><a href="#Introduction"> Introduction</a></li>
<li><a href="#How_data_is_encrypted">How data is encrypted</a></li>
<li><a href="#S3_Default_Encryption"> S3 Default Encryption</a></li>
<li><a href="#SSE-S3_Amazon_S3-Managed_Encryption_Keys"> SSE-S3 Amazon S3-Managed Encryption Keys</a>
<ul>
<li><a href="#Enabling_SSE-S3">Enabling SSE-S3</a></li>
<li><a href="#SSE-KMS:_Server-Encryption_with_KMS_Managed_Encryption_Keys"> SSE-KMS: Server-Encryption with KMS Managed Encryption Keys</a></li>
<li><a href="#Enabling_SSE-KMS">Enabling SSE-KMS</a></li>
<li><a href="#the_S3A_fs.s3a.encryption.key_key_only_affects_created_files">the S3A fs.s3a.encryption.key key only affects created files</a></li></ul></li>
<li><a href="#SSE-C:_Server_side_encryption_with_a_client-supplied_key."> SSE-C: Server side encryption with a client-supplied key.</a>
<ul>
<li><a href="#Enabling_SSE-C">Enabling SSE-C</a></li>
<li><a href="#The_fs.s3a.encryption.key_value_is_used_to_read_and_write_data">The fs.s3a.encryption.key value is used to read and write data</a></li>
<li><a href="#SSE-C_Warning">SSE-C Warning</a></li></ul></li>
<li><a href="#Encryption_best_practises"> Encryption best practises</a>
<ul>
<li><a href="#Mandate_encryption_through_policies"> Mandate encryption through policies</a></li>
<li><a href="#Use_S3a_per-bucket_configuration_to_control_encryption_settings"> Use S3a per-bucket configuration to control encryption settings</a></li>
<li><a href="#Using_hadoop_fs_-getfattr_to_view_encryption_information."> Using hadoop fs -getfattr to view encryption information.</a></li>
<li><a href="#Use_rename.28.29_to_encrypt_files_with_new_keys"> Use rename() to encrypt files with new keys</a></li></ul></li>
<li><a href="#Amazon_S3_Client_Side_Encryption"> Amazon S3 Client Side Encryption</a>
<ul>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Features">Features</a></li>
<li><a href="#Limitations">Limitations</a></li>
<li><a href="#Setup">Setup</a></li></ul></li>
<li><a href="#Troubleshooting_Encryption"> Troubleshooting Encryption</a></li></ul>
<section>
<h2><a name="Introduction"></a><a name="introduction"></a> Introduction</h2>
<p>The S3A filesystem client supports Amazon S3&#x2019;s Server Side Encryption and Client Side Encryption for encrypting data at-rest.</p>
<p>For up to date information on the encryption mechanisms, read:</p>
<ul>
<li><a class="externalLink" href="https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html">Protecting data using server-side encryption</a></li>
<li><a class="externalLink" href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingClientSideEncryption.html">Protecting data using client-side encryption</a></li>
</ul>
<p>When configuring an encryption method in the <code>core-site.xml</code>, this will apply cluster wide. Any new file written will be encrypted with this encryption configuration. When the S3A client reads a file, S3 will attempt to decrypt it using the mechanism and keys with which the file was encrypted.</p>
<ul>
<li>It is <b>NOT</b> advised to mix and match encryption types in a bucket.</li>
<li>It is much simpler and safer to encrypt with just one type and key per bucket.</li>
<li>You can use AWS bucket policies to mandate encryption rules for a bucket.</li>
<li>You can use S3A per-bucket configuration to ensure that S3A clients use encryption policies consistent with the mandated rules.</li>
<li>You can use S3 Default Encryption in AWS console to encrypt data without needing to set anything in the client.</li>
<li>Changing the encryption options on the client does not change how existing files were encrypted, except when the files are renamed.</li>
<li>For all mechanisms other than SSE-C and CSE-KMS, clients do not need any configuration options set in order to read encrypted data: it is all automatically handled in S3 itself.</li>
<li>Encryption options and secrets are collected by <a href="delegation_tokens.html">S3A Delegation Tokens</a> and passed to workers during job submission.</li>
<li>Encryption options and secrets MAY be stored in JCEKS files or any other Hadoop credential provider service. This allows for more secure storage than XML files, including password protection of the secrets.</li>
</ul></section><section>
<h2><a name="How_data_is_encrypted"></a><a name="encryption_types"></a>How data is encrypted</h2>
<p>AWS S3 supports server-side encryption inside the storage system itself. When an S3 client uploading data requests data to be encrypted, then an encryption key is used to encrypt the data as it saved to S3. It remains encrypted on S3 until deleted: clients cannot change the encryption attributes of an object once uploaded.</p>
<p>The Amazon AWS SDK also offers client-side encryption, in which all the encoding and decoding of data is performed on the client.</p>
<p>The server-side &#x201c;SSE&#x201d; encryption is performed with symmetric AES256 encryption; S3 offers different mechanisms for actually defining the key to use.</p>
<p>There are four key management mechanisms, which in order of simplicity of use, are:</p>
<ul>
<li>S3 Default Encryption</li>
<li>SSE-S3: an AES256 key is generated in S3, and saved alongside the data.</li>
<li>SSE-KMS: an AES256 key is generated in S3, and encrypted with a secret key provided by Amazon&#x2019;s Key Management Service, a key referenced by name in the uploading client.</li>
<li>SSE-C : the client specifies an actual base64 encoded AES-256 key to be used to encrypt and decrypt the data.</li>
</ul>
<p>Encryption options</p>
<table border="0" class="bodyTable">
<thead>
<tr class="a">
<th> type </th>
<th> encryption </th>
<th> config on write </th>
<th> config on read </th></tr>
</thead><tbody>
<tr class="b">
<td> <code>SSE-S3</code> </td>
<td> server side, AES256 </td>
<td> encryption algorithm </td>
<td> none </td></tr>
<tr class="a">
<td> <code>SSE-KMS</code> </td>
<td> server side, KMS key </td>
<td> key used to encrypt/decrypt </td>
<td> none </td></tr>
<tr class="b">
<td> <code>SSE-C</code> </td>
<td> server side, custom key </td>
<td> encryption algorithm and secret </td>
<td> encryption algorithm and secret </td></tr>
<tr class="a">
<td> <code>CSE-KMS</code> </td>
<td> client side, KMS key </td>
<td> encryption algorithm and key ID </td>
<td> encryption algorithm </td></tr>
</tbody>
</table>
<p>With server-side encryption, the data is uploaded to S3 unencrypted (but wrapped by the HTTPS encryption channel). The data is encrypted in the S3 store and decrypted when it&#x2019;s being retrieved.</p>
<p>A server side algorithm can be enabled by default for a bucket, so that whenever data is uploaded unencrypted a default encryption algorithm is added. When data is encrypted with S3-SSE or SSE-KMS it is transparent to all clients downloading the data. SSE-C is different in that every client must know the secret key needed to decypt the data.</p>
<p>Working with SSE-C data is harder because every client must be configured to use the algorithm and supply the key. In particular, it is very hard to mix SSE-C encrypted objects in the same S3 bucket with objects encrypted with other algorithms or unencrypted; The S3A client (and other applications) get very confused.</p>
<p>KMS-based key encryption is powerful as access to a key can be restricted to specific users/IAM roles. However, use of the key is billed and can be throttled. Furthermore as a client seeks around a file, the KMS key <i>may</i> be used multiple times.</p>
<p>S3 Client side encryption (CSE-KMS) is an experimental feature added in July 2021.</p>
<p>This encrypts the data on the client, before transmitting to S3, where it is stored encrypted. The data is unencrypted after downloading when it is being read back.</p>
<p>In CSE-KMS, the ID of an AWS-KMS key is provided to the S3A client; the client communicates with AWS-KMS to request a new encryption key, which KMS returns along with the same key encrypted with the KMS key. The S3 client encrypts the payload <i>and</i> attaches the KMS-encrypted version of the key as a header to the object.</p>
<p>When downloading data, this header is extracted, passed to AWS KMS, and, if the client has the appropriate permissions, the symmetric key is retrieved. This key is then used to decode the data.</p></section><section>
<h2><a name="S3_Default_Encryption"></a><a name="sse-s3"></a> S3 Default Encryption</h2>
<p>This feature allows the administrators of the AWS account to set the &#x201c;default&#x201d; encryption policy on a bucket -the encryption to use if the client does not explicitly declare an encryption algorithm.</p>
<p><a class="externalLink" href="https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html">S3 Default Encryption for S3 Buckets</a></p>
<p>This supports SSE-S3 and SSE-KMS.</p>
<p>There is no need to set anything up in the client: do it in the AWS console.</p></section><section>
<h2><a name="SSE-S3_Amazon_S3-Managed_Encryption_Keys"></a><a name="sse-s3"></a> SSE-S3 Amazon S3-Managed Encryption Keys</h2>
<p>In SSE-S3, all keys and secrets are managed inside S3. This is the simplest encryption mechanism. There is no extra cost for storing data with this option.</p><section>
<h3><a name="Enabling_SSE-S3"></a>Enabling SSE-S3</h3>
<p>To write S3-SSE encrypted files, the value of <code>fs.s3a.encryption.algorithm</code> must be set to that of the encryption mechanism used in <code>core-site</code>; currently only <code>AES256</code> is supported.</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.algorithm&lt;/name&gt;
&lt;value&gt;AES256&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
<p>Once set, all new data will be stored encrypted. There is no need to set this property when downloading data &#x2014; the data will be automatically decrypted when read using the Amazon S3-managed key.</p>
<p>To learn more, refer to <a class="externalLink" href="http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html">Protecting Data Using Server-Side Encryption with Amazon S3-Managed Encryption Keys (SSE-S3) in AWS documentation</a>.</p></section><section>
<h3><a name="SSE-KMS:_Server-Encryption_with_KMS_Managed_Encryption_Keys"></a><a name="sse-kms"></a> SSE-KMS: Server-Encryption with KMS Managed Encryption Keys</h3>
<p>Amazon offers a pay-per-use key management service, <a class="externalLink" href="https://aws.amazon.com/documentation/kms/">AWS KMS</a>. This service can be used to encrypt data on S3 by defining &#x201c;customer master keys&#x201d;, CMKs, which can be centrally managed and assigned to specific roles and IAM accounts.</p>
<p>The AWS KMS <a class="externalLink" href="http://docs.aws.amazon.com/kms/latest/developerguide/services-s3.html">can be used encrypt data on S3uploaded data</a>.</p>
<blockquote>
<p>The AWS KMS service is <b>not</b> related to the Key Management Service built into Hadoop (<i>Hadoop KMS</i>). The <i>Hadoop KMS</i> primarily focuses on managing keys for <i>HDFS Transparent Encryption</i>. Similarly, HDFS encryption is unrelated to S3 data encryption.</p>
</blockquote>
<p>When uploading data encrypted with SSE-KMS, the sequence is as follows.</p>
<ol style="list-style-type: decimal">
<li>
<p>The S3A client must declare a specific CMK in the property <code>fs.s3a.encryption.key</code>, or leave it blank to use the default configured for that region.</p>
</li>
<li>
<p>The S3A client uploads all the data as normal, now including encryption information.</p>
</li>
<li>
<p>The S3 service encrypts the data with a symmetric key unique to the new object.</p>
</li>
<li>
<p>The S3 service retrieves the chosen CMK key from the KMS service, and, if the user has the right to use it, uses it to encrypt the object-specific key.</p>
</li>
</ol>
<p>When downloading SSE-KMS encrypted data, the sequence is as follows</p>
<ol style="list-style-type: decimal">
<li>The S3A client issues an HTTP GET request to read the data.</li>
<li>S3 sees that the data was encrypted with SSE-KMS, and looks up the specific key in the KMS service</li>
<li>If and only if the requesting user has been granted permission to use the CMS key does the KMS service provide S3 with the key.</li>
<li>As a result, S3 will only decode the data if the user has been granted access to the key.</li>
</ol>
<p>KMS keys can be managed by an organization&#x2019;s administrators in AWS, including having access permissions assigned and removed from specific users, groups, and IAM roles. Only those &#x201c;principals&#x201d; with granted rights to a key may access it, hence only they may encrypt data with the key, <i>and decrypt data encrypted with it</i>. This allows KMS to be used to provide a cryptographically secure access control mechanism for data stores on S3.</p>
<p>Each KMS server is region specific, and accordingly, so is each CMK configured. A CMK defined in one region cannot be used with an S3 bucket in a different region.</p>
<p>Notes</p>
<ul>
<li>Callers are charged for every use of a key, both for encrypting the data in uploads and for decrypting it when reading it back.</li>
<li>Random-access IO on files may result in multiple GET requests of an object during a read sequence (especially for columnar data), so may require more than one key retrieval to process a single file,</li>
<li>The KMS service is throttled: too many requests may cause requests to fail.</li>
<li>As well as incurring charges, heavy I/O <i>may</i> reach IO limits for a customer. If those limits are reached, they can be increased through the AWS console.</li>
</ul></section><section>
<h3><a name="Enabling_SSE-KMS"></a>Enabling SSE-KMS</h3>
<p>To enable SSE-KMS, the property <code>fs.s3a.encryption.algorithm</code> must be set to <code>SSE-KMS</code> in <code>core-site</code>:</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.algorithm&lt;/name&gt;
&lt;value&gt;SSE-KMS&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
<p>The ID of the specific key used to encrypt the data should also be set in the property <code>fs.s3a.encryption.key</code>:</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.key&lt;/name&gt;
&lt;value&gt;arn:aws:kms:us-west-2:360379543683:key/071a86ff-8881-4ba0-9230-95af6d01ca01&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
<p>Organizations may define a default key in the Amazon KMS; if a default key is set, then it will be used whenever SSE-KMS encryption is chosen and the value of <code>fs.s3a.encryption.key</code> is empty.</p></section><section>
<h3><a name="the_S3A_fs.s3a.encryption.key_key_only_affects_created_files"></a>the S3A <code>fs.s3a.encryption.key</code> key only affects created files</h3>
<p>With SSE-KMS, the S3A client option <code>fs.s3a.encryption.key</code> sets the key to be used when new files are created. When reading files, this key, and indeed the value of <code>fs.s3a.encryption.algorithm</code> is ignored: S3 will attempt to retrieve the key and decrypt the file based on the create-time settings.</p>
<p>This means that</p>
<ul>
<li>There&#x2019;s no need to configure any client simply reading data.</li>
<li>It is possible for a client to read data encrypted with one KMS key, and write it with another.</li>
</ul></section></section><section>
<h2><a name="SSE-C:_Server_side_encryption_with_a_client-supplied_key."></a><a name="sse-c"></a> SSE-C: Server side encryption with a client-supplied key.</h2>
<p>In SSE-C, the client supplies the secret key needed to read and write data. Every client trying to read or write data must be configured with the same secret key.</p>
<p>SSE-C integration with Hadoop is still stabilizing; issues related to it are still surfacing. It is already clear that SSE-C with a common key <b>must</b> be used exclusively within a bucket if it is to be used at all. This is the only way to ensure that path and directory listings do not fail with &#x201c;Bad Request&#x201d; errors.</p><section>
<h3><a name="Enabling_SSE-C"></a>Enabling SSE-C</h3>
<p>To use SSE-C, the configuration option <code>fs.s3a.encryption.algorithm</code> must be set to <code>SSE-C</code>, and a base-64 encoding of the key placed in <code>fs.s3a.encryption.key</code>.</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.algorithm&lt;/name&gt;
&lt;value&gt;SSE-C&lt;/value&gt;
&lt;/property&gt;
&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.key&lt;/name&gt;
&lt;value&gt;SGVscCwgSSdtIHRyYXBwZWQgaW5zaWRlIGEgYmFzZS02NC1jb2RlYyE=&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
<p>All clients must share this same key.</p></section><section>
<h3><a name="The_fs.s3a.encryption.key_value_is_used_to_read_and_write_data"></a>The <code>fs.s3a.encryption.key</code> value is used to read and write data</h3>
<p>With SSE-C, the S3A client option <code>fs.s3a.encryption.key</code> sets the key to be used for both reading <i>and</i> writing data.</p>
<p>When reading any file written with SSE-C, the same key must be set in the property <code>fs.s3a.encryption.key</code>.</p>
<p>This is unlike SSE-S3 and SSE-KMS, where the information needed to decode data is kept in AWS infrastructure.</p></section><section>
<h3><a name="SSE-C_Warning"></a>SSE-C Warning</h3>
<p>You need to fully understand how SSE-C works in the S3 environment before using this encryption type. Please refer to the Server Side Encryption documentation available from AWS. SSE-C is only recommended for advanced users with advanced encryption use cases. Failure to properly manage encryption keys can cause data loss. Currently, the AWS S3 API(and thus S3A) only supports one encryption key and cannot support decrypting objects during moves under a previous key to a new destination. It is <b>NOT</b> advised to use multiple encryption keys in a bucket, and is recommended to use one key per bucket and to not change this key. This is due to when a request is made to S3, the actual encryption key must be provided to decrypt the object and access the metadata. Since only one encryption key can be provided at a time, S3A will not pass the correct encryption key to decrypt the data.</p></section></section><section>
<h2><a name="Encryption_best_practises"></a><a name="best_practises"></a> Encryption best practises</h2><section>
<h3><a name="Mandate_encryption_through_policies"></a><a name="bucket_policy"></a> Mandate encryption through policies</h3>
<p>Because it is up to the clients to enable encryption on new objects, all clients must be correctly configured in order to guarantee that data is encrypted.</p>
<p>To mandate that all data uploaded to a bucket is encrypted, you can set a <a class="externalLink" href="https://aws.amazon.com/blogs/security/how-to-prevent-uploads-of-unencrypted-objects-to-amazon-s3/">bucket policy</a> declaring that clients must provide encryption information with all data uploaded.</p>
<ul>
<li>Mandating an encryption mechanism on newly uploaded data does not encrypt existing data; existing data will retain whatever encryption (if any) applied at the time of creation*</li>
</ul>
<p>Here is a policy to mandate <code>SSE-S3/AES265</code> encryption on all data uploaded to a bucket. This covers uploads as well as the copy operations which take place when file/directory rename operations are mimicked.</p>
<div class="source">
<div class="source">
<pre>{
&quot;Version&quot;: &quot;2012-10-17&quot;,
&quot;Id&quot;: &quot;EncryptionPolicy&quot;,
&quot;Statement&quot;: [
{
&quot;Sid&quot;: &quot;RequireEncryptionHeaderOnPut&quot;,
&quot;Effect&quot;: &quot;Deny&quot;,
&quot;Principal&quot;: &quot;*&quot;,
&quot;Action&quot;: [
&quot;s3:PutObject&quot;
],
&quot;Resource&quot;: &quot;arn:aws:s3:::BUCKET/*&quot;,
&quot;Condition&quot;: {
&quot;Null&quot;: {
&quot;s3:x-amz-server-side-encryption&quot;: true
}
}
},
{
&quot;Sid&quot;: &quot;RequireAESEncryptionOnPut&quot;,
&quot;Effect&quot;: &quot;Deny&quot;,
&quot;Principal&quot;: &quot;*&quot;,
&quot;Action&quot;: [
&quot;s3:PutObject&quot;
],
&quot;Resource&quot;: &quot;arn:aws:s3:::BUCKET/*&quot;,
&quot;Condition&quot;: {
&quot;StringNotEquals&quot;: {
&quot;s3:x-amz-server-side-encryption&quot;: &quot;AES256&quot;
}
}
}
]
}
</pre></div></div>
<p>To use SSE-KMS, a different restriction must be defined:</p>
<div class="source">
<div class="source">
<pre>{
&quot;Version&quot;: &quot;2012-10-17&quot;,
&quot;Id&quot;: &quot;EncryptionPolicy&quot;,
&quot;Statement&quot;: [
{
&quot;Sid&quot;: &quot;RequireEncryptionHeaderOnPut&quot;,
&quot;Effect&quot;: &quot;Deny&quot;,
&quot;Principal&quot;: &quot;*&quot;,
&quot;Action&quot;: [
&quot;s3:PutObject&quot;
],
&quot;Resource&quot;: &quot;arn:aws:s3:::BUCKET/*&quot;,
&quot;Condition&quot;: {
&quot;Null&quot;: {
&quot;s3:x-amz-server-side-encryption&quot;: true
}
}
},
{
&quot;Sid&quot;: &quot;RequireKMSEncryptionOnPut&quot;,
&quot;Effect&quot;: &quot;Deny&quot;,
&quot;Principal&quot;: &quot;*&quot;,
&quot;Action&quot;: [
&quot;s3:PutObject&quot;
],
&quot;Resource&quot;: &quot;arn:aws:s3:::BUCKET/*&quot;,
&quot;Condition&quot;: {
&quot;StringNotEquals&quot;: {
&quot;s3:x-amz-server-side-encryption&quot;: &quot;SSE-KMS&quot;
}
}
}
]
}
</pre></div></div>
<p>To use one of these policies:</p>
<ol style="list-style-type: decimal">
<li>Replace <code>BUCKET</code> with the specific name of the bucket being secured.</li>
<li>Locate the bucket in the AWS console <a class="externalLink" href="https://console.aws.amazon.com/s3/home">S3 section</a>.</li>
<li>Select the &#x201c;Permissions&#x201d; tab.</li>
<li>Select the &#x201c;Bucket Policy&#x201d; tab in the permissions section.</li>
<li>Paste the edited policy into the form.</li>
<li>Save the policy.</li>
</ol></section><section>
<h3><a name="Use_S3a_per-bucket_configuration_to_control_encryption_settings"></a><a name="per_bucket_config"></a> Use S3a per-bucket configuration to control encryption settings</h3>
<p>In an organisation which has embraced S3 encryption, different buckets inevitably have different encryption policies, such as different keys for SSE-KMS encryption. In particular, as different keys need to be named for different regions, unless you rely on the administrator-managed &#x201c;default&#x201d; key for each S3 region, you will need unique keys.</p>
<p>S3A&#x2019;s per-bucket configuration enables this.</p>
<p>Here, for example, are settings for a bucket in London, <code>london-stats</code>:</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.bucket.london-stats.server-side-encryption-algorithm&lt;/name&gt;
&lt;value&gt;AES256&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
<p>This requests SSE-S; if matched with a bucket policy then all data will be encrypted as it is uploaded.</p>
<p>A different bucket can use a different policy (here SSE-KMS) and, when necessary, declare a key.</p>
<p>Here is an example bucket in S3 Ireland, which uses SSE-KMS and a KMS key hosted in the AWS-KMS service in the same region.</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.bucket.ireland-dev.server-side-encryption-algorithm&lt;/name&gt;
&lt;value&gt;SSE-KMS&lt;/value&gt;
&lt;/property&gt;
&lt;property&gt;
&lt;name&gt;fs.s3a.bucket.ireland-dev.server-side-encryption.key&lt;/name&gt;
&lt;value&gt;arn:aws:kms:eu-west-1:98067faff834c:key/071a86ff-8881-4ba0-9230-95af6d01ca01&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
<p>Again the appropriate bucket policy can be used to guarantee that all callers will use SSE-KMS; they can even mandate the name of the key used to encrypt the data, so guaranteeing that access to thee data can be read by everyone granted access to that key, and nobody without access to it.</p></section><section>
<h3><a name="Using_hadoop_fs_-getfattr_to_view_encryption_information."></a><a name="fattr"></a> Using <code>hadoop fs -getfattr</code> to view encryption information.</h3>
<p>The S3A client retrieves all HTTP headers from an object and returns them in the &#x201c;XAttr&#x201d; list of attributed, prefixed with <code>header.</code>. This makes them retrievable in the <code>getXAttr()</code> API calls, which is available on the command line through the <code>hadoop fs -getfattr -d</code> command.</p>
<p>This makes viewing the encryption headers of a file straightforward.</p>
<p>Here is an example of the operation invoked on a file where the client is using CSE-KMS:</p>
<div class="source">
<div class="source">
<pre>bin/hadoop fs -getfattr -d s3a://test-london/file2
2021-07-14 12:59:01,554 [main] WARN s3.AmazonS3EncryptionClientV2 (AmazonS3EncryptionClientV2.java:warnOnLegacyCryptoMode(409)) - The S3 Encryption Client is configured to read encrypted data with legacy encryption modes through the CryptoMode setting. If you don't have objects encrypted with these legacy modes, you should disable support for them to enhance security. See https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html
2021-07-14 12:59:01,558 [main] WARN s3.AmazonS3EncryptionClientV2 (AmazonS3EncryptionClientV2.java:warnOnRangeGetsEnabled(401)) - The S3 Encryption Client is configured to support range get requests. Range gets do not provide authenticated encryption properties even when used with an authenticated mode (AES-GCM). See https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html
# file: s3a://test-london/file2
header.Content-Length=&quot;0&quot;
header.Content-Type=&quot;application/octet-stream&quot;
header.ETag=&quot;63b3f4bd6758712c98f1be86afad095a&quot;
header.Last-Modified=&quot;Wed Jul 14 12:56:06 BST 2021&quot;
header.x-amz-cek-alg=&quot;AES/GCM/NoPadding&quot;
header.x-amz-iv=&quot;ZfrgtxvcR41yNVkw&quot;
header.x-amz-key-v2=&quot;AQIDAHjZrfEIkNG24/xy/pqPPLcLJulg+O5pLgbag/745OH4VQFuiRnSS5sOfqXJyIa4FOvNAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM7b5GZzD4eAGTC6gaAgEQgDte9Et/dhR7LAMU/NaPUZSgXWN5pRnM4hGHBiRNEVrDM+7+iotSTKxFco+VdBAzwFZfHjn0DOoSZEukNw==&quot;
header.x-amz-matdesc=&quot;{&quot;aws:x-amz-cek-alg&quot;:&quot;AES/GCM/NoPadding&quot;}&quot;
header.x-amz-server-side-encryption=&quot;AES256&quot;
header.x-amz-tag-len=&quot;128&quot;
header.x-amz-unencrypted-content-length=&quot;0&quot;
header.x-amz-version-id=&quot;zXccFCB9eICszFgqv_paG1pzaUKY09Xa&quot;
header.x-amz-wrap-alg=&quot;kms+context&quot;
</pre></div></div>
<p>Analysis</p>
<ol style="list-style-type: decimal">
<li>The WARN commands are the AWS SDK warning that because the S3A client uses an encryption algorithm which seek() requires, the SDK considers it less secure than the most recent algorithm(s). Ignore.</li>
</ol>
<ul>
<li><code>header.x-amz-server-side-encryption=&quot;AES256&quot;</code> : the file has been encrypted with S3-SSE. This is set up as the S3 default encryption, so even when CSE is enabled, the data is doubly encrypted.</li>
<li><code>header.x-amz-cek-alg=&quot;AES/GCM/NoPadding</code>: client-side encrypted with the <code>&quot;AES/GCM/NoPadding</code> algorithm.</li>
<li><code>header.x-amz-iv=&quot;ZfrgtxvcR41yNVkw&quot;</code>:</li>
<li><code>header.x-amz-key-v2=&quot;AQIDAHjZrfEIkNG24/xy/pqPPLcLJulg+O5pLgbag/745OH4VQFuiRnSS5sOfqXJyIa4FOvNAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM7b5GZzD4eAGTC6gaAgEQgDte9Et/dhR7LAMU/NaPUZSgXWN5pRnM4hGHBiRNEVrDM+7+iotSTKxFco+VdBAzwFZfHjn0DOoSZEukNw==&quot;</code>:</li>
<li><code>header.x-amz-unencrypted-content-length=&quot;0&quot;</code>: this is the length of the unencrypted data. The S3A client <i>DOES NOT</i> use this header;</li>
<li><code>header.x-amz-wrap-alg=&quot;kms+context&quot;</code>: the algorithm used to encrypt the CSE key it always removes 16 bytes from non-empty files when declaring the length.</li>
<li><code>header.x-amz-version-id=&quot;zXccFCB9eICszFgqv_paG1pzaUKY09Xa&quot;</code>: the bucket is versioned; this is the version ID.</li>
</ul>
<p>And a directory encrypted with S3-SSE only:</p>
<div class="source">
<div class="source">
<pre>bin/hadoop fs -getfattr -d s3a://test-london/user/stevel/target/test/data/sOCOsNgEjv
# file: s3a://test-london/user/stevel/target/test/data/sOCOsNgEjv
header.Content-Length=&quot;0&quot;
header.Content-Type=&quot;application/x-directory&quot;
header.ETag=&quot;d41d8cd98f00b204e9800998ecf8427e&quot;
header.Last-Modified=&quot;Tue Jul 13 20:12:07 BST 2021&quot;
header.x-amz-server-side-encryption=&quot;AES256&quot;
header.x-amz-version-id=&quot;KcDOVmznIagWx3gP1HlDqcZvm1mFWZ2a&quot;
</pre></div></div>
<p>A file with no-encryption (on a bucket without versioning but with intelligent tiering):</p>
<div class="source">
<div class="source">
<pre>bin/hadoop fs -getfattr -d s3a://landsat-pds/scene_list.gz
# file: s3a://landsat-pds/scene_list.gz
header.Content-Length=&quot;45603307&quot;
header.Content-Type=&quot;application/octet-stream&quot;
header.ETag=&quot;39c34d489777a595b36d0af5726007db&quot;
header.Last-Modified=&quot;Wed Aug 29 01:45:15 BST 2018&quot;
header.x-amz-storage-class=&quot;INTELLIGENT_TIERING&quot;
header.x-amz-version-id=&quot;null&quot;
</pre></div></div>
</section><section>
<h3><a name="Use_rename.28.29_to_encrypt_files_with_new_keys"></a><a name="changing-encryption"></a> Use <code>rename()</code> to encrypt files with new keys</h3>
<p>The encryption of an object is set when it is uploaded. If you want to encrypt an unencrypted file, or change the SEE-KMS key of a file, the only way to do so is by copying the object.</p>
<p>How can you do that from Hadoop? With <code>rename()</code>.</p>
<p>The S3A client mimics a real filesystem&#x2019;s&#x2019; rename operation by copying all the source files to the destination paths, then deleting the old ones.</p>
<p>Note: this does not work for SSE-C, because you cannot set a different key for reading as for writing, and you must supply that key for reading. There you need to copy one bucket to a different bucket, one with a different key. Use <code>distCp</code>for this, with per-bucket encryption policies.</p></section></section><section>
<h2><a name="Amazon_S3_Client_Side_Encryption"></a><a name="cse"></a> Amazon S3 Client Side Encryption</h2><section>
<h3><a name="Introduction"></a>Introduction</h3>
<p>Amazon S3 Client Side Encryption(S3-CSE), is used to encrypt data on the client-side and then transmit it over to S3 storage. The same encrypted data is then transmitted over to client while reading and then decrypted on the client-side.</p>
<p>S3-CSE, uses <code>AmazonS3EncryptionClientV2.java</code> as the AmazonS3 client. The encryption and decryption is done by AWS SDK. As of July 2021, Only CSE-KMS method is supported.</p>
<p>A key reason this feature (HADOOP-13887) has been unavailable for a long time is that the AWS S3 client pads uploaded objects with a 16 byte footer. This meant that files were shorter when being read than when are listed them through any of the list API calls/getFileStatus(). Which broke many applications, including anything seeking near the end of a file to read a footer, as ORC and Parquet do.</p>
<p>There is now a workaround: compensate for the footer in listings when CSE is enabled.</p>
<ul>
<li>When listing files and directories, 16 bytes are subtracted from the length of all non-empty objects( greater than or equal to 16 bytes).</li>
<li>Directory markers MAY be longer than 0 bytes long.</li>
</ul>
<p>This &#x201c;appears&#x201d; to work; secondly it does in the testing as of July 2021. However , the length of files when listed through the S3A client is now going to be shorter than the length of files listed with other clients -including S3A clients where S3-CSE has not been enabled.</p></section><section>
<h3><a name="Features"></a>Features</h3>
<ul>
<li>Supports client side encryption with keys managed in AWS KMS.</li>
<li>encryption settings propagated into jobs through any issued delegation tokens.</li>
<li>encryption information stored as headers in the uploaded object.</li>
</ul></section><section>
<h3><a name="Limitations"></a>Limitations</h3>
<ul>
<li>Performance will be reduced. All encrypt/decrypt is now being done on the client.</li>
<li>Writing files may be slower, as only a single block can be encrypted and uploaded at a time.</li>
<li>Multipart Uploader API disabled.</li>
<li>S3 Select is not supported.</li>
<li>Multipart uploads would be serial, and partSize must be a multiple of 16 bytes.</li>
<li>maximum message size in bytes that can be encrypted under this mode is 2^36-32, or ~64G, due to the security limitation of AES/GCM as recommended by NIST.</li>
</ul></section><section>
<h3><a name="Setup"></a>Setup</h3>
<ul>
<li>Generate an AWS KMS Key ID from AWS console for your bucket, with same region as the storage bucket.</li>
<li>If already created, <a class="externalLink" href="https://docs.aws.amazon.com/kms/latest/developerguide/find-cmk-id-arn.html">view the kms key ID by these steps.</a></li>
<li>Set <code>fs.s3a.encryption.algorithm=CSE-KMS</code>.</li>
<li>Set <code>fs.s3a.encryption.key=&lt;KMS_KEY_ID&gt;</code>.</li>
</ul>
<p>KMS_KEY_ID:</p>
<p>Identifies the symmetric CMK that encrypts the data key. To specify a CMK, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with &#x201c;alias/&#x201d;. To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.</p>
<p>For example: - Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code> - Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code> - Alias name: <code>alias/ExampleAlias</code> - Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p>
<p><i>Note:</i> If <code>fs.s3a.encryption.algorithm=CSE-KMS</code> is set, <code>fs.s3a.encryption.key=&lt;KMS_KEY_ID&gt;</code> property must be set for S3-CSE to work.</p>
<div class="source">
<div class="source">
<pre>&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.algorithm&lt;/name&gt;
&lt;value&gt;CSE-KMS&lt;/value&gt;
&lt;/property&gt;
&lt;property&gt;
&lt;name&gt;fs.s3a.encryption.key&lt;/name&gt;
&lt;value&gt;${KMS_KEY_ID}&lt;/value&gt;
&lt;/property&gt;
</pre></div></div>
</section></section><section>
<h2><a name="Troubleshooting_Encryption"></a><a name="troubleshooting"></a> Troubleshooting Encryption</h2>
<p>The <a href="./troubleshooting_s3a.html">troubleshooting</a> document covers stack traces which may surface when working with encrypted data.</p></section>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">
&#169; 2008-2023
Apache Software Foundation
- <a href="http://maven.apache.org/privacy-policy.html">Privacy Policy</a>.
Apache Maven, Maven, Apache, the Apache feather logo, and the Apache Maven project logos are trademarks of The Apache Software Foundation.
</div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>