Commit a8b966f4 authored by Matt Caswell's avatar Matt Caswell
Browse files

Run util/openssl-format-source -v -c .



Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent e3db68b7
Loading
Loading
Loading
Loading
+54 −53
Original line number Diff line number Diff line
@@ -5,97 +5,98 @@
extern "C" {
#endif



enum
{
enum {
    kMacSocket_TimeoutErr = -2
};


// Since MacSocket does busy waiting, I do a callback while waiting

typedef OSErr(*MacSocket_IdleWaitCallback) (void *);


// Call this before anything else!

OSErr MacSocket_Startup(void);


// Call this to cleanup before quitting

OSErr MacSocket_Shutdown(void);


//	Call this to allocate a "socket" (reference number is returned in outSocketNum)
//	Note that inDoThreadSwitching is pretty much irrelevant right now, since I ignore it
// Call this to allocate a "socket" (reference number is returned in
// outSocketNum)
// Note that inDoThreadSwitching is pretty much irrelevant right now, since I
// ignore it
// The inTimeoutTicks parameter is applied during reads/writes of data
//	The inIdleWaitCallback parameter specifies a callback which is called during busy-waiting periods
// The inIdleWaitCallback parameter specifies a callback which is called
// during busy-waiting periods
// The inUserRefPtr parameter is passed back to the idle-wait callback

OSErr MacSocket_socket(int *outSocketNum,const Boolean inDoThreadSwitching,const long inTimeoutTicks,MacSocket_IdleWaitCallback inIdleWaitCallback,void *inUserRefPtr);

OSErr MacSocket_socket(int *outSocketNum, const Boolean inDoThreadSwitching,
                       const long inTimeoutTicks,
                       MacSocket_IdleWaitCallback inIdleWaitCallback,
                       void *inUserRefPtr);

// Call this to connect to an IP/DNS address
//	Note that inTargetAddressAndPort is in "IP:port" format-- e.g. 10.1.1.1:123
// Note that inTargetAddressAndPort is in "IP:port" format-- e.g.
// 10.1.1.1:123

OSErr MacSocket_connect(const int inSocketNum, char *inTargetAddressAndPort);


// Call this to listen on a port
//	Since this a low-performance implementation, I allow a maximum of 1 (one!) incoming request when I listen
// Since this a low-performance implementation, I allow a maximum of 1 (one!)
// incoming request when I listen

OSErr MacSocket_listen(const int inSocketNum, const int inPortNum);


// Call this to close a socket

OSErr MacSocket_close(const int inSocketNum);


// Call this to receive data on a socket
//	Most parameters' purpose are obvious-- except maybe "inBlock" which controls whether I wait for data or return immediately

int MacSocket_recv(const int inSocketNum,void *outBuff,int outBuffLength,const Boolean inBlock);
// Most parameters' purpose are obvious-- except maybe "inBlock" which
// controls whether I wait for data or return immediately

int MacSocket_recv(const int inSocketNum, void *outBuff, int outBuffLength,
                   const Boolean inBlock);

// Call this to send data on a socket

int MacSocket_send(const int inSocketNum,const void *inBuff,int inBuffLength);
int MacSocket_send(const int inSocketNum, const void *inBuff,
                   int inBuffLength);


//	If zero bytes were read in a call to MacSocket_recv(), it may be that the remote end has done a half-close
// If zero bytes were read in a call to MacSocket_recv(), it may be that the
// remote end has done a half-close
// This function will let you check whether that's true or not

Boolean MacSocket_RemoteEndIsClosing(const int inSocketNum);


//	Call this to see if the listen has completed after a call to MacSocket_listen()
// Call this to see if the listen has completed after a call to
// MacSocket_listen()

Boolean MacSocket_ListenCompleted(const int inSocketNum);


// These really aren't very useful anymore

Boolean MacSocket_LocalEndIsOpen(const int inSocketNum);
Boolean MacSocket_RemoteEndIsOpen(const int inSocketNum);


//	You may wish to change the userRefPtr for a socket callback-- use this to do it
// You may wish to change the userRefPtr for a socket callback-- use this to
// do it

void MacSocket_SetUserRefPtr(const int inSocketNum, void *inNewRefPtr);


// Call these to get the socket's IP:port descriptor

void MacSocket_GetLocalIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength);
void MacSocket_GetRemoteIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength);

void MacSocket_GetLocalIPAndPort(const int inSocketNum, char *outIPAndPort,
                                 const int inIPAndPortLength);
void MacSocket_GetRemoteIPAndPort(const int inSocketNum, char *outIPAndPort,
                                  const int inIPAndPortLength);

// Call this to get error info from a socket

void MacSocket_GetSocketErrorInfo(const int inSocketNum,int *outSocketErrCode,char *outSocketErrString,const int inSocketErrStringMaxLength);
void MacSocket_GetSocketErrorInfo(const int inSocketNum,
                                  int *outSocketErrCode,
                                  char *outSocketErrString,
                                  const int inSocketErrStringMaxLength);


#ifdef __cplusplus
+37 −38
Original line number Diff line number Diff line
@@ -4,8 +4,7 @@

#include <MacTypes.h>

class CRandomizer
{
class CRandomizer {
 public:
    CRandomizer(void);
    void PeriodicAction(void);
+75 −65
Original line number Diff line number Diff line
@@ -21,8 +21,10 @@

#if defined(HEADER_RC4_H)
# if !defined(RC4_INT)
/* using int types make the structure larger but make the code faster
 * on most boxes I have tested - up to %20 faster. */
/*
 * using int types make the structure larger but make the code faster on most
 * boxes I have tested - up to %20 faster.
 */
/*-
 * I don't know what does "most" mean, but declaring "int" is a must on:
 * - Intel P6 because partial register stalls are very expensive;
@@ -40,8 +42,10 @@
#endif

#if defined(HEADER_DES_H) && !defined(DES_LONG)
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
 * %20 speed up (longs are 8 bytes, int's are 4). */
/*
 * If this is set to 'unsigned int' on a DEC Alpha, this gives about a %20
 * speed up (longs are 8 bytes, int's are 4).
 */
# ifndef DES_LONG
#  define DES_LONG unsigned long
# endif
@@ -58,9 +62,10 @@
/* Should we define BN_DIV2W here? */

/* Only one for the following should be defined */
/* The prime number generation stuff may not work when
 * EIGHT_BIT but I don't care since I've only used this mode
 * for debuging the bignum libraries */
/*
 * The prime number generation stuff may not work when EIGHT_BIT but I don't
 * care since I've only used this mode for debuging the bignum libraries
 */
# undef SIXTY_FOUR_BIT_LONG
# undef SIXTY_FOUR_BIT
# define THIRTY_TWO_BIT
@@ -70,8 +75,10 @@

#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
# define CONFIG_HEADER_RC4_LOCL_H
/* if this is defined data[i] is used instead of *data, this is a %20
 * speedup on x86 */
/*
 * if this is defined data[i] is used instead of *data, this is a %20 speedup
 * on x86
 */
# undef RC4_INDEX
#endif

@@ -82,15 +89,19 @@

#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
# define CONFIG_HEADER_DES_LOCL_H
/* the following is tweaked from a config script, that is why it is a
 * protected undef/define */
/*
 * the following is tweaked from a config script, that is why it is a
 * protected undef/define
 */
# ifndef DES_PTR
#  define DES_PTR
# endif

/* This helps C compiler generate the correct code for multiple functional
/*
 * This helps C compiler generate the correct code for multiple functional
 * units.  It reduces register dependancies at the expense of 2 more
 * registers */
 * registers
 */
# ifndef DES_RISC1
#  define DES_RISC1
# endif
@@ -102,15 +113,14 @@
# if defined(DES_RISC1) && defined(DES_RISC2)
YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED ! !!!!
# endif

/* Unroll the inner loop, this sometimes helps, sometimes hinders.
 * Very mucy CPU dependant */
/*
 * Unroll the inner loop, this sometimes helps, sometimes hinders. Very mucy
 * CPU dependant
 */
# ifndef DES_UNROLL
#  define DES_UNROLL
# endif

#endif                          /* HEADER_DES_LOCL_H */

#ifndef __POWERPC__
# define MD32_XARRAY
#endif
+95 −93
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@
#include <openssl/bio.h>
#include <openssl/rand.h>


static int seeded = 0;
static int egdsocket = 0;

@@ -133,26 +132,27 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)

    if (file == NULL)
        file = RAND_file_name(buffer, sizeof buffer);
	else if (RAND_egd(file) > 0)
		{
		/* we try if the given filename is an EGD socket.
		   if it is, we don't write anything back to the file. */
    else if (RAND_egd(file) > 0) {
        /*
         * we try if the given filename is an EGD socket. if it is, we don't
         * write anything back to the file.
         */
        egdsocket = 1;
        return 1;
    }
	if (file == NULL || !RAND_load_file(file, -1))
		{
		if (RAND_status() == 0)
			{
			if (!dont_warn)
				{
    if (file == NULL || !RAND_load_file(file, -1)) {
        if (RAND_status() == 0) {
            if (!dont_warn) {
                BIO_printf(bio_e, "unable to load 'random state'\n");
				BIO_printf(bio_e,"This means that the random number generator has not been seeded\n");
                BIO_printf(bio_e,
                           "This means that the random number generator has not been seeded\n");
                BIO_printf(bio_e, "with much random data.\n");
				if (consider_randfile) /* explanation does not apply when a file is explicitly named */
					{
					BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n");
					BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n");
                if (consider_randfile) { /* explanation does not apply when a
                                          * file is explicitly named */
                    BIO_printf(bio_e,
                               "Consider setting the RANDFILE environment variable to point at a file that\n");
                    BIO_printf(bio_e,
                               "'random' data can be kept in (the file will be overwritten).\n");
                }
            }
            return 0;
@@ -169,22 +169,24 @@ long app_RAND_load_files(char *name)
    long tot = 0;
    int egd;

	for (;;)
		{
    for (;;) {
        last = 0;
        for (p = name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++) ;
		if (*p == '\0') last=1;
        if (*p == '\0')
            last = 1;
        *p = '\0';
        n = name;
        name = p + 1;
		if (*n == '\0') break;
        if (*n == '\0')
            break;

        egd = RAND_egd(n);
        if (egd > 0)
            tot += egd;
        else
            tot += RAND_load_file(n, -1);
		if (last) break;
        if (last)
            break;
    }
    if (tot > 512)
        app_RAND_allow_write_file();
@@ -196,16 +198,16 @@ int app_RAND_write_file(const char *file, BIO *bio_e)
    char buffer[200];

    if (egdsocket || !seeded)
		/* If we did not manage to read the seed file,
		 * we should not write a low-entropy seed file back --
		 * it would suppress a crucial warning the next time
		 * we want to use it. */
        /*
         * If we did not manage to read the seed file, we should not write a
         * low-entropy seed file back -- it would suppress a crucial warning
         * the next time we want to use it.
         */
        return 0;

    if (file == NULL)
        file = RAND_file_name(buffer, sizeof buffer);
	if (file == NULL || !RAND_write_file(file))
		{
    if (file == NULL || !RAND_write_file(file)) {
        BIO_printf(bio_e, "unable to write 'random state'\n");
        return 0;
    }
+2417 −2546

File changed.

Preview size limit exceeded, changes collapsed.

Loading