summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2012-10-28 10:40:37 +0000
committerSimon Howard2012-10-28 10:40:37 +0000
commitf7ecbd1449871a448daa7b96ce121f3fe9d19aed (patch)
tree12cf9435454d448ac962309a798fafbfb302cb1e
parenta3b3e15f4eed9aaffc56be69784cd7447cf456de (diff)
downloadchocolate-doom-f7ecbd1449871a448daa7b96ce121f3fe9d19aed.tar.gz
chocolate-doom-f7ecbd1449871a448daa7b96ce121f3fe9d19aed.tar.bz2
chocolate-doom-f7ecbd1449871a448daa7b96ce121f3fe9d19aed.zip
Define PRNG seed as a type.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2534
-rw-r--r--src/Makefile.am1
-rw-r--r--src/aes_prng.c5
-rw-r--r--src/aes_prng.h6
3 files changed, 9 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 03942157..25766ca0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,6 +132,7 @@ deh_weapon.c
# 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 \
diff --git a/src/aes_prng.c b/src/aes_prng.c
index 0a68efb5..f6ded3c1 100644
--- 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 @@ static unsigned int prng_value_index = 0;
// 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 @@ void PRNG_Start(byte *key)
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;
diff --git a/src/aes_prng.h b/src/aes_prng.h
index c58166b8..4c06f3a3 100644
--- 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);