public override byte[] CreateSignature(byte[] rgbHash) { if (rgbHash == null) { throw new ArgumentNullException(nameof(rgbHash)); } ReadOnlySpan <byte> source = rgbHash; byte[] arrayToReturnToArrayPool = AdjustHashSizeIfNecessaryWithArrayPool(ref source); try { using (SafeNCryptKeyHandle keyHandle = GetDuplicatedKeyHandle()) { unsafe { return(CngCommon.SignHash(keyHandle, source, AsymmetricPaddingMode.None, null, source.Length * 2)); } } } finally { if (arrayToReturnToArrayPool != null) { Array.Clear(arrayToReturnToArrayPool, 0, source.Length); ArrayPool <byte> .Shared.Return(arrayToReturnToArrayPool); } } }
public override byte[] CreateSignature(byte[] rgbHash) { ArgumentNullException.ThrowIfNull(rgbHash); Span <byte> stackBuf = stackalloc byte[WindowsMaxQSize]; ReadOnlySpan <byte> source = AdjustHashSizeIfNecessary(rgbHash, stackBuf); using (SafeNCryptKeyHandle keyHandle = GetDuplicatedKeyHandle()) { unsafe { return(CngCommon.SignHash(keyHandle, source, AsymmetricPaddingMode.None, null, source.Length * 2)); } } }
public override byte[] CreateSignature(byte[] hash) { if (hash == null) { throw new ArgumentNullException(nameof(hash)); } hash = AdjustHashSizeIfNecessary(hash); using (SafeNCryptKeyHandle keyHandle = GetDuplicatedKeyHandle()) { unsafe { byte[] signature = CngCommon.SignHash(keyHandle, hash, AsymmetricPaddingMode.None, null, hash.Length * 2); return(signature); } } }