-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from spark/feature/secure-random-seed
Secure random seed from Spark Cloud
- Loading branch information
Showing
5 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#include "functions.h" | ||
#include <stdlib.h> | ||
|
||
/** | ||
* Handle the cryptographically secure random seed from the cloud by using | ||
* it to seed the stdlib PRNG. | ||
* @param seed A random value from a cryptographically secure random number generator. | ||
* | ||
* This function has weak linkage, so that user code may re-define this function and | ||
* handle the random number in some other way. For example, to combine with local | ||
* entropy sources. | ||
*/ | ||
__attribute__((weak)) void random_seed_from_cloud(unsigned int seed){ | ||
srand(seed); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* File: functions.h | ||
* Author: mat | ||
* | ||
* Created on 04 September 2014, 00:10 | ||
*/ | ||
|
||
#ifndef FUNCTIONS_H | ||
#define FUNCTIONS_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* Handle the cryptographically secure random seed from the cloud. | ||
* @param seed A random value. This is typically used to seed a pseudo-random generator. | ||
*/ | ||
extern void random_seed_from_cloud(unsigned int seed); | ||
|
||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* FUNCTIONS_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters