File indexing completed on 2024-06-16 03:53:04

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2001 George Staikos <staikos@kde.org>
0004 
0005     Based heavily on SHA1 code from GPG 1.0.3:
0006     SPDX-FileCopyrightText: 1998 FSF
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #ifndef __sha1__ko__h
0012 #define __sha1__ko__h
0013 
0014 #include "kwalletbackend_export.h"
0015 
0016 /* @internal
0017  */
0018 class KWALLETBACKEND_EXPORT SHA1
0019 {
0020 public:
0021     SHA1();
0022     ~SHA1();
0023 
0024     /*
0025      *  The number of bits in the hash generated.
0026      */
0027     int size() const;
0028 
0029     /*
0030      *  True if all settings are good and we are ready to hash.
0031      */
0032     bool readyToGo() const;
0033 
0034     /*
0035      *  Process a block of data for the hash function.
0036      */
0037     int process(const void *block, int len);
0038 
0039     /*
0040      *  Return the digest as a 20 byte array reference.
0041      *  Calling this makes readyToGo() == false.
0042      */
0043     const unsigned char *hash();
0044 
0045     /*
0046      *  Reset the digest so a new one can be calculated.
0047      */
0048     int reset();
0049 
0050 protected:
0051     int _hashlen;
0052     bool _init;
0053 
0054     long _h0, _h1, _h2, _h3, _h4;
0055     long _nblocks;
0056     int _count;
0057     unsigned char _buf[64];
0058     void transform(void *data);
0059 };
0060 
0061 #endif