Search in sources :

Example 6 with TlsCrypto

use of org.openecard.bouncycastle.tls.crypto.TlsCrypto in project open-ecard by ecsec.

the class ClientCertPSKTlsClient method getSupportedSignatureAlgorithms.

@Override
protected Vector getSupportedSignatureAlgorithms() {
    boolean weakCrypto = Boolean.valueOf(OpenecardProperties.getProperty("legacy.weak_crypto"));
    TlsCrypto crypto = context.getCrypto();
    short[] hashAlgorithms;
    if (!weakCrypto) {
        hashAlgorithms = new short[] { HashAlgorithm.sha512, HashAlgorithm.sha384, HashAlgorithm.sha256, HashAlgorithm.sha224 };
    } else {
        hashAlgorithms = new short[] { HashAlgorithm.sha512, HashAlgorithm.sha384, HashAlgorithm.sha256, HashAlgorithm.sha224, HashAlgorithm.sha1 };
    }
    short[] signatureAlgorithms = new short[] { SignatureAlgorithm.rsa, SignatureAlgorithm.ecdsa };
    Vector result = new Vector();
    for (int i = 0; i < signatureAlgorithms.length; ++i) {
        for (int j = 0; j < hashAlgorithms.length; ++j) {
            SignatureAndHashAlgorithm alg = new SignatureAndHashAlgorithm(hashAlgorithms[j], signatureAlgorithms[i]);
            if (crypto.hasSignatureAndHashAlgorithm(alg)) {
                result.addElement(alg);
            }
        }
    }
    return result;
}
Also used : Vector(java.util.Vector) TlsCrypto(org.openecard.bouncycastle.tls.crypto.TlsCrypto) SignatureAndHashAlgorithm(org.openecard.bouncycastle.tls.SignatureAndHashAlgorithm)

Aggregations

TlsCrypto (org.openecard.bouncycastle.tls.crypto.TlsCrypto)6 BcTlsCrypto (org.openecard.bouncycastle.tls.crypto.impl.bc.BcTlsCrypto)4 ClientCertDefaultTlsClient (org.openecard.crypto.tls.ClientCertDefaultTlsClient)4 DynamicAuthentication (org.openecard.crypto.tls.auth.DynamicAuthentication)4 URL (java.net.URL)3 JavaSecVerifier (org.openecard.crypto.tls.verify.JavaSecVerifier)3 MalformedURLException (java.net.MalformedURLException)2 Socket (java.net.Socket)2 Vector (java.util.Vector)2 ProtocolVersion (org.openecard.bouncycastle.tls.ProtocolVersion)2 SignatureAndHashAlgorithm (org.openecard.bouncycastle.tls.SignatureAndHashAlgorithm)2 TlsClientProtocol (org.openecard.bouncycastle.tls.TlsClientProtocol)2 SameCertVerifier (org.openecard.crypto.tls.verify.SameCertVerifier)2 TCTokenType (generated.TCTokenType)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 URISyntaxException (java.net.URISyntaxException)1 InvalidTCTokenElement (org.openecard.addons.cg.ex.InvalidTCTokenElement)1 Header (org.openecard.apache.http.Header)1