]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_apple_csp/lib/YarrowConnection.cpp
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_apple_csp / lib / YarrowConnection.cpp
index e6a8da606ae00843f8a6d7957d089a0464d70bb1..b83a4cfdf1dd3b7ac29bd3bc90e127223f3468b9 100644 (file)
  */
 #include "YarrowConnection.h"
 #include <security_utilities/globalizer.h>
-#include <security_utilities/devrandom.h>
 #include <Security/cssmtype.h>
-
-/* instantiated by C++ runtime at library load/init time */
-class YarrowConnection : public DevRandomGenerator {
-public:
-    YarrowConnection() : DevRandomGenerator(getuid() == 0), writable(getuid() == 0) { }
-    const bool writable;
-};
-
-/* the single global thing */
-static ModuleNexus<YarrowConnection> yarrowConnection;
-
+#include <Security/SecRandom.h>
 
 /* and the exported functions */
 void cspGetRandomBytes(void *buf, unsigned len)
 {
-       yarrowConnection().random(buf, len);
+    MacOSError::check(SecRandomCopyBytes(kSecRandomDefault, len, buf));
 }
 
+/* Unused, since SecRandomCopyBytes returns from a suitable CSPRNG seeded elsewhere */
 void cspAddEntropy(const void *buf, unsigned len)
 {
-    if (yarrowConnection().writable)
-        yarrowConnection().addEntropy(buf, len);
 }