DCMTK: SiMACConstructor Class Reference

DCMTK Version 3.6.9 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SiMACConstructor Class Reference

a class that allows to feed selected parts of a DICOM dataset into the MAC generation code More...

## Public Member Functions
| SiMACConstructor ()
| constructor
virtual | ~SiMACConstructor ()
| destructor
OFCondition | encodeDataset (DcmItem &item, SiMAC &mac, E_TransferSyntax oxfer, DcmAttributeTag &tagListOut, DcmAttributeTag *tagListIn=NULL)
| encodes a DICOM dataset (or parts of it) as a byte stream in the format required for DICOM digital signatures and feeds the byte stream into the given MAC codec.
OFCondition | encodeDatasetForVerification (DcmItem &item, SiMAC &mac, E_TransferSyntax oxfer, DcmAttributeTag *tagListIn)
| encodes a DICOM dataset (or parts of it) as a byte stream in the format required for DICOM digital signatures and feeds the byte stream into the given MAC codec, for the purpose of signature verification If a dump file was set with setDumpFile(), the byte stream is written to file as well.
OFCondition | encodeDigitalSignatureItem (DcmItem &signatureItem, SiMAC &mac, E_TransferSyntax oxfer)
| encodes the contents of the digital signature sequence except CertificateOfSigner, Signature, CertifiedTimestampType and CertifiedTimestamp as a byte stream in the format required for DICOM digital signatures and feeds the byte stream into the given MAC codec.
OFCondition | flush (SiMAC &mac)
| flushes all buffers inside this object, finalizing the MAC code
void | setDumpFile (FILE *f)
| dump all data that is fed into the MAC algorithm into the given file, which must be opened and closed by caller.

## Private Member Functions
| SiMACConstructor (SiMACConstructor &arg)
| private undefined copy constructor
SiMACConstructor & | operator= (SiMACConstructor &arg)
| private undefined copy assignment operator
OFCondition | flushBuffer (SiMAC &mac)
| flushes the internal buffer to the given MAC and to dumpFile if open
OFCondition | encodeElement (DcmElement *element, SiMAC &mac, E_TransferSyntax oxfer)
| feeds a DcmElement into the MAC data stream if is signable.

## Static Private Member Functions
static OFBool | inTagList (const DcmElement *element, DcmAttributeTag *tagList)
| checks whether the attribute tag of the given DcmElement is contained in the given list of tags.

## Private Attributes
unsigned char * | buf
| the buffer to which data is written
DcmOutputBufferStream | stream
| the internal buffer stream
FILE * | dumpFile
| if nonzero, the data fed to the MAC algorithm is also stored in this file.

## Detailed Description

a class that allows to feed selected parts of a DICOM dataset into the MAC generation code

Remarks
  this class is only available if DCMTK is compiled with OpenSSL support enabled.

## Member Function Documentation

## ◆ encodeDataset()

OFCondition SiMACConstructor::encodeDataset | ( | DcmItem & | item,
|  | SiMAC & | mac,
|  | E_TransferSyntax | oxfer,
|  | DcmAttributeTag & | tagListOut,
|  | DcmAttributeTag * | tagListIn = NULL )

encodes a DICOM dataset (or parts of it) as a byte stream in the format required for DICOM digital signatures and feeds the byte stream into the given MAC codec.

If a dump file was set with setDumpFile(), the byte stream is written to file as well.

Parameters

  item | the DICOM dataset to be encoded
  mac | the MAC codec into which the resulting byte stream is fed
  oxfer | the transfer syntax to be used when encoding the dataset. The caller might wish to use DcmItem::canWriteXfer() to check beforehand whether this transfer syntax can be used.
  tagListOut | upon return this parameter contains the list of attribute tags which were fed into the MAC codec. For sequences, only the sequence attribute tag is contained in this list; the items and elements within the items are not encoded.
  tagListIn | optional parameter restricting the parts of the dataset to be encoded. Only elements which are present in this list of tags, which are signable (see DcmTagKey::isSignable()) and are present in the dataset are encoded. Upon verification of a signature the caller might wish to compare tagListIn and tagListOut after successful return to see whether the lists of attributes are the same. If parameter is absent or NULL, a global match is assumed, i.e. all elements of the dataset which are present and signable are encoded.

Returns
  status code

## ◆ encodeDatasetForVerification()

OFCondition SiMACConstructor::encodeDatasetForVerification | ( | DcmItem & | item,
|  | SiMAC & | mac,
|  | E_TransferSyntax | oxfer,
|  | DcmAttributeTag * | tagListIn )

encodes a DICOM dataset (or parts of it) as a byte stream in the format required for DICOM digital signatures and feeds the byte stream into the given MAC codec, for the purpose of signature verification If a dump file was set with setDumpFile(), the byte stream is written to file as well.

Parameters

  item | the DICOM dataset to be encoded
  mac | the MAC codec into which the resulting byte stream is fed
  oxfer | the transfer syntax to be used when encoding the dataset. The caller might wish to use DcmItem::canWriteXfer() to check beforehand whether this transfer syntax can be used.
  tagListIn | list of elements to be encoded.

Returns
  status code

## ◆ encodeDigitalSignatureItem()

OFCondition SiMACConstructor::encodeDigitalSignatureItem | ( | DcmItem & | signatureItem,
|  | SiMAC & | mac,
|  | E_TransferSyntax | oxfer )

encodes the contents of the digital signature sequence except CertificateOfSigner, Signature, CertifiedTimestampType and CertifiedTimestamp as a byte stream in the format required for DICOM digital signatures and feeds the byte stream into the given MAC codec.

If a dump file was set with setDumpFile(), the byte stream is written to file as well.

Parameters

  signatureItem | the DICOM digital signature item to be encoded
  mac | the MAC codec into which the resulting byte stream is fed
  oxfer | the transfer syntax to be used when encoding the dataset. The caller might wish to use DcmItem::canWriteXfer() to check beforehand whether this transfer syntax can be used.

Returns
  status code

## ◆ encodeElement()

OFCondition SiMACConstructor::encodeElement | ( | DcmElement * | element,
|  | SiMAC & | mac,
|  | E_TransferSyntax | oxfer )
| private

feeds a DcmElement into the MAC data stream if is signable.

If the element is a sequence, all signable elements from all items are added.

Parameters

  element | pointer to element, must not be NULL
  mac | MAC to use
  oxfer | transfer syntax in which data is encoded

Returns
  status code

## ◆ flush()

OFCondition SiMACConstructor::flush | ( | SiMAC & | mac | ) |

flushes all buffers inside this object, finalizing the MAC code

Parameters

  mac | the MAC codec into which the resulting byte stream is fed

Returns
  status code

## ◆ flushBuffer()

OFCondition SiMACConstructor::flushBuffer | ( | SiMAC & | mac | ) |
| private

flushes the internal buffer to the given MAC and to dumpFile if open

Parameters

  mac | MAC to which the buffer content is added

Returns
  error code from MAC

## ◆ inTagList()

static OFBool SiMACConstructor::inTagList | ( | const DcmElement * | element,
|  | DcmAttributeTag * | tagList )
| staticprivate

checks whether the attribute tag of the given DcmElement is contained in the given list of tags.

If the list is absent (NULL), a universal match is assumed, i.e. always returns true if element is nonzero. Does not check whether an element is signable.

Parameters

  element | pointer to element to check
  tagList | pointer to list of attribute tags, may be NULL

Returns
  true if attribute is in tag list, false otherwise

## ◆ setDumpFile()

void SiMACConstructor::setDumpFile | ( | FILE * | f | ) |

dump all data that is fed into the MAC algorithm into the given file, which must be opened and closed by caller.

Parameters

  f | pointer to file already opened for writing; may be NULL.

The documentation for this class was generated from the following file:

- dcmsign/include/dcmtk/dcmsign/simaccon.h

Generated on Sat Mar 1 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2