Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / May 2005

Tip: Looking for answers? Try searching our database.

UsernameToken Signing and Envryption

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Jenkins - 09 May 2005 21:09 GMT
I have set up a simple policy with a requirement that the message is signed with a Username. This works great. I set up my client to create a token and pass in the username and password, requesting the password to be digested.

  UsernameToken token=new UsernameToken("name", "somepassword", PasswordOption.SendHashed);

  localhost.Service1 a=new PolicyClient.localhost.Service1();
  a.RequestSoapContext.Security.Tokens.Add(token);
  a.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));
 
  try
  {
   Console.WriteLine( a.HelloWorld() );
  }
  catch(Exception ex){
   Console.WriteLine(ex.Message);
   Console.ReadLine();
  }

I had assumed that if I then encrypt the data on the client with a

a.RequestSoapContext.Security.Elements.Add(new EncryptedData(token));

it would fail because I hadn't mentioned this in my policy.xml file. I thought the <Confidentiality> tag was supposed to cover this? Can someone correct me because this worked without any error.

Partial policy.xml
=========      <wssp:Integrity wsp:Usage="wsp:Required">
       <wssp:TokenInfo>
         <!--The SecurityToken element within the TokenInfo element describes which token type must be used for Signing.-->
         <wssp:SecurityToken>
                 <wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1
.0#UsernameToken</wssp:TokenType
>
           <wssp:Claims>
   <wssp:UsePassword Type="wssp:PasswordDigest" wsp:Usage="wsp:Required" />
           </wssp:Claims>
         </wssp:SecurityToken>
       </wssp:TokenInfo>
       <wssp:MessageParts Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body() wsp:Header(wsa:Action) wsp:Header(wsa:FaultTo) wsp:Header(wsa:From) wsp:Header(wsa:MessageID) wsp:Header(wsa:RelatesTo) wsp:Header(wsa:ReplyTo) wsp:Header(wsa:To) wse:Timestamp()</wssp:MessageParts>
     </wssp:Integrity>
Dilip Krishnan - 09 May 2005 21:56 GMT
The policy on the service only enforces a requirement that needs to be
satisfied. Now if in addition to the integrity if you also specify
confidentiality in the requests, they would still go through just fine,
as you've met the minimal policy (integrity)requirements by signing the
message.
   Now if you only encrypted in the client (as opposed to signed and
encrypted) then the service invokation should fail as you expected.

> I have set up a simple policy with a requirement that the message is
> signed with a Username. This works great. I set up my client to create a
[quoted text clipped - 48 lines]
> wse:Timestamp()</wssp:MessageParts>
>       </wssp:Integrity>

Signature

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilip.krishnan AT apdiya DOT com

John Jenkins - 10 May 2005 00:06 GMT
Ah, many thanks Dilip.

> The policy on the service only enforces a requirement that needs to be
> satisfied. Now if in addition to the integrity if you also specify
[quoted text clipped - 40 lines]
> > describes which token type must be used for Signing.-->
> >           <wssp:SecurityToken>

<wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-user
name-token-profile-1.0#UsernameToken</wssp:TokenType>
> >             <wssp:Claims>
> >     <wssp:UsePassword Type="wssp:PasswordDigest" wsp:Usage="wsp:Required" />
[quoted text clipped - 9 lines]
> > wse:Timestamp()</wssp:MessageParts>
> >       </wssp:Integrity>
William Stacey [MVP] - 13 May 2005 17:02 GMT
I would only note that SendHashed using a "normal" password is not much security as the plain password can be found pretty easy.  If password is some 10 random chars, then it is much harder.  However, you have to ask yourself if folks are really using passwords that strong.  A ~better option is to use SCTs instead of UTs as the password can not be dictionary attacked and the session key is not bassed on the password in any way.  
--
William Stacey [MVP]
 I have set up a simple policy with a requirement that the message is signed with a Username. This works great. I set up my client to create a token and pass in the username and password, requesting the password to be digested.

    UsernameToken token=new UsernameToken("name", "somepassword", PasswordOption.SendHashed);

    localhost.Service1 a=new PolicyClient.localhost.Service1();
    a.RequestSoapContext.Security.Tokens.Add(token);
    a.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));
   
    try
    {
     Console.WriteLine( a.HelloWorld() );
    }
    catch(Exception ex){
     Console.WriteLine(ex.Message);
     Console.ReadLine();
    }

 I had assumed that if I then encrypt the data on the client with a

  a.RequestSoapContext.Security.Elements.Add(new EncryptedData(token));

 it would fail because I hadn't mentioned this in my policy.xml file. I thought the <Confidentiality> tag was supposed to cover this? Can someone correct me because this worked without any error.

 Partial policy.xml
 =========        <wssp:Integrity wsp:Usage="wsp:Required">
         <wssp:TokenInfo>
           <!--The SecurityToken element within the TokenInfo element describes which token type must be used for Signing.-->
           <wssp:SecurityToken>
                   <wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1
.0#UsernameToken</wssp:TokenType
>
             <wssp:Claims>
     <wssp:UsePassword Type="wssp:PasswordDigest" wsp:Usage="wsp:Required" />
             </wssp:Claims>
           </wssp:SecurityToken>
         </wssp:TokenInfo>
         <wssp:MessageParts Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body() wsp:Header(wsa:Action) wsp:Header(wsa:FaultTo) wsp:Header(wsa:From) wsp:Header(wsa:MessageID) wsp:Header(wsa:RelatesTo) wsp:Header(wsa:ReplyTo) wsp:Header(wsa:To) wse:Timestamp()</wssp:MessageParts>
       </wssp:Integrity>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.