wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / crypto / wvoakley.cc
blobc16dadde1b1b8df779532655af5d10943d856417
1 /*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2003 Net Integration Technologies, Inc.
5 * Oakley authentication for IPSec
6 */
8 #include "wvoakley.h"
10 /* Group 1 prime */
11 static unsigned char group1_key[] =
12 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,
13 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
14 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,
15 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
16 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,
17 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
18 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,
19 0xA6, 0x3A, 0x36, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
22 /* Group 2 prime */
23 static unsigned char group2_key[] =
24 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,
25 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
26 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,
27 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
28 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,
29 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
30 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,
31 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
32 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11,
33 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81,
34 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
37 WvOakleyAuth::WvOakleyAuth(int group)
39 switch (group)
41 case 1:
42 dh = new WvDiffieHellman(group1_key, sizeof(group1_key),
43 DH_GENERATOR_2);
44 break;
45 case 2:
46 dh = new WvDiffieHellman(group2_key, sizeof(group2_key),
47 DH_GENERATOR_2);
48 break;
49 case 3: case 4:
50 /* We don't support any eliptic curve stuff. */
51 break;
53 pub_len = dh->pub_key_len();
56 short WvOakleyAuth::public_len()
58 return pub_len;
61 short WvOakleyAuth::get_public_key(WvBuf &outbuf, short len)
63 return dh->get_public_value(outbuf, len);
66 void WvOakleyAuth::create_secret(WvBuf &_other_pub_key, short len)
68 other_pub_key.put(_other_pub_key.peek(0, len), len);
69 other_len = len;
70 dh->create_secret(_other_pub_key, len, dh_secret);
71 return;
74 short WvOakleyAuth::other_pub_len()
76 return other_len;
79 short WvOakleyAuth::get_other_public_key(WvBuf &outbuf, short len)
81 if (len > other_len)
82 len = other_len;
84 outbuf.put(other_pub_key.peek(0, len), len);
85 return len;