add more spacing
[personal-kdebase.git] / runtime / kwalletd / backend / blockcipher.h
blobef8868d0f50121c1ce43c17c2539703f631e3eaa
1 /* This file is part of the KDE project
2 Copyright (C) 2001 George Staikos <staikos@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef BLOCKCIPHER_H
21 #define BLOCKCIPHER_H
23 /* @internal
25 class BlockCipher {
26 public:
27 BlockCipher();
28 virtual ~BlockCipher();
31 * Return the current blocksize in bytes.
33 int blockSize() const;
36 * Set the encryption key to key. Return true on success.
38 virtual bool setKey(void *key, int bitlength) = 0;
41 * Get the required (or if it's variable, then the maximum) key
42 * length for this cipher in bits.
44 virtual int keyLen() const = 0;
47 * True if the key is of a variable length. In this case,
48 * getKeyLen() will return the maximum length.
50 virtual bool variableKeyLen() const = 0;
53 * True if all settings are good and we are ready to encrypt.
55 virtual bool readyToGo() const = 0;
58 * Encrypt the block. Returns the number of bytes successfully
59 * encrypted. Can return -1 on error.
61 virtual int encrypt(void *block, int len) = 0;
64 * Decrypt the block. Returns as does encrypt();
66 virtual int decrypt(void *block, int len) = 0;
68 protected:
69 int _blksz;
70 int _keylen; // in bits
73 #endif // BLOCKCIPHER_H