#include "ltdic.h"
L_UINT16 LDicomDS::VerifySignature(pSignatureItem, uReserved = 0)
Verifies Digital Signatures in the Data Set.
Pointer to a DICOMELEMENT structure that specifies the Digital Signatures Sequence Item which corresponds to the Digital Signature to be verified. To verify all the Digital Signatures in the entire Data Set, set this parameter to NULL.
Reserved for future use. This must be set to 0.
Value | Meaning |
---|---|
DICOM_SUCCESS | The Digital Signature(s) was/were verified successfully. |
DICOM_ERROR_INVALID_SIGNATURE | The Digital Signature is invalid or at least one of the Digital Signatures is invalid. |
(Otherwise) | An error occurred. Refer to Return Codes. |
To verify all the Digital Signatures in the entire Data Set, set the pSignatureItem parameter to NULL. If at least one of these Digital Signatures is invalid, the function returns DICOM_ERROR_INVALID_SIGNATURE and does not examine the remaining Digital Signatures, if there are any.
Required DLLs and Libraries
Win32, x64
L_VOID ExamineSignature(LDicomDS& DataSet, pDICOMELEMENT pSignatureItem)
{
L_TCHAR szMsg[1024] = TEXT("");
// Verify the Digital Signature; if pSignatureItem is NULL, the function
// will verify all the Digital Signatures that exist in the Data Set
L_UINT16 uRet = DataSet.VerifySignature(pSignatureItem);
switch (uRet)
{
case DICOM_SUCCESS:
if (pSignatureItem)
{
::MessageBox(NULL,
TEXT("The Digital Signature was verified."),
TEXT("Sample"),
MB_OK);
}
else
{
::MessageBox(NULL,
TEXT("All Digital Signatures were verified (if there are any)."),
TEXT("Sample"),
MB_OK);
return;
}
break;
case DICOM_ERROR_INVALID_SIGNATURE:
if (pSignatureItem)
{
::MessageBox(NULL,
TEXT("The Digital Signature is invalid."),
TEXT("Sample"),
MB_OK);
}
else
{
::MessageBox(NULL,
TEXT("At least one Digital Signature is invalid."),
TEXT("Sample"),
MB_OK);
}
return;
default:
wsprintf(szMsg, TEXT("An error occurred [Error: %hu]."), uRet);
::MessageBox(NULL, szMsg, TEXT("Sample"), MB_OK);
return;
}
// The Digital Signature UID
L_TCHAR* pszSignatureUID;
pszSignatureUID = DataSet.GetSignatureUID(pSignatureItem);
if (pszSignatureUID)
{
wsprintf(szMsg, TEXT("Digital Signature UID: %s\n"), pszSignatureUID);
}
// The Digital Signature DateTime
pVALUEDATETIME pSignatureDateTime;
pSignatureDateTime = DataSet.GetSignatureDateTime(pSignatureItem);
if (pSignatureDateTime)
{
wsprintf(szMsg, TEXT("%sDigital Signature DateTime: %02hu/%02hu/%04hu %02hu:%02hu:%02hu.%06lu %c%04li\n"),
szMsg,
pSignatureDateTime->nMonth,
pSignatureDateTime->nDay,
pSignatureDateTime->nYear,
pSignatureDateTime->nHours,
pSignatureDateTime->nMinutes,
pSignatureDateTime->nSeconds,
pSignatureDateTime->nFractions,
(pSignatureDateTime->nOffset >= 0) ? '+' : '-',
pSignatureDateTime->nOffset);
}
// The MAC Calculation Transfer Syntax UID
L_TCHAR* pszMacTransferSyntax;
pszMacTransferSyntax = DataSet.GetMacTransferSyntax(pSignatureItem);
if (pszMacTransferSyntax)
{
wsprintf(szMsg, TEXT("%sMAC Calculation Transfer Syntax UID: %s\n"),
szMsg,
pszMacTransferSyntax);
}
// The MAC Algorithm
L_TCHAR* pszMacAlgorithm;
pszMacAlgorithm = DataSet.GetMacAlgorithm(pSignatureItem);
if (pszMacAlgorithm)
{
wsprintf(szMsg,TEXT( "%sMAC Algorithm: %s\n"),
szMsg,
pszMacAlgorithm);
}
// The Data Elements Signed
if (DataSet.GetSignedElementsCount(pSignatureItem) > 0)
{
lstrcat(szMsg, TEXT("Data Elements Signed: "));
// We will display only one
pDICOMELEMENT pSignedElement;
pSignedElement = DataSet.GetSignedElement(pSignatureItem, 0);
if (pSignedElement)
{
wsprintf(szMsg, TEXT("%s(%04X,%04X),..."),
szMsg,
GETGROUP(pSignedElement->nTag),
GETELEMENT(pSignedElement->nTag));
}
lstrcat(szMsg, TEXT("\n"));
}
lstrcat(szMsg, TEXT("\nDo you want to save the Certificate of Signer?"));
// Display the information we have about the Digital Signature
if (::MessageBox(NULL, szMsg, TEXT("Sample"), MB_YESNO) == IDYES)
{
// Save the Certificate of Signer
DataSet.SaveCertificate(pSignatureItem, MAKE_IMAGE_PATH(TEXT("CertOfSigner.cer")));
}
}
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.