Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -1362,7 +1362,7 @@ public static MLKem ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password,
/// The imported key.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="password" /> is <see langword="null" />.
/// <paramref name="password" /> or <paramref name="source" /> is <see langword="null" />.
/// </exception>
/// <exception cref="CryptographicException">
/// <para>
Expand All @@ -1385,9 +1385,10 @@ public static MLKem ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password,
/// The platform does not support ML-KEM. Callers can use the <see cref="IsSupported" /> property
/// to determine if the platform supports ML-KEM.
/// </exception>
public static MLKem ImportEncryptedPkcs8PrivateKey(string password, ReadOnlySpan<byte> source)
public static MLKem ImportEncryptedPkcs8PrivateKey(string password, byte[] source)
{
ArgumentNullException.ThrowIfNull(password);
ArgumentNullException.ThrowIfNull(source);
ThrowIfTrailingData(source);
ThrowIfNotSupported();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public static void ImportEncryptedPkcs8PrivateKey_WrongAlgorithm()
gJoH9z0+/Z9WzLU8ix8F7B+HWwRhib5Cd6si+AX6DsNelMq2zP1NO7Un416dkg==");

Assert.Throws<CryptographicException>(() =>
MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", new ReadOnlySpan<byte>(ecP256Key)));
MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", ecP256Key));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have to change that many tests because most of the tests used a string for the password parameter forces binding to a specific overload. I just changed this one since the span-wrapping served no purpose anymore.


Assert.Throws<CryptographicException>(() =>
MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER".AsSpan(), new ReadOnlySpan<byte>(ecP256Key)));
Expand Down Expand Up @@ -620,6 +620,16 @@ public static void ImportEncryptedPkcs8PrivateKey_Both_BytePassword()
}
}

[Fact]
public static void ImportEncryptedPkcs8PrivateKey_NullArgs()
{
AssertExtensions.Throws<ArgumentNullException>("source", static () =>
MLKem.ImportEncryptedPkcs8PrivateKey(MLKemTestData.EncryptedPrivateKeyPassword, (byte[])null));

AssertExtensions.Throws<ArgumentNullException>("password", static () =>
MLKem.ImportEncryptedPkcs8PrivateKey((string)null, MLKemTestData.IetfMlKem512EncryptedPrivateKeySeed));
}

[Fact]
public static void ImportFromPem_NullSource()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ public void ExportPrivateSeed(System.Span<byte> destination) { }
public static System.Security.Cryptography.MLKem ImportEncapsulationKey(System.Security.Cryptography.MLKemAlgorithm algorithm, System.ReadOnlySpan<byte> source) { throw null; }
public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(System.ReadOnlySpan<byte> passwordBytes, System.ReadOnlySpan<byte> source) { throw null; }
public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(System.ReadOnlySpan<char> password, System.ReadOnlySpan<byte> source) { throw null; }
public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(string password, System.ReadOnlySpan<byte> source) { throw null; }
public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(string password, byte[] source) { throw null; }
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(System.ReadOnlySpan<char> source, System.ReadOnlySpan<byte> passwordBytes) { throw null; }
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(System.ReadOnlySpan<char> source, System.ReadOnlySpan<char> password) { throw null; }
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(string source, byte[] passwordBytes) { throw null; }
Expand Down
Loading