-
Notifications
You must be signed in to change notification settings - Fork 159
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
bugfix: make Sep10Challenge.verifyTransactionSignatures
resilient against account IDs that are not compliant with ed25519
#440
Merged
marcelosalloum
merged 5 commits into
master
from
439-fix-crash-in-sep10challenge-for-invalid-ed25519-public-key
Jun 30, 2022
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
765ec08
Add test that fails when `Sep10Challenge.verifyChallengeTransactionTh…
marcelosalloum 6d8a397
Fix Sep10Challenge code.
marcelosalloum 71ca870
Bump version with bugfix.
marcelosalloum 4716b35
Update changelog description.
marcelosalloum a838a77
Address review suggestions.
marcelosalloum 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 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
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 |
---|---|---|
|
@@ -69,7 +69,7 @@ public void testChallenge() throws InvalidSep10ChallengeException { | |
} | ||
|
||
@Test | ||
public void testNewChallengeRejectsMuxedClientAccount() throws InvalidSep10ChallengeException { | ||
public void testNewChallengeRejectsMuxedClientAccount() { | ||
try { | ||
KeyPair server = KeyPair.random(); | ||
|
||
|
@@ -1608,6 +1608,43 @@ public void testVerifyChallengeTransactionThresholdValidServerAndMultipleClientK | |
assertEquals(new HashSet<String>(Arrays.asList(masterClient.getAccountId(), signerClient1.getAccountId())), signersFound); | ||
} | ||
|
||
@Test | ||
public void testVerifyChallengeTransactionThresholdValidServerAndMultipleClientKeyMeetingThresholdSomeUnusedAndOneNotEd25519Compliant() throws IOException, InvalidSep10ChallengeException { | ||
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. now that's a test case name, good coverage to assert the change! maybe condense the name down to just the non-compliant aspect. |
||
Network network = Network.TESTNET; | ||
KeyPair server = KeyPair.random(); | ||
KeyPair masterClient = KeyPair.random(); | ||
KeyPair signerClient1 = KeyPair.random(); | ||
KeyPair signerClient2 = KeyPair.random(); | ||
long now = System.currentTimeMillis() / 1000L; | ||
long end = now + 300; | ||
TimeBounds timeBounds = new TimeBounds(now, end); | ||
String domainName = "example.com"; | ||
String webAuthDomain = "example.com"; | ||
|
||
Transaction transaction = Sep10Challenge.newChallenge( | ||
server, | ||
network, | ||
masterClient.getAccountId(), | ||
domainName, | ||
webAuthDomain, | ||
timeBounds | ||
); | ||
|
||
transaction.sign(masterClient); | ||
transaction.sign(signerClient1); | ||
|
||
Set<Sep10Challenge.Signer> signers = new HashSet<Sep10Challenge.Signer>(Arrays.asList( | ||
new Sep10Challenge.Signer(masterClient.getAccountId(), 1), | ||
new Sep10Challenge.Signer(signerClient1.getAccountId(), 2), | ||
new Sep10Challenge.Signer(signerClient2.getAccountId(), 4), | ||
new Sep10Challenge.Signer("GA2T6GR7VXXXBETTERSAFETHANSORRYXXXPROTECTEDBYLOBSTRVAULT", 1) | ||
)); | ||
|
||
int threshold = 3; | ||
Set<String> signersFound = Sep10Challenge.verifyChallengeTransactionThreshold(transaction.toEnvelopeXdrBase64(), server.getAccountId(), network, domainName, webAuthDomain, threshold, signers); | ||
assertEquals(new HashSet<String>(Arrays.asList(masterClient.getAccountId(), signerClient1.getAccountId())), signersFound); | ||
} | ||
|
||
@Test | ||
public void testVerifyChallengeTransactionThresholdValidServerAndMultipleClientKeyMeetingThresholdSomeUnusedIgnorePreauthTxHashAndXHash() throws IOException, InvalidSep10ChallengeException { | ||
Network network = Network.TESTNET; | ||
|
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.
this console output is non-standard for the sdk which by default does not generate that type of output or logger outputs. So, to maintain consistency, would remove this and the stacktrace prints. the callers of this method could check the returned set, and determine which
signers
are missing, then it could deduce something was wrong and log something from the app layer, etc.