You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CryptographicException should be thrown when MLKem.ImportPkcs8PrivateKey is called with an input buffer that is shorter than expected, but AsnContentException is thrown instead.
[Fact]publicstaticvoidArgumentValidation_MalformedAsnEncoding(){// Generate a valid ASN.1 encodingAsnWriterwriter=newAsnWriter(AsnEncodingRules.BER);writer.WriteOctetString("some data"u8);byte[]encodedBytes=writer.Encode();intencodedLength=encodedBytes.Length;// Add a trailing byteArray.Resize(refencodedBytes,encodedLength+1);Assert.Throws<CryptographicException>(()=>MLKem.ImportPkcs8PrivateKey(encodedBytes));// Remove the last byte so the length indicated in the encoding will be larger than the actual data.Array.Resize(refencodedBytes,encodedLength-1);Assert.Throws<CryptographicException>(()=>MLKem.ImportPkcs8PrivateKey(encodedBytes));// <-- FAILS}
CryptographicException
should be thrown whenMLKem.ImportPkcs8PrivateKey
is called with an input buffer that is shorter than expected, butAsnContentException
is thrown instead.Error is thrown from:
runtime/src/libraries/Common/src/System/Security/Cryptography/MLKem.cs
Line 1746 in 32463ba
Test Failure:
The text was updated successfully, but these errors were encountered: