Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pkix/src/main/java/org/bouncycastle/operator/jcajce/JcaDigestCalculatorProviderBuilder.java')
-rw-r--r--pkix/src/main/java/org/bouncycastle/operator/jcajce/JcaDigestCalculatorProviderBuilder.java114
1 files changed, 0 insertions, 114 deletions
diff --git a/pkix/src/main/java/org/bouncycastle/operator/jcajce/JcaDigestCalculatorProviderBuilder.java b/pkix/src/main/java/org/bouncycastle/operator/jcajce/JcaDigestCalculatorProviderBuilder.java
deleted file mode 100644
index e3567962..00000000
--- a/pkix/src/main/java/org/bouncycastle/operator/jcajce/JcaDigestCalculatorProviderBuilder.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package org.bouncycastle.operator.jcajce;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.GeneralSecurityException;
-import java.security.MessageDigest;
-import java.security.Provider;
-
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.jcajce.util.DefaultJcaJceHelper;
-import org.bouncycastle.jcajce.util.NamedJcaJceHelper;
-import org.bouncycastle.jcajce.util.ProviderJcaJceHelper;
-import org.bouncycastle.operator.DigestCalculator;
-import org.bouncycastle.operator.DigestCalculatorProvider;
-import org.bouncycastle.operator.OperatorCreationException;
-
-public class JcaDigestCalculatorProviderBuilder
-{
- private OperatorHelper helper = new OperatorHelper(new DefaultJcaJceHelper());
-
- public JcaDigestCalculatorProviderBuilder()
- {
- }
-
- public JcaDigestCalculatorProviderBuilder setProvider(Provider provider)
- {
- this.helper = new OperatorHelper(new ProviderJcaJceHelper(provider));
-
- return this;
- }
-
- public JcaDigestCalculatorProviderBuilder setProvider(String providerName)
- {
- this.helper = new OperatorHelper(new NamedJcaJceHelper(providerName));
-
- return this;
- }
-
- public DigestCalculatorProvider build()
- throws OperatorCreationException
- {
- return new DigestCalculatorProvider()
- {
- public DigestCalculator get(final AlgorithmIdentifier algorithm)
- throws OperatorCreationException
- {
- final DigestOutputStream stream;
-
- try
- {
- MessageDigest dig = helper.createDigest(algorithm);
-
- stream = new DigestOutputStream(dig);
- }
- catch (GeneralSecurityException e)
- {
- throw new OperatorCreationException("exception on setup: " + e, e);
- }
-
- return new DigestCalculator()
- {
- public AlgorithmIdentifier getAlgorithmIdentifier()
- {
- return algorithm;
- }
-
- public OutputStream getOutputStream()
- {
- return stream;
- }
-
- public byte[] getDigest()
- {
- return stream.getDigest();
- }
- };
- }
- };
- }
-
- private class DigestOutputStream
- extends OutputStream
- {
- private MessageDigest dig;
-
- DigestOutputStream(MessageDigest dig)
- {
- this.dig = dig;
- }
-
- public void write(byte[] bytes, int off, int len)
- throws IOException
- {
- dig.update(bytes, off, len);
- }
-
- public void write(byte[] bytes)
- throws IOException
- {
- dig.update(bytes);
- }
-
- public void write(int b)
- throws IOException
- {
- dig.update((byte)b);
- }
-
- byte[] getDigest()
- {
- return dig.digest();
- }
- }
-} \ No newline at end of file