-
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.
SD-1822: Use certificates rather than public keys
As a side-effect of this, we can now support EC keys instead of only RSA keys (without having to manually parse and understand the DER/ASN.1 format).
- Loading branch information
Showing
2 changed files
with
116 additions
and
71 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
12 changes: 6 additions & 6 deletions
12
ebl/src/main/java/org/dcsa/conformance/standards/ebl/crypto/impl/RSAPayloadSigner.java
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package org.dcsa.conformance.standards.ebl.crypto.impl; | ||
|
||
import org.bouncycastle.cert.X509CertificateHolder; | ||
import org.dcsa.conformance.standards.ebl.crypto.JWSSignerDetails; | ||
import org.dcsa.conformance.standards.ebl.crypto.PayloadSignerWithKey; | ||
|
||
import java.security.interfaces.RSAPublicKey; | ||
|
||
import static org.dcsa.conformance.standards.ebl.crypto.PayloadSignerFactory.pemEncodeCertificate; | ||
import static org.dcsa.conformance.standards.ebl.crypto.PayloadSignerFactory.pemEncodeKey; | ||
|
||
public class RSAPayloadSigner extends DefaultPayloadSigner implements PayloadSignerWithKey { | ||
|
||
private final RSAPublicKey rsaPublicKey; | ||
private final X509CertificateHolder x509Cert; | ||
|
||
public RSAPayloadSigner(JWSSignerDetails jwsSignerDetails, RSAPublicKey rsaPublicKey) { | ||
public RSAPayloadSigner(JWSSignerDetails jwsSignerDetails, X509CertificateHolder x509Cert) { | ||
super(jwsSignerDetails); | ||
this.rsaPublicKey = rsaPublicKey; | ||
this.x509Cert = x509Cert; | ||
} | ||
|
||
@Override | ||
public String getPublicKeyInPemFormat() { | ||
return pemEncodeKey(this.rsaPublicKey); | ||
return pemEncodeCertificate(this.x509Cert); | ||
} | ||
} |