Skip to content

ML-DSA: NCrypt does not support signing empty data #116461

@PranavSenthilnathan

Description

@PranavSenthilnathan

Passing a zero length pHash buffer to NCryptSignHash gives the following error:

  Failed System.Security.Cryptography.Tests.MLDsaCngTests_AllowPlaintextExport.GenerateSignVerifyEmptyMessageWithContext(algorithm: MLDsaAlgorithm { Name = "ML-DSA-44", PrivateSeedSizeInBytes = 32, PublicKeySizeInBytes = 1312, SecretKeySizeInBytes = 2560, SignatureSizeInBytes = 2420 }) [2 ms]
  Error Message:
   System.Security.Cryptography.CryptographicException : The parameter is incorrect.
  Stack Trace:
     at System.Security.Cryptography.CngCommon.SignHash(SafeNCryptKeyHandle keyHandle, ReadOnlySpan`1 hash, Span`1 destination, AsymmetricPaddingMode paddingMode, Void* pPaddingInfo) in D:\git\runtime\src\libraries\System.Security.Cryptography\src\System\Security\Cryptography\CngCommon.SignVerify.cs:line 65
   at System.Security.Cryptography.MLDsaCng.SignDataCore(ReadOnlySpan`1 data, ReadOnlySpan`1 context, Span`1 destination) in D:\git\runtime\src\libraries\System.Security.Cryptography\src\System\Security\Cryptography\MLDsaCng.Windows.cs:line 229
   at System.Security.Cryptography.MLDsa.SignData(ReadOnlySpan`1 data, Span`1 destination, ReadOnlySpan`1 context) in D:\git\runtime\src\libraries\Common\src\System\Security\Cryptography\MLDsa.cs:line 128
   at System.Security.Cryptography.Tests.MLDsaTestsBase.GenerateSignVerifyEmptyMessageWithContext(MLDsaAlgorithm algorithm) in D:\git\runtime\src\libraries\Common\tests\System\Security\Cryptography\AlgorithmImplementations\MLDsa\MLDsaTestsBase.cs:line 70
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) in C:\d\git\runtime\src\coreclr\System.Private.CoreLib\src\System\RuntimeHandles.cs:line 1168
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) in C:\d\git\runtime\src\coreclr\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.CoreCLR.cs:line 36
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr) in C:\d\git\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.cs:line 174

The tests have been disabled until this is supported by Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions