Y L F M A E T Team-Fly® XML Security This page intentionally left blank. XML Security Blake Dournaee McGraw-Hill New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto Copyright ©2002 by TheMcGraw-Hill Companies, Inc. All rights reserved. Manufactured in the United States of America. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher. 0-07-222808-3 The material in this eBook also appears in the print version of this title: 0-07-219399-9. All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trade- marked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps. McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corpo- rate training programs. For more information, please contact George Hoare, Special Sales, at [email protected] or (212) 904-4069. TERMSOFUSE This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGraw-Hill”) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create deriv- ative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw- Hill’s prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms. THE WORK IS PROVIDED “AS IS”. McGRAW-HILLAND ITS LICENSORS MAKE NO GUARANTEES OR WAR- RANTIES AS TO THE ACCURACY, ADEQUACYOR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANYINFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLYDISCLAIM ANYWARRANTY, EXPRESS OR IMPLIED, INCLUD- ING BUTNOTLIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITYOR FITNESS FOR APARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or other- wise. DOI: 10.1036/0072228083 Dedication To my family,who gave me endless inspiration and support About the Author Blake Dournaeejoined the developer support team of RSA Security in 1999,specializing in support and training for the BSAFE cryptography toolkits. He has a B.S. in computer science from California Polytechnic State University in San Luis Obispo and is currently a graduate student at the University of Massachusetts. For more information about this title, click here. Contents at a Glance Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 2 Security Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Chapter 3 XML Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Chapter 4 Introduction to XML Digital Signatures . . . . . . . . . . . . . 107 Chapter 5 Introduction to XML Digital Signatures Part 2 . . . . . . . . 147 Chapter 6 XML Signature Examples . . . . . . . . . . . . . . . . . . . . . . . . 193 Chapter 7 Introduction to XML Encryption . . . . . . . . . . . . . . . . . . 227 Chapter 8 XML Signature Implementation: RSA BSAFE©Cert-J . . . . 279 Chapter 9 XML Key Management Specification and the Proliferation of Web Services . . . . . . . . . . . . . . 333 Appendix Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 355 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 Copyright 2002 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use. This page intentionally left blank. For more information about this title, click here. Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii About the Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 2 Security Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Symmetric Ciphers (The Nature of the Crank) . . . . . . . . . . . . . . . . . . . . . . 7 Triple-DES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Padding and Feedback Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 AES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Symmetric Key Generation (The Nature of the Key) . . . . . . . . . . . . . . . . . . 15 Symmetric Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Asymmetric Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Introduction to the RSA Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Asymmetric Encryption with RSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 RSA Algorithm Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Case 1: “The Engineer” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Case 2: “The Theoretician” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 RSA Logistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 RSA Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Digital Envelopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Key Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Diffie-Hellman Key Agreement Logistics . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Digital Signature Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Hash Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 RSA Signature Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 DSA Signature Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 HMAC Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Prelude to Trust and Standardization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Raw Cryptographic Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Cryptographic Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Trust, Certificates, and Path Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Path Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Path Validation State Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Copyright 2002 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use.