예제 #1
0
        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();
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }