/* rsa_key.c
 * 
 * Ray Jones 
 * DO NOT EDIT THIS FILE!!! GENERATED AUTOMATICALLY!!! 
 */
#include "copyright2.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include "defs.h"
#include "packets.h"
#include "Wlib.h"
#include "data.h"

encryptRSAPacket(spacket, cpacket)
struct rsa_key_spacket *spacket;
struct rsa_key_cpacket *cpacket;
{
    struct sockaddr_in saddr;
    int len;
    u_short port;
    unsigned char *data;
    unsigned char key_private[KEY_SIZE];
    unsigned char key_public[KEY_SIZE];
    unsigned char key_global[KEY_SIZE];

        /* query the socket to determine the remote host (ATM) */
    len = sizeof(saddr);
    if (getpeername(sock, &saddr, &len) < 0) {
        perror("getpeername(sock)");
        exit(1);
    }

    /* replace the first few bytes of the message */
    /* will be the low order bytes of the number */
    data = spacket->data;
    bcopy (&saddr.sin_addr.s_addr, data, sizeof(saddr.sin_addr.s_addr));
    data += sizeof(saddr.sin_addr.s_addr);
    bcopy (&saddr.sin_port, data, sizeof(saddr.sin_port));
    key_global[3] = 137;
    key_global[19] = key_global[3] + key_global[3] + -79;
    key_global[12] = key_global[3] + key_global[19] + key_global[3] + key_global[3] + -591;
    key_global[1] = key_global[3] + 59;
    key_global[10] = key_global[12] + 79;
    key_global[17] = key_global[12] + key_global[19] + key_global[19] + -153;
    key_global[4] = key_global[19] + key_global[10] + -62;
    key_global[29] = key_global[19] + 19;
    key_global[30] = key_global[3] + key_global[29] + key_global[10] + key_global[19] + -388;
    key_global[24] = key_global[1] + -123;
    key_global[13] = key_global[29] + key_global[1] + key_global[4] + -415;
    key_global[26] = key_global[17] + key_global[3] + key_global[3] + key_global[10] + -472;
    key_global[14] = key_global[30] + key_global[3] + key_global[30] + key_global[30] + -783;
    key_global[28] = key_global[26] + key_global[24] + key_global[19] + -201;
    key_global[2] = key_global[14] + key_global[28] + key_global[12] + key_global[28] + -322;
    key_global[25] = key_global[1] + key_global[4] + key_global[24] + -436;
    key_global[16] = key_global[10] + key_global[24] + -61;
    key_global[6] = key_global[19] + key_global[3] + key_global[4] + -557;
    key_global[15] = key_global[10] + key_global[29] + key_global[16] + key_global[12] + -294;
    key_global[0] = key_global[3] + -92;
    key_global[20] = key_global[3] + key_global[6] + key_global[15] + -259;
    key_global[9] = key_global[14] + key_global[19] + key_global[30] + key_global[13] + -703;
    key_global[8] = key_global[28] + key_global[24] + key_global[19] + -295;
    key_global[27] = key_global[28] + key_global[19] + key_global[14] + key_global[29] + -728;
    key_global[21] = key_global[4] + key_global[13] + -436;
    key_global[7] = key_global[17] + -216;
    key_global[5] = key_global[27] + key_global[25] + 141;
    key_global[23] = key_global[0] + key_global[7] + key_global[21] + 49;
    key_global[22] = key_global[0] + key_global[26] + key_global[10] + -225;
    key_global[18] = key_global[7] + key_global[20] + key_global[19] + -147;
    key_global[31] = key_global[23] + key_global[18] + key_global[5] + key_global[17] + -658;
    key_global[11] = key_global[6] + 156;
    key_public[26] = 150;
    key_public[21] = key_public[26] + key_public[26] + key_public[26] + -374;
    key_public[9] = key_public[21] + key_public[26] + -169;
    key_public[27] = key_public[9] + key_public[9] + key_public[21] + -180;
    key_public[25] = key_public[21] + -63;
    key_public[6] = key_public[26] + key_public[27] + -134;
    key_public[4] = key_public[21] + key_public[25] + key_public[9] + 44;
    key_public[14] = key_public[21] + key_public[9] + -96;
    key_public[3] = key_public[9] + key_public[14] + 32;
    key_public[23] = key_public[6] + key_public[14] + 188;
    key_public[8] = key_public[3] + -121;
    key_public[20] = key_public[6] + key_public[6] + key_public[25] + 17;
    key_public[31] = key_public[23] + key_public[25] + -260;
    key_public[10] = key_public[4] + -38;
    key_public[7] = key_public[21] + key_public[3] + key_public[4] + key_public[3] + -338;
    key_public[24] = key_public[27] + key_public[27] + 212;
    key_public[1] = key_public[31] + key_public[3] + key_public[31] + key_public[9] + -144;
    key_public[17] = key_public[10] + key_public[31] + key_public[20] + key_public[31] + -46;
    key_public[5] = key_public[17] + -186;
    key_public[16] = key_public[9] + key_public[24] + key_public[26] + key_public[4] + -405;
    key_public[15] = key_public[31] + 185;
    key_public[11] = key_public[26] + key_public[27] + key_public[4] + -273;
    key_public[0] = key_public[11] + -58;
    key_public[13] = key_public[10] + key_public[21] + 4;
    key_public[2] = key_public[16] + key_public[8] + key_public[9] + key_public[24] + -373;
    key_public[28] = key_public[15] + key_public[26] + key_public[21] + -342;
    key_public[19] = key_public[31] + 38;
    key_public[29] = key_public[31] + key_public[0] + 74;
    key_public[18] = key_public[21] + 54;
    key_public[30] = key_public[26] + key_public[29] + key_public[11] + key_public[23] + -503;
    key_public[22] = key_public[3] + key_public[4] + -94;
    key_public[12] = key_public[8] + key_public[15] + -192;
    key_private[1] = 181;
    key_private[23] = key_private[1] + -181;
    key_private[20] = key_private[1] + key_private[1] + key_private[23] + key_private[1] + -543;
    key_private[21] = key_private[1] + -181;
    key_private[25] = key_private[23] + key_private[23] + 0;
    key_private[3] = key_private[1] + key_private[21] + key_private[23] + key_private[23] + 28;
    key_private[26] = key_private[21] + key_private[21] + key_private[23] + 0;
    key_private[24] = key_private[21] + key_private[1] + key_private[3] + -390;
    key_private[5] = key_private[3] + key_private[21] + key_private[25] + key_private[24] + -168;
    key_private[11] = key_private[20] + key_private[23] + key_private[26] + 155;
    key_private[22] = key_private[5] + key_private[26] + key_private[20] + key_private[5] + -82;
    key_private[17] = key_private[20] + key_private[3] + -209;
    key_private[4] = key_private[22] + key_private[11] + key_private[25] + -37;
    key_private[13] = key_private[21] + key_private[17] + key_private[5] + key_private[24] + 96;
    key_private[0] = key_private[20] + key_private[4] + key_private[20] + key_private[1] + -208;
    key_private[15] = key_private[22] + key_private[0] + key_private[24] + key_private[0] + -78;
    key_private[8] = key_private[3] + key_private[22] + key_private[5] + key_private[1] + -226;
    key_private[10] = key_private[22] + key_private[4] + key_private[21] + -28;
    key_private[27] = key_private[10] + -90;
    key_private[30] = key_private[15] + key_private[20] + key_private[27] + key_private[23] + -104;
    key_private[19] = key_private[11] + key_private[5] + key_private[3] + key_private[20] + -405;
    key_private[16] = key_private[0] + key_private[4] + key_private[25] + key_private[3] + -341;
    key_private[7] = key_private[20] + key_private[25] + key_private[27] + 30;
    key_private[12] = key_private[0] + key_private[21] + key_private[27] + key_private[23] + -56;
    key_private[29] = key_private[24] + 0;
    key_private[6] = key_private[20] + key_private[22] + key_private[19] + key_private[26] + 92;
    key_private[18] = key_private[0] + -91;
    key_private[31] = key_private[17] + 0;
    key_private[9] = key_private[17] + 197;
    key_private[28] = key_private[27] + key_private[20] + 0;
    key_private[14] = key_private[19] + 138;
    key_private[2] = key_private[25] + key_private[0] + -18;
    /* do the actual computaions */
    rsa_encode(cpacket->resp, spacket->data, key_private, 
	       key_global, KEY_SIZE);
    
    bcopy(key_global, cpacket->global, KEY_SIZE);
    bcopy(key_public, cpacket->public, KEY_SIZE);
}
