]>
Commit | Line | Data |
---|---|---|
8efc0c15 | 1 | /* |
5260325f | 2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
5260325f | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | |
5260325f | 5 | * This file contains various auxiliary functions related to multiple |
6 | * precision integers. | |
6ae2364d | 7 | * |
bcbf86ec | 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 | */ | |
8efc0c15 | 14 | |
15 | #include "includes.h" | |
bcbf86ec | 16 | RCSID("$OpenBSD: mpaux.c,v 1.14 2000/09/07 20:27:52 deraadt Exp $"); |
8efc0c15 | 17 | |
35484284 | 18 | #include <openssl/bn.h> |
5260325f | 19 | #include "getput.h" |
20 | #include "xmalloc.h" | |
21 | ||
5881cd60 | 22 | #include <openssl/md5.h> |
5881cd60 | 23 | |
8efc0c15 | 24 | void |
25 | compute_session_id(unsigned char session_id[16], | |
7368a6c8 | 26 | unsigned char cookie[8], |
27 | BIGNUM* host_key_n, | |
28 | BIGNUM* session_key_n) | |
8efc0c15 | 29 | { |
95f1eccc | 30 | unsigned int host_key_bytes = BN_num_bytes(host_key_n); |
31 | unsigned int session_key_bytes = BN_num_bytes(session_key_n); | |
32 | unsigned int bytes = host_key_bytes + session_key_bytes; | |
5260325f | 33 | unsigned char *buf = xmalloc(bytes); |
34 | MD5_CTX md; | |
35 | ||
36 | BN_bn2bin(host_key_n, buf); | |
95f1eccc | 37 | BN_bn2bin(session_key_n, buf + host_key_bytes); |
5260325f | 38 | MD5_Init(&md); |
39 | MD5_Update(&md, buf, bytes); | |
95f1eccc | 40 | MD5_Update(&md, cookie, 8); |
5260325f | 41 | MD5_Final(session_id, &md); |
42 | memset(buf, 0, bytes); | |
43 | xfree(buf); | |
8efc0c15 | 44 | } |