internal static IDigest GetSignerDigest(ISigner signer) { var fields = signer.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic); var digestType = typeof(IDigest); foreach (var field in fields) { if (digestType.IsAssignableFrom(field.FieldType)) { return((IDigest)field.GetValue(signer)); } } throw new InvalidOperationException(); }
internal static void LogSigning(SignedXml signedXml, object key, ISigner signatureDescription) { Debug.Assert(signedXml != null, "signedXml != null"); Debug.Assert(signatureDescription != null, "signatureDescription != null"); if (InformationLoggingEnabled) { string logMessage = string.Format(CultureInfo.InvariantCulture, SR.Log_SigningAsymmetric, GetKeyName(key), signatureDescription.GetType().Name, signatureDescription.AlgorithmName, ""); WriteLine(signedXml, TraceEventType.Information, SignedXmlDebugEvent.Signing, logMessage); } }
internal static void LogVerifySignedInfo(SignedXml signedXml, AsymmetricKeyParameter key, ISigner signatureDescription, byte[] actualHashValue, byte[] signatureValue) { Debug.Assert(signedXml != null, "signedXml != null"); Debug.Assert(signatureDescription != null, "signatureDescription != null"); if (InformationLoggingEnabled) { string logMessage = string.Format(CultureInfo.InvariantCulture, SR.Log_VerifySignedInfoAsymmetric, GetKeyName(key), signatureDescription.GetType().Name, signatureDescription.AlgorithmName, ""); WriteLine(signedXml, TraceEventType.Information, SignedXmlDebugEvent.VerifySignedInfo, logMessage); } if (VerboseLoggingEnabled) { string hashLog = string.Format(CultureInfo.InvariantCulture, SR.Log_ActualHashValue, FormatBytes(actualHashValue)); WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, hashLog); string signatureLog = string.Format(CultureInfo.InvariantCulture, SR.Log_RawSignatureValue, FormatBytes(signatureValue)); WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, signatureLog); } }