diff options
author | PJ Fanning <fanningpj@apache.org> | 2018-01-26 13:30:32 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2018-01-26 13:30:32 +0000 |
commit | 47a21a80d4a35fd7905f092e71b80c8a6e2ae5cb (patch) | |
tree | bf5678abe07cbf5a6df5025434243dce13f2d771 /src | |
parent | 8e458d814a623f64f5c24e0d0ed4f9b6b85d5163 (diff) | |
download | poi-47a21a80d4a35fd7905f092e71b80c8a6e2ae5cb.tar.gz poi-47a21a80d4a35fd7905f092e71b80c8a6e2ae5cb.zip |
[github-90] change default DSIG algorithm to SHA256. Thanks to Jörn Franke. This closes #90
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1822293 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureConfig.java | 33 |
2 files changed, 35 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java index 6784ef10aa..85df30b3fd 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java @@ -74,7 +74,7 @@ public class SignatureConfig { private ThreadLocal<Provider> provider = new ThreadLocal<>(); private List<SignatureFacet> signatureFacets = new ArrayList<>(); - private HashAlgorithm digestAlgo = HashAlgorithm.sha1; + private HashAlgorithm digestAlgo = HashAlgorithm.sha256; private Date executionTime = new Date(); private PrivateKey key; private List<X509Certificate> signingCertificateChain; @@ -234,7 +234,7 @@ public class SignatureConfig { } /** - * @return the main digest algorithm, defaults to sha-1 + * @return the main digest algorithm, defaults to sha256 */ public HashAlgorithm getDigestAlgo() { return digestAlgo; diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureConfig.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureConfig.java new file mode 100644 index 0000000000..4ded53bb2d --- /dev/null +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureConfig.java @@ -0,0 +1,33 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.poifs.crypt.dsig; + +import org.apache.poi.poifs.crypt.HashAlgorithm; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TestSignatureConfig { + + @Test + public void testDigestAlgo() throws Exception { + SignatureConfig sc = new SignatureConfig(); + assertEquals(HashAlgorithm.sha256, sc.getDigestAlgo()); + sc.setDigestAlgo(HashAlgorithm.sha1); + assertEquals(HashAlgorithm.sha1, sc.getDigestAlgo()); + } +} |