]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/feeRandom.c
Security-59306.11.20.tar.gz
[apple/security.git] / OSX / libsecurity_cryptkit / lib / feeRandom.c
1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
2 *
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
10 *
11 * FeeRandom.c - generic, portable random number generator object
12 *
13 * Revision History
14 * ----------------
15 * 10/06/98 ap
16 * Changed to compile with C++.
17 * 19 Jun 97 at Apple
18 * Eliminated predictability of bytes 4 thru 15 of random data
19 * 18 Jun 97 at Apple
20 * Reduced size of per-instance giants from 128 to 32 shorts
21 * 23 Aug 96 at NeXT
22 * Created, based on Blaine Garst's NSRandomNumberGenerator class
23 */
24
25 #include "feeRandom.h"
26 #include "platform.h"
27 #include <Security/SecRandom.h>
28
29 feeRand feeRandAllocWithSeed(__attribute__((unused)) unsigned seed)
30 {
31 return NULL;
32 }
33
34 feeRand feeRandAlloc(void)
35 {
36 return NULL;
37 }
38
39 void feeRandFree(__attribute__((unused)) feeRand frand)
40 {
41
42 }
43
44 unsigned feeRandNextNum(feeRand frand)
45 {
46 unsigned rand;
47
48 feeRandBytes(frand, &rand, sizeof(rand));
49
50 return rand;
51 }
52
53 void feeRandBytes(__attribute__((unused)) feeRand frand, void *bytes, unsigned numBytes)
54 {
55 int err;
56
57 err = SecRandomCopyBytes(kSecRandomDefault, numBytes, bytes);
58 if (err != errSecSuccess) {
59 CKRaise("feeRandBytes");
60 }
61 }
62
63 /* new function, 5 March 1999 - dmitch */
64 void feeRandAddEntropy(__attribute__((unused)) feeRand frand, __attribute__((unused)) unsigned entropy)
65 {
66
67 }
68