forked from tink-crypto/tink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ECDSA's IEEE_P1363 signature format.
PiperOrigin-RevId: 205657904 GitOrigin-RevId: 7523f0021d17b79ab9eb4f365dd17ac65bbb4711
- Loading branch information
1 parent
949b4f2
commit a9870f7
Showing
17 changed files
with
216 additions
and
134 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
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
import com.google.crypto.tink.subtle.Base64; | ||
import com.google.crypto.tink.subtle.EcdsaSignJce; | ||
import com.google.crypto.tink.subtle.EllipticCurves; | ||
import com.google.crypto.tink.subtle.EllipticCurves.EcdsaEncoding; | ||
import com.google.crypto.tink.util.KeysDownloader; | ||
import java.net.URI; | ||
import java.nio.charset.Charset; | ||
|
@@ -75,7 +76,9 @@ public class RewardedAdsVerifierTest { | |
private static String signUrl(String rewardUrl, String privateKey, long keyId) throws Exception { | ||
EcdsaSignJce signer = | ||
new EcdsaSignJce( | ||
EllipticCurves.getEcPrivateKey(Base64.decode(privateKey)), "SHA256WithECDSA"); | ||
EllipticCurves.getEcPrivateKey(Base64.decode(privateKey)), | ||
"SHA256WithECDSA", | ||
EcdsaEncoding.DER); | ||
String queryString = new URI(rewardUrl).getQuery(); | ||
return buildUrl(rewardUrl, signer.sign(queryString.getBytes(UTF_8)), keyId); | ||
} | ||
|
@@ -126,9 +129,9 @@ public void testShouldVerifyWithEncodedUrl() throws Exception { | |
String decodedQueryString = "foo=hello world&[email protected]"; | ||
EcdsaSignJce signer = | ||
new EcdsaSignJce( | ||
EllipticCurves.getEcPrivateKey( | ||
Base64.decode(GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64)), | ||
"SHA256WithECDSA"); | ||
EllipticCurves.getEcPrivateKey(Base64.decode(GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64)), | ||
"SHA256WithECDSA", | ||
EcdsaEncoding.DER); | ||
byte[] signature = signer.sign(decodedQueryString.getBytes(UTF_8)); | ||
String signedUrl = buildUrl(rewardUrl, signature, KEY_ID); | ||
verifier.verify(signedUrl); | ||
|
@@ -214,7 +217,8 @@ public void testShouldFailIfSignatureWasChanged() throws Exception { | |
EcdsaSignJce signer = | ||
new EcdsaSignJce( | ||
EllipticCurves.getEcPrivateKey(Base64.decode(GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64)), | ||
"SHA256WithECDSA"); | ||
"SHA256WithECDSA", | ||
EcdsaEncoding.DER); | ||
RewardedAdsVerifier verifier = | ||
new RewardedAdsVerifier.Builder() | ||
.setVerifyingPublicKeys(GOOGLE_VERIFYING_PUBLIC_KEYS_JSON) | ||
|
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
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
Oops, something went wrong.