1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <oslrandom.h>
18 bool osl_get_system_random_data(char* buffer
, size_t desired_len
)
24 static int (*lok_open_urandom
)()
25 = reinterpret_cast<int (*)()>(dlsym(RTLD_DEFAULT
, "lok_open_urandom"));
26 if (!lok_open_urandom
|| (fd
= lok_open_urandom()) < 0)
27 fd
= open("/dev/urandom", O_RDONLY
);
34 if ((nb_read
= read(fd
, buffer
, desired_len
)) < 0)
45 desired_len
-= nb_read
;
54 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */