Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
0ed017f1
Commit
0ed017f1
authored
Aug 28, 1998
by
Niels Möller
Browse files
Do network-byte-order-conversions without the ntoh macros.
Rev: src/decrypt.c:1.2 Rev: src/pad.c:1.3 Rev: src/transport.h:1.3
parent
1d5b5784
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/decrypt.c
View file @
0ed017f1
...
...
@@ -39,7 +39,7 @@ static int do_decrypt(struct encrypt_processor *closure,
block_size
,
closure
->
block_buffer
,
closure
->
block_buffer
);
length
=
ntohl
(
*
(
UINT32
*
)
head
er
);
length
=
READ_INT32
(
closure
->
block_buff
er
);
if
(
length
>
closure
->
max_packet
)
return
0
;
...
...
src/pad.c
View file @
0ed017f1
...
...
@@ -11,8 +11,11 @@ static int do_pad(struct pad_processor *closure,
UINT8
padding
;
struct
simple_packet
*
new
;
struct
ssh_packet
*
ssh
;
#if 0
struct ssh_packet *ssh;
#endif
new_size
=
1
+
closure
->
block_size
*
(
(
8
+
packet
->
length
)
/
closure
->
block_size
);
...
...
@@ -20,13 +23,18 @@ static int do_pad(struct pad_processor *closure,
assert
(
ssh
->
padding_length
>=
4
);
new
=
simple_packet_alloc
(
new_size
);
ssh
=
(
struct
ssh_packet
*
)
new
->
data
;
#if 0
ssh = (struct ssh_packet *) new->data;
ssh->length = htonl(new_size);
ssh->padding_length = padding;
#endif
memcpy
(
ssh
->
data
,
packet
->
data
,
packet
->
length
);
closure
->
random
(
closure
->
state
,
padding
,
ssh
->
data
+
packet
->
length
);
WRITE_INT32
(
new
->
data
,
new_size
-
4
);
new
->
data
[
4
]
=
padding
;
memcpy
(
new
->
data
+
5
,
packet
->
data
,
packet
->
length
);
closure
->
random
(
closure
->
state
,
padding
,
new
->
data
+
5
+
packet
->
length
);
simple_packet_free
(
packet
);
...
...
src/transport.h
View file @
0ed017f1
...
...
@@ -10,6 +10,21 @@
#include
"config.h"
#endif
/* Reads a 32-bit integer, in network byte order */
#define READ_UINT32(p) \
((((UINT32) (p)[0]) << 24) \
| (((UINT32) (p)[0]) << 16) \
| (((UINT32) (p)[0]) << 8) \
| ((UINT32) (p)[0]))
#define WRITE_UINT32(p, i) \
do { \
(p)[0] = ((i) >> 24) & 0xff; \
(p)[0] = ((i) >> 16) & 0xff; \
(p)[0] = ((i) >> 8) & 0xff; \
(p)[0] = (i) & 0xff; \
} while(0)
/* Generic packet */
struct
simple_packet
{
...
...
@@ -17,18 +32,20 @@ struct simple_packet
UINT8
data
[
1
];
}
#if 0
struct ssh_packet
{
UINT32 packet_length; /* In network byteorder */
UINT8 padding_length;
UINT8 data[1]; /* Includes payload and padding */
};
#endif
/* Allocation */
/* The memory allocation model is as follows:
*
* Packets are allocated when the are needed.
They
may be passed
* Packets are allocated when the are needed.
A packet
may be passed
* through a chain of processing functions, until it is finally
* discarded or transmitted, at which time it is deallocated.
* Processing functions may deallocate their input packets and
...
...
@@ -45,24 +62,6 @@ struct ssh_packet
struct
simple_packet
*
simple_packet_alloc
(
UINT32
size
);
void
simple_packet_free
(
struct
simple_packet
*
packet
);
/* Simple buffer */
struct
simple_buffer
{
UNIT32
capacity
;
UINT32
pos
;
UINT8
*
data
;
};
void
simple_buffer_init
(
struct
simple_buffer
*
buffer
,
UINT32
capacity
,
UINT8
*
data
);
/* Returns the number of octets that were actually written into the buffer */
UINT32
simple_buffer_write
(
struct
simple_buffer
*
buffer
,
UINT32
length
,
UINT32
*
data
);
UINT32
simple_buffer_avail
(
struct
simple_buffer
*
buffer
);
/* A packet processing function.
*
* Typically, real processors will extend this struct, with fields
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment