org.bouncycastle.tls.crypto.impl.jcajce.JcaTlsDSAVerifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bctls-fips Show documentation
Show all versions of bctls-fips Show documentation
The Bouncy Castle Java APIs for the TLS, including a JSSE provider. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
package org.bouncycastle.tls.crypto.impl.jcajce;
import java.io.IOException;
import java.security.PublicKey;
import org.bouncycastle.tls.DigitallySigned;
import org.bouncycastle.tls.HashAlgorithm;
import org.bouncycastle.tls.SignatureAlgorithm;
import org.bouncycastle.tls.SignatureAndHashAlgorithm;
import org.bouncycastle.tls.crypto.TlsStreamVerifier;
/**
* Implementation class for the verification of the raw DSA signature type using the JCA.
*/
public class JcaTlsDSAVerifier
extends JcaTlsDSSVerifier
{
public JcaTlsDSAVerifier(JcaTlsCrypto crypto, PublicKey publicKey)
{
super(crypto, publicKey, SignatureAlgorithm.dsa, "NoneWithDSA");
}
public TlsStreamVerifier getStreamVerifier(DigitallySigned digitallySigned) throws IOException
{
SignatureAndHashAlgorithm algorithm = digitallySigned.getAlgorithm();
/*
* Unfortunately "NoneWithDSA" (a.k.a "RawDSA") only works with 20 byte inputs in the SUN
* provider. Therefore we need to use a stream signer for other cases.
*
* TODO We could do a test run for raw DSA support of other sizes and then resort to the
* stream signer only when the provider doesn't support wider hashes.
*/
if (null != algorithm
&& algorithmType == algorithm.getSignature()
&& HashAlgorithm.getOutputSize(algorithm.getHash()) != 20)
{
return crypto.createStreamVerifier(digitallySigned, publicKey);
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy