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: SiRIPEMD160
20  *
21  */
22 
23 #ifndef SIRIPEMD_H
24 #define SIRIPEMD_H
25 
26 #include "dcmtk/config/osconfig.h"
27 
28 #ifdef WITH_OPENSSL
29 
30 #include "dcmtk/dcmsign/simac.h"
31 #include "dcmtk/dcmsign/sitypes.h"
32 
33 struct RIPEMD160state_st;
34 typedef struct RIPEMD160state_st RIPEMD160_CTX;
35 
36 /**
37  * a class implementing the hash function RIPEMD160
38  * @remark this class is only available if DCMTK is compiled with
39  * OpenSSL support enabled.
40  */
41 class DCMTK_DCMSIGN_EXPORT SiRIPEMD160 : public SiMAC
42 {
43 public:
44   /// default constructor
45   SiRIPEMD160();
46 
47   /// destructor
48   virtual ~SiRIPEMD160();
49 
50   /** initializes the MAC algorithm.
51    *  @return status code
52    */
53   virtual OFCondition initialize();
54 
55   /** feeds data into the MAC algorithm
56    *  @param data pointer to raw data to be fed into the MAC, must not be NULL
57    *  @param length number of bytes in raw data array
58    *  @return status code
59    */
60   virtual OFCondition digest(const unsigned char *data, unsigned long length);
61 
62   /** finalizes the MAC and writes it to the given output array,
63    *  which must be at least getSize() bytes large.
64    *  After a call to finalize, the MAC algorithm must be initialized
65    *  again, see initialize().
66    *  @param result pointer to array of getSize() bytes into which the MAC is written
67    *  @return status code
68    */
69   virtual OFCondition finalize(unsigned char *result);
70 
71   /** returns the size of a MAC in bytes.
72    *  @return block size for this MAC algorithm
73    */
74   virtual unsigned long getSize() const;
75 
76   /** returns the type of MAC algorithm computed by this object
77    *  @return type of MAC algorithm
78    */
79   virtual E_MACType macType() const;
80 
81   /** returns the DICOM identifier for this MAC algorithm
82    *  @return DICOM defined term for algorithm
83    */
84   virtual const char *getDefinedTerm() const;
85 
86 private:
87 
88   /// private undefined copy constructor
89   SiRIPEMD160(SiRIPEMD160& arg);
90 
91   /// private undefined copy assignment operator
92   SiRIPEMD160& operator=(SiRIPEMD160& arg);
93 
94   /// OpenSSL RIPEMD 160 context
95   RIPEMD160_CTX *ctx;
96 };
97 
98 #endif
99 #endif
100