Skip to content

Commit ff9fcfa

Browse files
scottarcMatthewBenningtonjuneb
authored andcommitted
fix!: Update to the AWS Encryption CLI.
This change includes fixes for enabling or disabling discovery mode in the CLI. BREAKING CHANGE: --discovery parameter is removed. It is replaced by a ‘discovery’ attribute of --wrapping-keys parameter. Decrypt commands will fail if ‘discovery’ is used as a parameter. ‘discovery’ attribute is valid only in decrypt commands where the provider is ‘aws-kms’. The command will fail if ‘discovery’ attribute is combined with any other provider. See: https://docs.aws.amazon.com/encryption- sdk/latest/developer-guide/crypto-cli.html Co-authored-by: Matthew Jones <mmtj@amazon.com> Co-authored-by: June Blender <juneb@users.noreply.github.com>
1 parent 849e286 commit ff9fcfa

File tree

13 files changed

+713
-297
lines changed

13 files changed

+713
-297
lines changed

README.rst

Lines changed: 17 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@ Information for configuring a master key provider must be provided.
197197

198198
Parameters may be provided using `Parameter Values`_.
199199

200-
Required parameters:
200+
These parameters are common to all master key providers:
201201

202202
* **provider** *(default: aws-encryption-sdk-cli::aws-kms)* : Indicator of the master key
203203
provider to use.
204204

205205
* See `Advanced Configuration`_ for more information on using other master key providers.
206206

207-
* **key** *(at least one required, many allowed)* : Identifier for a master key to be used.
208-
Must be an identifier understood by the specified master key provider.
207+
* **key** *(on encrypt: at least one required, many allowed; on decrypt: one of key or discovery is required)* :
208+
Identifier for a wrapping key to be used in the operation. Must be an identifier understood by the specified master
209+
key provider. ``The discovery`` attribute is only available if you are using an ``aws-kms`` provider.
209210

210-
* If using ``aws-kms`` to decrypt, `you must not specify a key`_.
211+
* If using ``aws-kms`` to decrypt, `you must specify either a key or discovery with a value of true`_.
211212

212213
Any additional parameters supplied are collected into lists by parameter name and
213214
passed to the master key provider class when it is instantiated. Custom master key providers
@@ -222,18 +223,16 @@ If multiple master key providers are defined, the first one is treated as the pr
222223
If multiple master keys are defined in the primary master key provider, the first one is treated
223224
as the primary. The primary master key is used to generate the data key.
224225

225-
The below logic is used to construct all master key providers. We use
226-
``DiscoveryAwsKmsMasterKeyProvider`` as an example.
226+
The following logic is used to construct all master key providers. We use
227+
``StrictAwsKmsMasterKeyProvider`` as an example.
227228

228229
.. code-block:: python
229230
230231
# With parameters:
231232
--wrapping-keys provider=aws-kms key=$KEY_1 key=$KEY_2
232233
233234
# KMSMasterKeyProvider is called as:
234-
key_provider = DiscoveryAwsKmsMasterKeyProvider()
235-
key_provider.add_master_key($KEY_1)
236-
key_provider.add_master_key($KEY_2)
235+
key_provider = StrictAwsKmsMasterKeyProvider(key_ids=[$KEY_1, $KEY_2])
237236
238237
.. code-block:: sh
239238
@@ -259,6 +258,14 @@ There are some configuration options which are unique to the ``aws-kms`` master
259258

260259
* **profile** : Providing this configuration value will use the specified `named profile`_
261260
credentials.
261+
* **discovery** *(default: false; one of key or discovery with a value of true is required)* :
262+
Indicates whether this provider should be in "discovery" mode. If true (enabled), the AWS Encryption CLI will attempt
263+
to decrypt ciphertexts encrypted with any AWS KMS CMK. If false (disabled), the AWS Encryption CLI will only attempt
264+
to decrypt ciphertexts encrypted with the keys specified in the **key** attribute.
265+
* **discovery-account** *(optional; available only when discovery=true and discovery-partition is also provided)* :
266+
If discovery is enabled, limits decryption to AWS KMS CMKs in the specified accounts.
267+
* **discovery-partition** *(optional; available only when discovery=true and discovery-account is also provided)* :
268+
If discovery is enabled, limits decryption to AWS KMS CMKs in the specified partition, e.g. "aws" or "aws-gov".
262269
* **region** : This allows you to specify the target region.
263270

264271
The logic for determining which region to use is shown in the pseudocode below:
@@ -473,105 +480,6 @@ Be aware, however, that if you target multiple files either through a path expan
473480
targetting a directory, the requested decoding/encoding will be applied to all files.
474481

475482

476-
Execution
477-
=========
478-
479-
.. code-block:: sh
480-
481-
usage: aws-encryption-cli [-h] [--version] [-e] [-d] [-S]
482-
[--metadata-output METADATA_OUTPUT] [--overwrite-metadata]
483-
[-m MASTER_KEYS [MASTER_KEYS ...]]
484-
[--caching CACHING [CACHING ...]] -i INPUT -o OUTPUT
485-
[--encode] [--decode]
486-
[-c ENCRYPTION_CONTEXT [ENCRYPTION_CONTEXT ...]]
487-
[--algorithm {
488-
AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384,
489-
AES_192_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384,
490-
AES_128_GCM_IV12_TAG16_HKDF_SHA256_ECDSA_P256,
491-
AES_256_GCM_IV12_TAG16_HKDF_SHA256,
492-
AES_192_GCM_IV12_TAG16_HKDF_SHA256,
493-
AES_128_GCM_IV12_TAG16_HKDF_SHA256,
494-
AES_256_GCM_IV12_TAG16,
495-
AES_192_GCM_IV12_TAG16,
496-
AES_128_GCM_IV12_TAG16
497-
}]
498-
[--frame-length FRAME_LENGTH] [--max-length MAX_LENGTH]
499-
[--suffix [SUFFIX]] [--interactive] [--no-overwrite] [-r]
500-
[-v] [-q]
501-
502-
Encrypt or decrypt data using the AWS Encryption SDK
503-
504-
optional arguments:
505-
-h, --help show this help message and exit
506-
--version show program's version number and exit
507-
-e, --encrypt Encrypt data
508-
-d, --decrypt Decrypt data
509-
-S, --suppress-metadata
510-
Suppress metadata output.
511-
--metadata-output METADATA_OUTPUT
512-
File to which to write metadata records
513-
--overwrite-metadata Force metadata output to overwrite contents of file
514-
rather than appending to file
515-
-m MASTER_KEYS [MASTER_KEYS ...], --master-keys MASTER_KEYS [MASTER_KEYS ...]
516-
Identifying information for a master key provider and
517-
master keys. Each instance must include a master key
518-
provider identifier and identifiers for one or more
519-
master key supplied by that provider. ex: --master-
520-
keys provider=aws-kms key=$AWS_KMS_KEY_ARN
521-
-w WRAPPING_KEYS [WRAPPING_KEYS ...], --wrapping-keys WRAPPING_KEYS [WRAPPING_KEYS ...]
522-
Identifying information for a master key provider and
523-
master keys. Each instance must include a master key
524-
provider identifier and identifiers for one or more
525-
master key supplied by that provider. ex: --wrapping-
526-
keys provider=aws-kms key=$AWS_KMS_KEY_ARN
527-
--caching CACHING [CACHING ...]
528-
Configuration options for a caching cryptographic
529-
materials manager and local cryptographic materials
530-
cache. Must consist of "key=value" pairs. If caching,
531-
at least "capacity" and "max_age" must be defined. ex:
532-
--caching capacity=10 max_age=100.0
533-
-i INPUT, --input INPUT
534-
Input file or directory for encrypt/decrypt operation,
535-
or "-" for stdin.
536-
-o OUTPUT, --output OUTPUT
537-
Output file or directory for encrypt/decrypt
538-
operation, or - for stdout.
539-
--encode Base64-encode output after processing
540-
--decode Base64-decode input before processing
541-
-c ENCRYPTION_CONTEXT [ENCRYPTION_CONTEXT ...], --encryption-context ENCRYPTION_CONTEXT [ENCRYPTION_CONTEXT ...]
542-
key-value pair encryption context values (encryption
543-
only). Must a set of "key=value" pairs. ex: -c
544-
key1=value1 key2=value2
545-
--algorithm {
546-
AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384,
547-
AES_192_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384,
548-
AES_128_GCM_IV12_TAG16_HKDF_SHA256_ECDSA_P256,
549-
AES_256_GCM_IV12_TAG16_HKDF_SHA256,
550-
AES_192_GCM_IV12_TAG16_HKDF_SHA256,
551-
AES_128_GCM_IV12_TAG16_HKDF_SHA256,
552-
AES_256_GCM_IV12_TAG16,
553-
AES_192_GCM_IV12_TAG16,
554-
AES_128_GCM_IV12_TAG16
555-
}
556-
Algorithm name (encryption only)
557-
--frame-length FRAME_LENGTH
558-
Frame length in bytes (encryption only)
559-
--max-length MAX_LENGTH
560-
Maximum frame length (for framed messages) or content
561-
length (for non-framed messages) (decryption only)
562-
--suffix [SUFFIX] Custom suffix to use when target filename is not
563-
specified (empty if specified but no value provided)
564-
--interactive Force aws-encryption-cli to prompt you for verification before
565-
overwriting existing files
566-
--no-overwrite Never overwrite existing files
567-
-r, -R, --recursive Allow operation on directories as input
568-
-v Enables logging and sets detail level. Multiple -v
569-
options increases verbosity (max: 4).
570-
-q, --quiet Suppresses most warning and diagnostic messages
571-
572-
For more usage instructions and examples, see: http://aws-encryption-sdk-cli.readthedocs.io/en/latest/
573-
574-
575483
.. _AWS Encryption SDK: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html
576484
.. _message header data: http://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html#header-structure
577485
.. _message header authentication data: http://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html#header-authentication
@@ -585,5 +493,5 @@ Execution
585493
.. _argparse file support: https://docs.python.org/3/library/argparse.html#fromfile-prefix-chars
586494
.. _named profile: http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html
587495
.. _setuptools entry point: http://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins
588-
.. _you must not specify a key: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/crypto-cli-how-to.html#crypto-cli-master-key
496+
.. _you must specify either a key or discovery with a value of true: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/crypto-cli-how-to.html#crypto-cli-master-key
589497
.. _Security issue notifications: https://github.com/aws/aws-encryption-sdk-cli/tree/master/CONTRIBUTING.md#security-issue-notifications

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
base64io>=1.0.1
2-
aws-encryption-sdk>=1.7.0
2+
aws-encryption-sdk~=1.7
33
setuptools
4-
attrs>=17.1.0
4+
attrs>=17.1.0

src/aws_encryption_sdk_cli/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ def cli(raw_args=None):
265265
_LOGGER.debug("Encryption source: %s", args.input)
266266
_LOGGER.debug("Encryption destination: %s", args.output)
267267
_LOGGER.debug("Master key provider configuration: %s", args.master_keys)
268-
_LOGGER.debug("Discovery mode: %r", args.discovery)
269268
_LOGGER.debug("Suffix requested: %s", args.suffix)
270269

271270
if args.wrapping_keys is not None:

0 commit comments

Comments
 (0)