Changeset 713
- Timestamp:
- 12/23/06 18:22:30 (2 years ago)
- Files:
-
- gotek/gotekd/trunk/conf/gotekd.conf (modified) (1 diff)
- gotek/gotekd/trunk/configure.ac (modified) (1 diff)
- gotek/gotekd/trunk/src/GotekServerEndpoint.cpp (modified) (2 diffs)
- gotek/gotekd/trunk/src/HashManager.cpp (modified) (4 diffs)
- gotek/gotekd/trunk/src/HashManager.hpp (modified) (2 diffs)
- gotek/gotekd/trunk/src/Makefile.am (modified) (1 diff)
- gotek/gotekd/trunk/src/SecurityManager.cpp (modified) (5 diffs)
- gotek/gotekd/trunk/src/SecurityManager.hpp (modified) (1 diff)
- gotek/gotekd/trunk/src/gotekd.cpp (modified) (3 diffs)
- gotek/gotekd/trunk/src/gotekd.hpp (modified) (2 diffs)
- gotek/gotekd/trunk/src/hash (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gotek/gotekd/trunk/conf/gotekd.conf
r622 r713 1 # gotekdDaemon Configuration1 # G.O.T.E.K. Daemon Configuration 2 2 # $Id$ 3 4 3 { 4 # Basic control over the gotekd server. If this section is not present, 5 # the daemon fails to start up. 5 6 server 6 7 { 8 # The TCP port, the server is listening on. If not explicitly set, this 9 # port defaults to 61793, the global gotekd standard port. 7 10 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. 8 16 description = "mwcollect Alliance Central Repository"; 9 17 } 10 18 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''. 11 23 database = "dbname=gotekd"; 12 24 } gotek/gotekd/trunk/configure.ac
r622 r713 55 55 56 56 57 dnl ************************************************** 58 dnl * openssl (SHAx, MD5) Support * 59 dnl ************************************************** 60 AC_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 89 CHECK_CRYPTO() 90 91 92 57 93 AC_OUTPUT([ 58 94 Makefile gotek/gotekd/trunk/src/GotekServerEndpoint.cpp
r622 r713 21 21 22 22 NetworkEndpoint * GotekServerEndpointFactory::createEndpoint(NetworkSocket * socket) 23 { 23 { 24 24 return (NetworkEndpoint *) new GotekServerEndpoint(socket); 25 25 } … … 80 80 m_socket->send(command.data(), command.size()); 81 81 82 m_remoteNode = * remote; 83 82 m_remoteNode = * remote; 84 83 m_state = GSS_HANDSHAKE_SENT; 85 84 } gotek/gotekd/trunk/src/HashManager.cpp
r622 r713 43 43 44 44 case HT_SHA2_256: 45 sha256_init(&task.context.sha2_256);45 SHA256_Init(&task.context.sha2_256); 46 46 break; 47 47 48 48 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__); 50 54 } 51 55 … … 66 70 length = task->length - task->offset; \ 67 71 \ 72 LOG("<%s> Update %p from %p with %u bytes.", __PRETTY_FUNCTION__, &task->context.contextname, (unsigned char *) (task->data + task->offset), length);\ 73 \ 68 74 updatefn(&task->context.contextname, (unsigned char *) (task->data + \ 69 75 task->offset), length); \ … … 74 80 unsigned char digest[digestsize]; \ 75 81 \ 76 finalfn( &task->context.contextname, digest); \82 finalfn(digest, &task->context.contextname); \ 77 83 \ 78 84 task->receiver->hashComputed(task->type, task->data, \ … … 98 104 99 105 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); 102 108 break; 103 109 104 110 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); 107 113 break; 108 114 } gotek/gotekd/trunk/src/HashManager.hpp
r622 r713 14 14 #include <list> 15 15 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 17 22 18 23 … … 61 66 union 62 67 { 63 sha256_ctxsha2_256;64 sha512_ctxsha2_512;68 SHA256_CTX sha2_256; 69 SHA512_CTX sha2_512; 65 70 } context; 66 71 gotek/gotekd/trunk/src/Makefile.am
r622 r713 20 20 gotekd_SOURCES += SqlInterface.cpp 21 21 22 gotekd_SOURCES += hash/sha2.cpp23 24 22 25 23 gotekd_LDFLAGS = -lpthread -lpq gotek/gotekd/trunk/src/SecurityManager.cpp
r622 r713 59 59 SecurityManager::SecurityManager() 60 60 { 61 m_noCurrentPop = false; 61 62 } 62 63 … … 81 82 0, attempt.verifier); 82 83 84 LOG_CHECKPOINT(); 83 85 m_pendingAttempts.push_back(attempt); 84 86 } … … 134 136 135 137 if(memcmp(attempt->hash, hash, hashLength) == 0) 136 {137 LOG("Login Allowed.");138 138 attempt->verifier->loginAllowed(attempt->token); 139 }140 139 else 141 {142 LOG("Login Denied!");143 140 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(); 149 151 } 150 152 … … 153 155 { 154 156 std::list<LoginAttempt>::iterator i, n; 157 158 LOG_CHECKPOINT(); 155 159 156 160 for(i = m_pendingAttempts.begin(); i != m_pendingAttempts.end(); i = n) … … 160 164 161 165 if(i->verifier == verifier) 166 { 162 167 m_pendingAttempts.erase(i); 168 169 if(n == m_pendingAttempts.end()) 170 m_noCurrentPop = true; 171 } 163 172 } 164 173 } gotek/gotekd/trunk/src/SecurityManager.hpp
r622 r713 156 156 private: 157 157 std::list<LoginAttempt> m_pendingAttempts; 158 bool m_noCurrentPop; 158 159 }; 159 160 gotek/gotekd/trunk/src/gotekd.cpp
r622 r713 94 94 95 95 case 'v': 96 p uts("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()); 99 99 100 100 return 0; … … 210 210 // This is a blocking connect, but who bothers... 211 211 m_SqlInterface = new SqlInterface(m_Configuration->getString( 212 ":database", 0));212 ":database", "dbname=gotekd")); 213 213 } 214 214 catch(...) … … 238 238 bool GotekDaemon::loop() 239 239 { 240 m_NetworkManager.waitForEventsAndProcess(m_HashManager.computationPending() ?241 0 : 2000);242 240 m_NetworkManager.waitForEventsAndProcess(m_HashManager.computationPending() 241 ? 2000 : -1); 242 243 243 m_HashManager.loop(); 244 244 gotek/gotekd/trunk/src/gotekd.hpp
r622 r713 36 36 #define LOG(logformat...) (g_gotekDaemon->getLogManager()->logFormatMessage( \ 37 37 logformat)) 38 #define LOG_CHECKPOINT() LOG(__FILE__ ":%u <%s>", __LINE__, __PRETTY_FUNCTION__); 38 39 39 40 … … 86 87 87 88 //! Obtain a description string about the running version. 88 virtualconst char * getDescription();89 static const char * getDescription(); 89 90 90 91 //! Run this daemon, only called by the process' entry point.
