2 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
15 #include "internal/cryptlib.h"
16 #include <openssl/rand.h>
17 #include <openssl/crypto.h>
18 #include "rand_local.h"
19 #include "crypto/rand.h"
21 #include "internal/dso.h"
23 # include <sys/syscall.h>
24 # ifdef DEVRANDOM_WAIT
26 # include <sys/utsname.h>
29 #if (defined(__FreeBSD__) || defined(__NetBSD__)) && !defined(OPENSSL_SYS_UEFI)
30 # include <sys/types.h>
31 # include <sys/sysctl.h>
32 # include <sys/param.h>
34 #if defined(__OpenBSD__)
35 # include <sys/param.h>
38 #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
39 # include <sys/types.h>
40 # include <sys/stat.h>
43 # include <sys/time.h>
45 static uint64_t get_time_stamp(void);
46 static uint64_t get_timer_bits(void);
48 /* Macro to convert two thirty two bit values into a sixty four bit one */
49 # define TWO32TO64(a, b) ((((uint64_t)(a)) << 32) + (b))
52 * Check for the existence and support of POSIX timers. The standard
53 * says that the _POSIX_TIMERS macro will have a positive value if they
56 * However, we want an additional constraint: that the timer support does
57 * not require an extra library dependency. Early versions of glibc
58 * require -lrt to be specified on the link line to access the timers,
59 * so this needs to be checked for.
61 * It is worse because some libraries define __GLIBC__ but don't
62 * support the version testing macro (e.g. uClibc). This means
63 * an extra check is needed.
65 * The final condition is:
66 * "have posix timers and either not glibc or glibc without -lrt"
68 * The nested #if sequences are required to avoid using a parameterised
69 * macro that might be undefined.
71 # undef OSSL_POSIX_TIMER_OKAY
72 # if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
73 # if defined(__GLIBC__)
74 # if defined(__GLIBC_PREREQ)
75 # if __GLIBC_PREREQ(2, 17)
76 # define OSSL_POSIX_TIMER_OKAY
80 # define OSSL_POSIX_TIMER_OKAY
83 #endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS))
84 || defined(__DJGPP__) */
86 #if defined(OPENSSL_RAND_SEED_NONE)
87 /* none means none. this simplifies the following logic */
88 # undef OPENSSL_RAND_SEED_OS
89 # undef OPENSSL_RAND_SEED_GETRANDOM
90 # undef OPENSSL_RAND_SEED_LIBRANDOM
91 # undef OPENSSL_RAND_SEED_DEVRANDOM
92 # undef OPENSSL_RAND_SEED_RDTSC
93 # undef OPENSSL_RAND_SEED_RDCPU
94 # undef OPENSSL_RAND_SEED_EGD
97 #if (defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)) && \
98 !defined(OPENSSL_RAND_SEED_NONE)
99 # error "UEFI and VXWorks only support seeding NONE"
102 #if defined(OPENSSL_SYS_VXWORKS)
103 /* empty implementation */
104 int rand_pool_init(void)
109 void rand_pool_cleanup(void)
113 void rand_pool_keep_random_devices_open(int keep)
117 size_t rand_pool_acquire_entropy(RAND_POOL *pool)
119 return rand_pool_entropy_available(pool);
123 #if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) \
124 || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VXWORKS) \
125 || defined(OPENSSL_SYS_UEFI))
127 # if defined(OPENSSL_SYS_VOS)
129 # ifndef OPENSSL_RAND_SEED_OS
130 # error "Unsupported seeding method configured; must be os"
133 # if defined(OPENSSL_SYS_VOS_HPPA) && defined(OPENSSL_SYS_VOS_IA32)
134 # error "Unsupported HP-PA and IA32 at the same time."
136 # if !defined(OPENSSL_SYS_VOS_HPPA) && !defined(OPENSSL_SYS_VOS_IA32)
137 # error "Must have one of HP-PA or IA32"
141 * The following algorithm repeatedly samples the real-time clock (RTC) to
142 * generate a sequence of unpredictable data. The algorithm relies upon the
143 * uneven execution speed of the code (due to factors such as cache misses,
144 * interrupts, bus activity, and scheduling) and upon the rather large
145 * relative difference between the speed of the clock and the rate at which
146 * it can be read. If it is ported to an environment where execution speed
147 * is more constant or where the RTC ticks at a much slower rate, or the
148 * clock can be read with fewer instructions, it is likely that the results
149 * would be far more predictable. This should only be used for legacy
152 * As a precaution, we assume only 2 bits of entropy per byte.
154 size_t rand_pool_acquire_entropy(RAND_POOL *pool)
161 # ifdef OPENSSL_SYS_VOS_HPPA
163 extern void s$sleep(long *_duration, short int *_code);
166 extern void s$sleep2(long long *_duration, short int *_code);
169 bytes_needed = rand_pool_bytes_needed(pool, 4 /*entropy_factor*/);
171 for (i = 0; i < bytes_needed; i++) {
173 * burn some cpu; hope for interrupts, cache collisions, bus
176 for (k = 0; k < 99; k++)
177 ts.tv_nsec = random();
179 # ifdef OPENSSL_SYS_VOS_HPPA
180 /* sleep for 1/1024 of a second (976 us). */
182 s$sleep(&duration, &code);
184 /* sleep for 1/65536 of a second (15 us). */
186 s$sleep2(&duration, &code);
189 /* Get wall clock time, take 8 bits. */
190 clock_gettime(CLOCK_REALTIME, &ts);
191 v = (unsigned char)(ts.tv_nsec & 0xFF);
192 rand_pool_add(pool, arg, &v, sizeof(v) , 2);
194 return rand_pool_entropy_available(pool);
197 void rand_pool_cleanup(void)
201 void rand_pool_keep_random_devices_open(int keep)
207 # if defined(OPENSSL_RAND_SEED_EGD) && \
208 (defined(OPENSSL_NO_EGD) || !defined(DEVRANDOM_EGD))
209 # error "Seeding uses EGD but EGD is turned off or no device given"
212 # if defined(OPENSSL_RAND_SEED_DEVRANDOM) && !defined(DEVRANDOM)
213 # error "Seeding uses urandom but DEVRANDOM is not configured"
216 # if defined(OPENSSL_RAND_SEED_OS)
217 # if !defined(DEVRANDOM)
218 # error "OS seeding requires DEVRANDOM to be configured"
220 # define OPENSSL_RAND_SEED_GETRANDOM
221 # define OPENSSL_RAND_SEED_DEVRANDOM
224 # if defined(OPENSSL_RAND_SEED_LIBRANDOM)
225 # error "librandom not (yet) supported"
228 # if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(KERN_ARND)
230 * sysctl_random(): Use sysctl() to read a random number from the kernel
231 * Returns the number of bytes returned in buf on success, -1 on failure.
233 static ssize_t sysctl_random(char *buf, size_t buflen)
240 * Note: sign conversion between size_t and ssize_t is safe even
241 * without a range check, see comment in syscall_random()
245 * On FreeBSD old implementations returned longs, newer versions support
246 * variable sizes up to 256 byte. The code below would not work properly
247 * when the sysctl returns long and we want to request something not a
248 * multiple of longs, which should never be the case.
250 #if defined(__FreeBSD__)
251 if (!ossl_assert(buflen % sizeof(long) == 0)) {
258 * On NetBSD before 4.0 KERN_ARND was an alias for KERN_URND, and only
259 * filled in an int, leaving the rest uninitialized. Since NetBSD 4.0
260 * it returns a variable number of bytes with the current version supporting
262 * Just return an error on older NetBSD versions.
264 #if defined(__NetBSD__) && __NetBSD_Version__ < 400000000
273 len = buflen > 256 ? 256 : buflen;
274 if (sysctl(mib, 2, buf, &len, NULL, 0) == -1)
275 return done > 0 ? done : -1;
279 } while (buflen > 0);
285 # if defined(OPENSSL_RAND_SEED_GETRANDOM)
287 # if defined(__linux) && !defined(__NR_getrandom)
288 # if defined(__arm__)
289 # define __NR_getrandom (__NR_SYSCALL_BASE+384)
290 # elif defined(__i386__)
291 # define __NR_getrandom 355
292 # elif defined(__x86_64__)
293 # if defined(__ILP32__)
294 # define __NR_getrandom (__X32_SYSCALL_BIT + 318)
296 # define __NR_getrandom 318
298 # elif defined(__xtensa__)
299 # define __NR_getrandom 338
300 # elif defined(__s390__) || defined(__s390x__)
301 # define __NR_getrandom 349
302 # elif defined(__bfin__)
303 # define __NR_getrandom 389
304 # elif defined(__powerpc__)
305 # define __NR_getrandom 359
306 # elif defined(__mips__) || defined(__mips64)
307 # if _MIPS_SIM == _MIPS_SIM_ABI32
308 # define __NR_getrandom (__NR_Linux + 353)
309 # elif _MIPS_SIM == _MIPS_SIM_ABI64
310 # define __NR_getrandom (__NR_Linux + 313)
311 # elif _MIPS_SIM == _MIPS_SIM_NABI32
312 # define __NR_getrandom (__NR_Linux + 317)
314 # elif defined(__hppa__)
315 # define __NR_getrandom (__NR_Linux + 339)
316 # elif defined(__sparc__)
317 # define __NR_getrandom 347
318 # elif defined(__ia64__)
319 # define __NR_getrandom 1339
320 # elif defined(__alpha__)
321 # define __NR_getrandom 511
322 # elif defined(__sh__)
323 # if defined(__SH5__)
324 # define __NR_getrandom 373
326 # define __NR_getrandom 384
328 # elif defined(__avr32__)
329 # define __NR_getrandom 317
330 # elif defined(__microblaze__)
331 # define __NR_getrandom 385
332 # elif defined(__m68k__)
333 # define __NR_getrandom 352
334 # elif defined(__cris__)
335 # define __NR_getrandom 356
336 # elif defined(__aarch64__)
337 # define __NR_getrandom 278
339 # define __NR_getrandom 278
344 * syscall_random(): Try to get random data using a system call
345 * returns the number of bytes returned in buf, or < 0 on error.
347 static ssize_t syscall_random(void *buf, size_t buflen)
350 * Note: 'buflen' equals the size of the buffer which is used by the
351 * get_entropy() callback of the RAND_DRBG. It is roughly bounded by
353 * 2 * RAND_POOL_FACTOR * (RAND_DRBG_STRENGTH / 8) = 2^14
355 * which is way below the OSSL_SSIZE_MAX limit. Therefore sign conversion
356 * between size_t and ssize_t is safe even without a range check.
360 * Do runtime detection to find getentropy().
362 * Known OSs that should support this:
363 * - Darwin since 16 (OSX 10.12, IOS 10.0).
364 * - Solaris since 11.3
365 * - OpenBSD since 5.6
366 * - Linux since 3.17 with glibc 2.25
367 * - FreeBSD since 12.0 (1200061)
369 # if defined(__GNUC__) && __GNUC__>=2 && defined(__ELF__) && !defined(__hpux)
370 extern int getentropy(void *buffer, size_t length) __attribute__((weak));
372 if (getentropy != NULL)
373 return getentropy(buf, buflen) == 0 ? (ssize_t)buflen : -1;
377 int (*f)(void *buffer, size_t length);
381 * We could cache the result of the lookup, but we normally don't
382 * call this function often.
385 p_getentropy.p = DSO_global_lookup("getentropy");
387 if (p_getentropy.p != NULL)
388 return p_getentropy.f(buf, buflen) == 0 ? (ssize_t)buflen : -1;
391 /* Linux supports this since version 3.17 */
392 # if defined(__linux) && defined(__NR_getrandom)
393 return syscall(__NR_getrandom, buf, buflen, 0);
394 # elif (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(KERN_ARND)
395 return sysctl_random(buf, buflen);
401 # endif /* defined(OPENSSL_RAND_SEED_GETRANDOM) */
403 # if defined(OPENSSL_RAND_SEED_DEVRANDOM)
404 static const char *random_device_paths[] = { DEVRANDOM };
405 static struct random_device {
411 } random_devices[OSSL_NELEM(random_device_paths)];
412 static int keep_random_devices_open = 1;
414 # if defined(__linux) && defined(DEVRANDOM_WAIT) \
415 && defined(OPENSSL_RAND_SEED_GETRANDOM)
416 static void *shm_addr;
418 static void cleanup_shm(void)
424 * Ensure that the system randomness source has been adequately seeded.
425 * This is done by having the first start of libcrypto, wait until the device
426 * /dev/random becomes able to supply a byte of entropy. Subsequent starts
427 * of the library and later reseedings do not need to do this.
429 static int wait_random_seeded(void)
431 static int seeded = OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID < 0;
432 static const int kernel_version[] = { DEVRANDOM_SAFE_KERNEL };
440 /* See if anything has created the global seeded indication */
441 if ((shm_id = shmget(OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID, 1, 0)) == -1) {
443 * Check the kernel's version and fail if it is too recent.
445 * Linux kernels from 4.8 onwards do not guarantee that
446 * /dev/urandom is properly seeded when /dev/random becomes
447 * readable. However, such kernels support the getentropy(2)
448 * system call and this should always succeed which renders
449 * this alternative but essentially identical source moot.
451 if (uname(&un) == 0) {
452 kernel[0] = atoi(un.release);
453 p = strchr(un.release, '.');
454 kernel[1] = p == NULL ? 0 : atoi(p + 1);
455 if (kernel[0] > kernel_version[0]
456 || (kernel[0] == kernel_version[0]
457 && kernel[1] >= kernel_version[1])) {
461 /* Open /dev/random and wait for it to be readable */
462 if ((fd = open(DEVRANDOM_WAIT, O_RDONLY)) != -1) {
463 if (DEVRANDM_WAIT_USE_SELECT && fd < FD_SETSIZE) {
466 while ((r = select(fd + 1, &fds, NULL, NULL, NULL)) < 0
469 while ((r = read(fd, &c, 1)) < 0 && errno == EINTR);
474 /* Create the shared memory indicator */
475 shm_id = shmget(OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID, 1,
476 IPC_CREAT | S_IRUSR | S_IRGRP | S_IROTH);
483 * Map the shared memory to prevent its premature destruction.
484 * If this call fails, it isn't a big problem.
486 shm_addr = shmat(shm_id, NULL, SHM_RDONLY);
487 if (shm_addr != (void *)-1)
488 OPENSSL_atexit(&cleanup_shm);
493 # else /* defined __linux && DEVRANDOM_WAIT && OPENSSL_RAND_SEED_GETRANDOM */
494 static int wait_random_seeded(void)
501 * Verify that the file descriptor associated with the random source is
502 * still valid. The rationale for doing this is the fact that it is not
503 * uncommon for daemons to close all open file handles when daemonizing.
504 * So the handle might have been closed or even reused for opening
507 static int check_random_device(struct random_device * rd)
512 && fstat(rd->fd, &st) != -1
513 && rd->dev == st.st_dev
514 && rd->ino == st.st_ino
515 && ((rd->mode ^ st.st_mode) & ~(S_IRWXU | S_IRWXG | S_IRWXO)) == 0
516 && rd->rdev == st.st_rdev;
520 * Open a random device if required and return its file descriptor or -1 on error
522 static int get_random_device(size_t n)
525 struct random_device * rd = &random_devices[n];
527 /* reuse existing file descriptor if it is (still) valid */
528 if (check_random_device(rd))
531 /* open the random device ... */
532 if ((rd->fd = open(random_device_paths[n], O_RDONLY)) == -1)
535 /* ... and cache its relevant stat(2) data */
536 if (fstat(rd->fd, &st) != -1) {
539 rd->mode = st.st_mode;
540 rd->rdev = st.st_rdev;
550 * Close a random device making sure it is a random device
552 static void close_random_device(size_t n)
554 struct random_device * rd = &random_devices[n];
556 if (check_random_device(rd))
561 int rand_pool_init(void)
565 for (i = 0; i < OSSL_NELEM(random_devices); i++)
566 random_devices[i].fd = -1;
571 void rand_pool_cleanup(void)
575 for (i = 0; i < OSSL_NELEM(random_devices); i++)
576 close_random_device(i);
579 void rand_pool_keep_random_devices_open(int keep)
584 keep_random_devices_open = keep;
587 # else /* !defined(OPENSSL_RAND_SEED_DEVRANDOM) */
589 int rand_pool_init(void)
594 void rand_pool_cleanup(void)
598 void rand_pool_keep_random_devices_open(int keep)
602 # endif /* defined(OPENSSL_RAND_SEED_DEVRANDOM) */
605 * Try the various seeding methods in turn, exit when successful.
607 * TODO(DRBG): If more than one entropy source is available, is it
608 * preferable to stop as soon as enough entropy has been collected
609 * (as favored by @rsalz) or should one rather be defensive and add
610 * more entropy than requested and/or from different sources?
612 * Currently, the user can select multiple entropy sources in the
613 * configure step, yet in practice only the first available source
614 * will be used. A more flexible solution has been requested, but
615 * currently it is not clear how this can be achieved without
616 * overengineering the problem. There are many parameters which
617 * could be taken into account when selecting the order and amount
618 * of input from the different entropy sources (trust, quality,
619 * possibility of blocking).
621 size_t rand_pool_acquire_entropy(RAND_POOL *pool)
623 # if defined(OPENSSL_RAND_SEED_NONE)
624 return rand_pool_entropy_available(pool);
626 size_t entropy_available;
628 # if defined(OPENSSL_RAND_SEED_GETRANDOM)
631 unsigned char *buffer;
633 /* Maximum allowed number of consecutive unsuccessful attempts */
636 bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
637 while (bytes_needed != 0 && attempts-- > 0) {
638 buffer = rand_pool_add_begin(pool, bytes_needed);
639 bytes = syscall_random(buffer, bytes_needed);
641 rand_pool_add_end(pool, bytes, 8 * bytes);
642 bytes_needed -= bytes;
643 attempts = 3; /* reset counter after successful attempt */
644 } else if (bytes < 0 && errno != EINTR) {
649 entropy_available = rand_pool_entropy_available(pool);
650 if (entropy_available > 0)
651 return entropy_available;
654 # if defined(OPENSSL_RAND_SEED_LIBRANDOM)
656 /* Not yet implemented. */
660 # if defined(OPENSSL_RAND_SEED_DEVRANDOM)
661 if (wait_random_seeded()) {
663 unsigned char *buffer;
666 bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
667 for (i = 0; bytes_needed > 0 && i < OSSL_NELEM(random_device_paths);
670 /* Maximum number of consecutive unsuccessful attempts */
672 const int fd = get_random_device(i);
677 while (bytes_needed != 0 && attempts-- > 0) {
678 buffer = rand_pool_add_begin(pool, bytes_needed);
679 bytes = read(fd, buffer, bytes_needed);
682 rand_pool_add_end(pool, bytes, 8 * bytes);
683 bytes_needed -= bytes;
684 attempts = 3; /* reset counter on successful attempt */
685 } else if (bytes < 0 && errno != EINTR) {
689 if (bytes < 0 || !keep_random_devices_open)
690 close_random_device(i);
692 bytes_needed = rand_pool_bytes_needed(pool, 1);
694 entropy_available = rand_pool_entropy_available(pool);
695 if (entropy_available > 0)
696 return entropy_available;
700 # if defined(OPENSSL_RAND_SEED_RDTSC)
701 entropy_available = rand_acquire_entropy_from_tsc(pool);
702 if (entropy_available > 0)
703 return entropy_available;
706 # if defined(OPENSSL_RAND_SEED_RDCPU)
707 entropy_available = rand_acquire_entropy_from_cpu(pool);
708 if (entropy_available > 0)
709 return entropy_available;
712 # if defined(OPENSSL_RAND_SEED_EGD)
714 static const char *paths[] = { DEVRANDOM_EGD, NULL };
716 unsigned char *buffer;
719 bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
720 for (i = 0; bytes_needed > 0 && paths[i] != NULL; i++) {
724 buffer = rand_pool_add_begin(pool, bytes_needed);
725 num = RAND_query_egd_bytes(paths[i],
726 buffer, (int)bytes_needed);
727 if (num == (int)bytes_needed)
728 bytes = bytes_needed;
730 rand_pool_add_end(pool, bytes, 8 * bytes);
731 bytes_needed = rand_pool_bytes_needed(pool, 1);
733 entropy_available = rand_pool_entropy_available(pool);
734 if (entropy_available > 0)
735 return entropy_available;
739 return rand_pool_entropy_available(pool);
745 #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
746 int rand_pool_add_nonce_data(RAND_POOL *pool)
750 CRYPTO_THREAD_ID tid;
755 * Add process id, thread id, and a high resolution timestamp to
756 * ensure that the nonce is unique with high probability for
757 * different process instances.
760 data.tid = CRYPTO_THREAD_get_current_id();
761 data.time = get_time_stamp();
763 return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
766 int rand_pool_add_additional_data(RAND_POOL *pool)
770 CRYPTO_THREAD_ID tid;
775 * Add some noise from the thread id and a high resolution timer.
776 * The fork_id adds some extra fork-safety.
777 * The thread id adds a little randomness if the drbg is accessed
778 * concurrently (which is the case for the <master> drbg).
780 data.fork_id = openssl_get_fork_id();
781 data.tid = CRYPTO_THREAD_get_current_id();
782 data.time = get_timer_bits();
784 return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
789 * Get the current time with the highest possible resolution
791 * The time stamp is added to the nonce, so it is optimized for not repeating.
792 * The current time is ideal for this purpose, provided the computer's clock
795 static uint64_t get_time_stamp(void)
797 # if defined(OSSL_POSIX_TIMER_OKAY)
801 if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
802 return TWO32TO64(ts.tv_sec, ts.tv_nsec);
805 # if defined(__unix__) \
806 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
810 if (gettimeofday(&tv, NULL) == 0)
811 return TWO32TO64(tv.tv_sec, tv.tv_usec);
818 * Get an arbitrary timer value of the highest possible resolution
820 * The timer value is added as random noise to the additional data,
821 * which is not considered a trusted entropy sourec, so any result
824 static uint64_t get_timer_bits(void)
826 uint64_t res = OPENSSL_rdtsc();
831 # if defined(__sun) || defined(__hpux)
837 read_wall_time(&t, TIMEBASE_SZ);
838 return TWO32TO64(t.tb_high, t.tb_low);
840 # elif defined(OSSL_POSIX_TIMER_OKAY)
844 # ifdef CLOCK_BOOTTIME
845 # define CLOCK_TYPE CLOCK_BOOTTIME
846 # elif defined(_POSIX_MONOTONIC_CLOCK)
847 # define CLOCK_TYPE CLOCK_MONOTONIC
849 # define CLOCK_TYPE CLOCK_REALTIME
852 if (clock_gettime(CLOCK_TYPE, &ts) == 0)
853 return TWO32TO64(ts.tv_sec, ts.tv_nsec);
856 # if defined(__unix__) \
857 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
861 if (gettimeofday(&tv, NULL) == 0)
862 return TWO32TO64(tv.tv_sec, tv.tv_usec);
867 #endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS))
868 || defined(__DJGPP__) */