Skip to content
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

Update HttpEce to use BC provider when calling KeyAgreement #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/nl/martijndwars/webpush/HttpEce.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static javax.crypto.Cipher.DECRYPT_MODE;
import static javax.crypto.Cipher.ENCRYPT_MODE;
import static nl.martijndwars.webpush.Utils.*;
import static org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME;

/**
* An implementation of Encrypted Content-Encoding for HTTP.
Expand Down Expand Up @@ -335,7 +336,7 @@ public byte[] webpushSecret(String keyId, ECPublicKey dh, byte[] authSecret, int
log("sender pubkey", encode(senderPubKey));
log("receiver pubkey", encode(receiverPubKey));

KeyAgreement keyAgreement = KeyAgreement.getInstance("ECDH");
KeyAgreement keyAgreement = KeyAgreement.getInstance("ECDH", PROVIDER_NAME);
keyAgreement.init(getPrivateKey(keyId));
keyAgreement.doPhase(remotePubKey, true);
byte[] secret = keyAgreement.generateSecret();
Expand All @@ -357,7 +358,7 @@ public byte[] webpushSecret(String keyId, ECPublicKey dh, byte[] authSecret, int
private byte[][] extractDH(String keyid, ECPublicKey publicKey) throws NoSuchAlgorithmException, InvalidKeyException {
ECPublicKey senderPubKey = getPublicKey(keyid);

KeyAgreement keyAgreement = KeyAgreement.getInstance("ECDH");
KeyAgreement keyAgreement = KeyAgreement.getInstance("ECDH", PROVIDER_NAME);
keyAgreement.init(getPrivateKey(keyid));
keyAgreement.doPhase(publicKey, true);

Expand Down