Changeset 190:22bc1a693c15
- Timestamp:
- 05/28/08 17:17:38 (2 years ago)
- Branch:
- pubkey
- Files:
-
- 17 modified
-
Makefile (modified) (7 diffs)
-
src/client/cl_cgame.c (modified) (1 diff)
-
src/client/cl_main.c (modified) (4 diffs)
-
src/client/client.h (modified) (1 diff)
-
src/game/g_admin.c (modified) (20 diffs)
-
src/game/g_admin.h (modified) (2 diffs)
-
src/game/g_client.c (modified) (4 diffs)
-
src/game/g_cmds.c (modified) (3 diffs)
-
src/game/g_local.h (modified) (3 diffs)
-
src/game/g_main.c (modified) (3 diffs)
-
src/game/g_public.h (modified) (1 diff)
-
src/game/g_syscalls.asm (modified) (1 diff)
-
src/game/g_syscalls.c (modified) (1 diff)
-
src/qcommon/common.c (modified) (3 diffs)
-
src/qcommon/q_shared.h (modified) (1 diff)
-
src/qcommon/qcommon.h (modified) (3 diffs)
-
src/server/sv_game.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r125 r190 95 95 ifndef USE_OPENAL_DLOPEN 96 96 USE_OPENAL_DLOPEN=0 97 endif 98 99 ifndef USE_GMP_DLOPEN 100 USE_GMP_DLOPEN=0 101 endif 102 103 ifndef USE_NETTLE_DLOPEN 104 USE_NETTLE_DLOPEN=0 97 105 endif 98 106 … … 213 221 endif 214 222 223 ifeq ($(USE_NETTLE_DLOPEN),1) 224 BASE_CFLAGS += -DUSE_NETTLE_DLOPEN 225 else 226 USE_GMP_DLOPEN = 0 227 endif 228 ifeq ($(USE_GMP_DLOPEN),1) 229 BASE_CFLAGS += -DUSE_GMP_DLOPEN 230 endif 231 215 232 OPTIMIZE = -O2 -funroll-loops -fomit-frame-pointer 216 233 … … 264 281 endif 265 282 283 ifneq ($(USE_NETTLE_DLOPEN),1) 284 LDFLAGS += -lnettle 285 endif 286 ifneq ($(USE_GMP_DLOPEN),1) 287 LDFLAGS += -lgmp 288 endif 289 266 290 ifeq ($(ARCH),x86) 267 291 # linux32 make ... … … 397 421 endif 398 422 423 # Building nettle as a dll is broken, atm 424 # ifeq ($(USE_NETTLE_DLOPEN),1) 425 # BASE_CFLAGS += -DUSE_NETTLE_DLOPEN 426 # else 427 # USE_GMP_DLOPEN = 0 428 # endif 429 # ifeq ($(USE_GMP_DLOPEN),1) 430 # BASE_CFLAGS += -DUSE_GMP_DLOPEN 431 # endif 432 399 433 OPTIMIZE = -O2 -march=i586 -fno-omit-frame-pointer \ 400 434 -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \ … … 421 455 CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg 422 456 endif 457 458 # Building nettle as a dll is broken, atm 459 LDFLAGS += -lnettle -lgmp 460 # ifneq ($(USE_NETTLE_DLOPEN),1) 461 # LDFLAGS += -lnettle 462 # endif 463 # ifneq ($(USE_GMP_DLOPEN),1) 464 # LDFLAGS += -lgmp 465 # endif 423 466 424 467 ifeq ($(ARCH),x86) … … 1072 1115 $(B)/client/cmd.o \ 1073 1116 $(B)/client/common.o \ 1117 $(B)/client/crypto.o \ 1074 1118 $(B)/client/cvar.o \ 1075 1119 $(B)/client/files.o \ … … 1264 1308 $(B)/ded/cmd.o \ 1265 1309 $(B)/ded/common.o \ 1310 $(B)/ded/crypto.o \ 1266 1311 $(B)/ded/cvar.o \ 1267 1312 $(B)/ded/files.o \ -
src/client/cl_cgame.c
r125 r190 357 357 Cbuf_AddText( "wait ; wait ; wait ; wait ; screenshot levelshot\n" ); 358 358 return qtrue; 359 } 360 361 if ( cl_pubkeyID->integer && !strcmp( cmd, "pubkey_request" ) ) { 362 char buffer[ MAX_STRING_CHARS ] = "pubkey "; 363 qmpz_get_str( buffer + 7, 16, public_key.n ); 364 CL_AddReliableCommand( buffer ); 365 return qfalse; 366 } 367 368 if ( cl_pubkeyID->integer && !strcmp( cmd, "pubkey_decrypt" ) && argc > 1 ) { 369 char buffer[ MAX_STRING_CHARS ] = "pubkey_identify "; 370 unsigned int msg_len = MAX_STRING_CHARS - 16; 371 mpz_t message; 372 qmpz_init_set_str( message, Cmd_Argv( 1 ), 16 ); 373 if ( qrsa_decrypt( &private_key, &msg_len, (unsigned char *) buffer + 16, message ) ) 374 { 375 qnettle_mpz_set_str_256_u( message, msg_len, (unsigned char *) buffer + 16 ); 376 qmpz_get_str( buffer + 16, 16, message ); 377 CL_AddReliableCommand( buffer ); 378 } 379 qmpz_clear( message ); 380 return qfalse; 359 381 } 360 382 -
src/client/cl_main.c
r125 r190 79 79 80 80 cvar_t *cl_guidServerUniq; 81 82 cvar_t *cl_pubkeyID; 83 84 struct rsa_public_key public_key; 85 struct rsa_private_key private_key; 81 86 82 87 clientActive_t cl; … … 2602 2607 2603 2608 /* 2609 =============== 2610 CL_GeneratePKey 2611 2612 Check if the PKEY file contains a valid RSA keypair 2613 If not then generate a new keypair 2614 =============== 2615 */ 2616 static void CL_GeneratePKey(void) 2617 { 2618 int len; 2619 fileHandle_t f; 2620 void *buf; 2621 2622 qrsa_public_key_init( &public_key ); 2623 qrsa_private_key_init( &private_key ); 2624 2625 len = FS_SV_FOpenFileRead( PKEY_FILE, &f ); 2626 if ( !f || len < 1 ) 2627 { 2628 Com_Printf( "PKEY file not found, regenerating\n" ); 2629 goto new_key; 2630 } 2631 buf = Z_TagMalloc( len, TAG_CRYPTO ); 2632 FS_Read( buf, len, f ); 2633 FS_FCloseFile( f ); 2634 2635 if ( !qrsa_keypair_from_sexp( &public_key, &private_key, 0 , len, buf ) ) 2636 { 2637 Com_Printf( "Invalid RSA keypair in PKEY, regenerating\n" ); 2638 Z_Free( buf ); 2639 goto new_key; 2640 } 2641 2642 Z_Free( buf ); 2643 Com_Printf( "PKEY found.\n" ); 2644 return; 2645 2646 new_key: 2647 qmpz_set_ui(public_key.e, RSA_PUBLIC_EXPONENT); 2648 if ( !qrsa_generate_keypair( &public_key, &private_key, NULL, qnettle_random, NULL, NULL, RSA_KEY_LENGTH, 0 ) ) 2649 goto keygen_error; 2650 2651 struct nettle_buffer key_buffer; 2652 int key_buffer_len = 0; 2653 qnettle_buffer_init(&key_buffer, &key_buffer_len); 2654 if ( !qrsa_keypair_to_sexp( &key_buffer, NULL, &public_key, &private_key ) ) 2655 goto keygen_error; 2656 2657 f = FS_SV_FOpenFileWrite( PKEY_FILE ); 2658 if( !f ) 2659 { 2660 Com_Printf( "PKEY could not open %s for write, RSA support will be disabled\n", PKEY_FILE ); 2661 Cvar_Set( "cl_pubkeyID", "0" ); 2662 CRYPTO_Shutdown(); 2663 return; 2664 } 2665 FS_Write( key_buffer.contents, key_buffer.size, f ); 2666 qnettle_buffer_clear( &key_buffer ); 2667 FS_FCloseFile( f ); 2668 Com_Printf( "PKEY generated\n" ); 2669 return; 2670 2671 keygen_error: 2672 Com_Printf( "Error generating RSA keypair, RSA support will be disabled\n" ); 2673 Cvar_Set( "cl_pubkeyID", "0" ); 2674 CRYPTO_Shutdown(); 2675 } 2676 2677 /* 2604 2678 ==================== 2605 2679 CL_Init … … 2697 2771 2698 2772 cl_guidServerUniq = Cvar_Get ("cl_guidServerUniq", "1", CVAR_ARCHIVE); 2773 2774 cl_pubkeyID = Cvar_Get ("cl_pubkeyID", "1", CVAR_ARCHIVE | CVAR_USERINFO); 2699 2775 2700 2776 // userinfo … … 2750 2826 2751 2827 CL_GenerateQKey(); 2828 if (cl_pubkeyID->integer) 2829 CL_GeneratePKey(); 2752 2830 Cvar_Get( "cl_guid", "", CVAR_USERINFO | CVAR_ROM ); 2753 2831 CL_UpdateGUID( NULL, 0 ); -
src/client/client.h
r123 r190 379 379 extern cvar_t *cl_autoRecordDemo; 380 380 381 extern cvar_t *cl_pubkeyID; 382 383 extern struct rsa_public_key public_key; 384 extern struct rsa_private_key private_key; 385 381 386 //================================================= 382 387 -
src/game/g_admin.c
r175 r190 454 454 } 455 455 456 static voidadmin_writeconfig( void )456 void G_admin_writeconfig( void ) 457 457 { 458 458 fileHandle_t f; … … 471 471 if( len < 0 ) 472 472 { 473 G_Printf( " admin_writeconfig: could not open g_admin file \"%s\"\n",473 G_Printf( "G_admin_writeconfig: could not open g_admin file \"%s\"\n", 474 474 g_admin.string ); 475 475 return; … … 501 501 trap_FS_Write( "flags = ", 10, f ); 502 502 admin_writeconfig_string( g_admin_admins[ i ]->flags, f ); 503 trap_FS_Write( "pubkey = ", 10, f ); 504 admin_writeconfig_string( g_admin_admins[ i ]->pubkey, f ); 505 trap_FS_Write( "msg = ", 10, f ); 506 admin_writeconfig_string( g_admin_admins[ i ]->msg, f ); 507 trap_FS_Write( "msg2 = ", 10, f ); 508 admin_writeconfig_string( g_admin_admins[ i ]->msg2, f ); 509 trap_FS_Write( "counter = ", 10, f ); 510 admin_writeconfig_int( g_admin_admins[ i ]->counter, f ); 503 511 trap_FS_Write( "\n", 1, f ); 504 512 } … … 649 657 } 650 658 651 // return a levelfor a player entity.652 int G_admin_level( gentity_t *ent )659 // return the admin struct for a player entity. 660 g_admin_admin_t *G_admin_admin( gentity_t *ent ) 653 661 { 654 662 int i; … … 657 665 if( !ent ) 658 666 { 659 return MAX_ADMIN_LEVELS;667 return NULL; 660 668 } 661 669 … … 672 680 if( found ) 673 681 { 674 return g_admin_admins[ i ]->level;675 } 676 677 return 0;682 return g_admin_admins[i]; 683 } 684 685 return NULL; 678 686 } 679 687 … … 1152 1160 } 1153 1161 1162 void G_admin_pubkey( void ) 1163 { 1164 int i; 1165 g_admin_admin_t *highest = NULL; 1166 1167 // Uncomment this if your server lags (shouldn't happen unless you are on a *very* old computer) 1168 // Will only regenrate messages when there are no active client (When they are all loading the map) 1169 #if 0 1170 for( i = 0; i < level.maxclients; i++ ) 1171 { 1172 if( g_entities[ i ].client && g_entities[ i ].client->pers.connected == CON_CONNECTED ) 1173 return; 1174 } 1175 #endif 1176 1177 // Only do 1 encryption per frame to avoid lag 1178 for( i = 0; i < MAX_ADMIN_ADMINS && g_admin_admins[ i ]; i++ ) 1179 { 1180 if ( g_admin_admins[ i ]->counter == -1 && g_admin_admins[ i ]->pubkey[ 0 ] ) 1181 { 1182 highest = g_admin_admins[ i ]; 1183 break; 1184 } 1185 else if ( g_admin_admins[ i ]->counter == 0 || !g_admin_admins[ i ]->pubkey[ 0 ] ) 1186 continue; 1187 else if ( !highest ) 1188 { 1189 highest = g_admin_admins[ i ]; 1190 continue; 1191 } 1192 else if ( highest->counter < g_admin_admins[ i ]->counter ) 1193 highest = g_admin_admins[ i ]; 1194 } 1195 if ( highest ) 1196 { 1197 if ( trap_RSA_GenerateMessage( highest->pubkey, highest->msg, highest->msg2 ) ) 1198 highest->counter = 0; 1199 else 1200 { 1201 // If the key generation failed it can only be because of a bad pubkey 1202 // so we clear the pubkey and ask the client for a new one when he reconnects 1203 highest->pubkey[ 0 ] = '\0'; 1204 highest->msg[ 0 ] = '\0'; 1205 highest->msg2[ 0 ] = '\0'; 1206 highest->counter = -1; 1207 } 1208 G_admin_writeconfig( ); 1209 } 1210 } 1211 1154 1212 qboolean G_admin_readconfig( gentity_t *ent, int skiparg ) 1155 1213 { … … 1251 1309 { 1252 1310 admin_readconfig_string( &cnf, a->flags, sizeof( a->flags ) ); 1311 } 1312 else if( !Q_stricmp( t, "pubkey" ) ) 1313 { 1314 admin_readconfig_string( &cnf, a->pubkey, sizeof( a->pubkey ) ); 1315 } 1316 else if( !Q_stricmp( t, "msg" ) ) 1317 { 1318 admin_readconfig_string( &cnf, a->msg, sizeof( a->msg ) ); 1319 } 1320 else if( !Q_stricmp( t, "msg2" ) ) 1321 { 1322 admin_readconfig_string( &cnf, a->msg2, sizeof( a->msg2 ) ); 1323 } 1324 else if( !Q_stricmp( t, "counter" ) ) 1325 { 1326 admin_readconfig_int( &cnf, &a->counter ); 1253 1327 } 1254 1328 else … … 1362 1436 a->level = 0; 1363 1437 *a->flags = '\0'; 1438 *a->pubkey = '\0'; 1439 *a->msg = '\0'; 1440 *a->msg2 = '\0'; 1441 a->counter = -1; 1364 1442 admin_open = qtrue; 1365 1443 } … … 1418 1496 for( i = 0; i < level.maxclients; i++ ) 1419 1497 if( level.clients[ i ].pers.connected != CON_DISCONNECTED ) 1420 level.clients[ i ].pers.adminLevel = G_admin_level( &g_entities[ i ] ); 1498 { 1499 level.clients[ i ].pers.admin = G_admin_admin( &g_entities[ i ] ); 1500 level.clients[ i ].pers.adminLevel = ( level.clients[ i ].pers.pubkey_authenticated ? level.clients[ i ].pers.admin->level : 0 ); 1501 } 1421 1502 return qtrue; 1422 1503 } … … 1576 1657 if( !Q_stricmp( g_admin_admins[ i ]->guid, guid ) ) 1577 1658 { 1578 g_admin_admins[ i ]->level = l; 1579 Q_strncpyz( g_admin_admins[ i ]->name, adminname, 1580 sizeof( g_admin_admins[ i ]->name ) ); 1659 a = g_admin_admins[ i ]; 1660 a->level = l; 1661 Q_strncpyz( a->name, adminname, 1662 sizeof( a->name ) ); 1581 1663 updated = qtrue; 1582 1664 } … … 1594 1676 Q_strncpyz( a->guid, guid, sizeof( a->guid ) ); 1595 1677 *a->flags = '\0'; 1678 *a->pubkey = '\0'; 1679 *a->msg = '\0'; 1680 *a->msg2 = '\0'; 1681 a->counter = -1; 1596 1682 g_admin_admins[ i ] = a; 1597 1683 } … … 1601 1687 adminname, l, ( ent ) ? ent->client->pers.netname : "console" ) ); 1602 1688 if( vic ) 1689 { 1690 vic->client->pers.admin = ( l ? a : NULL ); 1603 1691 vic->client->pers.adminLevel = l; 1692 if ( l && l >= g_adminPubkeyID.integer && !a->pubkey[0] && vic->client->pers.cl_pubkeyID ) 1693 trap_SendServerCommand( vic - g_entities, "pubkey_request" ); 1694 } 1604 1695 1605 1696 if( !g_admin.string[ 0 ] ) … … 1607 1698 "to a file\n" ); 1608 1699 else 1609 admin_writeconfig();1700 G_admin_writeconfig(); 1610 1701 return qtrue; 1611 1702 } … … 1827 1918 ADM_NEW_BAN ); 1828 1919 if( g_admin.string[ 0 ] ) 1829 admin_writeconfig();1920 G_admin_writeconfig(); 1830 1921 } 1831 1922 … … 2055 2146 ADMP( "^3!ban: ^7WARNING g_admin not set, not saving ban to a file\n" ); 2056 2147 else 2057 admin_writeconfig();2148 G_admin_writeconfig(); 2058 2149 2059 2150 AP( va( "print \"^3!ban:^7 %s^7 has been banned by %s^7 " … … 2095 2186 ADMP( "^3!ban: ^7WARNING g_admin not set, not saving ban to a file\n" ); 2096 2187 else 2097 admin_writeconfig();2188 G_admin_writeconfig(); 2098 2189 2099 2190 if( g_admin_namelog[ logmatch ]->slot == -1 ) … … 2154 2245 ( ent ) ? ent->client->pers.netname : "console" ) ); 2155 2246 if( g_admin.string[ 0 ] ) 2156 admin_writeconfig();2247 G_admin_writeconfig(); 2157 2248 return qtrue; 2158 2249 } … … 3217 3308 } 3218 3309 3219 level = G_admin_level(ent);3310 level = ent->client->pers.adminLevel; 3220 3311 3221 3312 if( level == 0 ) … … 3256 3347 level = 0; 3257 3348 3258 level = G_admin_level(ent);3349 level = ent->client->pers.adminLevel; 3259 3350 if( level == 0 ) 3260 3351 level = 1; -
src/game/g_admin.h
r143 r190 109 109 int level; 110 110 char flags[ MAX_ADMIN_FLAGS ]; 111 char pubkey[ RSA_STRING_LENGTH ]; 112 char msg[ RSA_STRING_LENGTH ]; 113 char msg2[ RSA_STRING_LENGTH ]; 114 int counter; 111 115 } 112 116 g_admin_admin_t; … … 147 151 qboolean G_admin_cmd_check( gentity_t *ent, qboolean say ); 148 152 qboolean G_admin_readconfig( gentity_t *ent, int skiparg ); 153 void G_admin_writeconfig( void ); 149 154 qboolean G_admin_permission( gentity_t *ent, char flag ); 150 155 qboolean G_admin_guid_permission( char *guid, char flag ); 151 156 qboolean G_admin_name_check( gentity_t *ent, char *name, char *err, int len ); 152 157 void G_admin_namelog_update( gclient_t *ent, qboolean disconnect ); 153 int G_admin_level( gentity_t *ent ); 158 g_admin_admin_t *G_admin_admin( gentity_t *ent ); 159 void G_admin_pubkey( void ); 154 160 155 161 // ! command functions -
src/game/g_client.c
r143 r190 1264 1264 int used_privateSlots; 1265 1265 int privateClients; 1266 g_admin_admin_t *admin; 1266 1267 1267 1268 ent = &g_entities[ clientNum ]; … … 1340 1341 } 1341 1342 Q_strncpyz( client->pers.ip, ip, sizeof( client->pers.ip ) ); 1342 client->pers.adminLevel = G_admin_level( ent ); 1343 1343 admin = G_admin_admin( ent ); 1344 client->pers.admin = admin; 1345 client->pers.adminLevel = admin->level; 1346 client->pers.pubkey_authenticated = -1; 1347 client->pers.cl_pubkeyID = atoi( Info_ValueForKey( userinfo, "cl_pubkeyID" ) ); 1348 1349 if ( g_adminPubkeyID.integer && admin ) 1350 { 1351 if ( admin->pubkey[0] && admin->counter != -1 && admin->level >= g_adminPubkeyID.integer ) 1352 { 1353 // remove admin from client 1354 client->pers.pubkey_authenticated = 0; 1355 client->pers.adminLevel = 0; 1356 Q_strncpyz( client->pers.guid, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", sizeof( client->pers.guid ) ); 1357 // save name before we get renamed to UnamedPlayer 1358 Q_strncpyz( client->pers.connect_name, Info_ValueForKey( userinfo, "name" ), sizeof( client->pers.connect_name ) ); 1359 } 1360 } 1361 1344 1362 // do autoghost now so that there won't be any name conflicts later on 1345 1363 if ( g_autoGhost.integer ) … … 1383 1401 gclient_t *client; 1384 1402 int flags; 1403 g_admin_admin_t *admin; 1385 1404 1386 1405 ent = g_entities + clientNum; … … 1424 1443 // request the clients PTR code 1425 1444 trap_SendServerCommand( ent - g_entities, "ptrcrequest" ); 1445 1446 // ask for identification 1447 admin = client->pers.admin; 1448 if ( g_adminPubkeyID.integer && admin && client->pers.cl_pubkeyID ) 1449 { 1450 if ( admin->level >= g_adminPubkeyID.integer && !admin->pubkey[0] ) 1451 trap_SendServerCommand( ent - g_entities, "pubkey_request" ); 1452 else if ( client->pers.pubkey_authenticated == 0 ) 1453 { 1454 trap_SendServerCommand( ent - g_entities, va( "pubkey_decrypt %s", admin->msg2 ) ); 1455 admin->counter++; 1456 // copy the decrypted message because generating a new message will overwrite it 1457 Q_strncpyz( client->pers.pubkey_msg, admin->msg, sizeof( client->pers.pubkey_msg ) ); 1458 G_admin_writeconfig( ); 1459 } 1460 } 1426 1461 1427 1462 G_LogPrintf( "ClientBegin: %i\n", clientNum ); -
src/game/g_cmds.c
r185 r190 888 888 default: 889 889 case SAY_ALL: 890 if(ent->client->pers.teamSelection == TEAM_NONE && G_admin_level(ent)<g_minLevelToSpecMM1.integer)890 if(ent->client->pers.teamSelection == TEAM_NONE && ent->client->pers.adminLevel<g_minLevelToSpecMM1.integer) 891 891 { 892 892 trap_SendServerCommand( ent-g_entities,va( "print \"Sorry, but your admin level is not permitted to speak to all while spectating.\n\"") ); … … 3529 3529 } 3530 3530 3531 static void Cmd_Pubkey_f( gentity_t *ent ) 3532 { 3533 char buffer[ RSA_STRING_LENGTH ]; 3534 g_admin_admin_t *admin = ent->client->pers.admin; 3535 if ( !g_adminPubkeyID.integer || ent->client->pers.adminLevel < g_adminPubkeyID.integer || trap_Argc() != 2 ) 3536 return; 3537 if ( admin->pubkey[0] ) 3538 return; 3539 trap_Argv( 1, buffer, sizeof( buffer ) ); 3540 Q_strncpyz( admin->pubkey, buffer, sizeof( admin->pubkey ) ); 3541 admin->counter = -1; 3542 G_admin_writeconfig( ); 3543 } 3544 3545 static void Cmd_Pubkey_Identify_f( gentity_t *ent ) 3546 { 3547 char buffer[ MAX_STRING_CHARS ]; 3548 char userinfo[ MAX_INFO_STRING ]; 3549 g_admin_admin_t *admin = ent->client->pers.admin; 3550 if ( !g_adminPubkeyID.integer || ent->client->pers.admin->level < g_adminPubkeyID.integer || trap_Argc() != 2 ) 3551 return; 3552 if ( ent->client->pers.pubkey_authenticated != 0 || !admin->pubkey[0] || admin->counter == -1 || !ent->client->pers.pubkey_msg[0] ) 3553 return; 3554 trap_Argv( 1, buffer, sizeof( buffer ) ); 3555 if ( Q_strncmp( buffer, ent->client->pers.pubkey_msg, MAX_STRING_CHARS ) ) 3556 return; 3557 ent->client->pers.pubkey_authenticated = 1; 3558 ent->client->pers.pubkey_msg[0] = '\0'; 3559 ent->client->pers.adminLevel = admin->level; 3560 trap_GetUserinfo( ent - g_entities, userinfo, sizeof( userinfo ) ); 3561 Q_strncpyz( ent->client->pers.guid, Info_ValueForKey( userinfo, "cl_guid" ), sizeof( ent->client->pers.guid ) ); 3562 Info_SetValueForKey( userinfo, "name", ent->client->pers.connect_name ); 3563 trap_SetUserinfo( ent - g_entities, userinfo ); 3564 ClientUserinfoChanged( ent - g_entities ); 3565 } 3566 3531 3567 commands_t cmds[ ] = { 3532 3568 // normal commands … … 3571 3607 { "donate", CMD_TEAM, Cmd_Donate_f }, 3572 3608 3609 { "pubkey", CMD_INTERMISSION, Cmd_Pubkey_f }, 3610 { "pubkey_identify", CMD_INTERMISSION, Cmd_Pubkey_Identify_f }, 3611 3573 3612 { "follow", CMD_NOTEAM, Cmd_Follow_f }, 3574 3613 { "follownext", CMD_NOTEAM, Cmd_FollowCycle_f }, -
src/game/g_local.h
r182 r190 324 324 int specExpires; // level.time at which a player can join a team again after !spec 325 325 char voice[ MAX_VOICE_NAME_LEN ]; 326 g_admin_admin_t *admin; 327 int pubkey_authenticated; // -1 = does not have pubkey, 0 = not authenticated, 1 = authenticated 328 int cl_pubkeyID; 329 char pubkey_msg[ RSA_STRING_LENGTH ]; 330 char connect_name[ MAX_NAME_LENGTH ]; // Name of client before admin was removed with pubkey 326 331 } clientPersistant_t; 327 332 … … 1223 1228 extern vmCvar_t g_adminNameProtect; 1224 1229 extern vmCvar_t g_adminTempBan; 1230 extern vmCvar_t g_adminPubkeyID; 1225 1231 extern vmCvar_t g_adminTempSpec; 1226 1232 extern vmCvar_t g_minLevelToSpecMM1; … … 1301 1307 void trap_SnapVector( float *v ); 1302 1308 void trap_SendGameStat( const char *data ); 1309 int trap_RSA_GenerateMessage( const char *public_key, char *cleartext, char *encrypted ); 1303 1310 1304 1311 void do_health( gentity_t *ent, int quantity ); -
src/game/g_main.c
r185 r190 149 149 vmCvar_t g_autoRegister; 150 150 vmCvar_t g_adminTempBan; 151 vmCvar_t g_adminPubkeyID; 151 152 vmCvar_t g_adminTempSpec; 152 153 vmCvar_t g_minLevelToSpecMM1; … … 329 330 { &g_adminNameProtect, "g_adminNameProtect", "1", CVAR_ARCHIVE, 0, qfalse }, 330 331 { &g_adminTempBan, "g_adminTempBan", "120", CVAR_ARCHIVE, 0, qfalse }, 332 { &g_adminPubkeyID, "g_adminPubkeyID", "2", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, 331 333 { &g_adminTempSpec, "g_adminTempSpec", "120", CVAR_ARCHIVE, 0, qfalse }, 332 334 { &g_adminWarnMessage, "g_adminWarnMessage", "You have been warned by an administrator.\n Cease imeediately or face admin action!\n", CVAR_ARCHIVE, 0, qfalse }, … … 2735 2737 CheckTeamVote( TEAM_ALIENS ); 2736 2738 2739 // generate public-key messages 2740 if ( g_adminPubkeyID.integer ) 2741 G_admin_pubkey(); 2742 2737 2743 // for tracking changes 2738 2744 CheckCvars( ); -
src/game/g_public.h
r156 r190 221 221 G_PARSE_SOURCE_FILE_AND_LINE, 222 222 223 G_SEND_GAMESTAT 223 G_SEND_GAMESTAT, 224 225 G_RSA_GENMSG // ( const char *public_key, char *cleartext, char *encrypted ) 224 226 } gameImport_t; 225 227 -
src/game/g_syscalls.asm
r125 r190 51 51 52 52 equ trap_SendGameStat -48 53 equ trap_RSA_GenerateMessage -49 53 54 54 55 -
src/game/g_syscalls.c
r156 r190 258 258 } 259 259 260 int trap_RSA_GenerateMessage( const char *public_key, char *cleartext, char *encrypted ) 261 { 262 return syscall( G_RSA_GENMSG, public_key, cleartext, encrypted ); 263 } 264 260 265 int trap_Parse_AddGlobalDefine( char *define ) 261 266 { -
src/qcommon/common.c
r125 r190 83 83 cvar_t *com_unfocused; 84 84 cvar_t *com_minimized; 85 cvar_t *com_gmpLibName; 86 cvar_t *com_nettleLibName; 85 87 86 88 // com_speeds times … … 2471 2473 com_minimized = Cvar_Get( "com_minimized", "0", CVAR_ROM ); 2472 2474 2475 com_gmpLibName = Cvar_Get( "com_gmpLibName", DEFAULT_GMP_LIB, CVAR_ARCHIVE ); 2476 com_nettleLibName = Cvar_Get( "com_nettleLibName", DEFAULT_NETTLE_LIB, CVAR_ARCHIVE ); 2477 2473 2478 if ( com_developer && com_developer->integer ) { 2474 2479 Cmd_AddCommand ("error", Com_Error_f); … … 2486 2491 VM_Init(); 2487 2492 SV_Init(); 2493 if (!CRYPTO_Init()) 2494 { 2495 // Disable all crypto functions 2496 Cvar_Get("g_adminPubkeyID", "0", CVAR_ROM); 2497 #ifndef DEDICATED 2498 Cvar_Get("cl_pubkeyID", "0", CVAR_ROM); 2499 #endif 2500 } 2488 2501 2489 2502 com_dedicated->modified = qfalse; -
src/qcommon/q_shared.h
r174 r190 1332 1332 #define MAX_EMOTICONS 64 1333 1333 1334 /* This should not be changed because this value is 1335 * expected to be the same on the client and on the server */ 1336 #define RSA_KEY_LENGTH 2048 1337 #define RSA_STRING_LENGTH (RSA_KEY_LENGTH / 4 + 1) 1338 1334 1339 #endif // __Q_SHARED_H -
src/qcommon/qcommon.h
r125 r190 26 26 27 27 #include "../qcommon/cm_public.h" 28 29 #include "../qcommon/crypto.h" 28 30 29 31 //Ignore __attribute__ on non-gcc platforms … … 785 787 extern cvar_t *com_minimized; 786 788 extern cvar_t *com_altivec; 789 extern cvar_t *com_gmpLibName; 790 extern cvar_t *com_nettleLibName; 787 791 788 792 // both client and server must agree to pause … … 811 815 TAG_BOTLIB, 812 816 TAG_RENDERER, 817 TAG_CRYPTO, 813 818 TAG_SMALL, 814 819 TAG_STATIC -
src/server/sv_game.c
r0 r190 435 435 SV_MasterGameStat( VMA(1) ); 436 436 return 0; 437 case G_RSA_GENMSG: 438 { 439 struct rsa_public_key public_key; 440 mpz_t message; 441 unsigned char buffer[ RSA_KEY_LENGTH / 8 - 11 ]; 442 int retval; 443 Com_RandomBytes( buffer, RSA_KEY_LENGTH / 8 - 11 ); 444 qnettle_mpz_init_set_str_256_u( message, RSA_KEY_LENGTH / 8 - 11, buffer ); 445 qmpz_get_str( VMA(2), 16, message ); 446 qrsa_public_key_init( &public_key ); 447 qmpz_set_ui( public_key.e, RSA_PUBLIC_EXPONENT ); 448 retval = qmpz_set_str( public_key.n, VMA(1), 16 ) + 1; 449 if ( retval ) 450 { 451 qrsa_public_key_prepare( &public_key ); 452 retval = qrsa_encrypt( &public_key, NULL, qnettle_random, RSA_KEY_LENGTH / 8 - 11, buffer, message ); 453 } 454 qrsa_public_key_clear( &public_key ); 455 qmpz_get_str( VMA(3), 16, message ); 456 qmpz_clear( message ); 457 return retval; 458 } 437 459 438 460 //====================================
