SlideShare a Scribd company logo
1 of 16
XML Encryption:  Processing Rules for XML Elements and Content Nihar Ranjan Behera I/07/34
Overview ,[object Object],[object Object],[object Object],[object Object]
Overview Note:  I am not suggesting that XML Encryption specify an API design, absolutely NOT!  However, I don’t want XML Encryption to unnecessarily restrict API designs either. Note 2:  Slides with detailed code are included for completeness; they are not essential for understanding this topic.
How the current Processing Rules work Original/Decrypted <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <Customers> <Customer> <Name>Jose Aznar</Name> <CreditCard> <Number>   1000 1234 5678 0001   </Number> <ExpiryDate>   2003 June 30   </ExpiryDate> </CreditCard> </Customer> . . . </Customers> Encrypted <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <Customers> <Customer> <Name> <EncryptedData…> </Name> <CreditCard> <Number> <EncryptedData…> </Number> <ExpiryDate>   2003 June 30   </ExpiryDate> </Customer> . . . </Customers>
What the code looks like Encrypting // Encrypt the content of the <CreditCard>/<Number> elements NodeIterator ni2 =  XPathAPI.selectNodeIterator(doc,&quot;//CreditCard/Number&quot;); // Encrypt the nodes (only element content is encrypted) while ((node = ni2.nextNode())!= null) { System.out.print(&quot;.&quot;);  xmlencEncryptor. encryptAndReplace ((Element)node, true,  getEncryptedDataTemplate(desKey, true), desKey); Decrypting // Get the nodes to be decrypted NodeList nl2 = DOMUtil.getElementsByTagNameNS( doc, XEncryption.XMLENC_NS, &quot;EncryptedData&quot;); // Decrypt for (int i = 0; i < nl2.getLength(); i++) {  System.out.print(&quot;.&quot;);  Element el = (Element)nl2.item(i); xmlencDecryptor. decryptAndReplace (el); }
Other processing scenarios Scenario A:  The XML source has no encrypted parts and is protected through authorization instead.  However, there is an authorized app which selects certain credit card info for processing.  It wants to query <CreditCard> elements and/or content, encrypt, and import the resulting <EncryptedData> element into a SOAP message. Scenario B:  The XML source has encrypted elements and content accessible by a number of applications.  When one of these applications queries an encrypted element, that app needs to decrypt the element but MUST NOT modify the source.
Scenario A:   SOAP msg w/ encrypted data  customer.xml (no encryption) Authorization control Credit card info app SOAP msg 1.Select node 2.  Encrypt node (no replace)   and return to application 3. Form SOAP msg
Scenario A: SOAP message ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scenario A code Encrypting // Encrypt the content of the 2nd <CreditCard>/<Number> element nodeToBeEncrypted = XPathAPI.selectSingleNode(doc, &quot;//Customer[2]/CreditCard/Number&quot;); // Encrypt the nodes (whole elements are encrypted) Element elemEncryptedData =  xmlencEncryptor. encrypt ((Element)nodeToBeEncrypted, false,  getEncryptedDataTemplate(desKey, false), desKey); Document docSoap = new DocumentImpl(); Element elemEnvelope = docSoap.createElement(&quot;Envelope&quot;); Element elemBody = docSoap.createElement(&quot;Body&quot;); Element elemBodyChild = docSoap.createElement(&quot;VerifyCreditCardRequest&quot;); Node nodeImported = docSoap. importNode (elemEncryptedData, true); elemBodyChild.appendChild(nodeImported); elemBody.appendChild(elemBodyChild); elemEnvelope.appendChild(elemBody); docSoap.appendChild(elemEnvelope);
Scenario A code… Note: The preceding code works (uses IBM’s XSS4J) but, according to the spec, its illegal because the XML source is not being replaced.
Scenario B: Encrypted customer DB 1.Select <Encrypted Data>node 2.  Dencrypt node (no replace)   and return to application 3. Display info to authorized user  customer.xml   (encrypted) Credit card info app Interface to  authorized user Customer name N Ranjan Credit card# 0048
Scenario B code Decrypting // Get the nodes to be decrypted Element elemEncryptedDataToDecrypt = (Element) DOMUtil.getElementsByTagNameNS(doc, XEncryption.XMLENC_NS,  &quot;EncryptedData&quot;).item(5); Element elemIV = (Element) elemEncryptedDataToDecrypt.getElementsByTagName(&quot;IV&quot;).item(0); String strIV = elemIV.getFirstChild().getNodeValue(); Element elemCipherData = (Element) elemEncryptedDataToDecrypt.getElementsByTagName(&quot;CipherText&quot;).item(0); String strCipherData = elemCipherData.getFirstChild().getNodeValue(); javax.crypto.spec.IvParameterSpec ivparmspec = new  javax.crypto.spec.IvParameterSpec(com.ibm.xml.dsig.Base64.decode(strIV)); Cipher desCipher = Cipher.getInstance(&quot;DESede/CBC/PKCS5Padding&quot;); desCipher.init(Cipher.DECRYPT_MODE, desKey, ivparmspec); byte[] bytesPlainData = desCipher.doFinal(com.ibm.xml.dsig.Base64.decode(strCipherData)); String strCreditCardNumber = new String(bytesPlainData);
Scenario B code… Don’t want to use decryptAndReplace() because I don’t want to modify the XML source. But XML Encryption doesn’t allow Toolkits to give me an alternative so I have to use low-level security APIs instead! Rather, XML Encryption should allow Toolkits to return the decrypted XML element or content without requiring replacement in the source.
QAQ (Quietly Anticipated Questions) Question: Why not create a dummy document before and/or after encrypting? Answer:  Yes, one could create a dummy document and copy in the relevant elements before encrypting or decrypting and still conform to the XML Encryption spec as it currently stands. However, this would be inefficient and often inelegant. Question: The example code you showed doesn’t deal with more complex context situations such as inherited namespaces, default attributes, etc..  How will those artifacts affect the no-replacement processing of <EncryptedData> elements? Answer: I think this question will only be answered through more coding and application experience.  There could be some issues that arise .
ANY QUESTION??
THANK U

More Related Content

Similar to Xml encryption

Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18HUST
 
Significant Characteristics In Planets Manfred Thaller
Significant Characteristics In Planets Manfred ThallerSignificant Characteristics In Planets Manfred Thaller
Significant Characteristics In Planets Manfred ThallerDigitalPreservationEurope
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2borkweb
 
Struts2
Struts2Struts2
Struts2yuvalb
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Securityjemond
 
the next web now
the next web nowthe next web now
the next web nowzulin Gu
 
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskRichard Davis
 
Struts2 course chapter 2: installation and configuration
Struts2 course chapter 2: installation and configurationStruts2 course chapter 2: installation and configuration
Struts2 course chapter 2: installation and configurationJavaEE Trainers
 
Expanding a tree node
Expanding a tree nodeExpanding a tree node
Expanding a tree nodeHemakumar.S
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2wiradikusuma
 
Lecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITPLecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITPyucefmerhi
 
Aug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics IntegrationAug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics IntegrationMariAnne Woehrle
 
Application Security
Application SecurityApplication Security
Application Securityflorinc
 

Similar to Xml encryption (20)

Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18
 
Significant Characteristics In Planets Manfred Thaller
Significant Characteristics In Planets Manfred ThallerSignificant Characteristics In Planets Manfred Thaller
Significant Characteristics In Planets Manfred Thaller
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
Struts2
Struts2Struts2
Struts2
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
the next web now
the next web nowthe next web now
the next web now
 
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To Ask
 
Struts2 course chapter 2: installation and configuration
Struts2 course chapter 2: installation and configurationStruts2 course chapter 2: installation and configuration
Struts2 course chapter 2: installation and configuration
 
Expanding a tree node
Expanding a tree nodeExpanding a tree node
Expanding a tree node
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Lecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITPLecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITP
 
Aug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics IntegrationAug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics Integration
 
&lt;img src="xss.com">
&lt;img src="xss.com">&lt;img src="xss.com">
&lt;img src="xss.com">
 
Fav
FavFav
Fav
 
Struts2
Struts2Struts2
Struts2
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
 
Application Security
Application SecurityApplication Security
Application Security
 
ajax_pdf
ajax_pdfajax_pdf
ajax_pdf
 
ajax_pdf
ajax_pdfajax_pdf
ajax_pdf
 

Recently uploaded

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Xml encryption

  • 1. XML Encryption: Processing Rules for XML Elements and Content Nihar Ranjan Behera I/07/34
  • 2.
  • 3. Overview Note: I am not suggesting that XML Encryption specify an API design, absolutely NOT! However, I don’t want XML Encryption to unnecessarily restrict API designs either. Note 2: Slides with detailed code are included for completeness; they are not essential for understanding this topic.
  • 4. How the current Processing Rules work Original/Decrypted <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <Customers> <Customer> <Name>Jose Aznar</Name> <CreditCard> <Number> 1000 1234 5678 0001 </Number> <ExpiryDate> 2003 June 30 </ExpiryDate> </CreditCard> </Customer> . . . </Customers> Encrypted <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <Customers> <Customer> <Name> <EncryptedData…> </Name> <CreditCard> <Number> <EncryptedData…> </Number> <ExpiryDate> 2003 June 30 </ExpiryDate> </Customer> . . . </Customers>
  • 5. What the code looks like Encrypting // Encrypt the content of the <CreditCard>/<Number> elements NodeIterator ni2 = XPathAPI.selectNodeIterator(doc,&quot;//CreditCard/Number&quot;); // Encrypt the nodes (only element content is encrypted) while ((node = ni2.nextNode())!= null) { System.out.print(&quot;.&quot;); xmlencEncryptor. encryptAndReplace ((Element)node, true, getEncryptedDataTemplate(desKey, true), desKey); Decrypting // Get the nodes to be decrypted NodeList nl2 = DOMUtil.getElementsByTagNameNS( doc, XEncryption.XMLENC_NS, &quot;EncryptedData&quot;); // Decrypt for (int i = 0; i < nl2.getLength(); i++) { System.out.print(&quot;.&quot;); Element el = (Element)nl2.item(i); xmlencDecryptor. decryptAndReplace (el); }
  • 6. Other processing scenarios Scenario A: The XML source has no encrypted parts and is protected through authorization instead. However, there is an authorized app which selects certain credit card info for processing. It wants to query <CreditCard> elements and/or content, encrypt, and import the resulting <EncryptedData> element into a SOAP message. Scenario B: The XML source has encrypted elements and content accessible by a number of applications. When one of these applications queries an encrypted element, that app needs to decrypt the element but MUST NOT modify the source.
  • 7. Scenario A: SOAP msg w/ encrypted data customer.xml (no encryption) Authorization control Credit card info app SOAP msg 1.Select node 2. Encrypt node (no replace) and return to application 3. Form SOAP msg
  • 8.
  • 9. Scenario A code Encrypting // Encrypt the content of the 2nd <CreditCard>/<Number> element nodeToBeEncrypted = XPathAPI.selectSingleNode(doc, &quot;//Customer[2]/CreditCard/Number&quot;); // Encrypt the nodes (whole elements are encrypted) Element elemEncryptedData = xmlencEncryptor. encrypt ((Element)nodeToBeEncrypted, false, getEncryptedDataTemplate(desKey, false), desKey); Document docSoap = new DocumentImpl(); Element elemEnvelope = docSoap.createElement(&quot;Envelope&quot;); Element elemBody = docSoap.createElement(&quot;Body&quot;); Element elemBodyChild = docSoap.createElement(&quot;VerifyCreditCardRequest&quot;); Node nodeImported = docSoap. importNode (elemEncryptedData, true); elemBodyChild.appendChild(nodeImported); elemBody.appendChild(elemBodyChild); elemEnvelope.appendChild(elemBody); docSoap.appendChild(elemEnvelope);
  • 10. Scenario A code… Note: The preceding code works (uses IBM’s XSS4J) but, according to the spec, its illegal because the XML source is not being replaced.
  • 11. Scenario B: Encrypted customer DB 1.Select <Encrypted Data>node 2. Dencrypt node (no replace) and return to application 3. Display info to authorized user customer.xml (encrypted) Credit card info app Interface to authorized user Customer name N Ranjan Credit card# 0048
  • 12. Scenario B code Decrypting // Get the nodes to be decrypted Element elemEncryptedDataToDecrypt = (Element) DOMUtil.getElementsByTagNameNS(doc, XEncryption.XMLENC_NS, &quot;EncryptedData&quot;).item(5); Element elemIV = (Element) elemEncryptedDataToDecrypt.getElementsByTagName(&quot;IV&quot;).item(0); String strIV = elemIV.getFirstChild().getNodeValue(); Element elemCipherData = (Element) elemEncryptedDataToDecrypt.getElementsByTagName(&quot;CipherText&quot;).item(0); String strCipherData = elemCipherData.getFirstChild().getNodeValue(); javax.crypto.spec.IvParameterSpec ivparmspec = new javax.crypto.spec.IvParameterSpec(com.ibm.xml.dsig.Base64.decode(strIV)); Cipher desCipher = Cipher.getInstance(&quot;DESede/CBC/PKCS5Padding&quot;); desCipher.init(Cipher.DECRYPT_MODE, desKey, ivparmspec); byte[] bytesPlainData = desCipher.doFinal(com.ibm.xml.dsig.Base64.decode(strCipherData)); String strCreditCardNumber = new String(bytesPlainData);
  • 13. Scenario B code… Don’t want to use decryptAndReplace() because I don’t want to modify the XML source. But XML Encryption doesn’t allow Toolkits to give me an alternative so I have to use low-level security APIs instead! Rather, XML Encryption should allow Toolkits to return the decrypted XML element or content without requiring replacement in the source.
  • 14. QAQ (Quietly Anticipated Questions) Question: Why not create a dummy document before and/or after encrypting? Answer: Yes, one could create a dummy document and copy in the relevant elements before encrypting or decrypting and still conform to the XML Encryption spec as it currently stands. However, this would be inefficient and often inelegant. Question: The example code you showed doesn’t deal with more complex context situations such as inherited namespaces, default attributes, etc.. How will those artifacts affect the no-replacement processing of <EncryptedData> elements? Answer: I think this question will only be answered through more coding and application experience. There could be some issues that arise .