1 /* 2 * 3 * Copyright (C) 1998-2019, OFFIS e.V. 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation were developed by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * 14 * Module: dcmsign 15 * 16 * Author: Norbert Loxen, Marco Eichelberg 17 * 18 * Purpose: 19 * classes: SiMAC 20 * 21 */ 22 23 #ifndef SIMAC_H 24 #define SIMAC_H 25 26 #include "dcmtk/config/osconfig.h" 27 28 #ifdef WITH_OPENSSL 29 30 #include "dcmtk/dcmsign/sitypes.h" 31 32 /** 33 * a base class for all classes that implement hash functions. 34 * @remark this class is only available if DCMTK is compiled with 35 * OpenSSL support enabled. 36 */ 37 class DCMTK_DCMSIGN_EXPORT SiMAC 38 { 39 public: 40 41 /// default constructor SiMAC()42 SiMAC() { } 43 44 /// destructor ~SiMAC()45 virtual ~SiMAC() { } 46 47 /** initializes the MAC algorithm. 48 * @return status code 49 */ 50 virtual OFCondition initialize() = 0; 51 52 /** feeds data into the MAC algorithm 53 * @param data pointer to raw data to be fed into the MAC, must not be NULL 54 * @param length number of bytes in raw data array 55 * @return status code 56 */ 57 virtual OFCondition digest(const unsigned char *data, unsigned long length) = 0; 58 59 /** finalizes the MAC and writes it to the given output array, 60 * which must be at least getSize() bytes large. 61 * After a call to finalize, the MAC algorithm must be initialized 62 * again, see initialize(). 63 * @param result pointer to array of getSize() bytes into which the MAC is written 64 * @return status code 65 */ 66 virtual OFCondition finalize(unsigned char *result) = 0; 67 68 /** returns the size of a MAC in bytes. 69 * @return block size for this MAC algorithm 70 */ 71 virtual unsigned long getSize() const = 0; 72 73 /** returns the type of MAC algorithm computed by this object 74 * @return type of MAC algorithm 75 */ 76 virtual E_MACType macType() const = 0; 77 78 /** returns the DICOM identifier for this MAC algorithm 79 * @return DICOM defined term for algorithm 80 */ 81 virtual const char *getDefinedTerm() const = 0; 82 83 }; 84 85 #endif 86 #endif 87