зеркало из https://github.com/github/putty.git
Unify GET_32BIT()/PUT_32BIT() et al from numerous source files into misc.h.
I've done a bit of testing (not exhaustive), and I don't _think_ I've broken anything... [originally from svn r5632]
This commit is contained in:
Родитель
5f12a93e1e
Коммит
6eec320f0b
12
import.c
12
import.c
|
@ -12,18 +12,6 @@
|
|||
#include "ssh.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define PUT_32BIT(cp, value) do { \
|
||||
(cp)[3] = (unsigned char)(value); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[0] = (unsigned char)((value) >> 24); } while (0)
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
int openssh_encrypted(const Filename *filename);
|
||||
struct ssh2_userkey *openssh_read(const Filename *filename, char *passphrase,
|
||||
const char **errmsg_p);
|
||||
|
|
44
misc.h
44
misc.h
|
@ -80,4 +80,48 @@ void debug_memdump(void *buf, int len, int L);
|
|||
#define max(x,y) ( (x) > (y) ? (x) : (y) )
|
||||
#endif
|
||||
|
||||
#define GET_32BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[3] << 24))
|
||||
|
||||
#define PUT_32BIT_LSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (unsigned char)(value), \
|
||||
(cp)[1] = (unsigned char)((value) >> 8), \
|
||||
(cp)[2] = (unsigned char)((value) >> 16), \
|
||||
(cp)[3] = (unsigned char)((value) >> 24) )
|
||||
|
||||
#define GET_16BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8))
|
||||
|
||||
#define PUT_16BIT_LSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (unsigned char)(value), \
|
||||
(cp)[1] = (unsigned char)((value) >> 8) )
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define GET_32BIT(cp) GET_32BIT_MSB_FIRST(cp)
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (unsigned char)((value) >> 24), \
|
||||
(cp)[1] = (unsigned char)((value) >> 16), \
|
||||
(cp)[2] = (unsigned char)((value) >> 8), \
|
||||
(cp)[3] = (unsigned char)(value) )
|
||||
|
||||
#define PUT_32BIT(cp, value) PUT_32BIT_MSB_FIRST(cp, value)
|
||||
|
||||
#define GET_16BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[1]))
|
||||
|
||||
#define PUT_16BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (unsigned char)((value) >> 8), \
|
||||
(cp)[1] = (unsigned char)(value) )
|
||||
|
||||
#endif
|
||||
|
|
40
portfwd.c
40
portfwd.c
|
@ -11,46 +11,6 @@
|
|||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define GET_32BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[3] << 24))
|
||||
|
||||
#define PUT_32BIT_LSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (value), \
|
||||
(cp)[1] = (value) >> 8, \
|
||||
(cp)[2] = (value) >> 16, \
|
||||
(cp)[3] = (value) >> 24 )
|
||||
|
||||
#define GET_16BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8))
|
||||
|
||||
#define PUT_16BIT_LSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (value), \
|
||||
(cp)[1] = (value) >> 8 )
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (value) >> 24, \
|
||||
(cp)[1] = (value) >> 16, \
|
||||
(cp)[2] = (value) >> 8, \
|
||||
(cp)[3] = (value) )
|
||||
|
||||
#define GET_16BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[1]))
|
||||
|
||||
#define PUT_16BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (value) >> 8, \
|
||||
(cp)[1] = (value) )
|
||||
|
||||
struct PFwdPrivate {
|
||||
const struct plug_function_table *fn;
|
||||
/* the above variable absolutely *must* be the first in this structure */
|
||||
|
|
12
sftp.c
12
sftp.c
|
@ -13,18 +13,6 @@
|
|||
#include "tree234.h"
|
||||
#include "sftp.h"
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT(cp, value) { \
|
||||
(cp)[0] = (unsigned char)((value) >> 24); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[3] = (unsigned char)(value); }
|
||||
|
||||
struct sftp_packet {
|
||||
char *data;
|
||||
unsigned length, maxlen;
|
||||
|
|
12
ssh.c
12
ssh.c
|
@ -256,18 +256,6 @@ static char *ssh2_pkt_type(int pkt_ctx, int type)
|
|||
#undef translate
|
||||
#undef translatec
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT(cp, value) { \
|
||||
(cp)[0] = (unsigned char)((value) >> 24); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[3] = (unsigned char)(value); }
|
||||
|
||||
/* Enumeration values for fields in SSH-1 packets */
|
||||
enum {
|
||||
PKT_END, PKT_INT, PKT_CHAR, PKT_DATA, PKT_STR, PKT_BIGNUM,
|
||||
|
|
12
sshaes.c
12
sshaes.c
|
@ -38,18 +38,6 @@
|
|||
|
||||
#define mulby2(x) ( ((x&0x7F) << 1) ^ (x & 0x80 ? 0x1B : 0) )
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[3]) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[0] << 24))
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) do { \
|
||||
(cp)[3] = (value); \
|
||||
(cp)[2] = (value) >> 8; \
|
||||
(cp)[1] = (value) >> 16; \
|
||||
(cp)[0] = (value) >> 24; } while (0)
|
||||
|
||||
typedef struct AESContext AESContext;
|
||||
|
||||
struct AESContext {
|
||||
|
|
24
sshblowf.c
24
sshblowf.c
|
@ -13,30 +13,6 @@ typedef struct {
|
|||
word32 iv0, iv1; /* for CBC mode */
|
||||
} BlowfishContext;
|
||||
|
||||
#define GET_32BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[3] << 24))
|
||||
|
||||
#define PUT_32BIT_LSB_FIRST(cp, value) do { \
|
||||
(cp)[0] = (value); \
|
||||
(cp)[1] = (value) >> 8; \
|
||||
(cp)[2] = (value) >> 16; \
|
||||
(cp)[3] = (value) >> 24; } while (0)
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) do { \
|
||||
(cp)[0] = (value) >> 24; \
|
||||
(cp)[1] = (value) >> 16; \
|
||||
(cp)[2] = (value) >> 8; \
|
||||
(cp)[3] = (value); } while (0)
|
||||
|
||||
/*
|
||||
* The Blowfish init data: hex digits of the fractional part of pi.
|
||||
* (ie pi as a hex fraction is 3.243F6A8885A308D3...)
|
||||
|
|
|
@ -42,12 +42,6 @@ typedef unsigned short uint16;
|
|||
|
||||
#define HASH_MINBLOCKS (7*SSH_BLOCKSIZE)
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
/* Hash function (Input keys are cipher results) */
|
||||
#define HASH(x) GET_32BIT_MSB_FIRST(x)
|
||||
|
||||
|
|
12
sshdes.c
12
sshdes.c
|
@ -600,18 +600,6 @@ static void des_decipher(word32 * output, word32 L, word32 R,
|
|||
output[1] = R;
|
||||
}
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[3]) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[0] << 24))
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) do { \
|
||||
(cp)[3] = (value); \
|
||||
(cp)[2] = (value) >> 8; \
|
||||
(cp)[1] = (value) >> 16; \
|
||||
(cp)[0] = (value) >> 24; } while (0)
|
||||
|
||||
static void des_cbc_encrypt(unsigned char *dest, const unsigned char *src,
|
||||
unsigned int len, DESContext * sched)
|
||||
{
|
||||
|
|
12
sshdss.c
12
sshdss.c
|
@ -5,18 +5,6 @@
|
|||
#include "ssh.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT(cp, value) { \
|
||||
(cp)[0] = (unsigned char)((value) >> 24); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[3] = (unsigned char)(value); }
|
||||
|
||||
static void sha_mpint(SHA_State * s, Bignum b)
|
||||
{
|
||||
unsigned char lenbuf[4];
|
||||
|
|
12
sshpubk.c
12
sshpubk.c
|
@ -13,18 +13,6 @@
|
|||
#include "ssh.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define PUT_32BIT(cp, value) do { \
|
||||
(cp)[3] = (value); \
|
||||
(cp)[2] = (value) >> 8; \
|
||||
(cp)[1] = (value) >> 16; \
|
||||
(cp)[0] = (value) >> 24; } while (0)
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define rsa_signature "SSH PRIVATE KEY FILE FORMAT 1.1\n"
|
||||
|
||||
#define BASE64_TOINT(x) ( (x)-'A'<26 ? (x)-'A'+0 :\
|
||||
|
|
12
sshrsa.c
12
sshrsa.c
|
@ -10,18 +10,6 @@
|
|||
#include "ssh.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT(cp, value) { \
|
||||
(cp)[0] = (unsigned char)((value) >> 24); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[3] = (unsigned char)(value); }
|
||||
|
||||
int makekey(unsigned char *data, int len, struct RSAKey *result,
|
||||
unsigned char **keystr, int order)
|
||||
{
|
||||
|
|
|
@ -14,12 +14,6 @@
|
|||
#include "tree234.h"
|
||||
#include "puttymem.h"
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
int agent_exists(void)
|
||||
{
|
||||
if (getenv("SSH_AUTH_SOCK") != NULL)
|
||||
|
|
10
unix/uxnet.c
10
unix/uxnet.c
|
@ -811,16 +811,6 @@ static void sk_tcp_close(Socket sock)
|
|||
sfree(s);
|
||||
}
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (char)((value) >> 24), \
|
||||
(cp)[1] = (char)((value) >> 16), \
|
||||
(cp)[2] = (char)((value) >> 8), \
|
||||
(cp)[3] = (char)(value) )
|
||||
|
||||
#define PUT_16BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (char)((value) >> 8), \
|
||||
(cp)[1] = (char)(value) )
|
||||
|
||||
void *sk_getxdmdata(void *sock, int *lenp)
|
||||
{
|
||||
Actual_Socket s = (Actual_Socket) sock;
|
||||
|
|
|
@ -156,18 +156,6 @@ struct blob {
|
|||
};
|
||||
static int cmpkeys_ssh2_asymm(void *av, void *bv);
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT(cp, value) { \
|
||||
(cp)[0] = (unsigned char)((value) >> 24); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[3] = (unsigned char)(value); }
|
||||
|
||||
#define PASSPHRASE_MAXLEN 512
|
||||
|
||||
struct PassphraseProcStruct {
|
||||
|
|
|
@ -10,12 +10,6 @@
|
|||
#define AGENT_COPYDATA_ID 0x804e50ba /* random goop */
|
||||
#define AGENT_MAX_MSGLEN 8192
|
||||
|
||||
#define GET_32BIT(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
int agent_exists(void)
|
||||
{
|
||||
HWND hwnd;
|
||||
|
|
40
x11fwd.c
40
x11fwd.c
|
@ -11,46 +11,6 @@
|
|||
#include "ssh.h"
|
||||
#include "tree234.h"
|
||||
|
||||
#define GET_32BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[3] << 24))
|
||||
|
||||
#define PUT_32BIT_LSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (char)(value), \
|
||||
(cp)[1] = (char)((value) >> 8), \
|
||||
(cp)[2] = (char)((value) >> 16), \
|
||||
(cp)[3] = (char)((value) >> 24) )
|
||||
|
||||
#define GET_16BIT_LSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0]) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 8))
|
||||
|
||||
#define PUT_16BIT_LSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (char)(value), \
|
||||
(cp)[1] = (char)((value) >> 8) )
|
||||
|
||||
#define GET_32BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
||||
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
||||
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (char)((value) >> 24), \
|
||||
(cp)[1] = (char)((value) >> 16), \
|
||||
(cp)[2] = (char)((value) >> 8), \
|
||||
(cp)[3] = (char)(value) )
|
||||
|
||||
#define GET_16BIT_MSB_FIRST(cp) \
|
||||
(((unsigned long)(unsigned char)(cp)[0] << 8) | \
|
||||
((unsigned long)(unsigned char)(cp)[1]))
|
||||
|
||||
#define PUT_16BIT_MSB_FIRST(cp, value) ( \
|
||||
(cp)[0] = (char)((value) >> 8), \
|
||||
(cp)[1] = (char)(value) )
|
||||
|
||||
#define GET_16BIT(endian, cp) \
|
||||
(endian=='B' ? GET_16BIT_MSB_FIRST(cp) : GET_16BIT_LSB_FIRST(cp))
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче