~ubuntu-branches/ubuntu/raring/quassel/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/cipher.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-08-11 12:48:08 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20100811124808-wl3zpp4gpbzmvn4t
Tags: 0.7~beta1-0ubuntu1
* New upstream beta release
  - Add libqca2-dev to build-depends for blowfish support
* Switch to source format v3 (Quilt) to use .bz2 tarball
  - Drop build-depends on quilt and update debian/rules
  - Add debian/source/format

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  This file has been derived from Konversation, the KDE IRC client.
 
3
  You can redistribute it and/or modify it under the terms of the
 
4
  GNU General Public License as published by the Free Software Foundation;
 
5
  either version 2 of the License, or (at your option) any later version.
 
6
*/
 
7
 
 
8
/*
 
9
  Copyright (C) 1997 Robey Pointer <robeypointer@gmail.com>
 
10
  Copyright (C) 2005 Ismail Donmez <ismail@kde.org>
 
11
  Copyright (C) 2009 Travis McHenry <tmchenryaz@cox.net>
 
12
  Copyright (C) 2009 Johannes Huber <johu@gmx.de>
 
13
*/
 
14
 
 
15
#ifndef CIPHER_H
 
16
#define CIPHER_H
 
17
 
 
18
#include<QtCrypto>
 
19
 
 
20
class Cipher
 
21
{
 
22
  public:
 
23
    Cipher();
 
24
    explicit Cipher(QByteArray key, QString cipherType=QString("blowfish"));
 
25
    ~Cipher();
 
26
    QByteArray decrypt(QByteArray cipher);
 
27
    QByteArray decryptTopic(QByteArray cipher);
 
28
    bool encrypt(QByteArray& cipher);
 
29
    QByteArray initKeyExchange();
 
30
    QByteArray parseInitKeyX(QByteArray key);
 
31
    bool parseFinishKeyX(QByteArray key);
 
32
    bool setKey(QByteArray key);
 
33
    QByteArray key() { return m_key; }
 
34
    bool setType(const QString &type);
 
35
    QString type() { return m_type; }
 
36
 
 
37
  private:
 
38
    //direction is true for encrypt, false for decrypt
 
39
    QByteArray blowfishCBC(QByteArray cipherText, bool direction);
 
40
    QByteArray blowfishECB(QByteArray cipherText, bool direction);
 
41
    QByteArray b64ToByte(QByteArray text);
 
42
    QByteArray byteToB64(QByteArray text);
 
43
 
 
44
    QCA::Initializer init;
 
45
    QByteArray m_key;
 
46
    QCA::DHPrivateKey m_tempKey;
 
47
    QCA::BigInteger m_primeNum;
 
48
    QString m_type;
 
49
    bool m_cbc;
 
50
};
 
51
#endif // CIPHER_H