diff options
author | Colin Watson <cjwatson@debian.org> | 2005-09-14 11:27:01 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2005-09-14 11:27:01 +0000 |
commit | 16704d57999d987fb8d9ba53379841a79f016d67 (patch) | |
tree | b7ecfbd5be83f191af382f3186c39ba1843ba7a1 /mpaux.c | |
parent | c8ab8ceacbe4dbdd7afea4e890d92e86282d050e (diff) | |
parent | a55bd782aa819b7f5ae716de000f19f4f531850e (diff) |
Import OpenSSH 4.2p1.
Diffstat (limited to 'mpaux.c')
-rw-r--r-- | mpaux.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/mpaux.c b/mpaux.c new file mode 100644 index 000000000..0c486275f --- /dev/null +++ b/mpaux.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | ||
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | ||
4 | * All rights reserved | ||
5 | * This file contains various auxiliary functions related to multiple | ||
6 | * precision integers. | ||
7 | * | ||
8 | * As far as I am concerned, the code I have written for this software | ||
9 | * can be used freely for any purpose. Any derived versions of this | ||
10 | * software must be clearly marked as such, and if the derived work is | ||
11 | * incompatible with the protocol description in the RFC file, it must be | ||
12 | * called by a name other than "ssh" or "Secure Shell". | ||
13 | */ | ||
14 | |||
15 | #include "includes.h" | ||
16 | RCSID("$OpenBSD: mpaux.c,v 1.16 2001/02/08 19:30:52 itojun Exp $"); | ||
17 | |||
18 | #include <openssl/bn.h> | ||
19 | #include "getput.h" | ||
20 | #include "xmalloc.h" | ||
21 | |||
22 | #include <openssl/md5.h> | ||
23 | |||
24 | #include "mpaux.h" | ||
25 | |||
26 | void | ||
27 | compute_session_id(u_char session_id[16], | ||
28 | u_char cookie[8], | ||
29 | BIGNUM* host_key_n, | ||
30 | BIGNUM* session_key_n) | ||
31 | { | ||
32 | u_int host_key_bytes = BN_num_bytes(host_key_n); | ||
33 | u_int session_key_bytes = BN_num_bytes(session_key_n); | ||
34 | u_int bytes = host_key_bytes + session_key_bytes; | ||
35 | u_char *buf = xmalloc(bytes); | ||
36 | MD5_CTX md; | ||
37 | |||
38 | BN_bn2bin(host_key_n, buf); | ||
39 | BN_bn2bin(session_key_n, buf + host_key_bytes); | ||
40 | MD5_Init(&md); | ||
41 | MD5_Update(&md, buf, bytes); | ||
42 | MD5_Update(&md, cookie, 8); | ||
43 | MD5_Final(session_id, &md); | ||
44 | memset(buf, 0, bytes); | ||
45 | xfree(buf); | ||
46 | } | ||