public bool VerifySignature(
DicomElement signatureItem
)
public:
bool VerifySignature(
DicomElement^ signatureItem
)
signatureItem
The Digital Signatures Sequence Item that corresponds to the Digital Signature to be verified. To verify all the Digital Signatures in the entire Data Set, set this parameter to null.
true if The Digital Signature(s) was/were verified successfully; false if the Digital Signature is invalid or at least one of the Digital Signatures is invalid.
To verify all the Digital Signatures in the entire Data Set, set the signatureItem parameter to null. If at least one of these Digital Signatures is invalid, the method returns false and does not examine the remaining Digital Signatures, if there are any.
This example will verify a DICOM digital signature and display its details.
using Leadtools;
using Leadtools.Dicom;
public void ExamineSignature(DicomDataSet dataset, DicomElement signatureItem)
{
// Verify the Digital Signature; if pSignatureItem is NULL, the function
// will verify all the Digital Signatures that exist in the Data Set
bool ret = dataset.VerifySignature(signatureItem);
if (ret == true)
{
if (signatureItem != null)
{
Console.WriteLine("Sample: The Digital Signature was verified.");
}
else
{
Console.WriteLine("Sample: All Digital Signatures were verified (if there are any).");
}
}
else
{
if (signatureItem != null)
{
Console.WriteLine("Sample: The Digital Signature is invalid.");
}
else
{
Console.WriteLine("Sample: At least one Digital Signature is invalid.");
}
}
// The Digital Signature UID
StringBuilder msg = new StringBuilder();
msg.Append(dataset.GetSignatureUID(signatureItem));
// The Digital Signature DateTime
DicomDateTimeValue digitalSignatureDateTime = dataset.GetSignatureDateTime(signatureItem);
if (digitalSignatureDateTime.IsEmpty == false)
{
msg.AppendFormat(" Digital Signature DateTime:{0}/{1}/{2} {3}:{4}:{5}.{6} {7}{8}{9}",
digitalSignatureDateTime.Month,
digitalSignatureDateTime.Day,
digitalSignatureDateTime.Year,
digitalSignatureDateTime.Hours,
digitalSignatureDateTime.Minutes,
digitalSignatureDateTime.Seconds,
digitalSignatureDateTime.Fractions,
(digitalSignatureDateTime.Offset >= 0) ? '+' : '-',
digitalSignatureDateTime.Offset,
Environment.NewLine);
}
string macTransferSyntax = dataset.GetMacTransferSyntax(signatureItem);
if (macTransferSyntax != null)
{
msg.AppendFormat("MAC Calculation Transfer Syntax UID: {0}", macTransferSyntax);
}
string macAlgorithm = dataset.GetMacAlgorithm(signatureItem);
if (macAlgorithm != null)
{
msg.AppendFormat("MAC Algorithm: {0}", macAlgorithm);
}
// The Data Elements Signed
if (dataset.GetSignedElementsCount(signatureItem) > 0)
{
// We will display only one
DicomElement element = dataset.GetSignedElement(signatureItem, 0);
msg.AppendFormat(" Data Elements Signed:{0}{1}{1}", element.Tag, Environment.NewLine);
}
msg.AppendFormat("{0}Do you want to save the Certificate of Signer?", Environment.NewLine);
Console.WriteLine($"Sample: {msg.ToString()}");
dataset.SaveCertificate(signatureItem, Path.Combine(LEAD_VARS.ImagesDir, "CertOfSigner.cer"), DicomCertificateFormat.Pem);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document