Changeset 713

Show
Ignore:
Timestamp:
12/23/06 18:22:30 (2 years ago)
Author:
oxff
Message:

gotekd:

  • changed sha stuff to libcrypto (openssl)
    • added autoconf stuff to find openssl
    • removed old sha code
  • fixed a misconception in the security manager
  • changed output of -v
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gotek/gotekd/trunk/conf/gotekd.conf

    r622 r713  
    1 # gotekd Daemon Configuration 
     1# G.O.T.E.K. Daemon Configuration 
    22# $Id$ 
    3  
    43{ 
     4        # Basic control over the gotekd server. If this section is not present, 
     5        # the daemon fails to start up. 
    56        server 
    67        { 
     8                # The TCP port, the server is listening on. If not explicitly set, this 
     9                # port defaults to 61793, the global gotekd standard port.               
    710                port = "4321"; 
     11                 
     12                # The description of this node in the G.O.T.E.K. network. This 
     13                # information is automatically exchanged with other nodes in the network 
     14                # upon connection, but has no real meaning. It's solely used for 
     15                # identifying nodes on your network, e.g. when debugging your network. 
    816                description = "mwcollect Alliance Central Repository"; 
    917        } 
    1018         
     19        # This is the PostgreSQL connection string, refer to your PostgreSQL 
     20        # client library's documentation for information, what to specify here. 
     21        # If the database is local, it is usually enough to specify the database's 
     22        # name. Defaults to ``dbname=gotekd''. 
    1123        database = "dbname=gotekd"; 
    1224} 
  • gotek/gotekd/trunk/configure.ac

    r622 r713  
    5555 
    5656 
     57dnl ************************************************** 
     58dnl * openssl (SHAx, MD5) Support                    * 
     59dnl ************************************************** 
     60AC_DEFUN([CHECK_CRYPTO], 
     61[AC_MSG_CHECKING(for libcrypto) 
     62     
     63    for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do 
     64        ssldir="$dir" 
     65        if test -f "$dir/include/openssl/sha.h"; then 
     66            found_ssl="yes"; 
     67            CFLAGS="$CFLAGS -I$ssldir/include/openssl -DHAVE_CRYPTO=1"; 
     68            CXXFLAGS="$CXXFLAGS -I$ssldir/include/openssl -DHAVE_CRYPTO=1"; 
     69            break; 
     70        fi 
     71        if test -f "$dir/include/sha.h"; then 
     72            found_ssl="yes"; 
     73            CFLAGS="$CFLAGS -I$ssldir/include/ -DHAVE_CRYPTO=1"; 
     74            CXXFLAGS="$CXXFLAGS -I$ssldir/include/ -DHAVE_CRYPTO=1"; 
     75            break 
     76        fi 
     77    done 
     78    if test x_$found_ssl != x_yes; then 
     79        AC_MSG_ERROR(no) 
     80    else 
     81        LIBS="$LIBS -lcrypto"; 
     82        LDFLAGS="$LDFLAGS -L$ssldir/lib"; 
     83        HAVE_CRYPTO=yes 
     84        AC_MSG_RESULT(yes) 
     85    fi 
     86    AC_SUBST(HAVE_CRYPTO) 
     87])dnl 
     88 
     89CHECK_CRYPTO() 
     90 
     91 
     92 
    5793AC_OUTPUT([ 
    5894        Makefile 
  • gotek/gotekd/trunk/src/GotekServerEndpoint.cpp

    r622 r713  
    2121 
    2222NetworkEndpoint * GotekServerEndpointFactory::createEndpoint(NetworkSocket * socket) 
    23 { 
     23{       
    2424        return (NetworkEndpoint *) new GotekServerEndpoint(socket); 
    2525} 
     
    8080        m_socket->send(command.data(), command.size()); 
    8181         
    82         m_remoteNode = * remote; 
    83          
     82        m_remoteNode = * remote;         
    8483        m_state = GSS_HANDSHAKE_SENT; 
    8584} 
  • gotek/gotekd/trunk/src/HashManager.cpp

    r622 r713  
    4343                         
    4444                case HT_SHA2_256: 
    45                         sha256_init(&task.context.sha2_256); 
     45                        SHA256_Init(&task.context.sha2_256); 
    4646                        break; 
    4747                         
    4848                case HT_SHA2_512: 
    49                         sha512_init(&task.context.sha2_512); 
     49                        SHA512_Init(&task.context.sha2_512); 
     50                        break; 
     51                 
     52                default: 
     53                        LOG("Unknown hash type in <%s>!", __PRETTY_FUNCTION__); 
    5054        } 
    5155         
     
    6670                length = task->length - task->offset; \ 
    6771        \ 
     72        LOG("<%s> Update %p from %p with %u bytes.", __PRETTY_FUNCTION__, &task->context.contextname, (unsigned char *) (task->data + task->offset), length);\ 
     73        \ 
    6874        updatefn(&task->context.contextname, (unsigned char *) (task->data + \ 
    6975                task->offset), length); \ 
     
    7480                unsigned char digest[digestsize]; \ 
    7581                \ 
    76                 finalfn(&task->context.contextname, digest); \ 
     82                finalfn(digest, &task->context.contextname); \ 
    7783                \ 
    7884                task->receiver->hashComputed(task->type, task->data, \ 
     
    98104                         
    99105                case HT_SHA2_256: 
    100                         DIGEST_ROUND(SHA256_DIGEST_SIZE, SHA256_BLOCK_SIZE, sha2_256, 
    101                                 sha256_update, sha256_final); 
     106                        DIGEST_ROUND(SHA256_DIGEST_LENGTH, SHA256_CBLOCK, sha2_256, 
     107                                SHA256_Update, SHA256_Final); 
    102108                        break; 
    103109                         
    104110                case HT_SHA2_512: 
    105                         DIGEST_ROUND(SHA512_DIGEST_SIZE, SHA512_BLOCK_SIZE, sha2_512, 
    106                                 sha512_update, sha512_final);                  
     111                        DIGEST_ROUND(SHA512_DIGEST_LENGTH, SHA512_CBLOCK, sha2_512, 
     112                                SHA512_Update, SHA512_Final);                  
    107113                        break; 
    108114        } 
  • gotek/gotekd/trunk/src/HashManager.hpp

    r622 r713  
    1414#include <list> 
    1515 
    16 #include "hash/sha2.hpp" 
     16#ifdef HAVE_CRYPTO 
     17#include <openssl/sha.h> 
     18#else 
     19#error Could not compile, as libcrypto (from openssl) was not found. 
     20#error This is required for hashing functions, as SHA512 and MD5. 
     21#endif 
    1722 
    1823 
     
    6166        union 
    6267        { 
    63                 sha256_ctx sha2_256; 
    64                 sha512_ctx sha2_512; 
     68                SHA256_CTX sha2_256; 
     69                SHA512_CTX sha2_512; 
    6570        } context; 
    6671         
  • gotek/gotekd/trunk/src/Makefile.am

    r622 r713  
    2020gotekd_SOURCES += SqlInterface.cpp 
    2121 
    22 gotekd_SOURCES += hash/sha2.cpp 
    23  
    2422 
    2523gotekd_LDFLAGS = -lpthread -lpq 
  • gotek/gotekd/trunk/src/SecurityManager.cpp

    r622 r713  
    5959SecurityManager::SecurityManager() 
    6060{ 
     61        m_noCurrentPop = false; 
    6162} 
    6263 
     
    8182                0, attempt.verifier); 
    8283         
     84        LOG_CHECKPOINT(); 
    8385        m_pendingAttempts.push_back(attempt); 
    8486} 
     
    134136         
    135137        if(memcmp(attempt->hash, hash, hashLength) == 0) 
    136         { 
    137                 LOG("Login Allowed."); 
    138138                attempt->verifier->loginAllowed(attempt->token); 
    139         } 
    140139        else 
    141         { 
    142                 LOG("Login Denied!"); 
    143140                attempt->verifier->loginDenied(); 
    144         } 
    145                  
    146         LOG("Login result dispatched."); 
    147                  
    148         m_pendingAttempts.pop_front(); 
     141         
     142        LOG_CHECKPOINT(); 
     143         
     144        if(!m_noCurrentPop) 
     145        { 
     146                m_pendingAttempts.pop_front(); 
     147                m_noCurrentPop = false; 
     148        } 
     149         
     150        LOG_CHECKPOINT(); 
    149151} 
    150152 
     
    153155{ 
    154156        std::list<LoginAttempt>::iterator i, n; 
     157         
     158        LOG_CHECKPOINT(); 
    155159         
    156160        for(i = m_pendingAttempts.begin(); i != m_pendingAttempts.end(); i = n) 
     
    160164                 
    161165                if(i->verifier == verifier) 
     166                { 
    162167                        m_pendingAttempts.erase(i); 
     168                         
     169                        if(n == m_pendingAttempts.end()) 
     170                                m_noCurrentPop = true; 
     171                } 
    163172        } 
    164173} 
  • gotek/gotekd/trunk/src/SecurityManager.hpp

    r622 r713  
    156156private: 
    157157        std::list<LoginAttempt> m_pendingAttempts; 
     158        bool m_noCurrentPop; 
    158159}; 
    159160 
  • gotek/gotekd/trunk/src/gotekd.cpp

    r622 r713  
    9494                         
    9595                        case 'v': 
    96                                 puts("gotekd v" VERSION " -- a G.O.T.E.K. file submission" \ 
    97                                         " server and network hub\n(c) 2006 by Georg Wicherski," \ 
    98                                         "dedicated to the gorgeous and great Janine Dreistein\n"); 
     96                                printf("%s\n(c) 2006 by Georg Wicherski, dedicated to the " \ 
     97                                        "gorgeous and great Janine Dreistein.\n", gotekd:: 
     98                                        GotekDaemon::getDescription()); 
    9999                                 
    100100                                return 0; 
     
    210210                // This is a blocking connect, but who bothers... 
    211211                m_SqlInterface = new SqlInterface(m_Configuration->getString( 
    212                         ":database", 0)); 
     212                        ":database", "dbname=gotekd")); 
    213213        } 
    214214        catch(...) 
     
    238238bool GotekDaemon::loop() 
    239239{ 
    240         m_NetworkManager.waitForEventsAndProcess(m_HashManager.computationPending() ? 
    241                 0 : 2000); 
    242          
     240        m_NetworkManager.waitForEventsAndProcess(m_HashManager.computationPending() 
     241                ? 2000 : -1); 
     242 
    243243        m_HashManager.loop(); 
    244244         
  • gotek/gotekd/trunk/src/gotekd.hpp

    r622 r713  
    3636#define LOG(logformat...) (g_gotekDaemon->getLogManager()->logFormatMessage( \ 
    3737        logformat)) 
     38#define LOG_CHECKPOINT() LOG(__FILE__ ":%u <%s>", __LINE__, __PRETTY_FUNCTION__); 
    3839 
    3940 
     
    8687         
    8788        //! Obtain a description string about the running version. 
    88         virtual const char * getDescription(); 
     89        static const char * getDescription(); 
    8990         
    9091        //! Run this daemon, only called by the process' entry point.