mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	merge revision(s) 55232: [Backport #12823]
crypt.c: protoize * missing/crypt.c: protoize function definitions and make always-zero functions void. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									5045461656
								
							
						
					
					
						commit
						55f7a78ca3
					
				
					 2 changed files with 33 additions and 57 deletions
				
			
		| 
						 | 
				
			
			@ -107,16 +107,13 @@ static char sccsid[] = "@(#)crypt.c	8.1 (Berkeley) 6/4/93";
 | 
			
		|||
#define	LARGEDATA
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int des_setkey(), des_cipher();
 | 
			
		||||
void des_setkey(const char *key);
 | 
			
		||||
void des_cipher(const char *in, char *out, long salt, int num_iter);
 | 
			
		||||
 | 
			
		||||
/* compile with "-DSTATIC=int" when profiling */
 | 
			
		||||
#ifndef STATIC
 | 
			
		||||
#define	STATIC	static
 | 
			
		||||
#endif
 | 
			
		||||
STATIC void init_des(), init_perm(), permute();
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
STATIC void prtab();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* ==================================== */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -302,11 +299,7 @@ typedef union {
 | 
			
		|||
	{ C_block tblk; permute((cpp),&tblk,(p),4); LOAD ((d),(d0),(d1),tblk); }
 | 
			
		||||
 | 
			
		||||
STATIC void
 | 
			
		||||
permute(cp, out, p, chars_in)
 | 
			
		||||
	unsigned char *cp;
 | 
			
		||||
	C_block *out;
 | 
			
		||||
	register C_block *p;
 | 
			
		||||
	int chars_in;
 | 
			
		||||
permute(unsigned char *cp, C_block *out, register C_block *p, int chars_in)
 | 
			
		||||
{
 | 
			
		||||
	register DCL_BLOCK(D,D0,D1);
 | 
			
		||||
	register C_block *tp;
 | 
			
		||||
| 
						 | 
				
			
			@ -322,6 +315,12 @@ permute(cp, out, p, chars_in)
 | 
			
		|||
}
 | 
			
		||||
#endif /* LARGEDATA */
 | 
			
		||||
 | 
			
		||||
STATIC void init_des(void);
 | 
			
		||||
STATIC void init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS], unsigned char p[64], int chars_in, int chars_out);
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
STATIC void prtab(const char *s, const unsigned char *t, int num_rows);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* =====  (mostly) Standard DES Tables ==================== */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -496,9 +495,7 @@ static char	cryptresult[1+4+4+11+1];	/* encrypted result */
 | 
			
		|||
 * followed by an encryption produced by the "key" and "setting".
 | 
			
		||||
 */
 | 
			
		||||
char *
 | 
			
		||||
crypt(key, setting)
 | 
			
		||||
	register const char *key;
 | 
			
		||||
	register const char *setting;
 | 
			
		||||
crypt(const char *key, const char *setting)
 | 
			
		||||
{
 | 
			
		||||
	register char *encp;
 | 
			
		||||
	register long i;
 | 
			
		||||
| 
						 | 
				
			
			@ -512,8 +509,7 @@ crypt(key, setting)
 | 
			
		|||
			key++;
 | 
			
		||||
		keyblock.b[i] = t;
 | 
			
		||||
	}
 | 
			
		||||
	if (des_setkey((char *)keyblock.b))	/* also initializes "a64toi" */
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	des_setkey((char *)keyblock.b);	/* also initializes "a64toi" */
 | 
			
		||||
 | 
			
		||||
	encp = &cryptresult[0];
 | 
			
		||||
	switch (*setting) {
 | 
			
		||||
| 
						 | 
				
			
			@ -522,16 +518,14 @@ crypt(key, setting)
 | 
			
		|||
		 * Involve the rest of the password 8 characters at a time.
 | 
			
		||||
		 */
 | 
			
		||||
		while (*key) {
 | 
			
		||||
			if (des_cipher((char *)&keyblock,
 | 
			
		||||
			    (char *)&keyblock, 0L, 1))
 | 
			
		||||
				return (NULL);
 | 
			
		||||
			des_cipher((char *)&keyblock,
 | 
			
		||||
				   (char *)&keyblock, 0L, 1);
 | 
			
		||||
			for (i = 0; i < 8; i++) {
 | 
			
		||||
				if ((t = 2*(unsigned char)(*key)) != 0)
 | 
			
		||||
					key++;
 | 
			
		||||
				keyblock.b[i] ^= t;
 | 
			
		||||
			}
 | 
			
		||||
			if (des_setkey((char *)keyblock.b))
 | 
			
		||||
				return (NULL);
 | 
			
		||||
			des_setkey((char *)keyblock.b);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		*encp++ = *setting++;
 | 
			
		||||
| 
						 | 
				
			
			@ -561,9 +555,8 @@ crypt(key, setting)
 | 
			
		|||
		salt = (salt<<6) | a64toi[t];
 | 
			
		||||
	}
 | 
			
		||||
	encp += salt_size;
 | 
			
		||||
	if (des_cipher((char *)&constdatablock, (char *)&rsltblock,
 | 
			
		||||
	    salt, num_iter))
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	des_cipher((char *)&constdatablock, (char *)&rsltblock,
 | 
			
		||||
		   salt, num_iter);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Encode the 64 cipher bits as 11 ascii characters.
 | 
			
		||||
| 
						 | 
				
			
			@ -598,9 +591,8 @@ static C_block	KS[KS_SIZE];
 | 
			
		|||
/*
 | 
			
		||||
 * Set up the key schedule from the key.
 | 
			
		||||
 */
 | 
			
		||||
int
 | 
			
		||||
des_setkey(key)
 | 
			
		||||
	register const char *key;
 | 
			
		||||
void
 | 
			
		||||
des_setkey(const char *key)
 | 
			
		||||
{
 | 
			
		||||
	register DCL_BLOCK(K, K0, K1);
 | 
			
		||||
	register C_block *ptabp;
 | 
			
		||||
| 
						 | 
				
			
			@ -622,7 +614,6 @@ des_setkey(key)
 | 
			
		|||
		PERM6464(K,K0,K1,(unsigned char *)key,ptabp);
 | 
			
		||||
		STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key);
 | 
			
		||||
	}
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			@ -633,12 +624,8 @@ des_setkey(key)
 | 
			
		|||
 * NOTE: the performance of this routine is critically dependent on your
 | 
			
		||||
 * compiler and machine architecture.
 | 
			
		||||
 */
 | 
			
		||||
int
 | 
			
		||||
des_cipher(in, out, salt, num_iter)
 | 
			
		||||
	const char *in;
 | 
			
		||||
	char *out;
 | 
			
		||||
	long salt;
 | 
			
		||||
	int num_iter;
 | 
			
		||||
void
 | 
			
		||||
des_cipher(const char *in, char *out, long salt, int num_iter)
 | 
			
		||||
{
 | 
			
		||||
	/* variables that we want in registers, most important first */
 | 
			
		||||
#if defined(pdp11)
 | 
			
		||||
| 
						 | 
				
			
			@ -746,7 +733,6 @@ des_cipher(in, out, salt, num_iter)
 | 
			
		|||
#else
 | 
			
		||||
	STORE(L,L0,L1,*(C_block *)out);
 | 
			
		||||
#endif
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -755,7 +741,7 @@ des_cipher(in, out, salt, num_iter)
 | 
			
		|||
 * done at compile time, if the compiler were capable of that sort of thing.
 | 
			
		||||
 */
 | 
			
		||||
STATIC void
 | 
			
		||||
init_des()
 | 
			
		||||
init_des(void)
 | 
			
		||||
{
 | 
			
		||||
	register int i, j;
 | 
			
		||||
	register long k;
 | 
			
		||||
| 
						 | 
				
			
			@ -899,10 +885,8 @@ init_des()
 | 
			
		|||
 * "perm" must be all-zeroes on entry to this routine.
 | 
			
		||||
 */
 | 
			
		||||
STATIC void
 | 
			
		||||
init_perm(perm, p, chars_in, chars_out)
 | 
			
		||||
	C_block perm[64/CHUNKBITS][1<<CHUNKBITS];
 | 
			
		||||
	unsigned char p[64];
 | 
			
		||||
	int chars_in, chars_out;
 | 
			
		||||
init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS],
 | 
			
		||||
	  unsigned char p[64], int chars_in, int chars_out)
 | 
			
		||||
{
 | 
			
		||||
	register int i, j, k, l;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -922,9 +906,8 @@ init_perm(perm, p, chars_in, chars_out)
 | 
			
		|||
/*
 | 
			
		||||
 * "setkey" routine (for backwards compatibility)
 | 
			
		||||
 */
 | 
			
		||||
int
 | 
			
		||||
setkey(key)
 | 
			
		||||
	register const char *key;
 | 
			
		||||
void
 | 
			
		||||
setkey(const char *key)
 | 
			
		||||
{
 | 
			
		||||
	register int i, j, k;
 | 
			
		||||
	C_block keyblock;
 | 
			
		||||
| 
						 | 
				
			
			@ -937,16 +920,14 @@ setkey(key)
 | 
			
		|||
		}
 | 
			
		||||
		keyblock.b[i] = k;
 | 
			
		||||
	}
 | 
			
		||||
	return (des_setkey((char *)keyblock.b));
 | 
			
		||||
	des_setkey((char *)keyblock.b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * "encrypt" routine (for backwards compatibility)
 | 
			
		||||
 */
 | 
			
		||||
int
 | 
			
		||||
encrypt(block, flag)
 | 
			
		||||
	register char *block;
 | 
			
		||||
	int flag;
 | 
			
		||||
void
 | 
			
		||||
encrypt(char *block, int flag)
 | 
			
		||||
{
 | 
			
		||||
	register int i, j, k;
 | 
			
		||||
	C_block cblock;
 | 
			
		||||
| 
						 | 
				
			
			@ -959,8 +940,7 @@ encrypt(block, flag)
 | 
			
		|||
		}
 | 
			
		||||
		cblock.b[i] = k;
 | 
			
		||||
	}
 | 
			
		||||
	if (des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1)))
 | 
			
		||||
		return (1);
 | 
			
		||||
	des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1));
 | 
			
		||||
	for (i = 7; i >= 0; i--) {
 | 
			
		||||
		k = cblock.b[i];
 | 
			
		||||
		for (j = 7; j >= 0; j--) {
 | 
			
		||||
| 
						 | 
				
			
			@ -968,15 +948,11 @@ encrypt(block, flag)
 | 
			
		|||
			k >>= 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
STATIC void
 | 
			
		||||
prtab(s, t, num_rows)
 | 
			
		||||
	char *s;
 | 
			
		||||
	unsigned char *t;
 | 
			
		||||
	int num_rows;
 | 
			
		||||
prtab(const char *s, const unsigned char *t, int num_rows)
 | 
			
		||||
{
 | 
			
		||||
	register int i, j;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
#define RUBY_VERSION "2.3.2"
 | 
			
		||||
#define RUBY_RELEASE_DATE "2016-10-12"
 | 
			
		||||
#define RUBY_PATCHLEVEL 195
 | 
			
		||||
#define RUBY_RELEASE_DATE "2016-10-18"
 | 
			
		||||
#define RUBY_PATCHLEVEL 196
 | 
			
		||||
 | 
			
		||||
#define RUBY_RELEASE_YEAR 2016
 | 
			
		||||
#define RUBY_RELEASE_MONTH 10
 | 
			
		||||
#define RUBY_RELEASE_DAY 12
 | 
			
		||||
#define RUBY_RELEASE_DAY 18
 | 
			
		||||
 | 
			
		||||
#include "ruby/version.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue