-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add TLS Cipher API * Update Dependencies to use PostQuantum Compatible Versions
- Loading branch information
Showing
6 changed files
with
251 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/software/amazon/awssdk/crt/io/TlsCipherPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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. | ||
*/ | ||
package software.amazon.awssdk.crt.io; | ||
|
||
public enum TlsCipherPreference { | ||
/** | ||
* Use whatever the System Default Preference is. This is usually the best option, as it will be automatically | ||
* updated as the underlying OS or platform changes. | ||
*/ | ||
TLS_CIPHER_SYSTEM_DEFAULT(0), | ||
|
||
/** | ||
* Contains Draft Hybrid TLS Ciphers: https://tools.ietf.org/html/draft-campagna-tls-bike-sike-hybrid | ||
* | ||
* These ciphers perform two Key Exchanges (1 ECDHE + 1 Post-Quantum) during the TLS Handshake in order to | ||
* combine the security of Classical ECDHE Key Exchange with the conjectured quantum-resistance of newly | ||
* proposed key exchanges. | ||
* | ||
* The algorithms these new Post-Quantum ciphers are based on have been submitted to NIST's Post-Quantum Crypto | ||
* Standardization Process, and are still under review. | ||
* | ||
* This Cipher Preference may stop being supported at any time. | ||
*/ | ||
TLS_CIPHER_KMS_PQ_TLSv1_0_2019_06(1); | ||
|
||
private int val; | ||
|
||
TlsCipherPreference(int val) { | ||
this.val = val; | ||
} | ||
|
||
int getValue() { return val; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/software/amazon/awssdk/crt/test/TlsContextOptionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package software.amazon.awssdk.crt.test; | ||
|
||
import static software.amazon.awssdk.crt.io.TlsContextOptions.TlsVersions; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import software.amazon.awssdk.crt.CrtResource; | ||
import software.amazon.awssdk.crt.io.TlsCipherPreference; | ||
import software.amazon.awssdk.crt.io.TlsContextOptions; | ||
|
||
public class TlsContextOptionsTest { | ||
|
||
@Test | ||
public void testTlsContextOptionsAPI() { | ||
Assert.assertEquals(0, CrtResource.getAllocatedNativeResourceCount()); | ||
|
||
TlsContextOptions options = new TlsContextOptions(); | ||
|
||
for (TlsVersions tlsVersion: TlsContextOptions.TlsVersions.values()) { | ||
options.setMinimumTlsVersion(tlsVersion); | ||
} | ||
|
||
options.setMinimumTlsVersion(TlsVersions.TLS_VER_SYS_DEFAULTS); | ||
|
||
for (TlsCipherPreference pref: TlsCipherPreference.values()) { | ||
if (TlsContextOptions.isCipherPreferenceSupported(pref)) { | ||
options.setCipherPreference(pref); | ||
} | ||
} | ||
|
||
boolean exceptionThrown = false; | ||
|
||
try { | ||
options.setCipherPreference(TlsCipherPreference.TLS_CIPHER_KMS_PQ_TLSv1_0_2019_06); | ||
options.setMinimumTlsVersion(TlsVersions.TLSv1_2); | ||
Assert.fail(); | ||
} catch (IllegalArgumentException e) { | ||
exceptionThrown = true; | ||
} | ||
|
||
Assert.assertTrue(exceptionThrown); | ||
|
||
options.close(); | ||
Assert.assertEquals(0, CrtResource.getAllocatedNativeResourceCount()); | ||
} | ||
} |