1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/rand/rand_symbian.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,61 @@
1.4 +/*
1.5 +Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.6 +
1.7 +Redistribution and use in source and binary forms, with or without
1.8 +modification, are permitted provided that the following conditions are met:
1.9 +
1.10 +* Redistributions of source code must retain the above copyright notice, this
1.11 + list of conditions and the following disclaimer.
1.12 +* Redistributions in binary form must reproduce the above copyright notice,
1.13 + this list of conditions and the following disclaimer in the documentation
1.14 + and/or other materials provided with the distribution.
1.15 +* Neither the name of Nokia Corporation nor the names of its contributors
1.16 + may be used to endorse or promote products derived from this software
1.17 + without specific prior written permission.
1.18 +
1.19 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1.20 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.21 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1.22 +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1.23 +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.24 +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.25 +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1.26 +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1.27 +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1.28 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.29 +
1.30 +Description:
1.31 +*/
1.32 +
1.33 +#include <stdio.h>
1.34 +
1.35 +#define USE_SOCKETS
1.36 +#include "e_os.h"
1.37 +#include "cryptlib.h"
1.38 +#include <openssl/rand.h>
1.39 +#include "rand_lcl.h"
1.40 +
1.41 +#include <sys/types.h>
1.42 +#include <sys/time.h>
1.43 +#include <sys/stat.h>
1.44 +#include <fcntl.h>
1.45 +#include <unistd.h>
1.46 +#include <time.h>
1.47 +
1.48 +
1.49 +EXPORT_C int RAND_poll(void)
1.50 +{
1.51 + u_int32_t rnd = 0, i;
1.52 + unsigned char buf[ENTROPY_NEEDED];
1.53 +
1.54 + for (i = 0; i < sizeof(buf); i++) {
1.55 + if (i % 4 == 0)
1.56 + rnd = rand();
1.57 + buf[i] = rnd;
1.58 + rnd >>= 8;
1.59 + }
1.60 + RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
1.61 + memset(buf, 0, sizeof(buf));
1.62 +
1.63 + return 1;
1.64 +}