Skip to content

Commit bd4da5b

Browse files
authored
Merge pull request #189 from mattsb42-aws/revert
revert keyrings
2 parents d88fe8b + 682d262 commit bd4da5b

File tree

131 files changed

+1153
-11291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1153
-11291
lines changed

CHANGELOG.md

-30
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
11
# Changelog
22

3-
## 1.7.0 -- unreleased
4-
5-
### Deprecation Warnings
6-
* Deprecated `MasterKey` and `MasterKeyProvider`. Replace your usage of these classes with `Keyring`. See `StandardKeyrings`
7-
for the built-in keyrings that replace `KmsMasterKeyProvider`, `JceMasterKey`, and `MultiProviderFactory`.
8-
We still support using master key providers and are not removing them yet.
9-
When we decide to remove them, we will communicate that as defined in our versioning policy.
10-
* Deprecated `encryptData`, `decryptData` and related methods in `AwsCrypto`. Replace your calls to these methods with
11-
calls to `AwsCrypto.encrypt(EncryptRequest)` and `AwsCrypto.decrypt(DecryptRequest)`.
12-
13-
### Major Changes
14-
* Introduce `Keyring` interface, built in Keyring implementations, and
15-
methods in AwsCrypto that use keyrings [PR #173](https://github.com/aws/aws-encryption-sdk-java/pull/173)
16-
17-
### Patches
18-
* Validate final frame length does not exceed the frame size in the message header [PR #166](https://github.com/aws/aws-encryption-sdk-java/pull/166)
19-
20-
### Maintenance
21-
* Update AWS Java SDK version from 1.11.561 to 1.11.677. [PR #147](https://github.com/aws/aws-encryption-sdk-java/pull/147)
22-
* Upgrade JUnit from 4.12 to 5.5.2 [PR #151](https://github.com/aws/aws-encryption-sdk-java/pull/151)
23-
* Upgrade Mockito from 2.28.1 to 3.1.0 [PR #142](https://github.com/aws/aws-encryption-sdk-java/pull/142)
24-
* Upgrade Bouncy Castle from 1.61 to 1.65 [PR #179](https://github.com/aws/aws-encryption-sdk-java/pull/179)
25-
26-
### Documentation
27-
* Added new examples demonstrating how to use
28-
APIs, keyrings, cryptographic materials managers, and master key providers. PRs
29-
[#165](https://github.com/aws/aws-encryption-sdk-java/pull/165),
30-
[#168](https://github.com/aws/aws-encryption-sdk-java/pull/168),
31-
and [#170](https://github.com/aws/aws-encryption-sdk-java/pull/170).
32-
333
## 1.6.1 -- 2019-10-29
344

355
### Deprecation Warnings

README.md

+70-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# AWS Encryption SDK for Java
22

3-
The AWS Encryption SDK is a client-side encryption library designed to make it easy for everyone to encrypt and decrypt data using industry standards and best practices. It enables you to focus on the core functionality of your application, rather than on how to best encrypt and decrypt your data.
3+
The AWS Encryption SDK enables secure client-side encryption. It uses cryptography best practices to protect your data and the encryption keys used to protect that data. Each data object is protected with a unique data encryption key (DEK), and the DEK is protected with a key encryption key (KEK) called a *master key*. The encrypted DEK is combined with the encrypted data into a single [encrypted message](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html), so you don't need to keep track of the DEKs for your data. The SDK supports master keys in [AWS Key Management Service](https://aws.amazon.com/kms/) (KMS), and it also provides APIs to define and use other master key providers. The SDK provides methods for encrypting and decrypting strings, byte arrays, and byte streams. For details, see the [example code][examples] and the [Javadoc](https://aws.github.io/aws-encryption-sdk-java/javadoc/).
44

5-
For details about the design, architecture and usage of the SDK, see the [official documentation](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/), [example code][examples] and the [Javadoc](https://aws.github.io/aws-encryption-sdk-java/javadoc/).
5+
For more details about the design and architecture of the SDK, see the [official documentation](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/).
66

77
[Security issue notifications](./CONTRIBUTING.md#security-issue-notifications)
88

@@ -60,9 +60,75 @@ You can get the latest release from Maven:
6060
</dependency>
6161
```
6262

63-
### Sample Code
63+
### Get Started
64+
65+
The following code sample demonstrates how to get started:
66+
67+
1. Instantiate the SDK.
68+
2. Define the master key provider.
69+
3. Encrypt and decrypt data.
70+
71+
```java
72+
// This sample code encrypts and then decrypts a string using a KMS CMK.
73+
// You provide the KMS key ARN and plaintext string as arguments.
74+
package com.amazonaws.crypto.examples;
75+
76+
import java.util.Collections;
77+
import java.util.Map;
78+
79+
import com.amazonaws.encryptionsdk.AwsCrypto;
80+
import com.amazonaws.encryptionsdk.CryptoResult;
81+
import com.amazonaws.encryptionsdk.kms.KmsMasterKey;
82+
import com.amazonaws.encryptionsdk.kms.KmsMasterKeyProvider;
83+
84+
public class StringExample {
85+
private static String keyArn;
86+
private static String data;
87+
88+
public static void main(final String[] args) {
89+
keyArn = args[0];
90+
data = args[1];
91+
92+
// Instantiate the SDK
93+
final AwsCrypto crypto = new AwsCrypto();
94+
95+
// Set up the master key provider
96+
final KmsMasterKeyProvider prov = new KmsMasterKeyProvider(keyArn);
97+
98+
// Encrypt the data
99+
//
100+
// NOTE: Encrypted data should have associated encryption context
101+
// to protect integrity. For this example, just use a placeholder
102+
// value. For more information about encryption context, see
103+
// https://amzn.to/1nSbe9X (blogs.aws.amazon.com)
104+
final Map<String, String> context = Collections.singletonMap("Example", "String");
105+
106+
final String ciphertext = crypto.encryptString(prov, data, context).getResult();
107+
System.out.println("Ciphertext: " + ciphertext);
108+
109+
// Decrypt the data
110+
final CryptoResult<String, KmsMasterKey> decryptResult = crypto.decryptString(prov, ciphertext);
111+
// Check the encryption context (and ideally the master key) to
112+
// ensure this is the expected ciphertext
113+
if (!decryptResult.getMasterKeyIds().get(0).equals(keyArn)) {
114+
throw new IllegalStateException("Wrong key id!");
115+
}
116+
117+
// The SDK may add information to the encryption context, so check to
118+
// ensure all of the values are present
119+
for (final Map.Entry<String, String> e : context.entrySet()) {
120+
if (!e.getValue().equals(decryptResult.getEncryptionContext().get(e.getKey()))) {
121+
throw new IllegalStateException("Wrong Encryption Context!");
122+
}
123+
}
124+
125+
// The data is correct, so output it.
126+
System.out.println("Decrypted: " + decryptResult.getResult());
127+
}
128+
}
129+
```
64130

65-
You can find sample code in the [examples directory][examples].
131+
You can find more examples in the [examples directory][examples].
66132

67133
## Public API
68134

pom.xml

+16-56
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,16 @@
5353
</dependency>
5454

5555
<dependency>
56-
<groupId>org.junit.jupiter</groupId>
57-
<artifactId>junit-jupiter</artifactId>
58-
<version>5.5.2</version>
59-
<scope>test</scope>
60-
</dependency>
61-
62-
<dependency>
63-
<groupId>org.junit.vintage</groupId>
64-
<artifactId>junit-vintage-engine</artifactId>
65-
<version>5.5.2</version>
56+
<groupId>org.mockito</groupId>
57+
<artifactId>mockito-core</artifactId>
58+
<version>2.28.1</version>
6659
<scope>test</scope>
6760
</dependency>
6861

6962
<dependency>
70-
<groupId>org.mockito</groupId>
71-
<artifactId>mockito-junit-jupiter</artifactId>
72-
<version>3.1.0</version>
63+
<groupId>junit</groupId>
64+
<artifactId>junit</artifactId>
65+
<version>4.12</version>
7366
<scope>test</scope>
7467
</dependency>
7568

@@ -80,19 +73,6 @@
8073
<scope>test</scope>
8174
</dependency>
8275

83-
<dependency>
84-
<groupId>com.amazonaws</groupId>
85-
<artifactId>aws-lambda-java-core</artifactId>
86-
<version>1.2.0</version>
87-
<scope>test</scope>
88-
</dependency>
89-
90-
<dependency>
91-
<groupId>com.amazonaws</groupId>
92-
<artifactId>aws-lambda-java-events</artifactId>
93-
<version>2.2.7</version>
94-
<scope>test</scope>
95-
</dependency>
9676

9777
<dependency>
9878
<groupId>com.google.code.findbugs</groupId>
@@ -210,7 +190,7 @@
210190
</profile>
211191

212192
<profile>
213-
<id>test-suite</id>
193+
<id>full-test-suite</id>
214194
<activation>
215195
<activeByDefault>true</activeByDefault>
216196
</activation>
@@ -221,50 +201,30 @@
221201
<artifactId>maven-surefire-plugin</artifactId>
222202
<version>2.22.0</version>
223203
<configuration>
224-
<excludedGroups>ad_hoc</excludedGroups>
204+
<includes>
205+
<include>**/AllTestsSuite.java</include>
206+
</includes>
225207
</configuration>
226208
</plugin>
227209
</plugins>
228210
</build>
229211
</profile>
230212

231-
<!-- This test profile is intended to assist in rapid development; it filters out some of the slower,
232-
more exhaustive tests in the overall test suite to allow for a rapid edit-test cycle. -->
233213
<profile>
234214
<id>fast-tests-only</id>
215+
<activation>
216+
<activeByDefault>false</activeByDefault>
217+
</activation>
235218
<build>
236219
<plugins>
237220
<plugin>
238221
<groupId>org.apache.maven.plugins</groupId>
239222
<artifactId>maven-surefire-plugin</artifactId>
240223
<version>2.22.0</version>
241224
<configuration>
242-
<excludedGroups>ad_hoc, integration</excludedGroups>
243-
<systemPropertyVariables>
244-
<fastTestsOnly>true</fastTestsOnly>
245-
</systemPropertyVariables>
246-
<!-- Require that this fast suite completes relatively quickly. If you're seeing
247-
this timeout get hit, it's time to pare down tests some more. As a general rule of
248-
thumb, we should avoid any single test taking more than 10s, and try to keep the
249-
number of such slow tests to a minimum. -->
250-
<forkedProcessTimeoutInSeconds>120</forkedProcessTimeoutInSeconds>
251-
</configuration>
252-
</plugin>
253-
</plugins>
254-
</build>
255-
</profile>
256-
257-
<!-- This test profile will run only the integration tests. -->
258-
<profile>
259-
<id>integration</id>
260-
<build>
261-
<plugins>
262-
<plugin>
263-
<groupId>org.apache.maven.plugins</groupId>
264-
<artifactId>maven-surefire-plugin</artifactId>
265-
<version>2.22.0</version>
266-
<configuration>
267-
<groups>integration</groups>
225+
<includes>
226+
<include>**/FastTestsOnlySuite.java</include>
227+
</includes>
268228
</configuration>
269229
</plugin>
270230
</plugins>

src/examples/README.md

-132
This file was deleted.

0 commit comments

Comments
 (0)