System.Security.Cryptography.DSAImplementation.DSAOpenSsl.CreateSignature C# (CSharp) Method

CreateSignature() public method

public CreateSignature ( byte rgbHash ) : byte[]
rgbHash byte
return byte[]
            public override byte[] CreateSignature(byte[] rgbHash)
            {
                if (rgbHash == null)
                    throw new ArgumentNullException(nameof(rgbHash));

                SafeDsaHandle key = _key.Value;
                byte[] signature = new byte[Interop.Crypto.DsaEncodedSignatureSize(key)];

                int signatureSize;
                bool success = Interop.Crypto.DsaSign(key, rgbHash, rgbHash.Length, signature, out signatureSize);
                if (!success)
                {
                    throw Interop.Crypto.CreateOpenSslCryptographicException();
                }

                Debug.Assert(
                    signatureSize <= signature.Length,
                    "DSA_sign reported an unexpected signature size",
                    "DSA_sign reported signatureSize was {0}, when <= {1} was expected",
                    signatureSize,
                    signature.Length);

                int signatureFieldSize = Interop.Crypto.DsaSignatureFieldSize(key) * BitsPerByte;
                byte[] converted = OpenSslAsymmetricAlgorithmCore.ConvertDerToIeee1363(signature, 0, signatureSize, signatureFieldSize);
                return converted;
            }