use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testSHA3_384.
@org.junit.Test
public void testSHA3_384() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_384);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_384, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-384");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testSHA512.
@org.junit.Test
public void testSHA512() throws Exception {
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-512");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testSHA3_512.
@org.junit.Test
public void testSHA3_512() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_512);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_512, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-512");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testWhirlpool.
@org.junit.Test
public void testWhirlpool() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_WHIRLPOOL);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_WHIRLPOOL, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("WHIRLPOOL");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testSHA3_224.
@org.junit.Test
public void testSHA3_224() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_224);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_224, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-224");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
Aggregations