[BACK]Return to mpaux.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/mpaux.c, Revision 1.11

1.1       deraadt     1: /*
1.8       deraadt     2:  *
                      3:  * mpaux.c
                      4:  *
                      5:  * Author: Tatu Ylonen <ylo@cs.hut.fi>
                      6:  *
                      7:  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
                      8:  *                    All rights reserved
                      9:  *
                     10:  * Created: Sun Jul 16 04:29:30 1995 ylo
                     11:  *
                     12:  * This file contains various auxiliary functions related to multiple
                     13:  * precision integers.
                     14:  *
1.1       deraadt    15: */
                     16:
                     17: #include "includes.h"
1.11    ! markus     18: RCSID("$Id: mpaux.c,v 1.10 2000/03/28 20:27:09 markus Exp $");
1.1       deraadt    19:
1.11    ! markus     20: #include <openssl/bn.h>
1.1       deraadt    21: #include "getput.h"
                     22: #include "xmalloc.h"
1.3       deraadt    23:
1.11    ! markus     24: #include <openssl/md5.h>
1.1       deraadt    25:
1.2       provos     26: void
                     27: compute_session_id(unsigned char session_id[16],
1.10      markus     28:     unsigned char cookie[8],
                     29:     BIGNUM* host_key_n,
                     30:     BIGNUM* session_key_n)
1.1       deraadt    31: {
1.9       markus     32:        unsigned int host_key_bytes = BN_num_bytes(host_key_n);
                     33:        unsigned int session_key_bytes = BN_num_bytes(session_key_n);
                     34:        unsigned int bytes = host_key_bytes + session_key_bytes;
1.7       markus     35:        unsigned char *buf = xmalloc(bytes);
                     36:        MD5_CTX md;
1.6       markus     37:
1.7       markus     38:        BN_bn2bin(host_key_n, buf);
1.9       markus     39:        BN_bn2bin(session_key_n, buf + host_key_bytes);
1.7       markus     40:        MD5_Init(&md);
                     41:        MD5_Update(&md, buf, bytes);
1.9       markus     42:        MD5_Update(&md, cookie, 8);
1.7       markus     43:        MD5_Final(session_id, &md);
                     44:        memset(buf, 0, bytes);
                     45:        xfree(buf);
1.1       deraadt    46: }