Search in sources :

Example 6 with DidInfo

use of org.openecard.crypto.common.sal.did.DidInfo in project open-ecard by ecsec.

the class SmartCardCredentialFactory method removeUnsupportedAlgs.

private List<DidInfo> removeUnsupportedAlgs(List<DidInfo> infos) {
    ArrayList<DidInfo> result = new ArrayList<>();
    for (DidInfo next : infos) {
        try {
            AlgorithmInfoType algInfo = next.getGenericCryptoMarker().getAlgorithmInfo();
            String algStr = algInfo.getAlgorithmIdentifier().getAlgorithm();
            SignatureAlgorithms alg = SignatureAlgorithms.fromAlgId(algStr);
            switch(alg) {
                case CKM_ECDSA:
                // case CKM_ECDSA_SHA1: // too weak
                case CKM_ECDSA_SHA256:
                case CKM_ECDSA_SHA384:
                case CKM_ECDSA_SHA512:
                case CKM_RSA_PKCS:
                // case CKM_SHA1_RSA_PKCS: // too weak
                case CKM_SHA256_RSA_PKCS:
                case CKM_SHA384_RSA_PKCS:
                case CKM_SHA512_RSA_PKCS:
                    result.add(next);
            }
        } catch (UnsupportedAlgorithmException ex) {
            LOG.error("Unsupported algorithm used in CIF. Skipping DID " + next.getDidName() + ".", ex);
        } catch (WSHelper.WSException ex) {
            LOG.error("Unknown error accessing DID " + next.getDidName() + ".", ex);
        }
    }
    return result;
}
Also used : WSHelper(org.openecard.common.WSHelper) DidInfo(org.openecard.crypto.common.sal.did.DidInfo) AlgorithmInfoType(iso.std.iso_iec._24727.tech.schema.AlgorithmInfoType) SignatureAlgorithms(org.openecard.crypto.common.SignatureAlgorithms) UnsupportedAlgorithmException(org.openecard.crypto.common.UnsupportedAlgorithmException) ArrayList(java.util.ArrayList)

Aggregations

DidInfo (org.openecard.crypto.common.sal.did.DidInfo)6 SecurityConditionUnsatisfiable (org.openecard.common.SecurityConditionUnsatisfiable)5 WSHelper (org.openecard.common.WSHelper)5 UnsupportedAlgorithmException (org.openecard.crypto.common.UnsupportedAlgorithmException)5 AlgorithmInfoType (iso.std.iso_iec._24727.tech.schema.AlgorithmInfoType)4 DidInfos (org.openecard.crypto.common.sal.did.DidInfos)4 IOException (java.io.IOException)3 X509Certificate (java.security.cert.X509Certificate)3 ArrayList (java.util.ArrayList)3 SignatureAlgorithms (org.openecard.crypto.common.SignatureAlgorithms)3 NoSuchDid (org.openecard.crypto.common.sal.did.NoSuchDid)3 CertificateException (java.security.cert.CertificateException)2 ParameterInvalid (org.openecard.addons.cg.ex.ParameterInvalid)2 SlotHandleInvalid (org.openecard.addons.cg.ex.SlotHandleInvalid)2 ThreadTerminateException (org.openecard.common.ThreadTerminateException)2 InvocationTargetExceptionUnchecked (org.openecard.common.interfaces.InvocationTargetExceptionUnchecked)2 AlgorithmIdentifierType (iso.std.iso_iec._24727.tech.schema.AlgorithmIdentifierType)1 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 StringWriter (java.io.StringWriter)1 InvalidParameterException (java.security.InvalidParameterException)1