KWallet

blockcipher.h
1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2001 George Staikos <staikos@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef BLOCKCIPHER_H
9#define BLOCKCIPHER_H
10
11#include "kwalletbackend_export.h"
12
13/* @internal
14 */
15class KWALLETBACKEND_EXPORT BlockCipher
16{
17public:
18 BlockCipher();
19 virtual ~BlockCipher();
20
21 /*
22 * Return the current blocksize in bytes.
23 */
24 int blockSize() const;
25
26 /*
27 * Set the encryption key to key. Return true on success.
28 */
29 virtual bool setKey(void *key, int bitlength) = 0;
30
31 /*
32 * Get the required (or if it's variable, then the maximum) key
33 * length for this cipher in bits.
34 */
35 virtual int keyLen() const = 0;
36
37 /*
38 * True if the key is of a variable length. In this case,
39 * getKeyLen() will return the maximum length.
40 */
41 virtual bool variableKeyLen() const = 0;
42
43 /*
44 * True if all settings are good and we are ready to encrypt.
45 */
46 virtual bool readyToGo() const = 0;
47
48 /*
49 * Encrypt the block. Returns the number of bytes successfully
50 * encrypted. Can return -1 on error.
51 */
52 virtual int encrypt(void *block, int len) = 0;
53
54 /*
55 * Decrypt the block. Returns as does encrypt();
56 */
57 virtual int decrypt(void *block, int len) = 0;
58
59protected:
60 int _blksz;
61 int _keylen; // in bits
62};
63
64#endif // BLOCKCIPHER_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:16:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.