/// <summary> /// Метод вычисления подписи без использования закрытого ключа /// </summary> /// <param name="prefix"></param> /// <param name="certificate"></param> public void ComputeSignatureWithoutPrivateKey(string prefix, IntPtr certificate) { if (SignServiceUtils.IsUnix) { CryptoConfig.AddAlgorithm(typeof(HashAlgGost2001Unix), new string[1] { "http://www.w3.org/2001/04/xmldsig-more#gostr3411" }); CryptoConfig.AddAlgorithm(typeof(HashAlgGost2012_256Unix), new string[1] { "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-256" }); CryptoConfig.AddAlgorithm(typeof(HashAlgGost2012_512Unix), new string[1] { "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-512" }); } else { CryptoConfig.AddAlgorithm(typeof(HashAlgGost2001Win), new string[1] { "http://www.w3.org/2001/04/xmldsig-more#gostr3411" }); CryptoConfig.AddAlgorithm(typeof(HashAlgGost2012_256Win), new string[1] { "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-256" }); CryptoConfig.AddAlgorithm(typeof(HashAlgGost2012_512Win), new string[1] { "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-512" }); } CryptoConfig.AddAlgorithm(typeof(SmevTransformAlg), new string[1] { SmevTransformAlg.ALGORITHM_URI }); BuildDigestedReferences(); int algId = 0; HashAlgorithm hash = SignServiceUtils.GetHashAlgObject(certificate, ref algId); GetDigest(hash, prefix); uint keySpec = CApiExtConst.AT_SIGNATURE; IntPtr cpHandle = (SignServiceUtils.IsUnix) ? UnixExtUtil.GetHandler(certificate, out keySpec) : Win32ExtUtil.GetHandler(certificate, out keySpec); byte[] sign = (SignServiceUtils.IsUnix) ? UnixExtUtil.SignValue(cpHandle, (int)keySpec, hash.Hash, (int)0, algId) : Win32ExtUtil.SignValue(cpHandle, (int)keySpec, hash.Hash, (int)0, algId); Array.Reverse(sign); m_signature.SignatureValue = sign; SignServiceUtils.ReleaseProvHandle(cpHandle); }