Skip to content

Commit 86a4557

Browse files
committed
feat: Add support for PS256 in JWT.
1 parent 90d7da8 commit 86a4557

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

src/main/java/com/danubetech/verifiablecredentials/jwt/JwtObject.java

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.danubetech.verifiablecredentials.jwt;
22

3-
import com.nimbusds.jose.*;
4-
import com.nimbusds.jose.util.JSONObjectUtils;
5-
import com.nimbusds.jwt.JWTClaimsSet;
63
import com.danubetech.keyformats.crypto.ByteSigner;
74
import com.danubetech.keyformats.crypto.ByteVerifier;
85
import com.danubetech.keyformats.crypto.impl.*;
6+
import com.nimbusds.jose.*;
7+
import com.nimbusds.jose.util.JSONObjectUtils;
8+
import com.nimbusds.jwt.JWTClaimsSet;
99
import info.weboftrust.ldsignatures.adapter.JWSSignerAdapter;
1010
import info.weboftrust.ldsignatures.adapter.JWSVerifierAdapter;
1111
import org.bitcoinj.core.ECKey;
@@ -53,6 +53,30 @@ private String sign(JWSSigner jwsSigner, JWSAlgorithm alg, String kid, boolean c
5353
return this.compactSerialization;
5454
}
5555

56+
public String sign_RSA_PS256(ByteSigner signer, String kid, boolean canonicalize) throws JOSEException {
57+
return this.sign(new JWSSignerAdapter(signer, JWSAlgorithm.PS256), JWSAlgorithm.PS256, kid, canonicalize);
58+
}
59+
60+
public String sign_RSA_PS256(ByteSigner signer) throws JOSEException {
61+
return this.sign_RSA_PS256(signer, null, false);
62+
}
63+
64+
public String sign_RSA_PS256(RSAPrivateKey privateKey, String kid, boolean canonicalize) throws JOSEException {
65+
return this.sign_RSA_PS256(new RSA_PS256_PrivateKeySigner(privateKey), kid, canonicalize);
66+
}
67+
68+
public String sign_RSA_PS256(RSAPrivateKey privateKey) throws JOSEException {
69+
return this.sign_RSA_PS256(privateKey, null, false);
70+
}
71+
72+
public String sign_RSA_PS256(com.nimbusds.jose.jwk.RSAKey privateKey, String kid, boolean canonicalize) throws JOSEException {
73+
return this.sign(new com.nimbusds.jose.crypto.RSASSASigner(privateKey), JWSAlgorithm.PS256, kid, canonicalize);
74+
}
75+
76+
public String sign_RSA_PS256(com.nimbusds.jose.jwk.RSAKey privateKey) throws JOSEException {
77+
return this.sign_RSA_PS256(privateKey, null, false);
78+
}
79+
5680
public String sign_RSA_RS256(ByteSigner signer, String kid, boolean canonicalize) throws JOSEException {
5781
return this.sign(new JWSSignerAdapter(signer, JWSAlgorithm.RS256), JWSAlgorithm.RS256, kid, canonicalize);
5882
}
@@ -133,6 +157,18 @@ private boolean verify(JWSVerifier jwsVerifier) throws JOSEException {
133157
return this.jwsObject.verify(jwsVerifier);
134158
}
135159

160+
public boolean verify_RSA_PS256(ByteVerifier verifier) throws JOSEException {
161+
return this.verify(new JWSVerifierAdapter(verifier, JWSAlgorithm.RS256));
162+
}
163+
164+
public boolean verify_RSA_PS256(RSAPublicKey publicKey) throws JOSEException {
165+
return this.verify_RSA_PS256(new RSA_PS256_PublicKeyVerifier(publicKey));
166+
}
167+
168+
public boolean verify_RSA_PS256(com.nimbusds.jose.jwk.RSAKey publicKey) throws JOSEException {
169+
return this.verify(new com.nimbusds.jose.crypto.RSASSAVerifier(publicKey));
170+
}
171+
136172
public boolean verify_RSA_RS256(ByteVerifier verifier) throws JOSEException {
137173
return this.verify(new JWSVerifierAdapter(verifier, JWSAlgorithm.RS256));
138174
}

0 commit comments

Comments
 (0)