public unsafe int SignHash(IHashProvider provider, SignatureScheme scheme, ref WritableBuffer writer, byte *message, int messageLength) { var hash = provider.GetHashInstance(_hashType); hash.HashData(message, messageLength); var digest = new byte[hash.HashSize]; fixed(byte *dPtr = digest) { hash.InterimHash(dPtr, digest.Length); } writer.Ensure(_privateKey.KeySize); var result = _privateKey.SignHash(digest); writer.Write(result); return(result.Length); }
public unsafe int SignHash(IHashProvider provider, SignatureScheme scheme, ref WritableBuffer writer, byte *message, int messageLength) { var hash = provider.GetHashInstance(_hashType); hash.HashData(message, messageLength); var digest = new byte[hash.HashSize]; fixed(byte *dPtr = digest) { hash.InterimHash(dPtr, digest.Length); } var result = _privateKey.SignHash(digest); var enc = new System.Security.Cryptography.AsnEncodedData(_certificate.SignatureAlgorithm, result); writer.Write(result); return(result.Length); }
public unsafe int SignHash(IHashProvider provider, SignatureScheme scheme, ref WritableBuffer writer, byte *message, int messageLength) { var hash = provider.GetHashInstance(_hashType); hash.HashData(message, messageLength); var digest = new byte[hash.HashSize]; fixed(byte *dPtr = digest) { hash.InterimHash(dPtr, digest.Length); } writer.Ensure(ECDSA_size(_ecKey)); GCHandle handle; var output = writer.Memory.GetPointer(out handle); try { fixed(byte *iPtr = digest) { var sigSize = writer.Memory.Length; ThrowOnError(ECDSA_sign(0, iPtr, digest.Length, output, ref sigSize, _ecKey)); writer.Advance(sigSize); return(sigSize); } } finally { if (handle.IsAllocated) { handle.Free(); } } }