-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8341346: Add support for exporting TLS Keying Material #24976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
f5a403c
8341346: Add support for exporting TLS Keying Material
bradfordwetmore e974596
Tweak API to be more KDF like in unextractable case.
bradfordwetmore a0332f8
Moved too fast
bradfordwetmore bdd1605
Codereview comments.
bradfordwetmore a8411b3
Merge branch 'master' into JDK-8341346
bradfordwetmore 64d46d9
More codereview/CSR comments
bradfordwetmore 92f45f7
Add in the SharedSecrets SecretKeySpec clearing mechanism
bradfordwetmore c6baa83
Updated to use the upcoming KDF (still in preview) + bits of JDK-8353…
bradfordwetmore 2e5f534
More Codereview comments
bradfordwetmore 598fc57
Rework to avoid PKCS11 data extraction problems, and enhanced input v…
bradfordwetmore 03be590
Merge branch 'master' into JDK-8341346
bradfordwetmore 4d9a3a0
Adjustments made for JDK-8350830
bradfordwetmore bd227aa
Merge branch 'master' into JDK-8341346
bradfordwetmore b21a42d
More codereview comments
bradfordwetmore 0da8f6f
Missed one review comment
bradfordwetmore 87ad9ea
Merge branch 'master' into JDK-8341346
bradfordwetmore cc265d6
Merge
bradfordwetmore 513c803
Merged with changes for JDK-8353578
bradfordwetmore e912fb6
Codereview: removed serialization of of exporter Secret/randoms, and…
bradfordwetmore cbcac31
Codereview comments: updated test to extend from SSLEngineTemplate, …
bradfordwetmore 7c68394
Codereview comments: updated test to extend from SSLEngineTemplate, …
bradfordwetmore bf05ddc
Minor Codereview comments.
bradfordwetmore e93e38e
Merge branch 'master' into JDK-8341346
bradfordwetmore 1355e3f
Updated API to include SecretKey type, and a couple minor codereview …
bradfordwetmore 0f08ff2
Merge branch 'master' into JDK-8341346
bradfordwetmore 638985b
Updated copyright dates.
bradfordwetmore ff49422
Merge branch 'master' into JDK-8341346
bradfordwetmore cde5edb
get*() no longer needed, backout error (oops!)
bradfordwetmore 8189e17
Private Codereview comment: Don't allow use of null keyAlgs, plus so…
bradfordwetmore 3e28d34
Merge branch 'master' into JDK-8341346
bradfordwetmore 33baa38
Missed one change
bradfordwetmore dae583e
Minor bug
bradfordwetmore c92d1e8
Added PKCS11 testing
bradfordwetmore e6b563e
Merge branch 'master' into JDK-8341346
bradfordwetmore 4f35913
Merge branch 'master' into JDK-8341346
bradfordwetmore 67480e9
Remove TlsExporterKeyingMaterial for now. Can add later if needed.
bradfordwetmore 858362c
Merge branch 'master' into JDK-8341346
bradfordwetmore d0a0a7b
Last minute codereview comments
bradfordwetmore cecd520
Merge branch 'master' into JDK-8341346
bradfordwetmore 07fda41
Merge branch 'master' into JDK-8341346
bradfordwetmore d0cf691
Resolved Merge Problem
bradfordwetmore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -26,6 +26,7 @@ | |
| package javax.net.ssl; | ||
|
|
||
| import java.util.List; | ||
| import javax.crypto.SecretKey; | ||
|
|
||
| /** | ||
| * Extends the {@code SSLSession} interface to support additional | ||
|
|
@@ -163,4 +164,113 @@ public List<SNIServerName> getRequestedServerNames() { | |
| public List<byte[]> getStatusResponses() { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| /** | ||
| * Generates Exported Keying Material (EKM) calculated according to the | ||
| * algorithms defined in RFCs 5705/8446. | ||
| * <P> | ||
| * RFC 5705 (for (D)TLSv1.2 and earlier) calculates different EKM | ||
| * values depending on whether {@code context} is null or non-null/empty. | ||
| * RFC 8446 (TLSv1.3) treats a null context as non-null/empty. | ||
| * <P> | ||
| * {@code label} will be converted to bytes using | ||
| * the {@link java.nio.charset.StandardCharsets#UTF_8} | ||
| * character encoding. | ||
| * | ||
| * @spec https://www.rfc-editor.org/info/rfc5705 | ||
| * RFC 5705: Keying Material Exporters for Transport Layer | ||
| * Security (TLS) | ||
| * @spec https://www.rfc-editor.org/info/rfc8446 | ||
| * RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3 | ||
| * | ||
| * @implSpec The default implementation throws | ||
| * {@code UnsupportedOperationException}. | ||
| * | ||
| * @param keyAlg the algorithm of the resultant {@code SecretKey} object. | ||
| * See the SecretKey Algorithms section in the | ||
| * <a href="{@docRoot}/../specs/security/standard-names.html#secretkey-algorithms"> | ||
| * Java Security Standard Algorithm Names Specification</a> | ||
| * for information about standard secret key algorithm | ||
| * names. | ||
| * @param label the label bytes used in the EKM calculation. | ||
| * {@code label} will be converted to a {@code byte[]} | ||
| * before the operation begins. | ||
| * @param context the context bytes used in the EKM calculation, or null | ||
| * @param length the number of bytes of EKM material needed | ||
| * | ||
| * @throws SSLKeyException if the key cannot be generated | ||
| * @throws IllegalArgumentException if {@code keyAlg} is empty, | ||
| * {@code length} is non-positive, or if the {@code label} or | ||
| * {@code context} length can not be accommodated | ||
| * @throws NullPointerException if {@code keyAlg} or {@code label} is null | ||
| * @throws IllegalStateException if this session does not have the | ||
| * necessary key generation material (for example, a session | ||
| * under construction during handshaking) | ||
| * @throws UnsupportedOperationException if the underlying provider | ||
| * does not implement the operation | ||
| * | ||
| * @return a {@code SecretKey} that contains {@code length} bytes of the | ||
| * EKM material | ||
| * | ||
| * @since 25 | ||
| */ | ||
| public SecretKey exportKeyingMaterialKey(String keyAlg, | ||
| String label, byte[] context, int length) throws SSLKeyException { | ||
| throw new UnsupportedOperationException( | ||
| "Underlying provider does not implement the method"); | ||
| } | ||
|
|
||
| /** | ||
| * Generates Exported Keying Material (EKM) calculated according to the | ||
| * algorithms defined in RFCs 5705/8446. | ||
| * <P> | ||
| * RFC 5705 (for (D)TLSv1.2 and earlier) calculates different EKM | ||
| * values depending on whether {@code context} is null or non-null/empty. | ||
| * RFC 8446 (TLSv1.3) treats a null context as non-null/empty. | ||
| * <P> | ||
| * {@code label} will be converted to bytes using | ||
| * the {@link java.nio.charset.StandardCharsets#UTF_8} | ||
| * character encoding. | ||
| * <P> | ||
| * Depending on the chosen underlying key derivation mechanism, the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reads like it should maybe be an |
||
| * raw bytes might not be extractable/exportable. In such cases, the | ||
| * {@link #exportKeyingMaterialKey(String, String, byte[], int)} method | ||
| * should be used instead to access the generated key material. | ||
| * | ||
| * @spec https://www.rfc-editor.org/info/rfc5705 | ||
| * RFC 5705: Keying Material Exporters for Transport Layer | ||
| * Security (TLS) | ||
| * @spec https://www.rfc-editor.org/info/rfc8446 | ||
| * RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3 | ||
| * | ||
| * @implSpec The default implementation throws | ||
| * {@code UnsupportedOperationException}. | ||
| * | ||
| * @param label the label bytes used in the EKM calculation. | ||
| * {@code label} will be converted to a {@code byte[]} | ||
| * before the operation begins. | ||
| * @param context the context bytes used in the EKM calculation, or null | ||
| * @param length the number of bytes of EKM material needed | ||
| * | ||
| * @throws SSLKeyException if the key cannot be generated | ||
| * @throws IllegalArgumentException if {@code length} is non-positive, | ||
| * or if the {@code label} or {@code context} length can | ||
| * not be accommodated | ||
| * @throws NullPointerException if {@code label} is null | ||
| * @throws IllegalStateException if this session does not have the | ||
| * necessary key generation material (for example, a session | ||
| * under construction during handshaking) | ||
| * @throws UnsupportedOperationException if the underlying provider | ||
| * does not implement the operation, or if the derived | ||
| * keying material is not extractable | ||
| * | ||
| * @return a byte array of size {@code length} that contains the EKM | ||
| * material | ||
| * @since 25 | ||
| */ | ||
| public byte[] exportKeyingMaterialData( | ||
| String label, byte[] context, int length) throws SSLKeyException { | ||
| throw new UnsupportedOperationException( | ||
| "Underlying provider does not implement the method"); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.