summaryrefslogtreecommitdiff
path: root/smcc/src
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-06-04 12:50:24 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-06-04 12:50:24 +0000
commitb71102bec28087ea3514f54af81741fa48502ccc (patch)
tree1569886242da6e17da5e8fba24842d1e5b4ce411 /smcc/src
parent05f743f601a30eac884e2e1819c34c1ebefd4d98 (diff)
downloadmocca-b71102bec28087ea3514f54af81741fa48502ccc.tar.gz
mocca-b71102bec28087ea3514f54af81741fa48502ccc.tar.bz2
mocca-b71102bec28087ea3514f54af81741fa48502ccc.zip
Enable different hashing algorithms for use with SWCard
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1185 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smcc/src')
-rw-r--r--smcc/src/main/java/at/gv/egiz/smcc/SWCard.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java
index 81b347c3..a896c9a1 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java
@@ -375,7 +375,28 @@ public class SWCard implements SignatureCard {
}
String algorithm = privateKey.getAlgorithm();
- algorithm = "SHA1with" + algorithm;
+
+ if (algorithm.equals("RSA")) {
+ if (alg == null ||
+ "http://www.w3.org/2000/09/xmldsig#rsa-sha1".equals(alg)) {
+ algorithm = "SHA1withRSA";
+ } else if (
+ "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256".equals(alg)) {
+ algorithm = "SHA256withRSA";
+ }
+ } else if (algorithm.equals("ECDSA")) {
+ if (alg == null ||
+ "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1".equals(alg)) {
+ algorithm = "SHA1withECDSA";
+ } else if (
+ "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256".equals(alg)) {
+ algorithm = "SHA256withECDSA";
+ } else if (
+ "http://www.w3.org/2007/05/xmldsig-more#ecdsa-ripemd160".equals(alg)) {
+ algorithm = "RIPEMD160withECDSA";
+ }
+ }
+
try {
Signature signature = Signature.getInstance(algorithm);
signature.initSign(privateKey);