Connecting to WEP using opennetcf SDF2.2

A

Abhi

Hi,

I am trying to connect to WEP network using OpenNETCF SDF 2.2 API
AddPreferredNetwork() and ConnectToPreferredNetwork(). Per the WEP
conventions, I am converting the 5 or 10 character ASCII passphrase to
HEX. But I am facing a few problems:

On my router settings, I set the WEP to be 64-bit 10 HEX digits. Then
I get a 10-digit HEX network keys for a 5-digit ASCII passphrase. When
I use this 10-digit in the AddPreferredNetwork()API, it works
perfectly and connects to the network. But if I try to convert it to a
13 or 26 digit HEX, I get an exception saying the key is not of the
right length. Also if I try to enter the 5-digit ASCII passphrase and
convert it to HEX I still get the same exception. Could anyone please
let me know what could be wrong here?

My code is below.

void ConnectToWEP ()
{

string useKey = key;

//THIS IS WEP so need to pass in a 13 or
26 character hex..which means converting a 5 or 10 character string
if (key.Length == 5 || key.Length == 10)
{
//useKey = convertToHex(key);
}
mWzc.AddPreferredNetwork(ssid, true,
useKey, 1, OpenNETCF.Net.NetworkInformation.AuthenticationMode.Open,
OpenNETCF.Net.NetworkInformation.WEPStatus.WEPEnabled, null);
mWzc.ConnectToPreferredNetwork(ssid);

}


/// <summary>
/// Converts passphrase to hex
/// </summary>
/// <param name="asciiString">Passphrase</param>
/// <returns>Passphrase in hex</returns>
private string convertToHex(string asciiString)
{
if (string.IsNullOrEmpty(asciiString))
{
return string.Empty;
}
string hex = "";
try
{
foreach (char c in asciiString)
{
int tmp = c;
hex += String.Format("{0:x2}",
(uint)System.Convert.ToUInt32(tmp.ToString()));
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Hand,
MessageBoxDefaultButton.Button1);
return string.Empty;
}
return hex;
}
 
P

Paul G. Tobey [eMVP]

Recalculate those things. 10 hex digits != 64 bits. That would be five
bytes, or 40 bits, not 64. I think that, if you synchronize your thinking
with the number of bits in a byte, you'll be fine. Your conversion to hex
subroutine also appears wrong to me, but you'll have to step through it in
the debugger and see if the results make sense one byte at a time.

As for this, "But if I try to convert it to a 13 or 26 digit HEX..." If you
try to convert *what*, exactly? And what do you mean by 13-digit HEX? That
would be 6 and *a half* bytes. How would that ever work?

Paul T.
 
A

Abhi

Hi Paul,

Do you have a function that converts a 5-byte ASCII passphrase to a 13-
byte HEX network key?

Thanks,
Abhi
 
C

Chris Tacke, eMVP

What is a 13-byte HEX network key exactly? What does it look like? Where
are you getting it? How do you set it manually in the UI? For that matter,
the same questions apply for a "5-byte ASCII passphrase".

For example my network requires 10 hex characters to be typed in for the WEP
key. Each character represents 4 bits of the key, yielding good-old 40-bit
encryption.

128-bit typically requires that you enter 26 hex characters.

So I have no idea what you're talkign about with either the 5 byte or 13
byte items.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

Hi Paul,

Do you have a function that converts a 5-byte ASCII passphrase to a 13-
byte HEX network key?

Thanks,
Abhi
 
A

Abhi

Hi,

Sorry the problem was with my code. I was not passing in 10 or 26
character key for OpenNETCF.

Thanks,
Abhi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top