Skip to content

Commit

Permalink
Update HttpEce to use BC provider when calling KeyAgreement
Browse files Browse the repository at this point in the history
Since there already is a dependency to BouncyCastle in Utils.java it doesn't add any more restrictions doing this, also this solves the following issue web-push-libs#5
  • Loading branch information
frmans authored May 9, 2023
1 parent b7e0e39 commit 9ab1e8f
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 9ab1e8f

Please sign in to comment.