Leanpub Header

Skip to main content

Java Cryptography: Tools and Techniques

Between the standard Java Runtime and the Bouncy Castle APIs there is a rich tool set of APIs to help work with the maze of standards and protocols needed for secure communication, storage and identity management. This book will help you navigate that maze and shine light into some of the darker corridors.

Minimum price

$16.00

$30.00

You pay

$30.00

Authors earn

$24.00
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
1,309
Readers
About

About

About the Book

Cryptography is about the security of communications. It provides mechanisms for hiding messages from outside observers, accurately identifying the originators of messages, determining that messages have been delivered safely without tampering, and making it possible to accurately identify both the entities receiving and sending messages when messages are being delivered between different parties.

Over time, in our increasingly connected world, issues related to cryptography and security have increasingly become common in the development of applications and even other APIs. In this environment, Java still maintains its popularity as a language for the development and implementation of Internet applications. While Java has an established API for basic cryptography defined as part of the regular Java runtime, many things that developers generally need to do, such as producing and managing certificates, client credentials, time stamps, and secure messaging are not provided. The Legion of the Bouncy Castle Cryptography APIs were developed to fill a large part of this gap. That said, there is an awful lot to know, and many developers do not get the time to take a sabbatical to brush up on the right security API to use when a security related application arrives on their desk. While falling into fear and panic is always an option, we felt it might be better to provide a book, drawing on our experience, that goes beyond what is commonly available in API documentation. A book that provides some basic real world examples of how to use the APIs and address the questions developers most commonly ask and the issues developers most commonly have trouble with. One with a warm friendly cover, designed to avoid panic, and to help keep the reader focused on the idea of getting a job done. It is our aim that "Java Cryptography: Tools and Techniques" is that book.

Share this book

Author

About the Authors

David Hook

David Hook is an active developer and co-founder of the Bouncy Castle cryptography project, now in its 23rd year, and has been working with the Java Cryptography APIs since their original publication in the late 1990s. In addition to his development work with Bouncy Castle, David has also given presentations and tutorials on the Java Cryptography framework and on the use of the Bouncy Castle APIs, as well as writing several articles, a previous book "Beginning Cryptography with Java" and the mini-ebook "BC FIPS in 100 Examples". He currently works at Keyfactor supporting the use and development of the Bouncy Castle APIs and has recently lead the "charge" which resulted in a version of the APIs being certified for FIPS 140-2. He is a member of the Association of Computing Machinery and the IEEE.

Jon Eaves

Jon has more than 25 years of experience constructing software, he has built software in a wide range of domains, from controlling hardware to payroll systems and the standard consumer centric web applications. Jon is particularly interested in software design and how to influence teams in building good software, the latter which takes up more and more of his time. 

On most days you will find Jon riding one of his bikes, drinking coffee at the local cafe and being heckled by colleagues as he wistfully remembers the time he spent all day, every day writing code. 

Contents

Table of Contents

Acknowledgements

Introduction

Chapter 1: Getting Started, an Overview

  1. The Java Provider Architecture
  2. Architecture of the Bouncy Castle APIs
  3. The Supporting APIs
  4. The Bouncy Castle FIPS distribution
  5. Installing Bouncy Castle
  6. A Word About Entropy
  7. Bits of Security
  8. Summary

Chapter 2: Block and Stream Ciphers

  1. The Basics
  2. Algorithm Security Strengths
  3. Block Ciphers
  4. Block Modes
  5. Streaming Block Modes
  6. Stream Ciphers
  7. Cipher Based Input/Output
  8. Summary

Chapter 3: Message Digests, MACs, HMACs, KDFs, and XOFs

  1. Message Digests
  2. MACs
  3. HMACs
  4. Key Derivation Functions
  5. Expandable Output Functions
  6. Bouncy Castle Calculator Interfaces for Digests and MACs
  7. An Application of Digests: Merkle Trees
  8. Summary

Chapter 4: Authenticated Modes, Key Wrapping, and the SealedObject

  1. Setup for the Examples
  2. Authenticated Encryption Modes
  3. Key Wrapping Algorithms
  4. The SealedObject Class
  5. Summary

Chapter 5: Password Based Key Generation and Key Splitting

  1. Password Based Key Generation
  2. PKCS5 Scheme 2
  3. SCRYPT
  4. Other PBKDFs
  5. Key Splitting
  6. An Implementation of Key Splitting
  7. Summary

Chapter 6: Signatures

  1. Key Pair Generation and Import
  2. Digital Signatures
  3. Signature Security Strengths
  4. The Digital Signature Algorithm
  5. DSA with Edwards Curves (EdDSA)
  6. DSTU 4145
  7. GOST
  8. RSA Signature Algorithms
  9. SM2
  10. Bouncy Castle Calculator Interfaces for Signatures
  11. Summary

Chapter 7: Key Transport, Key Agreement, and Key Exchange

  1. Algorithm Security Strengths
  2. Key Transport
  3. Key Agreement and Key Exchange
  4. Key Confirmation
  5. Summary

Chapter 8: X.509 Certificates and Attribute Certificates

  1. The X.500 Distinguished Name
  2. Public Key Certificates
  3. Creating a Basic Public Key Certificate
  4. Converting an X509CertificateHolder to an X509Certificate
  5. The CertificateFactory Class
  6. Creating a CA Certificate with Extensions
  7. Creating End-Entity Certificates
  8. Attribute Certificates
  9. Summary

Chapter 9: Certificate Revocation and Certificate Paths

  1. Certificate Revocation Lists (CRLs)
  2. Converting an X509CRLHolder to an X509CRL
  3. Obtaining Revocation Information from a Certificate Issuer
  4. Online Certificate Status Protocol
  5. Certificate Path Validation
  6. Summary

Chapter 10: Key and Certificate Storage

  1. Setup for the Examples
  2. Early KeyStore Types: JKS, JCEKS, BKS, and UBER
  3. The keytool Command
  4. The PKCS12 KeyStore Type
  5. The BCFKS/BCSFKS KeyStore Type
  6. Summary

Chapter 11: Cryptographic Message Syntax, S/MIME, and TSP

  1. Cryptographic Message Syntax
  2. Data Content
  3. SignedData Content
  4. EnvelopedData Content
  5. S/MIME
  6. Things to Watch With JavaMail
  7. Time-Stamp Protocol
  8. An Application of Time-Stamps: CAdES-T
  9. Summary

Chapter 12: Certification Requests and Certificate Management

  1. PKCS #10 Certification Requests
  2. Certificate Request Message Format
  3. Certificate Management over CMS
  4. Enrolment over Secure Transport
  5. Certificate Management Protocol
  6. Summary

Chapter 13: OpenPGP

  1. The Basics
  2. Generating Armored Output
  3. Generating Key Rings
  4. Adding a Sub-Key to an Existing Key Ring
  5. Encapsulated Signed Messages
  6. Detached Signatures
  7. Signing Text Data
  8. Cleartext Signatures
  9. Public Key Encryption
  10. PBE Encryption
  11. Keybox Files
  12. Using S-expressions for Private Keys
  13. Summary

Chapter 14: Transport Layer Security

  1. Introduction
  2. Installation
  3. Conventions
  4. Some Preparation - a Simple Protocol
  5. A Basic TLS Server
  6. A Basic TLS Client
  7. Using Client-Side Authentication
  8. Another Look a TrustManagers
  9. Properties
  10. BC JSSE Extensions
  11. Using the low level (D)TLS API
  12. The Low-level TLS API
  13. DTLS
  14. Low-level TLS API Overrides
  15. Specialist Protocols: PSK and SRP
  16. Summary

Chapter 15: The Future

  1. Installing the Bouncy Castle Post-Quantum Provider
  2. Stateful Signature Algorithms
  3. Stateless Signature Algorithms
  4. Key Encapsulation Mechanisms
  5. Hybrid Encryption
  6. Summary

Appendix A: ASN.1 and Bouncy Castle

  1. Basic ASN.1 Syntax
  2. The Types
  3. Encoding Rules
  4. Basic Guidance
  5. Defining Your Own Objects

Appendix B: The Bouncy Castle Kotlin API

  1. A Note on Packaging
  2. Generating a PKCS#10 Certification Request
  3. Generating a Certificate

Appendix C: Algorithms provided by the Bouncy Castle Providers

Acronyms and Definitions

Bibliography and Further Reading

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub