mirror of
https://github.com/clearml/dropbear
synced 2025-02-08 13:43:45 +00:00
merge of 'a101cbd046507cf723e6362a49196dbd4b924042'
and 'c8e1b84cfe874887ad7df0dd95a00de46dbc0136' --HG-- extra : convert_revision : fe8161b0698c9816b98f79e3cab2b9d59f2be71b
This commit is contained in:
commit
35f3d2ff90
@ -25,7 +25,7 @@ COMMONOBJS=dbutil.o buffer.o \
|
|||||||
SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
|
SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
|
||||||
svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
|
svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
|
||||||
svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
|
svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
|
||||||
svr-tcpfwd.o svr-authpam.o
|
svr-tcpfwd.o svr-authpam.o @CRYPTLIB@
|
||||||
|
|
||||||
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
|
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
|
||||||
cli-session.o cli-service.o cli-runopts.o cli-chansession.o \
|
cli-session.o cli-service.o cli-runopts.o cli-chansession.o \
|
||||||
|
@ -82,7 +82,8 @@ AC_CHECK_DECL(__UCLIBC__,
|
|||||||
],,,)
|
],,,)
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
|
AC_CHECK_LIB(crypt, crypt, CRYPTLIB="-lcrypt")
|
||||||
|
AC_SUBST(CRYPTLIB)
|
||||||
|
|
||||||
# Check if zlib is needed
|
# Check if zlib is needed
|
||||||
AC_ARG_WITH(zlib,
|
AC_ARG_WITH(zlib,
|
||||||
|
34
packet.c
34
packet.c
@ -249,17 +249,16 @@ void decrypt_packet() {
|
|||||||
buf_setpos(ses.decryptreadbuf, blocksize);
|
buf_setpos(ses.decryptreadbuf, blocksize);
|
||||||
|
|
||||||
/* decrypt it */
|
/* decrypt it */
|
||||||
while (ses.readbuf->pos < ses.readbuf->len - macsize) {
|
len = ses.readbuf->len - macsize - ses.readbuf->pos;
|
||||||
if (ses.keys->recv_crypt_mode->decrypt(
|
if (ses.keys->recv_crypt_mode->decrypt(
|
||||||
buf_getptr(ses.readbuf, blocksize),
|
buf_getptr(ses.readbuf, len),
|
||||||
buf_getwriteptr(ses.decryptreadbuf, blocksize),
|
buf_getwriteptr(ses.decryptreadbuf, len),
|
||||||
blocksize,
|
len,
|
||||||
&ses.keys->recv_cipher_state) != CRYPT_OK) {
|
&ses.keys->recv_cipher_state) != CRYPT_OK) {
|
||||||
dropbear_exit("error decrypting");
|
dropbear_exit("error decrypting");
|
||||||
}
|
}
|
||||||
buf_incrpos(ses.readbuf, blocksize);
|
buf_incrpos(ses.readbuf, len);
|
||||||
buf_incrwritepos(ses.decryptreadbuf, blocksize);
|
buf_incrwritepos(ses.decryptreadbuf, len);
|
||||||
}
|
|
||||||
|
|
||||||
/* check the hmac */
|
/* check the hmac */
|
||||||
buf_setpos(ses.readbuf, ses.readbuf->len - macsize);
|
buf_setpos(ses.readbuf, ses.readbuf->len - macsize);
|
||||||
@ -463,7 +462,7 @@ void encrypt_packet() {
|
|||||||
buffer * writebuf; /* the packet which will go on the wire */
|
buffer * writebuf; /* the packet which will go on the wire */
|
||||||
buffer * clearwritebuf; /* unencrypted, possibly compressed */
|
buffer * clearwritebuf; /* unencrypted, possibly compressed */
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
unsigned int clear_len;
|
unsigned int len;
|
||||||
|
|
||||||
type = ses.writepayload->data[0];
|
type = ses.writepayload->data[0];
|
||||||
TRACE(("enter encrypt_packet()"))
|
TRACE(("enter encrypt_packet()"))
|
||||||
@ -483,12 +482,12 @@ void encrypt_packet() {
|
|||||||
/* Encrypted packet len is payload+5, then worst case is if we are 3 away
|
/* Encrypted packet len is payload+5, then worst case is if we are 3 away
|
||||||
* from a blocksize multiple. In which case we need to pad to the
|
* from a blocksize multiple. In which case we need to pad to the
|
||||||
* multiple, then add another blocksize (or MIN_PACKET_LEN) */
|
* multiple, then add another blocksize (or MIN_PACKET_LEN) */
|
||||||
clear_len = (ses.writepayload->len+4+1) + MIN_PACKET_LEN + 3;
|
len = (ses.writepayload->len+4+1) + MIN_PACKET_LEN + 3;
|
||||||
|
|
||||||
#ifndef DISABLE_ZLIB
|
#ifndef DISABLE_ZLIB
|
||||||
clear_len += ZLIB_COMPRESS_INCR; /* bit of a kludge, but we can't know len*/
|
len += ZLIB_COMPRESS_INCR; /* bit of a kludge, but we can't know len*/
|
||||||
#endif
|
#endif
|
||||||
clearwritebuf = buf_new(clear_len);
|
clearwritebuf = buf_new(len);
|
||||||
buf_setlen(clearwritebuf, PACKET_PAYLOAD_OFF);
|
buf_setlen(clearwritebuf, PACKET_PAYLOAD_OFF);
|
||||||
buf_setpos(clearwritebuf, PACKET_PAYLOAD_OFF);
|
buf_setpos(clearwritebuf, PACKET_PAYLOAD_OFF);
|
||||||
|
|
||||||
@ -540,17 +539,16 @@ void encrypt_packet() {
|
|||||||
writebuf = buf_new(clearwritebuf->len + macsize);
|
writebuf = buf_new(clearwritebuf->len + macsize);
|
||||||
|
|
||||||
/* encrypt it */
|
/* encrypt it */
|
||||||
while (clearwritebuf->pos < clearwritebuf->len) {
|
len = clearwritebuf->len;
|
||||||
if (ses.keys->trans_crypt_mode->encrypt(
|
if (ses.keys->trans_crypt_mode->encrypt(
|
||||||
buf_getptr(clearwritebuf, blocksize),
|
buf_getptr(clearwritebuf, len),
|
||||||
buf_getwriteptr(writebuf, blocksize),
|
buf_getwriteptr(writebuf, len),
|
||||||
blocksize,
|
len,
|
||||||
&ses.keys->trans_cipher_state) != CRYPT_OK) {
|
&ses.keys->trans_cipher_state) != CRYPT_OK) {
|
||||||
dropbear_exit("error encrypting");
|
dropbear_exit("error encrypting");
|
||||||
}
|
}
|
||||||
buf_incrpos(clearwritebuf, blocksize);
|
buf_incrpos(clearwritebuf, len);
|
||||||
buf_incrwritepos(writebuf, blocksize);
|
buf_incrwritepos(writebuf, len);
|
||||||
}
|
|
||||||
|
|
||||||
/* now add a hmac and we're done */
|
/* now add a hmac and we're done */
|
||||||
writemac(writebuf, clearwritebuf);
|
writemac(writebuf, clearwritebuf);
|
||||||
|
@ -202,5 +202,8 @@
|
|||||||
#define IS_DROPBEAR_CLIENT 1
|
#define IS_DROPBEAR_CLIENT 1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error You must compiled with either DROPBEAR_CLIENT or DROPBEAR_SERVER selected
|
/* Just building key utils? */
|
||||||
|
#define IS_DROPBEAR_SERVER 0
|
||||||
|
#define IS_DROPBEAR_CLIENT 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user