←Select platform

GetMacTransferSyntax Method

Summary
Returns the Message Authentication Code (MAC) Calculation Transfer Syntax UID (0400,0010) used in the creation of the specified Digital Signature.
Syntax
C#
C++/CLI
public string GetMacTransferSyntax( 
   DicomElement signatureItem 
) 
public: 
String^ GetMacTransferSyntax(  
   DicomElement^ signatureItem 
)  

Parameters

signatureItem
The Digital Signatures Sequence Item that corresponds to the Digital Signature. This cannot be null.

Return Value

The MAC Calculation Transfer Syntax UID (0400,0010) used in the creation of the specified Digital Signature. The return value can be a null reference (Nothing in VB).

Remarks

The Digital Signatures Sequence Item of a Digital Signature should reference an item under the MAC Parameters Sequence associated with the Digital Signatures Sequence. The MAC Calculation Transfer Syntax UID (0400,0010) under the referenced MAC Parameters Sequence Item specifies the Transfer Syntax used in the calculation of the Message Authentication Code (MAC). The encrypted MAC is the digital signature itself. Call this method to obtain the value of this Data Element. If the Data Set was properly encoded, the return value will be a Transfer Syntax that Explicitly includes the Value Representation (VR) and uses Little Endian encoding.

The following methods can also be used to get information about the Digital Signature:

GetSignatureUID

GetSignatureDateTime

GetSignedElementsCount

GetSignedElement

GetMacAlgorithm

SaveCertificate

Example
C#
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:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.