all groups > dotnet web services enhancements > december 2005 >
You're in the

dotnet web services enhancements

group:

Generating encryption keys


Generating encryption keys JamesWilson
12/13/2005 1:25:02 AM
dotnet web services enhancements:
Hi everyone,

I'm wanting to encrypt the soap body using the username token (i'm using WSE
2 SP3), and it has worked. However my colleague is using PHP and is wanting
to decrypt the soap message however we are not sure how the key and IV for
the aes encryption is created. Does anyone know how it generates the key and
IV for the encryption ? I have looked everywhere and can't seem to find
anything about it, or anyone who knows.

James
Re: Generating encryption keys Eric Pearson
12/13/2005 5:04:15 PM
Here's how I create the algorithm in my security token.

I first get a regular Symmetric algorithm

//algorithmName is a string representing the..uh...algorithm ("Rijndael"
for aes)
SymmetricAlgorithm alg = SymmetricAlgorithm.Create(algorithmName);
alg.KeySize = key.Length * 8;
alg.Key = key;
alg.IV = iv;


if you are GENERATING the key/iv, call GenerateKey(), GenerateIV() on the
SymmetricAlgorithm


Then on your Custom token class (mine supports AES128/192/256 and 3des, depending
on client/server negotiation)

public override KeyAlgorithm Key
{
get
{
if (m_KeyAlgorithm != null) return m_KeyAlgorithm;

if (this.m_SymmetricAlgorithm is Rijndael)
{
switch(this.m_SymmetricAlgorithm.KeySize)
{
case 128:
this.m_KeyAlgorithm = new AES128((Rijndael)this.m_SymmetricAlgorithm);
break;
case 192:
this.m_KeyAlgorithm = new AES192((Rijndael)this.m_SymmetricAlgorithm);
break;
case 256:
this.m_KeyAlgorithm = new AES256((Rijndael)m_SymmetricAlgorithm);
break;
default:
throw(new InvalidOperationException("" + this.m_SymmetricAlgorithm.KeySize
+ " is not a valid key length"));
break;
}
}
else if (this.m_SymmetricAlgorithm is System.Security.Cryptography.TripleDES)

{
this.m_KeyAlgorithm = new Microsoft.Web.Services2.Security.Cryptography.TripleDES(this.m_SymmetricAlgorithm);
}
return this.m_KeyAlgorithm;
}
}


[quoted text, click to view]

Re: Generating encryption keys JamesWilson
12/14/2005 12:23:02 AM
Hi Eric,

sorry I don't think I was clear enough. I am not wanting to know how to do
it in .net, but merely the algorithim it uses. E.g. does it use P_SHA1 to
create the key, or does it use some other kind of hashing?

What I have heard is that it uses P_SHA1 to create the key, by P_SHA1(shared
secret, label+nonce+created) where + is concatentation.

James


[quoted text, click to view]
AddThis Social Bookmark Button