Message Security
As we gear up for the final deliverable (code-named Bread & Butter) of our project, one of the requirements we've implemented is message security.
Essentially, in this deliverable we'll be dealing with financial information and in order to comply with the Payment Card Industry Data Security Standard we need to be able to protect credit card and bank account information. This is also a part of a larger security initiative within the organization whereby data elements are tagged with a protection level and treated accordingly and includes the deployment of a PKI (public key infrastructure) solution.
Although that initiative is not yet in full swing we've implemented the ablility within our services to tag specific schema elements and attributes as requiring protection and then encrypting and decrypting those elements and attributes using public key cryptography.
Our solution includes the following components:
In the remainder of this post we'll look at the encryption components.
Encryption Components
The set of encryption components we've built are implemented in two assemblies named Compassion.Services.Security.Attributes.dll and Compassion.Services.Security.Common.dll. The types that are implemented in the two assemblies are discussed below.
Compassion.Services.Security.Attribute
This assembly contains the following types.
[ProtectedData(EncryptionFormat.Inline)]
public string AccountNumber;
<CreditCardPaymentSourceData>
<CardholderName>Daniel Ducat</CardholderName>
<ExpirationDate>2007-03-31T00:00:00.0000000-07:00</ExpirationDate>
<AccountNumber>AkxcG3qHALhDzqd+5Gxrod1tb2q7V8tYQ5MyJxfk/oFd+J0HkPPM
+J67hMfq2XMgw97kmuDKqnlhiGA7KE3SNkLNAkvmPMwuWUCn7djOEPLKHb+7MDkN
4JAX2rIGvgr0N1etazudfegNtGRg3fhLp2Nl8lTD8O/KY5gHVA051mU=
</AccountNumber>
<CardType>Visa</CardType>
<Description>****1111</Description>
</CreditCardPaymentSourceData>
The value XMLEnc will be used to specify that the W3C XML Encryption Syntax and Processing specification will be used For example, that specification allows for the encryption of individual elements like so:
<?xml version='1.0'?>
<PaymentInfo xmlns='http://example.org/paymentv2'>
<Name>John Smith</Name>
<CreditCard Limit='5,000' Currency='USD'>
<Number>4019 2445 0277 5567</Number>
<Issuer>Example Bank</Issuer>
<Expiration>04/02</Expiration>
</CreditCard>
</PaymentInfo>
Where the CreditCard element is then encrypted as:
<?xml version='1.0'?>
<PaymentInfo xmlns='http://example.org/paymentv2'>
<Name>John Smith</Name>
<CreditCard Limit='5,000' Currency='USD'>
<EncryptedData
xmlns='http://www.w3.org/2001/04/xmlenc#'
Type='http://www.w3.org/2001/04/xmlenc#Content'>
<CipherData>
<CipherValue>A23B45C56</CipherValue>
</CipherData>
</EncryptedData>
</CreditCard>
</PaymentInfo>
The .NET Framework 2.0 exposes objects in the System.Security.Cryptography.Xml namespace to perform this encryption automatically. In order to implement this in the .NET Framework v1.1 the .NET component that will be implemented must perform the encryption behind the scenes. When we move to .NET 2.0 we’ll likely want to reimplement this class accordingly.
Compassion.Services.Security.Common
This assembly contains the following types.
RSACryptoServiceProvider aag =
new RSACryptoServiceProvider();
KeyFileProvider kfPublic = new KeyFileProvider(aag,
@"C:\PublicOnlyKey.xml");
ObjectEncryptor.Encrypt(pcr, kfPublic);
Here the client instantiates the asymmetric algorithm to use, passes that into the IAsymmetricKeyProvider (in this case along with the path to the key) and finally uses the Encrypt method of the ObjectEncryptor to encrypt the object. Since the object is passed by reference the object will contain the newly encrypted data.
Next time we'll look at the handler we implemented so that service operations can encrypt and decrypt data.
1 Comments:
Hi Dan
Enjoy your blog, lots of good information in there. However for your security component I would have expected to see you use WS-Security.
Any reasons why not?
3:19 PM
Post a Comment
<< Home