Skip to content

Commit f660683

Browse files
author
Cavalcante Damascena
committed
Documentation
1 parent f19651d commit f660683

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

docs/utilities/data_masking.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Before you start, you will need a KMS symmetric key to encrypt and decrypt your
9696

9797
1. [Key policy examples using IAM Roles](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#key-policy-default-allow-administrators){target="_blank"}
9898
2. [SAM generated CloudFormation Resources](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-generated-resources-function.html#sam-specification-generated-resources-function-not-role){target="_blank"}
99+
3. Required only when using [multiple keys](#using-multiple-keys)
99100

100101
### Erasing data
101102

@@ -411,6 +412,14 @@ For compatibility or performance, you can optionally pass your own JSON serializ
411412
--8<-- "examples/data_masking/src/advanced_custom_serializer.py"
412413
```
413414

415+
### Using multiple keys
416+
417+
You can use multiple KMS keys from more than one AWS account for higher availability, when instantiating `AWSEncryptionSDKProvider`.
418+
419+
```python hl_lines="15" title="using_multiple_keys.py"
420+
--8<-- "examples/data_masking/src/using_multiple_keys.py"
421+
```
422+
414423
### Providers
415424

416425
#### AWS Encryption SDK
@@ -442,14 +451,6 @@ For example, the AWS Encryption SDK defaults to using the `AES_256_GCM_HKDF_SHA5
442451
--8<-- "examples/data_masking/src/changing_default_algorithm.py"
443452
```
444453

445-
##### Using multiple keys
446-
447-
You can use multiple KMS keys from more than one AWS account for higher availability, when instantiating `AWSEncryptionSDKProvider`.
448-
449-
```python hl_lines="15" title="using_multiple_keys.py"
450-
--8<-- "examples/data_masking/src/using_multiple_keys.py"
451-
```
452-
453454
### Data masking request flow
454455

455456
The following sequence diagrams explain how `DataMasking` behaves under different scenarios.
@@ -508,7 +509,7 @@ sequenceDiagram
508509

509510
#### Encrypt operation with multiple KMS Keys
510511

511-
When encrypting data with multiple KMS keys, the `aws_encryption_sdk` executes additional encryption calls to encrypt the data with each of the specified keys.
512+
When encrypting data with multiple KMS keys, the `aws_encryption_sdk` makes additional API calls to encrypt the data with each of the specified keys.
512513

513514
<center>
514515
```mermaid
@@ -520,19 +521,19 @@ sequenceDiagram
520521
participant EncryptionProvider as Encryption Provider
521522
Client->>Lambda: Invoke (event)
522523
Lambda->>DataMasking: Init Encryption Provider with master key
523-
Note over Lambda,DataMasking: AWSEncryptionSDKProvider([KMS_KEY])
524+
Note over Lambda,DataMasking: AWSEncryptionSDKProvider([KEY_1, KEY_2])
524525
Lambda->>DataMasking: encrypt(data)
525526
DataMasking->>EncryptionProvider: Create unique data key
526-
Note over DataMasking,EncryptionProvider: KMS GenerateDataKey API
527+
Note over DataMasking,EncryptionProvider: KMS GenerateDataKey API - KEY_1
527528
DataMasking->>DataMasking: Cache new unique data key
528529
DataMasking->>DataMasking: DATA_KEY.encrypt(data)
529-
DataMasking->>DataMasking: MASTER_KEY.encrypt(DATA_KEY)
530-
DataMasking->>DataMasking: Create encrypted message
531-
alt Using another KMS key?
532-
DataMasking->>EncryptionProvider: Encrypt data
533-
Note over DataMasking,EncryptionProvider: KMS Encrypt API
530+
DataMasking->>DataMasking: KEY_1.encrypt(DATA_KEY)
531+
loop For every additional KMS Key
532+
DataMasking->>EncryptionProvider: Encrypt DATA_KEY
533+
Note over DataMasking,EncryptionProvider: KMS Encrypt API - KEY_2
534534
end
535-
Note over DataMasking: Encrypted message includes encrypted data, data key encrypted, algorithm, and more.
535+
DataMasking->>DataMasking: Create encrypted message
536+
Note over DataMasking: Encrypted message includes encrypted data, all data keys encrypted, algorithm, and more.
536537
DataMasking->>Lambda: Ciphertext from encrypted message
537538
Lambda-->>Client: Return response
538539
```

examples/data_masking/sam/template.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,6 @@ Resources:
6262
Action:
6363
- kms:Decrypt # to decrypt encrypted data key
6464
- kms:GenerateDataKey # to create an unique and random data key for encryption
65+
# Encrypt permission is required only when using multiple keys
66+
- kms:Encrypt # (3)!
6567
Resource: "*"

0 commit comments

Comments
 (0)