diff --git a/src/libraries/Common/src/System/Security/Cryptography/MLKem.cs b/src/libraries/Common/src/System/Security/Cryptography/MLKem.cs index 4d830326d9c3ce..7a107be189a162 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/MLKem.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/MLKem.cs @@ -1362,7 +1362,7 @@ public static MLKem ImportEncryptedPkcs8PrivateKey(ReadOnlySpan password, /// The imported key. /// /// - /// is . + /// or is . /// /// /// @@ -1385,9 +1385,10 @@ public static MLKem ImportEncryptedPkcs8PrivateKey(ReadOnlySpan password, /// The platform does not support ML-KEM. Callers can use the property /// to determine if the platform supports ML-KEM. /// - public static MLKem ImportEncryptedPkcs8PrivateKey(string password, ReadOnlySpan source) + public static MLKem ImportEncryptedPkcs8PrivateKey(string password, byte[] source) { ArgumentNullException.ThrowIfNull(password); + ArgumentNullException.ThrowIfNull(source); ThrowIfTrailingData(source); ThrowIfNotSupported(); diff --git a/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs b/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs index 6fb11ab0c8b771..414cb86020461c 100644 --- a/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs +++ b/src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs @@ -464,7 +464,7 @@ public static void ImportEncryptedPkcs8PrivateKey_WrongAlgorithm() gJoH9z0+/Z9WzLU8ix8F7B+HWwRhib5Cd6si+AX6DsNelMq2zP1NO7Un416dkg=="); Assert.Throws(() => - MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", new ReadOnlySpan(ecP256Key))); + MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", ecP256Key)); Assert.Throws(() => MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER".AsSpan(), new ReadOnlySpan(ecP256Key))); @@ -620,6 +620,16 @@ public static void ImportEncryptedPkcs8PrivateKey_Both_BytePassword() } } + [Fact] + public static void ImportEncryptedPkcs8PrivateKey_NullArgs() + { + AssertExtensions.Throws("source", static () => + MLKem.ImportEncryptedPkcs8PrivateKey(MLKemTestData.EncryptedPrivateKeyPassword, (byte[])null)); + + AssertExtensions.Throws("password", static () => + MLKem.ImportEncryptedPkcs8PrivateKey((string)null, MLKemTestData.IetfMlKem512EncryptedPrivateKeySeed)); + } + [Fact] public static void ImportFromPem_NullSource() { diff --git a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs index 3666f4573e9009..c3b79c1288cff2 100644 --- a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs +++ b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs @@ -1909,7 +1909,7 @@ public void ExportPrivateSeed(System.Span destination) { } public static System.Security.Cryptography.MLKem ImportEncapsulationKey(System.Security.Cryptography.MLKemAlgorithm algorithm, System.ReadOnlySpan source) { throw null; } public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(System.ReadOnlySpan passwordBytes, System.ReadOnlySpan source) { throw null; } public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(System.ReadOnlySpan password, System.ReadOnlySpan source) { throw null; } - public static System.Security.Cryptography.MLKem ImportEncryptedPkcs8PrivateKey(string password, System.ReadOnlySpan 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 source, System.ReadOnlySpan passwordBytes) { throw null; } public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(System.ReadOnlySpan source, System.ReadOnlySpan password) { throw null; } public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(string source, byte[] passwordBytes) { throw null; }