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

Keys

The java.security.Key interface encapsulates a cryptographic key. It defines only three methods:

public String getAlgorithm()

This method returns the name of the cryptographic algorithm for which this key is used. An example is DSA, the Digital Signature Algorithm.

public byte[] getEncoded()

You can retrieve the encoded value of the key by calling this method. Encoding is a process of mapping the key’s value into an array of bytes. The getFormat() method will return the name of the format used to encode the key.

public String getFormat()

This method returns the name of the format used to encode the key. An example is X.509.

Several interfaces extend the Key interface. These child interfaces define different flavors of keys, but none of them defines any additional methods; they are used for clarity and type safety. As we saw in Chapter 2, keys are used differently for symmetric ciphers, asymmetric ciphers, and signatures. Semantic extensions to the Key interfaces keep the concepts clear. In the JDK, there are two such interfaces:

java.security.PublicKey

This interface represents the public key of a key pair, suitable for use with a signature or an asymmetric cipher (see Chapter 6, and Chapter 7, respectively). When used with a signature, a PublicKey is used to verify a signature (see initVerify() in the Signature class).

java.security.PrivateKey

This interface represents the other half of a key pair. Just like a public key, a private key can be used with a signature or an ...

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