ref: f7ecbd1449871a448daa7b96ce121f3fe9d19aed
parent: a3b3e15f4eed9aaffc56be69784cd7447cf456de
author: Simon Howard <[email protected]>
date: Sun Oct 28 06:40:37 EDT 2012
Define PRNG seed as a type. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2534
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,6 +132,7 @@
# source files needed for FEATURE_MULTIPLAYER
FEATURE_MULTIPLAYER_SOURCE_FILES= \
+aes_prng.c aes_prng.h \
net_client.c net_client.h \
net_common.c net_common.h \
net_dedicated.c net_dedicated.h \
--- a/src/aes_prng.c
+++ b/src/aes_prng.c
@@ -70,6 +70,7 @@
#include <stdlib.h>
#include <string.h> /* for memcmp() */
+#include "aes_prng.h"
#include "doomtype.h"
#include "i_system.h"
@@ -948,7 +949,7 @@
// Initialize Pseudo-RNG using the specified 128-bit key.
-void PRNG_Start(byte *key)
+void PRNG_Start(prng_seed_t key)
{
char *errormsg;
@@ -959,7 +960,7 @@
I_Error("Failed to initialize PRNG: %s", errormsg);
}
- AES_SetKey(&prng_context, key, 128 / 8);
+ AES_SetKey(&prng_context, key, sizeof(prng_seed_t));
prng_value_index = 4;
prng_input_counter = 0;
prng_enabled = true;
--- a/src/aes_prng.h
+++ b/src/aes_prng.h
@@ -28,7 +28,11 @@
#include "doomtype.h"
-void PRNG_Start(byte *key);
+// Nonce value used as random seed for secure demos.
+
+typedef byte prng_seed_t[16];
+
+void PRNG_Start(prng_seed_t seed);
void PRNG_Stop(void);
unsigned int PRNG_Random(void);