Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable skipped SSC.Algorithms tests on Andorid #56573

Merged
merged 3 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,48 @@ public override void ImportParameters(RSAParameters parameters)
ValidateParameters(ref parameters);
ThrowIfDisposed();

if (parameters.Exponent == null || parameters.Modulus == null)
{
throw new CryptographicException(SR.Cryptography_InvalidRsaParameters);
}

if (parameters.D == null)
steveisok marked this conversation as resolved.
Show resolved Hide resolved
{
if (parameters.P != null ||
parameters.DP != null ||
parameters.Q != null ||
parameters.DQ != null ||
parameters.InverseQ != null)
{
throw new CryptographicException(SR.Cryptography_InvalidRsaParameters);
}
}
else
{
if (parameters.P == null ||
parameters.DP == null ||
parameters.Q == null ||
parameters.DQ == null ||
parameters.InverseQ == null)
{
throw new CryptographicException(SR.Cryptography_InvalidRsaParameters);
}

// Half, rounded up.
int halfModulusLength = (parameters.Modulus.Length + 1) / 2;

// Matching the .NET Framework RSACryptoServiceProvider behavior, as that's the .NET de facto standard
if (parameters.D.Length != parameters.Modulus.Length ||
parameters.P.Length != halfModulusLength ||
parameters.Q.Length != halfModulusLength ||
parameters.DP.Length != halfModulusLength ||
parameters.DQ.Length != halfModulusLength ||
parameters.InverseQ.Length != halfModulusLength)
{
throw new CryptographicException(SR.Cryptography_InvalidRsaParameters);
}
}

SafeRsaHandle key = Interop.AndroidCrypto.RsaCreate();
bool imported = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ public static void VerifyDefaultKeySize_Fips186_2()
}

[ConditionalFact(nameof(SupportsKeyGeneration))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/50580", TestPlatforms.Android)]
public static void GenerateMinKey()
{
GenerateKey(dsa => GetMin(dsa.LegalKeySizes));
}

[ConditionalFact(nameof(SupportsKeyGeneration), nameof(HasSecondMinSize))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/50580", TestPlatforms.Android)]
public static void GenerateSecondMinKey()
{
GenerateKey(dsa => GetSecondMin(dsa.LegalKeySizes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,6 @@ public static void FromInvalidXml()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/29515", TestPlatforms.OSX | TestPlatforms.Android)]
public static void FromNonsenseXml()
{
// This is DiminishedDPParameters XML, but with a P that is way too long.
Expand Down