private static void CheckGenericDsaRsaCryptographyAlgorithms(ITypeSymbol containingType, SyntaxNode syntaxElement, SyntaxNode keyLengthSyntax, SyntaxNodeAnalysisContext c) { if (containingType.DerivesFromAny(SystemSecurityCryptographyDsaRsa) && keyLengthSyntax != null && IsInvalidCommonKeyLength(keyLengthSyntax, c)) { c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, syntaxElement.GetLocation(), MinimalCommonKeyLength, CipherName(containingType), "")); } }
private void CheckSystemSecurityEllipticCurve(ITypeSymbol containingType, SyntaxNode syntaxElement, ArgumentListSyntax argumentList, SyntaxNodeAnalysisContext c) { var firstParam = argumentList.Get(0); if (firstParam == null || containingType == null || !containingType.DerivesFromAny(SystemSecurityCryptographyCurveClasses)) { return; } if (c.SemanticModel.GetSymbolInfo(firstParam).Symbol is { } paramSymbol) { CheckCurveNameKeyLength(syntaxElement, paramSymbol.Name, c); } }
public static bool DerivesOrImplementsAny(this ITypeSymbol type, ISet <KnownType> baseTypes) { return(type.ImplementsAny(baseTypes) || type.DerivesFromAny(baseTypes)); }