RSA Implementation using java.math.BigInteger Class
This chapter provides tutorial notes and example codes on RSA implementation using Java BigInteger class. Topics include introduction of the java.math.BigInteger class; generating large probable prime numbers; generating RSA public key and private key; validating RSA keys; determining cleartext and ciphertext block sizes; padding last block of cleartext; implementing RSA encryption and decryption operations.
These sections are omitted from this Web preview version. To view the full content,
see information on how to obtain the full version this book.
Generating Prime Number with BigInteger Class
Performance of Prime Number Generation
RSA Encryption Implementation using BigInteger Class
RsaKeyGenerator.java for RSA Key Generation
RSA Keys Generated by RsaKeyGenerator.java
RsaKeyValidator.java for RSA Key Validation
64-bit RSA Key Validated by RsaKeyValidator.java
Converting Byte Sequences to Positive Integers
Cleartext Block Size for RSA Encryption
Cleartext Message Padding and Revised Block Size
Ciphertext Block Size for RSA Encryption
RsaKeyEncryption.java for RSA Encryption Operation
RsaKeyDecryption.java for RSA Decryption Operation
Testing RsaKeyEncryption.java with a 16-bit Key
Testing RsaKeyEncryption.java with a 64-bit Key
Testing RsaKeyEncryption.java with a 3072-bit Key
- java.math.BigInteger class is designed to offer you
enough methods to build a full solution for RSA public key encryption.
- The probablePrime() method can be used to generate very large positive probable prime numbers.
The probability of generated numbers are prime numbers is 100-100/(2**100) percent.
- The gcd() method can be used to calculate the greatest common divisor
for coprime number generation.
- The modInverse() method can be used to calculate the private key from the public key.
- The modPow() method can be used to carry out the RSA encryption and decryption operations.
- Cleartext block size can be set to "min(floor((RsaKeySize-1)/8), 256)".
- The block of cleartext can be padded using the same idea as the PKCS5Padding schema.
- Ciphertext block size can be set to "1+floor((RsaKeySize-1)/8)".
- A simple full implementation of RSA public key algorithm is presented using the java.math.BigInteger class.
- The implementation passed tests with RSA keys up to 3072 bits.
Table of Contents
About This Book
Cryptography Basic Concepts
Introduction to AES (Advanced Encryption Standard)
Introduction to DES Algorithm
DES Algorithm - Illustrated with Java Programs
DES Algorithm Java Implementation
DES Algorithm - Java Implementation in JDK JCE
DES Encryption Operation Modes
DES in Stream Cipher Modes
PHP Implementation of DES - mcrypt
Blowfish - 8-Byte Block Cipher
Secret Key Generation and Management
Cipher - Secret Key Encryption and Decryption
Introduction of RSA Algorithm
►RSA Implementation using java.math.BigInteger Class
Introduction of DSA (Digital Signature Algorithm)
Java Default Implementation of DSA
Private key and Public Key Pair Generation
PKCS#8/X.509 Private/Public Encoding Standards
Cipher - Public Key Encryption and Decryption
MD5 Mesasge Digest Algorithm
SHA1 Mesasge Digest Algorithm
OpenSSL Introduction and Installation
OpenSSL Generating and Managing RSA Keys
OpenSSL Managing Certificates
OpenSSL Generating and Signing CSR
OpenSSL Validating Certificate Path
"keytool" and "keystore" from JDK
"OpenSSL" Signing CSR Generated by "keytool"
Migrating Keys from "keystore" to "OpenSSL" Key Files
Certificate X.509 Standard and DER/PEM Formats
Migrating Keys from "OpenSSL" Key Files to "keystore"
Using Certificates in IE
Using Certificates in Google Chrome
Using Certificates in Firefox
Full Version in PDF/EPUB