mirrored from https://www.bouncycastle.org/repositories/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
initial implementation of Token Binding Extension TLS #261
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
Open
inthirakumaaran
wants to merge
5
commits into
bcgit:master
Choose a base branch
from
inthirakumaaran:Token-Binding-Extension-Push
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
68 changes: 68 additions & 0 deletions
68
tls/src/main/java/org/bouncycastle/tls/NegotiatedTokenBinding.java
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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package org.bouncycastle.tls; | ||
|
|
||
| /** | ||
| * This class captures the negotiated parameters from the TLS handshake | ||
| */ | ||
| public class NegotiatedTokenBinding { | ||
|
|
||
| private String selectedKeyParameter; | ||
| protected String RSA2048_PCKS15 = "rsa2048_pcks15"; | ||
| protected String RSA2048_PSS = "rsa2048_pss"; | ||
| protected String RSA2048_ECDSAP256 = "rsa2048_ecdsap256"; | ||
|
|
||
| public byte[] exportKeyingMaterial; | ||
|
|
||
| public byte[] getExportKeyingMaterial() { | ||
| return exportKeyingMaterial; | ||
| } | ||
|
|
||
| public void setExportKeyingMaterial(byte[] exportKeyingMaterial) { | ||
| this.exportKeyingMaterial = exportKeyingMaterial; | ||
| } | ||
|
|
||
| public int MajorProtocolVerison = 0; | ||
| public int MinorProtocolVerison = 13; | ||
|
|
||
| public String getSelectedKeyParameter() { | ||
| return selectedKeyParameter; | ||
| } | ||
|
|
||
| public void setSelectedKeyParameter(String selectedKeyParameter) { | ||
| this.selectedKeyParameter = selectedKeyParameter; | ||
| } | ||
|
|
||
| public int getMajorProtocolVerison() { | ||
| return MajorProtocolVerison; | ||
| } | ||
|
|
||
| public void setMajorProtocolVerison(int majorProtocolVerison) { | ||
| MajorProtocolVerison = majorProtocolVerison; | ||
| } | ||
|
|
||
| public int getMinorProtocolVerison() { | ||
| return MinorProtocolVerison; | ||
| } | ||
|
|
||
| public void setMinorProtocolVerison(int minorProtocolVerison) { | ||
| MinorProtocolVerison = minorProtocolVerison; | ||
| } | ||
|
|
||
| public NegotiatedTokenBinding decode(int[] serverdata) throws TlsFatalAlert { | ||
|
|
||
| if (serverdata.length != 4) { | ||
| throw new TlsFatalAlert(AlertDescription.unsupported_extension); | ||
| } | ||
| this.setMajorProtocolVerison(serverdata[0]); | ||
| this.setMinorProtocolVerison(serverdata[1]); | ||
| if (serverdata[3] == 0) { | ||
| this.setSelectedKeyParameter(RSA2048_PCKS15); | ||
| } else if (serverdata[3] == 1) { | ||
| this.setSelectedKeyParameter(RSA2048_PSS); | ||
| } else if (serverdata[3] == 2) { | ||
| this.setSelectedKeyParameter(RSA2048_ECDSAP256); | ||
| } else { | ||
| throw new TlsFatalAlert(AlertDescription.unsupported_extension); | ||
| } | ||
| return this; | ||
| } | ||
| } |
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
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
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
74 changes: 74 additions & 0 deletions
74
tls/src/main/java/org/bouncycastle/tls/TokenBindingExtension.java
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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package org.bouncycastle.tls; | ||
|
|
||
| import org.bouncycastle.util.io.Streams; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.IOException; | ||
| import java.io.OutputStream; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Token binding (draft) extension to TLS | ||
| */ | ||
| public class TokenBindingExtension { | ||
|
|
||
| public static final Integer rsa2048_pcks15 = 0; | ||
| public static final Integer rsa2048_pss = 1; | ||
| public static final Integer rsa2048_ecdsap256 = 2; | ||
|
|
||
| List<Integer> TokenBindingKeyParameters = new ArrayList<Integer>(); | ||
|
|
||
| private static int MajorProtocolVerison = 0; | ||
|
|
||
| public static int getMajorProtocolVerison() { | ||
| return MajorProtocolVerison; | ||
| } | ||
|
|
||
| public static int getMinorProtocolVerison() { | ||
| return MinorProtocolVerison; | ||
| } | ||
|
|
||
| private static int MinorProtocolVerison = 13; | ||
|
|
||
| public static void setMajorProtocolVerison(int majorProtocolVerison) { | ||
| MajorProtocolVerison = majorProtocolVerison; | ||
| } | ||
|
|
||
| public static void setMinorProtocolVerison(int minorProtocolVerison) { | ||
| MinorProtocolVerison = minorProtocolVerison; | ||
| } | ||
|
|
||
| public void addTokenbindingKeyParameters(int parameter) { | ||
| TokenBindingKeyParameters.add(parameter); | ||
| } | ||
|
|
||
| public List<Integer> getTokenBindingKeyParameters() { | ||
| if (TokenBindingKeyParameters.size() < 1) { | ||
| TokenBindingKeyParameters.add(rsa2048_pcks15); | ||
| } | ||
| Collections.sort(TokenBindingKeyParameters, Collections.reverseOrder()); | ||
| return TokenBindingKeyParameters; | ||
| } | ||
|
|
||
| public void encode(OutputStream output) throws IOException { | ||
| ByteArrayOutputStream buf = new ByteArrayOutputStream(); | ||
|
|
||
| TlsUtils.checkUint8(MajorProtocolVerison); | ||
| TlsUtils.checkUint8(MinorProtocolVerison); | ||
| TlsUtils.writeUint8(MajorProtocolVerison, output); | ||
| TlsUtils.writeUint8(MinorProtocolVerison, output); | ||
|
|
||
| for (Integer param : this.getTokenBindingKeyParameters()) { | ||
| TlsUtils.checkUint8(param); | ||
| TlsUtils.writeUint8(param, buf); | ||
| } | ||
|
|
||
| TlsUtils.checkUint8(buf.size()); | ||
| TlsUtils.writeUint8(buf.size(), output); | ||
| Streams.writeBufTo(buf, output); | ||
|
|
||
| } | ||
|
|
||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be in upper case since these are constants? Do contrast with the token binding spec as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec always denote them in the simple letters