/// <summary> /// Creates the signature. /// </summary> /// <param name="input">The input.</param> /// <returns> /// Signed input data. /// </returns> public override byte[] Sign(byte[] input) { #if NETSTANDARD2_0 var signed = _key.Ecdsa.SignData(input, _key.HashAlgorithm); #else var ecdsa = (ECDsaCng)_key.Ecdsa; ecdsa.HashAlgorithm = _key.HashAlgorithm; var signed = ecdsa.SignData(input); #endif var ssh_data = new SshDataSignature(signed.Length); ssh_data.Signature = signed; return(ssh_data.GetBytes()); }
/// <summary> /// Verifies the signature. /// </summary> /// <param name="input">The input.</param> /// <param name="signature">The signature.</param> /// <returns> /// <c>true</c> if signature was successfully verified; otherwise <c>false</c>. /// </returns> public override bool Verify(byte[] input, byte[] signature) { // for 521 sig_size is 132 var sig_size = _key.KeyLength == 521 ? 132 : _key.KeyLength / 4; var ssh_data = new SshDataSignature(signature, sig_size); #if NETSTANDARD2_0 return(_key.Ecdsa.VerifyData(input, ssh_data.Signature, _key.HashAlgorithm)); #else var ecdsa = (ECDsaCng)_key.Ecdsa; ecdsa.HashAlgorithm = _key.HashAlgorithm; return(ecdsa.VerifyData(input, ssh_data.Signature)); #endif }