MagicSmoke  $VERSION$
hmac.h
Go to the documentation of this file.
1 //
2 // C++ Interface: hmac
3 //
4 // Description:
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
8 //
9 // Copyright: See README/COPYING.GPL files that come with this distribution
10 //
11 //
12 
13 #ifndef SMOKE_HMAC_H
14 #define SMOKE_HMAC_H
15 
16 #include <QCryptographicHash>
17 
18 #include "commonexport.h"
19 
22 {
23  public:
25  SMHmac(QCryptographicHash::Algorithm algo,const QByteArray&key);
27  void addData(const char * data, int length );
29  void addData(const QByteArray & data );
31  void reset();
33  QByteArray result();
34 
36  static int resultWidth(QCryptographicHash::Algorithm);
38  static int blockWidth(QCryptographicHash::Algorithm);
40  static QByteArray hmac(const QByteArray&data,const QByteArray&key,QCryptographicHash::Algorithm method);
41  private:
42  //the two key schedules
43  QByteArray keyA,keyB;
44  //remember where we are
45  enum State {Collecting,Finished};
46  mutable State state;
47  //inner hash function
48  QCryptographicHash subhashin,subhashout;
49 };
50 
51 
52 #endif
#define MAGICSMOKE_COMMON_EXPORT
Definition: commonexport.h:7
Calculate a cryptographic HMAC (used by authentication algorithm)
Definition: hmac.h:21