Friday, March 31, 2006

How to consume tokens from Infocard

So - if you’ve been wondering how my RP works...here’s an overview. I’m not going to cover declaring Policy or anything, as Mike Jones’ paper seems to have covered it in pretty good detail. I’m assuming here you can get InfoCard to invoke and POST a token.

To get started, you need to get your hands on the XML Token. This should be pretty simple, as your web framework will generally hand back parameters already URL decoded.

Once you’ve got the token, you’ll need to decrypt the token. The token is transmitted as encrypted XML, and will look something like this:


<enc:EncryptedData xmlns:enc="http://www.w3.org/2001/04/xmlenc#"
Type="http://www.w3.org/2001/04/xmlenc#Element">
<enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<dsig:KeyInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
<enc:EncryptedKey>
<enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
</enc:EncryptionMethod>
<dsig:KeyInfo>
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">zHXxYr8jTDe/UhznC81ixsQXSpI=</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</dsig:KeyInfo>
<enc:CipherData>
<enc:CipherValue>hgBNzEXXnoLNu6DPhXJanirEPOK/ey53RKISJrwvRhQazPBgqcnZPaxNVqZf6TOR1VbryCU6fbGw
jIuuXzTb5Z+0PsRPM4N8CLSBxYxN1BFCNnhW67qJ4zrw72OTIkkTLWvPDpJpAak6X6RGFteaf3zD
uVYU4Ta0sDmMD6lxgjs=</enc:CipherValue>
</enc:CipherData>
</enc:EncryptedKey>
</dsig:KeyInfo>
<enc:CipherData>
<enc:CipherValue>qCi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ZkxtZyK5uIB6IIs1b1bHiaKJHwp4qTw7k3xxXuhSUPdRSncSL19XVUNwnWhQtS4r+jvoM2gsglXDB8yjhXWwc6JvLTp0VKq4XsAM6BV4DodPC4N/GgGYghhxy6uO7ViRU+R0z/H4o/VMifUvOs4anMY1SSe</enc:CipherValue>
</enc:CipherData>
</enc:EncryptedData>


Basically what you have here is an ephemeral symmetric encryption key, which has itself been encrypted with the Public Key of the SSL Cert for the website InfoCard is interacting with. As you can see from the metadata provided in the KeyInfo fragment, the key is encrypted using RSA with OAEP encoding and SHA1, using the certificate identified in the SecurityTokenReference with the provided fingerprint (the fingerprint is a SHA1 hash of the cert bytes)

Your first job is to decrypt that encryption key. Step one - remove the Base64 encoding. Step 2 - you need to write a function which takes the private key for the cert referenced by the fingerprint, along with the data as input, and decrypts in this manner RSA-OAEP

Once you’ve successfully decrypted the key ( it should be 256 bits), you can use it to decrypt the token. As you can see in the XML, you need to use AES with a ChainedBlockCipher. Decrypt the token (Don’t forget to strip the initialization vectors...thanks Gary ), and you should see something similar to the following:



<saml:Assertion MajorVersion="1" MinorVersion="1"
AssertionID="uuid:d2de97e7-96ac-4bb3-a373-4fc11c914519"
Issuer="http://schemas.microsoft.com/ws/2005/05/identity/issuer/self"
IssueInstant="2006-03-29T20:52:45.312Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:Conditions NotBefore="2006-03-29T20:52:45.312Z" NotOnOrAfter="2006-03-29T21:52:45.312Z" />
<saml:AttributeStatement>
<saml:Subject>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</saml:ConfirmationMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
</e:EncryptionMethod>
<KeyInfo>
<o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">BCDy8bwQIxTqcoTObIhcvR2KOLw=</o:KeyIdentifier>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>XjkCVuQZ19sYbSnEeKYQ7wD/+bKvGL6kkS2yuVjQX4y3N7U86zRJ66njNPdFNdh8k/x+5CNF1rpjq/Be75a1skO9ePjLgik/UA1DlDo9jaFoYvRlEj0BN/TPJaMZ24kcmcG+QeU89rdg0S4+bqxytHyh14m6IaIaX4aj88RRVq4=</e:CipherValue>
</e:CipherData>
</e:EncryptedKey>
</KeyInfo>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Attribute AttributeName="GivenName" AttributeNamespace="http://schemas.microsoft.com/ws/2005/05/identity/claims">
<saml:AttributeValue>Mister</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute AttributeName="Surname" AttributeNamespace="http://schemas.microsoft.com/ws/2005/05/identity/claims">
<saml:AttributeValue>Milo</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute AttributeName="EmailAddress" AttributeNamespace="http://schemas.microsoft.com/ws/2005/05/identity/claims">
<saml:AttributeValue>milo@xmldap.org</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#uuid:d2de97e7-96ac-4bb3-a373-4fc11c914519">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>leav91ZV/KJpwumP/j+4XtlEvJg=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>gEVmREMwNiE67hMdOf7uuC4jnhG4f9y3WYL2pL6d9F3Nblf3qddMe6K+d/b6ucePKS3Q9XXBmBu2tWtmZlwTzldVjx8IYZb5u5jcQByAp2GrTJb/XxHA/3BkE073zdFRlmHje467kVd4Mcg6X2qNsV1N+euZqCUfmrXyf3cs5n4u6A9A1CTuQhCOGhE7jjDUGPmyChJa2YfHqpiVPEXgqN+RYOTLUFbA2kKj1Jyi8+FJD7vHP/5/kblge82waNFOOaA6d7lXDhr4lBDDhr5vKoNWy91bDMStn+nKN7Nzj7zPjxjynp7CisSewyWxAjcD9XDl/I9Va2UVDmPr4JC4bw==</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue>
<Modulus>rCOb7lDap18tsTurz6j/fSYnO+ck5or10hn9tZhCDwXfJip2lqjIFcj3fYv1cyP96dl4++x8QGXSB5WAu3NNtjZkVxTDO4sOk+IpkLOlE5vM6ClMSV46tx9fo6tbQ9EhJTy7vXAbCH6hQnowxdmUEVKJudCtlMeHSotix98T5zJXYMjeLvmDPmSK8pG/t+kBmRjsgSZGqjD4VFlnDBpYOZ4R+nH2ESudyvZUwAkgPAEtGuBcc+nXVUEbs+O1xOkzcTRCm9FCoww1oNSi2maRGontD14Cbyy3DuNRxqPSxEc8rN7KBoq5w2y+Q5YTVYBB+qn2rXbO0aQlYHXIZOATpw==</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</Signature>
</saml:Assertion>



The next step would be to quickly check the validity period on this Assertion to make sure it’s still fresh. You might also want to check the AssertionID against a table of previously seen assertions to prevent replay...depends on your level of paranoia.

On to signature validation...you should follow the steps outlined in XML-DSIG, but to paraphrase, check the digest of the canonicalized assetion against the digest in the SignedInfo block, and then valhttp://www.blogger.com/img/gl.link.gifidate the signature of the canonicalized SignedInfo using a PublicKey constructed from the provided KeyInfo.

Now, what’s bugging me is the use for the Symmetric Proof key provided in the Subject of the Assertion. Super Pat and I discussed this for awhile, and since it’s not used immediately in this protocol exchange, our best guess is that it’s used in subsequent interactions with the service, although I must admit the InfoCard docs are a little fuzzy on this subject. If anyone can fill me in, I’d appreciate it!

Finally, if your signature validation worked, extract the claims, enforce any policy you’d like, create a session, set a cookie, etc...

good luck!

21 comments:

Anonymous said...

Have you tried asking Kim?

My only thought... it would be a bit odd to use a symmetric key for 'proofs' (e.g. proof of origin, proof of integrity &c) when you have a PKI pair available.

So as you say, maybe this is for later use as a data key... but again, why do that if you trust the SSL session you're using?

cmort said...

Hey Robin...

I agree, it's a bit odd. That being said, the web browser binding (for lack of a better term) of infocard was defined after the web service version. In the full version, the RP declares in policy what key type it would like (symmeteric being the default) and there are really 3 parties involved. It might also be a residual from that...

All good questions though - at the moment I'm speculating. Hopefully Kim will comment...?

Anonymous said...

Gee, I would say it's a bit odd to go through all the public key rigamarole to establish proof of origin (authenticity) and proof of integrity if you have a shared secret (symmetric key) available that will do the both much easier.

One of the main purposes of the SSL handshake is to establish such a shared secret that can be used for other messages in the session.

I don't know if that helps or not.

Anonymous said...

I tried to decrypt (with Java) the symmKey using the server private key and the RSA algorithm.
But i'm still having a 128 bytes resulting key.
Can't go far with this.
Some tips plz.

regards

cmort said...

With something like this, it's pretty hard to tell without seeing your code...

You could read my source, available at xmldap.org, or post yours and I'll take a look.

Ngo Quang Ha said...

hi,Im new comer of CardSpace.
I have a question.
How can I retrive the key of the certificate?Is that the www.fabrikam.com.pfx one?If so, how can I get it using Java?

cmort said...

Private keys are relative to the certificate being used - you can do this in Java by accessing the keystore being used. You might want to check out a quick PKI primer.

The fabrikum cert is simply something from microsoft demo code

Ngo Quang Ha said...

Hi Cmort, Im again..

I am trying to implement a Java program that can be able to decrypt the xml file sent by the STS server.

Now Im stuck in finding the public key to decrypt the certificate of the website (I use the OpenSSL to create a certificate myself). Is this a must to have the pulic key from the CA to get the pulic key in the certificate, since when I try to read the certificate, it returns the encoded information that I can not decrypt...If so, where can I get the public key I want or is there any other way to decrypt the xml file?..
Thanks alot!
Alex

cmort said...

Hey - I've got to say that I don't quite understand your question. Can you rephrase please?

thanks

Ngo Quang Ha said...

Ok, Im sorry since my English is not very good.

My question is:
I want to decrypt the information in the xml file, that is sent from STS server.I notice that the key to decrypt data is also encrypted and we must use the thumbprint to search for the certificate.
Then, when we have the certificate, will we use the public key of the certificate to decrypte the xml's key? If so, how to get the public key there, since everything is encrypted and we dont have the CA's private key..:)
I hope this would be clearer..:)

cmort said...

Thanks for restating

The xml payload should arrive encrypted using the SSL cert of the Relying Party. You should have access to the private key which can be used for decryption

Feel free to read through the xmldap code for a description

Ngo Quang Ha said...

Thank Cmort..Yes, now I have the encrypted token,I can get the public key and private key from the certificate. When I decrypt the key (in xml file), I get the key with 256 bytes..I also notice that for the AES 256, it requires the key of 32 bytes.How can I use the 256-byte key to decrypt the data using AES? Or only part of the 256 bytes is used to decrypt?

cmort said...

The key you should get back is 256 bits. 256 bits = 32 bytes. Hope that is clear...

Ngo Quang Ha said...

The key's size is 32 bytes?

You mean the cipher value of the key after decryption ?

cmort said...

Yes - key size. Basically you're decrypting a 256bit AES key.

No - not the cipher value but rather the clear text value. Basically you should get back 256 bits which you'll use for the key in the AES decrypt

Anonymous said...

Hi, I have a question..

How can I use a Java program to retrieve the private key from LocalMachine (the ..\RSA\MachineKeys store)
I can use the findprivatekey.exe to get the file..But, for the Java program, how to get it?
:)

cmort said...

Sorry - no clue....I work on a Mac.

The xmldap code simply uses Java Keystores. I'd do some googling.

Anonymous said...

These comments have been invaluable to me as is this whole site. I thank you for your comment.

cmort said...

Glad you've enjoyed!

Satish Burnwal said...

I have a signed SAML token that I am trying to verify and this very much similar to the SAML:Assertion that you posted. I see that URI attr in ds:Reference element is the value of AssertionID. I want to know if it is a standard way to have the URI attr of ds:Reference same as AssertionID? Any document (like oasis etc) to suffice that?

cmort said...

I'd check out section 5 of SAML 1.1 core