OSDN Git Service

libktorrent: generate Sha-1 hashes via Katie provided class instead of QCA
authorIvailo Monev <xakepa10@gmail.com>
Mon, 10 Aug 2020 19:19:56 +0000 (22:19 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 10 Aug 2020 19:19:56 +0000 (22:19 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
libktorrent/CMakeLists.txt
libktorrent/src/CMakeLists.txt
libktorrent/src/util/sha1hashgen.cpp
libktorrent/src/util/sha1hashgen.h

index c8b3dac..eed10c4 100644 (file)
@@ -8,14 +8,6 @@ set_package_properties(GMP PROPERTIES
     TYPE REQUIRED
 )
 
-find_package(QCA2)
-set_package_properties(QCA2 PROPERTIES
-    DESCRIPTION "Qt Cryptographic Architecture"
-    URL "https://github.com/fluxer/qca"
-    PURPOSE "Support for encrypted OpenDocument Text documents in Okular"
-    TYPE REQUIRED
-)
-
 find_package(LibGcrypt)
 set_package_properties(LibGcrypt PROPERTIES
     DESCRIPTION "General purpose cryptographic library based on the code from GnuPG"
index bdf4945..45844a7 100644 (file)
@@ -2,7 +2,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-ktorrent.h.cmake ${CMAKE_BINAR
 
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${LIBGCRYPT_INCLUDE_DIR} ${QCA2_INCLUDE_DIR})
+include_directories(${LIBGCRYPT_INCLUDE_DIR})
 remove_definitions(-DQT_NO_HTTP)
 
 set(libktorrent_SRC
@@ -218,7 +218,7 @@ set(libktorrent_SRC
 # kde4_add_kcfg_files(libktorrent_SRC settings.kcfgc)
 add_library(ktorrent SHARED ${libktorrent_SRC})
 
-target_link_libraries(ktorrent PRIVATE ${KDE4_KIO_LIBS} ${GMP_LIBRARIES} ${KDE4_SOLID_LIBS} ${LIBGCRYPT_LIBRARIES} ${QCA2_LIBRARIES})
+target_link_libraries(ktorrent PRIVATE ${KDE4_KIO_LIBS} ${GMP_LIBRARIES} ${KDE4_SOLID_LIBS} ${LIBGCRYPT_LIBRARIES})
 target_link_libraries(ktorrent PUBLIC ${KDE4_KDEUI_LIBS})
 set_target_properties(ktorrent PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION})
 install(TARGETS ktorrent  ${INSTALL_TARGETS_DEFAULT_ARGS} )
index c3976e0..29fa8ad 100644 (file)
 #include "sha1hashgen.h"
 #include <stdio.h>
 #include <string.h>
-#include <arpa/inet.h>
-#include <QtCrypto>
 #include "functions.h"
 
 
 
 namespace bt
 {
-       static QCA::Initializer qca_init;
-
-       SHA1HashGen::SHA1HashGen() : h(new QCA::Hash("sha1"))
+       SHA1HashGen::SHA1HashGen() : h(new QCryptographicHash(QCryptographicHash::Sha1))
        {
                memset(result,9,20);
        }
@@ -43,24 +39,24 @@ namespace bt
 
        SHA1Hash SHA1HashGen::generate(const Uint8* data,Uint32 len)
        {
-               h->update((const char*)data,len);
-               return SHA1Hash((const bt::Uint8*)h->final().constData());
+               h->addData((const char*)data,len);
+               return SHA1Hash((const bt::Uint8*)h->result().constData());
        }
        
        void SHA1HashGen::start()
        {
-               h->clear();
+               h->reset();
        }
                
        void SHA1HashGen::update(const Uint8* data,Uint32 len)
        {
-               h->update((const char*)data,len);
+               h->addData((const char*)data,len);
        }
                
         
        void SHA1HashGen::end()
        {
-               memcpy(result,h->final().constData(),20);
+               memcpy(result,h->result().constData(),20);
        }
                
 
index deff84f..3de664b 100644 (file)
 #include "constants.h"
 #include "sha1hash.h"
 
-namespace QCA
-{
-       class Hash;
-}
+#include <QCryptographicHash>
 
 namespace bt
 {
@@ -81,7 +78,7 @@ namespace bt
                SHA1Hash get() const;
                
        private:
-               QCA::Hash* h;
+               QCryptographicHash* h;
                Uint8 result[20];
        };