PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/extern/spongycastle/pkix/src/main/java/org/spongycastle/operator/bc/BcDSAContentVerifierProviderBuilder.java

https://gitlab.com/vizilo/fdroidclient
Java | 40 lines | 33 code | 7 blank | 0 comment | 0 complexity | 6e94adf63c6be0b4e2a373aaa5563193 MD5 | raw file
 1package org.spongycastle.operator.bc;
 2
 3import java.io.IOException;
 4
 5import org.spongycastle.asn1.x509.AlgorithmIdentifier;
 6import org.spongycastle.asn1.x509.SubjectPublicKeyInfo;
 7import org.spongycastle.crypto.Digest;
 8import org.spongycastle.crypto.Signer;
 9import org.spongycastle.crypto.params.AsymmetricKeyParameter;
10import org.spongycastle.crypto.signers.DSADigestSigner;
11import org.spongycastle.crypto.signers.DSASigner;
12import org.spongycastle.crypto.util.PublicKeyFactory;
13import org.spongycastle.operator.DigestAlgorithmIdentifierFinder;
14import org.spongycastle.operator.OperatorCreationException;
15
16public class BcDSAContentVerifierProviderBuilder
17    extends BcContentVerifierProviderBuilder
18{
19    private DigestAlgorithmIdentifierFinder digestAlgorithmFinder;
20
21    public BcDSAContentVerifierProviderBuilder(DigestAlgorithmIdentifierFinder digestAlgorithmFinder)
22    {
23        this.digestAlgorithmFinder = digestAlgorithmFinder;
24    }
25
26    protected Signer createSigner(AlgorithmIdentifier sigAlgId)
27        throws OperatorCreationException
28    {
29        AlgorithmIdentifier digAlg = digestAlgorithmFinder.find(sigAlgId);
30        Digest dig = digestProvider.get(digAlg);
31
32        return new DSADigestSigner(new DSASigner(), dig);
33    }
34
35    protected AsymmetricKeyParameter extractKeyParameters(SubjectPublicKeyInfo publicKeyInfo)
36        throws IOException
37    {
38        return PublicKeyFactory.createKey(publicKeyInfo);
39    }
40}