Skip to content

Commit

Permalink
RsaSignature2018 suite uses only the RS256 algorithm.
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Sabadello <markus@danubetech.com>
  • Loading branch information
peacekeeper committed Jan 10, 2020
1 parent f83a59a commit 4cbbb55
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public String sign(String canonicalizedDocument) throws GeneralSecurityException

public interface Signer {

public byte[] sign(String algorithm, byte[] content) throws GeneralSecurityException;
public byte[] sign(byte[] content) throws GeneralSecurityException;
}

public static class PrivateKeySigner extends RSASSASigner implements Signer {
Expand All @@ -103,9 +103,9 @@ public PrivateKeySigner(RSAPrivateKey privateKey) {
super(privateKey);
}

public byte[] sign(String algorithm, byte[] content) throws GeneralSecurityException {
public byte[] sign(byte[] content) throws GeneralSecurityException {

JWSHeader jwsHeader = new JWSHeader(new JWSAlgorithm(algorithm));
JWSHeader jwsHeader = new JWSHeader(JWSAlgorithm.RS256);

try {

Expand All @@ -129,11 +129,11 @@ private JWSSignerAdapter(Signer signer) {
@Override
public Base64URL sign(final JWSHeader header, final byte[] signingInput) throws JOSEException {

String algorithm = header.getAlgorithm().getName();
if (! JWSAlgorithm.RS256.equals(header.getAlgorithm())) throw new JOSEException("Unexpected algorithm: " + header.getAlgorithm());

try {

return Base64URL.encode(this.signer.sign(algorithm, signingInput));
return Base64URL.encode(this.signer.sign(signingInput));
} catch (GeneralSecurityException ex) {

throw new JOSEException(ex.getMessage(), ex);
Expand Down

0 comments on commit 4cbbb55

Please sign in to comment.