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
70da1760
Commit
70da1760
authored
Sep 17, 1998
by
Niels Möller
Browse files
Intialize key exchange, using a fix dss key.
Rev: src/lshd.c:1.7
parent
6badc772
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lshd.c
View file @
70da1760
...
...
@@ -30,9 +30,21 @@
#include
"getopt.h"
#include
"alist.h"
#include
"atoms.h"
#include
"crypto.h"
#include
"format.h"
#include
"io.h"
#include
"
werror
.h"
#include
"
randomness
.h"
#include
"server.h"
#include
"server_keyexchange.h"
#include
"werror.h"
#include
"xalloc.h"
#if 0
#include "crypto.h"
#include "publickey_crypto.h"
#endif
#define BLOCK_SIZE 32768
...
...
@@ -50,11 +62,11 @@ struct signer *secret_key;
struct
lsh_string
*
public_key
;
/* A key generated by gnupg */
void
init_host_key
(
struct
randomness
*
r
)
static
void
init_host_key
(
struct
randomness
*
r
)
{
mpz_t
p
,
q
,
g
,
y
,
a
;
mpz_t
tmp
;
lsh_string
*
s
;
struct
lsh_string
*
s
;
mpz_init_set_str
(
p
,
"BC7797D55CF2449CA4B02396246AF5C75CA38C52B6F2E543"
...
...
@@ -62,7 +74,7 @@ void init_host_key(struct randomness *r)
"B58D64762D40EAA8D70F282B3AC4A7771171B1B1D1AE89F4"
"1CD091FE95A6F42A2340081F9E97A4B5F953DE223F10F878"
"4C0619A9979643E5325DF71C9C088F3BC82FA0A6C47B5C64"
"BC07A31B9CDB2B07"
,
6
);
"BC07A31B9CDB2B07"
,
1
6
);
mpz_init_set_str
(
q
,
"867F7E6563B3FAF19B65C83E9B843150C5CC2201"
,
16
);
mpz_init_set_str
(
g
,
...
...
@@ -104,6 +116,47 @@ void init_host_key(struct randomness *r)
mpz_clear
(
a
);
}
struct
simple_kexinit
{
struct
make_kexinit
super
;
struct
randomness
*
r
;
};
static
struct
kexinit
*
do_make_kexinit
(
struct
make_kexinit
*
c
)
{
struct
simple_kexinit
*
closure
=
(
struct
simple_kexinit
*
)
c
;
struct
kexinit
*
res
=
xalloc
(
sizeof
(
struct
kexinit
));
static
int
kex_algorithms
[]
=
{
ATOM_DIFFIE_HELLMAN_GROUP1_SHA1
,
0
};
static
int
server_hostkey_algorithms
[]
=
{
ATOM_SSH_DSS
,
0
};
static
int
crypto_algorithms
[]
=
{
ATOM_ARCFOUR
,
ATOM_NONE
,
0
};
static
int
mac_algorithms
[]
=
{
ATOM_HMAC_SHA1
,
0
};
static
int
compression_algorithms
[]
=
{
ATOM_NONE
,
0
};
RANDOM
(
closure
->
r
,
16
,
res
->
cookie
);
res
->
kex_algorithms
=
kex_algorithms
;
res
->
server_hostkey_algorithms
=
server_hostkey_algorithms
;
res
->
parameters
[
KEX_ENCRYPTION_CLIENT_TO_SERVER
]
=
crypto_algorithms
;
res
->
parameters
[
KEX_ENCRYPTION_SERVER_TO_CLIENT
]
=
crypto_algorithms
;
res
->
parameters
[
KEX_MAC_CLIENT_TO_SERVER
]
=
mac_algorithms
;
res
->
parameters
[
KEX_MAC_SERVER_TO_CLIENT
]
=
mac_algorithms
;
res
->
parameters
[
KEX_COMPRESSION_CLIENT_TO_SERVER
]
=
compression_algorithms
;
res
->
parameters
[
KEX_COMPRESSION_SERVER_TO_CLIENT
]
=
compression_algorithms
;
res
->
first_kex_packet_follows
=
0
;
return
res
;
}
struct
make_kexinit
*
make_simple_kexinit
(
struct
randomness
*
r
)
{
struct
simple_kexinit
*
res
=
xalloc
(
sizeof
(
struct
simple_kexinit
));
res
->
super
.
make
=
do_make_kexinit
;
res
->
r
=
r
;
return
&
res
->
super
;
}
int
main
(
int
argc
,
char
**
argv
)
{
char
*
host
=
NULL
;
/* Interface to bind */
...
...
@@ -111,7 +164,13 @@ int main(int argc, char **argv)
int
option
;
struct
sockaddr_in
local
;
struct
randomness
*
r
;
struct
diffie_hellman_method
*
dh
;
struct
keyexchange_algorithm
*
kex
;
struct
alist
*
algorithms
;
struct
packet_handler
*
kexinit_handler
;
/* For filtering messages. Could perhaps also be used when converting
* strings to and from UTF8. */
setlocale
(
LC_CTYPE
,
""
);
...
...
@@ -141,6 +200,17 @@ int main(int argc, char **argv)
if
(
(
argc
-
optind
)
!=
0
)
usage
();
r
=
make_poor_random
(
&
sha_algorithm
,
ssh_format
(
"%z"
,
"gazonk"
));
dh
=
make_dh1
(
r
);
init_host_key
(
r
);
/* Initializes public_key and secret_key */
kex
=
make_dh_server
(
dh
,
public_key
,
secret_key
);
algorithms
=
make_alist
(
4
,
ATOM_ARCFOUR
,
crypto_rc4_algorithm
,
ATOM_HMAC_SHA1
,
make_hmac_algorithm
(
&
sha_algorithm
),
ATOM_DIFFIE_HELLMAN_GROUP1_SHA1
,
kex
,
ATOM_SSH_DSS
,
make_dss_algorithm
(
r
),
-
1
);
kexinit_handler
=
make_kexinit_handler
(
make_simple_kexinit
(
r
),
algorithms
);
if
(
!
get_inaddr
(
&
local
,
host
,
port
,
"tcp"
))
{
fprintf
(
stderr
,
"No such host or service"
);
...
...
@@ -149,8 +219,9 @@ int main(int argc, char **argv)
if
(
!
io_listen
(
&
backend
,
&
local
,
make_server_callback
(
&
backend
,
"lshd - a free ssh"
,
BLOCK_SIZE
)))
"lsh - a free ssh"
,
BLOCK_SIZE
,
kexinit_handler
)))
{
werror
(
"lsh: Connection failed: %s
\n
"
,
strerror
(
errno
));
return
1
;
...
...
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