Skip to Content
Java Cryptography
book

Java Cryptography

by Jonathan Knudsen
May 1998
Intermediate to advanced
362 pages
10h 8m
English
O'Reilly Media, Inc.
Content preview from Java Cryptography

Gimme the Keys...

We can either generate keys for an identity or import them from a file. Generally speaking, you’ll generate key pairs for the signers you “own” and import public keys for everyone else. Marian, for example, will generate her own public and private keys. She, however, will import public keys for both Will Scarlet and Sheriff.

Let’s begin by generating a public and private key pair for Marian. We’ll use the -gk option, which can be abbreviated to -g. To generate the keys, we need to specify which public key cipher algorithm we wish to use. JDK 1.1 ships with support for the DSA algorithm, so that’s what we’ll use.

Finally, javakey needs to know how long to make the keys. This is the size, in bits, of the keys. Longer keys are more secure, but they take more time to create and use. You need to generate keys only once, though, so you might as well bite the bullet and generate longer keys. You probably won’t notice the extra time it takes to use a longer key. The DSA algorithm can generate keys of 512, 768, or 1024 bits.

C:\ javakey -gk Marian DSA 1024
Generated DSA keys for Marian (strength: 1024).

This is a lengthy process: You should probably kick this off and take a break while it chugs along.

When you generate the keys this way, they are stored in javakey’s internal database. If you want to store the keys by themselves in external files, you can specify the filenames at the end of the javakey command, like this:

C:\ javakey -gk Marian DSA 1024 public.x509 private.x509 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Hands-On Cryptography with Java

Hands-On Cryptography with Java

Erik Costlow
Java Security Handbook

Java Security Handbook

Jamie Jaworski, Paul J. Perrone, Venkata S.R. Krishna Chaganti

Publisher Resources

ISBN: 1565924029Errata Page