com.didisoft.pgp
Class KeyStore

java.lang.Object
  extended by com.didisoft.pgp.KeyStore
All Implemented Interfaces:
java.io.Serializable

public class KeyStore
extends java.lang.Object
implements java.io.Serializable

Represents an OpenPGP Key Store.

The KeyStore file contains both the public and secret key rings combined in one file and protected with password.
' (In PGP (r) and GnuPG they are stored in two different files)

It can be used with PGPLib in cases that require KeyStore parameter, or alone when only KeyStore or key generation operations are required.

See Also:
Serialized Form

Field Summary
static java.lang.String DSA
          DSA Algorithm constant, implementation of DH/DSS (signature)
static java.lang.String EC
          Elliptic Curve cryptography (ECC) in OpenPGP
static java.lang.String ELGAMAL
          ElGamal Algorithm constant, implementation of DH/DSS (encryption)
static java.lang.String RSA
          RSA Algorithm constant
 
Constructor Summary
KeyStore()
          Creates a new Key Store object stored in-memory.
KeyStore(java.lang.String keystoreFileName, java.lang.String keystorePassword)
          Creates a new Key Store object backed by a file.
 
Method Summary
 void addCertification(long keyId, long certKeyId, java.lang.String certPassword, java.lang.String userID)
          Appends certification to a given OpenPGP key in the key store.
 void addUserId(long keyId, java.lang.String privateKeyPassword, java.lang.String newUserId)
          Appends an additional User Id signature to a key contained in this key store.
 void changePrimaryUserId(long keyId, java.lang.String privateKeyPassword, java.lang.String newUserId)
          Changes the primary (first) user Id signature of a key with a new user Id


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.
 void changePrivateKeyPassword(long keyId, java.lang.String oldPassword, java.lang.String newPassword)
          Changes private key password.
 boolean changePrivateKeyPassword(java.lang.String userId, java.lang.String oldPassword, java.lang.String newPassword)
          Changes private key password.
 boolean changeUserId(long keyId, java.lang.String privateKeyPassword, java.lang.String oldUserId, java.lang.String newUserId)
          Changes an existing user Id signature of a key with a new user Id


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.
static boolean checkPassword(java.lang.String keystoreFileName, java.lang.String password)
          Checks if a password for a key store file is correct Example usage:
 boolean containsKey(long keyId)
          Returns true if a public or private key with the specified Key Id exists in this KeyStore

Example:
 boolean containsKey(java.lang.String userId)
          Returns true if public or private key with the specified User ID exists in this KeyStore

Example:
 boolean containsPrivateKey(long keyId)
          Returns true if a private key with the specified Key Id exists in this KeyStore

Example:
 boolean containsPrivateKey(java.lang.String userId)
          Returns true if a private key with the specified User ID exists in this KeyStore

Example:
 boolean containsPublicKey(long keyId)
          Returns true if a public key with the specified Key Id exists in this KeyStore

Example:
 boolean containsPublicKey(java.lang.String userId)
          Returns true if a public key with the specified User ID exists in this KeyStore

Example:
 void deleteKeyPair(long keyId)
          Deletes public and private key pair from this key store that have the specified Key Id.
 boolean deleteKeyPair(java.lang.String userId)
          Deletes the first public and private key pair from this key store that have the specified User Id.
 boolean deletePrivateKey(long keyId)
          Deletes the first private key with the specified User Id from this KeyStore.
 boolean deletePrivateKey(java.lang.String userId)
          Deletes the first private key with the specified User Id from this KeyStore.
 boolean deletePublicKey(long keyId)
          Deletes the first public key with the specified Key Id from this KeyStore.
 boolean deletePublicKey(java.lang.String userId)
          Deletes the first public key with the specified User Id from this KeyStore.
 boolean deleteUserId(long keyId, java.lang.String userId)
          Removes a user Id signature from a key


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.
 void exportKeyRing(java.io.OutputStream outputStream, long keyId, boolean asciiArmor)
          Exports Key ring (both public and private key) located in this Key store into a stream.
 void exportKeyRing(java.io.OutputStream outputStream, java.lang.String userId, boolean asciiArmor)
          Exports Key ring (both public and private key) located in this Key store into a stream.
 void exportKeyRing(java.lang.String fileName, long keyId, boolean asciiArmor)
          Exports Key ring (both public and private key) located in this Key store in one file.
 void exportKeyRing(java.lang.String fileName, java.lang.String userId)
          Exports Key ring (both public and private key) located in this Key store in one file.
 void exportKeyRing(java.lang.String fileName, java.lang.String userId, boolean asciiArmor)
          Exports Key ring (both public and private key) located in this Key store in one file.
 void exportPrivateKey(java.io.OutputStream outputStream, long keyId, boolean asciiArmored)
          Exports a private key from this KeyStore instance into a stream.
 void exportPrivateKey(java.io.OutputStream outputStream, java.lang.String userId, boolean asciiArmored)
          Exports a private key from this OpenPGP key store into a stream.
 void exportPrivateKey(java.lang.String fileName, long keyId, boolean asciiArmored)
          Exports private key from this KeyStore instance, into a file.
 void exportPrivateKey(java.lang.String fileName, java.lang.String userId, boolean asciiArmored)
          Exports private key from this OpenPGP key store, into a file.
 void exportPublicKey(java.io.OutputStream outputStream, long keyId, boolean asciiArmored)
          Exports public key from this KeyStore instance into a file.
 void exportPublicKey(java.io.OutputStream outputStream, java.lang.String userId, boolean asciiArmored)
          Exports a public key from this KeyStore instance into a stream.
 void exportPublicKey(java.lang.String fileName, long keyId, boolean asciiArmored)
          Exports public key from this KeyStore instance into a file.
 void exportPublicKey(java.lang.String fileName, java.lang.String userId, boolean asciiArmored)
          Exports a public key from this KeyStore instance into a file.
 KeyPairInformation generateEccKeyPair(java.lang.String ecCurve, java.lang.String userId, java.lang.String privateKeyPassword)
          Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Default algorithms for the key are:
Symmetric cipher: AES-256, AES-192, AES-128
Hash: SHA-512, SHA-384, SHA-256
Compression: ZIP, ZLIB, BZIP2, Uncompressed
 KeyPairInformation generateEccKeyPair(java.lang.String ecCurve, java.lang.String userId, java.lang.String privateKeyPassword, long expirationAfterDays)
          Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Default algorithms for the key are:
Symmetric cipher: AES-256, AES-192, AES-128
Hash: SHA-512, SHA-384, SHA-256
Compression: ZIP, ZLIB, BZIP2, Uncompressed
 KeyPairInformation generateEccKeyPair(java.lang.String ecCurve, java.lang.String userId, java.lang.String privateKeyPassword, java.lang.String[] compressionTypes, java.lang.String[] hashingAlgorithmTypes, java.lang.String[] cipherTypes)
          Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Note: The generated key pair has no expiration date
 KeyPairInformation generateEccKeyPair(java.lang.String ecCurve, java.lang.String userId, java.lang.String privateKeyPassword, java.lang.String[] compressionTypes, java.lang.String[] hashingAlgorithmTypes, java.lang.String[] cipherTypes, long expirationAfterDays)
          Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm
 KeyPairInformation generateElGamalKeyPair(int keySize, java.lang.String userId, java.lang.String password)
          Generates OpenPGP Key pair with ElGamal (DH/DSS) encryption and predefined values for compression, hashing and cypher like the ones generated with PGP Desktop(tm) key generation wizard.
 KeyPairInformation generateKeyPair(int keySize, java.lang.String userId, java.lang.String password)
          Generates OpenPGP Key pair with RSA encryption and predefined values for compression, hashing and cypher like the ones generated with PGP Desktop(tm) key generation wizard.
 KeyPairInformation generateKeyPair(int keySize, java.lang.String userId, java.lang.String keyAlgorithm, java.lang.String password, java.lang.String[] compressionTypes, java.lang.String[] hashingAlgorithmTypes, java.lang.String[] cipherTypes)
          Generates OpenPGP key pair (public and private key).
 KeyPairInformation generateKeyPair(int keySize, java.lang.String userId, java.lang.String keyAlgorithm, java.lang.String password, java.lang.String[] compressionTypes, java.lang.String[] hashingAlgorithmTypes, java.lang.String[] cipherTypes, long expirationAfterDays)
          Generates OpenPGP key pair (public and private key).
 KeyPairInformation generateKeyPair(int keySize, java.lang.String userId, java.lang.String keyAlgorithm, java.lang.String password, java.lang.String compressionTypes, java.lang.String hashingAlgorithmTypes, java.lang.String cipherTypes)
          Generates OpenPGP Key pair (public and private key).
 KeyPairInformation generateKeyPair(int keySize, java.lang.String userId, java.lang.String keyAlgorithm, java.lang.String password, java.lang.String compressionTypes, java.lang.String hashingAlgorithmTypes, java.lang.String cipherTypes, long expirationAfterDays)
          Generates OpenPGP Key pair (public and private key).
 KeyPairInformation generateRsaKeyPair(int keySize, java.lang.String userId, java.lang.String password)
          Generates OpenPGP Key pair with RSA encryption and predefined values for compression, hashing and cypher like the ones generated with PGP Desktop(tm) key generation wizard.
 java.lang.String getAsciiVersionHeader()
          Returns the Version comment text that is printed in ASCII armored output
 KeyPairInformation getKey(long keyId)
          Returns the key pair with the specified Key Id
 KeyPairInformation getKey(java.lang.String userId)
          Returns the key pair with the specified User Id
 java.lang.String[] getKeyHexIds()
          Returns array of Hexadecimal string representation of the key Id's for the keys contained in this KeyStore instance.
 long getKeyIdForKeyIdHex(java.lang.String keyIdHex)
          Returns the real Key ID (of type long) corresponding to this Hexadecimal Key Id.
 long getKeyIdForUserId(java.lang.String userId)
          Returns the real Key ID (of type long) corresponding to this User Id.
 KeyPairInformation[] getKeys()
          Returns the key pairs stored in this OpenPGP key store.
 java.lang.String getKeystoreFileName()
          Returns this Key store file name (absolute or relative path)
 java.lang.String getKeystorePassword()
          Returns The password of this KeyStore
 PGPPublicKeyRingCollection getRawPublicKeys()
          Raw access to the secret keys contained in this KeyStore
 PGPSecretKeyRingCollection getRawSecretKeys()
          Raw access to the secret keys contained in this KeyStore
 boolean getUsePrecomputedPrimes()
          Returns will the key generation use build in precomputed primes.
 java.lang.String[] getUserIds()
          Returns array of Strings representing all user Id's contained in this KeyStore instance.
 KeyPairInformation[] importKeyRing(java.io.InputStream keyStream)
          Imports OpenPGP key ring stream into this KeyStore instance.
 KeyPairInformation[] importKeyRing(java.io.InputStream keyStream, java.lang.String privateKeyPassword)
          Imports OpenPGP key ring stream into this KeyStore instance.
 KeyPairInformation[] importKeyRing(java.lang.String keyRingFileName)
          Imports OpenPGP key ring into this KeyStore instance.
 KeyPairInformation[] importKeyRing(java.lang.String keyRingFileName, java.lang.String privateKeyPassword)
          Imports OpenPGP key ring into this KeyStore instance.
 KeyPairInformation[] importKeyStore(KeyStore keyStore)
          Imports the keys contained in another KeyStore object into the current instance.
 KeyPairInformation[] importPrivateKey(java.io.InputStream privateKeyStream)
          Imports private key stream into this KeyStore instance.
 KeyPairInformation[] importPrivateKey(java.io.InputStream privateKeyStream, java.lang.String password)
          Imports private key stream into this KeyStore instance.
 KeyPairInformation[] importPrivateKey(java.lang.String privateKeyFileName)
          Imports a private key file into this KeyStore instance.
 KeyPairInformation[] importPrivateKey(java.lang.String privateKeyFileName, java.lang.String password)
          Imports private key file into this KeyStore instance.
 KeyPairInformation[] importPublicKey(java.io.InputStream publicKeyStream)
          Imports an OpenPGP public key into this KeyStore instance.
 KeyPairInformation[] importPublicKey(java.lang.String publicKeyFileName)
          Imports an OpenPGP public key into this KeyStore instance.
 void importPublickKey(java.lang.String publicKeyFileName)
          Deprecated. Replaced by importPublicKey(String)
 boolean isAutoSave()
          Returns is auto save on.
 boolean isBackupOnSave()
          Returns should backups be made on save.
 boolean isInMemory()
          Indicates is this KeyStore instance stored in-memory
 boolean isPartialMatchUserIds()
          Returns can Key User ID parameters be specified with part of the User ID (true) or with the whole User ID (false)
 boolean isSkipLucasLehmerPrimeTest()
          Will Lucas-Lehmer prime number check be skipped when generating prime numbers for ElGamal keys.
 boolean isTrusted(long keyId)
          Returns is a public key with the supplied Key Id trusted in this key store.
 boolean isTrusted(java.lang.String keyUserId)
          Returns is a public key with the supplied Key User Id trusted in this key store.
 KeyPairInformation[] listKeys()
          Lists keys stored in this OpenPGP key store to the System.out

Example:
 void loadFromStream(java.io.InputStream keystoreStream)
          Loads the KeyStore data from a stream, where it has been stored previously
 void loadFromStream(java.io.InputStream keysStream, java.lang.String password)
          Loads the KeyStore data from a stream, where it has been stored previously.
static KeyStore openFile(java.lang.String filename, java.lang.String password)
          Initializes a new Key Store object.
static KeyStore openInMemory()
          Creates a new in-memory KeyStore instance.
 void purge()
          Clears the internal state of this key store.
 void save()
          Saves the backing file of this KeyStore instance to disk.
 void saveToStream(java.io.OutputStream keystoreStream)
          Saves the key store data to a stream
The KeyStore is stored unprotected with a password
 void setAsciiVersionHeader(java.lang.String creator)
          Sets the Version comment text that is printed in ASCII armored output

Example usage:
 void setAutoSave(boolean save)
          Sets the KeyStore to call save() automatically after each operation that modifies it (for example import key, delete key, etc.)
 void setBackupOnSave(boolean backupOnSave)
          Sets backup file be created (with extension .bak) for this KeyStore on save() operations.
 void setPartialMatchUserIds(boolean partialMatch)
          Sets whether the library will use precomputed prime numbers for key generation
 void setSkipLucasLehmerPrimeTest(boolean skipLucasLehmerPrimeTest)
          Sets should Lucas-Lehmer prime number check be skipped when generating prime numbers for ElGamal keys
 void setTrust(long keyId, byte trustValue)
          Sets an internal trust value for a public key, valid only in this KeyStore instance

PGP command line (r) equivalent:
pgp --set-trust keyId --trust trustValue
 void setTrust(java.lang.String keyUserId, byte trustValue)
          Sets an internal trust value for a public key, valid only in this KeyStore instance

PGP command line (r) equivalent:
pgp --set-trust keyUserId --trust trustValue
 void setUsePrecomputedPrimes(boolean usePrecomputedPrimes)
          Sets whether the library will use precomputed prime numbers for key generation
 void signPublicKey(long keyId, long signKeyId, java.lang.String signPassword)
          Signs a public key with a private key.
 void signPublicKey(java.lang.String keyUserId, java.lang.String signKeyUserId, java.lang.String signPassword)
          Signs a public key with a private key.
 void signPublicKeyAsTrustedIntroducer(long keyId, long signKeyId, java.lang.String signPassword)
          Signs a public key as trusted introducer

When you import keys into your KeyStore and are sure that the trusted third party is really the person they claim to be, you can sign his/her keys.
 void signPublicKeyAsTrustedIntroducer(java.lang.String keyUserId, java.lang.String signKeyUserId, java.lang.String signPassword)
          Signs a public key as a trusted introducer with a private key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELGAMAL

public static final java.lang.String ELGAMAL
ElGamal Algorithm constant, implementation of DH/DSS (encryption)

See Also:
Constant Field Values

DSA

public static final java.lang.String DSA
DSA Algorithm constant, implementation of DH/DSS (signature)

See Also:
Constant Field Values

RSA

public static final java.lang.String RSA
RSA Algorithm constant

See Also:
Constant Field Values

EC

public static final java.lang.String EC
Elliptic Curve cryptography (ECC) in OpenPGP

See Also:
Constant Field Values
Constructor Detail

KeyStore

public KeyStore()
Creates a new Key Store object stored in-memory.


KeyStore

public KeyStore(java.lang.String keystoreFileName,
                java.lang.String keystorePassword)
         throws java.io.IOException,
                PGPException
Creates a new Key Store object backed by a file.
NOTE: If the key store file does not exist, it will be created on first key manipulation operation.

Parameters:
keystoreFileName - File name of the Key store (absolute or relative path)
keystorePassword - Password for the Key store.
Throws:
java.io.IOException - if an I/O error occurs
PGPException - error decoding KeyStore data
{@link - WrongPasswordException} of the password of the KeyStore is wrong
Method Detail

openFile

public static KeyStore openFile(java.lang.String filename,
                                java.lang.String password)
                         throws PGPException,
                                java.io.IOException
Initializes a new Key Store object.
NOTE: The Key store file may not exist, it will be created on first key manipulation operation.

Parameters:
filename - File name of the Key store (absolute or relative path)
password - Password for the Key store.
Returns:
initialized KeyStore object
Throws:
PGPException - if an error occurs decrypting the KeyStore contents
java.io.IOException - if an I/O error occurs

openInMemory

public static KeyStore openInMemory()
Creates a new in-memory KeyStore instance.

Returns:
initialized KeyStore object

purge

public void purge()
           throws PGPException
Clears the internal state of this key store.

All existing keys already contained in this key store are deleted permanently.

Throws:
PGPException - error saving the key store

loadFromStream

public void loadFromStream(java.io.InputStream keysStream,
                           java.lang.String password)
                    throws java.io.IOException,
                           PGPException
Loads the KeyStore data from a stream, where it has been stored previously.
Note: The current KeyStore data is erased after this operation. If your intention is to append new keys, please use importKeyRing(InputStream) or importKeyStore(KeyStore)

Parameters:
keystoreStream - Input stream with keys,
can be a KeyStore serialized with saveToStream(OutputStream), a KeyStore file stream, or a stream obtained from .asc files or PGP(r)/GnuPGP .pkr and .skr keyring files
password - Password if the KeyStore was previously protected with a password
Throws:
java.io.IOException - in case of an I/O error
PGPException - error decrypting the KeyStore data

loadFromStream

public void loadFromStream(java.io.InputStream keystoreStream)
                    throws java.io.IOException,
                           PGPException
Loads the KeyStore data from a stream, where it has been stored previously

Parameters:
keystoreStream - KeyStore input stream
Throws:
java.io.IOException - in case of an I/O error
PGPException - error decrypting the KeyStore data

saveToStream

public void saveToStream(java.io.OutputStream keystoreStream)
                  throws java.io.IOException
Saves the key store data to a stream
The KeyStore is stored unprotected with a password

Parameters:
keystoreStream - key store output stream
Throws:
java.io.IOException - in case of an I/O error

isPartialMatchUserIds

public boolean isPartialMatchUserIds()
Returns can Key User ID parameters be specified with part of the User ID (true) or with the whole User ID (false)

Returns:
can Key User ID parameters be specified with part of the User ID (true) or with the whole User ID (false)
Since:
2.6.1
See Also:
setPartialMatchUserIds(boolean)

setPartialMatchUserIds

public void setPartialMatchUserIds(boolean partialMatch)
Sets whether the library will use precomputed prime numbers for key generation

Parameters:
partialMatch - if true, Key User ID parameters can be specified with part of the User ID when false the whole User ID must be specified
Since:
2.6.1
See Also:
isPartialMatchUserIds()

getUsePrecomputedPrimes

public boolean getUsePrecomputedPrimes()
Returns will the key generation use build in precomputed primes.

Returns:
will the key generation use build in precomputed primes.
Since:
2.5.9
See Also:
setUsePrecomputedPrimes(boolean)

setUsePrecomputedPrimes

public void setUsePrecomputedPrimes(boolean usePrecomputedPrimes)
Sets whether the library will use precomputed prime numbers for key generation

Parameters:
usePrecomputedPrimes - if true, the library will use precomputed prime numbers, when false the library will generate prime numbers for each new key pair
Since:
2.5.9
See Also:
getUsePrecomputedPrimes()

isInMemory

public boolean isInMemory()
Indicates is this KeyStore instance stored in-memory

Returns:
if true this instance is store in-memory, when false it is backed by a file

getAsciiVersionHeader

public java.lang.String getAsciiVersionHeader()
Returns the Version comment text that is printed in ASCII armored output

Returns:
Version comment text printed in ASCII armored output
See Also:
setAsciiVersionHeader(String)

setAsciiVersionHeader

public void setAsciiVersionHeader(java.lang.String creator)
Sets the Version comment text that is printed in ASCII armored output

Example usage:
 KeyStore ks = new KeyStore();
 ks.setAsciiVersionHeader("My Application 1.1"); 
 // Now in ASCII armored output will be printed "Version: My Application 1.1"  
 

Parameters:
creator - Program name and version that will be written in ASCII armored output Version: field

getRawSecretKeys

public PGPSecretKeyRingCollection getRawSecretKeys()
Raw access to the secret keys contained in this KeyStore

Returns:
secret keys contained in this KeyStore

getRawPublicKeys

public PGPPublicKeyRingCollection getRawPublicKeys()
Raw access to the secret keys contained in this KeyStore

Returns:
secret keys contained in this KeyStore

checkPassword

public static boolean checkPassword(java.lang.String keystoreFileName,
                                    java.lang.String password)
                             throws java.io.IOException
Checks if a password for a key store file is correct Example usage:
 boolean passwordIsCorrect = KeyStore.checkPassword("c:\\java_pgp.keystore", password);
 

Parameters:
keystoreFileName - File name of the KeyStore (absolute or relative path)
password - password for the KeyStore
Returns:
true if the password is correct, false otherwise
Throws:
java.io.IOException - If the file does not exist or an I/O error occur

getUserIds

public java.lang.String[] getUserIds()
Returns array of Strings representing all user Id's contained in this KeyStore instance.

Returns:
array of Strings representing all user Id's contained in this KeyStore instance

getKeyHexIds

public java.lang.String[] getKeyHexIds()
Returns array of Hexadecimal string representation of the key Id's for the keys contained in this KeyStore instance.

This hexadecimal value is composed of the lower four bytes of the real key Id (8 bytes) and is the same as the one displayed by PGP (r) and GnuPG.

Returns:
array of Hexadecimal string representation of the key Id's for the keys contained in this KeyStore instance

getKeyIdForUserId

public long getKeyIdForUserId(java.lang.String userId)
Returns the real Key ID (of type long) corresponding to this User Id.

Parameters:
userId - User Id of the key owner.
Returns:
the real Key ID (of type long) corresponding to this User Id. If there is no key with such User Id -1 is returned.

getKeyIdForKeyIdHex

public long getKeyIdForKeyIdHex(java.lang.String keyIdHex)
Returns the real Key ID (of type long) corresponding to this Hexadecimal Key Id.

This example shows how to get the real key Id of type long for given hex key.
 import com.didisoft.pgp.KeyStore;
 
 public class KeyIdHexDemo {
  public static void main(String[] args) throws Exception{
    // initialize a KeyStore instance
    KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
    
    // get the key id corresponding to this hexadecimal key id 
    String hexKeyId = "74BB3286";               
    long keyId = keyStore.getKeyIdForKeyIdHex(hexKeyId);
    if (keyId == -1) {
      System.out.println("No key found with Key Id " + hexKeyId);
      return;
    }
    
    // ... Now we can use keyId in the PGPLib methods 
    // that accept KeyStore object and key id.   
  }
 }

Parameters:
keyIdHex - Hexadecimal Key Id used by other OpenPG software (e.g. PGP (r) and GnuPG).
Returns:
the real Key ID (of type long) corresponding to this Hexadecimal Key Id. If there is no key with such Hexadecimal Key Id -1 is returned.

addCertification

public void addCertification(long keyId,
                             long certKeyId,
                             java.lang.String certPassword,
                             java.lang.String userID)
                      throws PGPException
Appends certification to a given OpenPGP key in the key store.

Parameters:
keyId - Key ID of the key to receive this certification
certKeyId - certifying key ID
certPassword - certifying key password
userID - user id giving the certification
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
NoPrivateKeyFoundException - No private key has been found with such Key Id
PGPException - OpenPGP signing error

signPublicKey

public void signPublicKey(long keyId,
                          long signKeyId,
                          java.lang.String signPassword)
                   throws PGPException
Signs a public key with a private key.

Signing a key certifies that you know the owner of the keys.
When you import keys into your KeyStore and are sure that the trusted third party is really the organization/person they claim to be, you can sign his/her keys.

PGP command line(r) equivalent:
pgp --sign-key keyId --signer signKeyId --sig-type exportable

GnuPG equivalent command:
gpg --local-user signKeyId --sign-key keyId

Example usage:
 import com.didisoft.pgp.*;
 
 public class SignKeyDemo { 
  public static void main(String[] a) throws Exception {
      KeyStore keyStore = new KeyStore("mykeys.keystore", "password");
  
      long partnerKeyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
      long mySecretKeyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
      
      keyStore.signPublicKey(partnerKeyId, mySecretKeyId, "my secret key password");
  }
 } 
 

Parameters:
keyId - Key ID of the public key to be signed
signKeyId - Key ID of the private key to used sign the public key with
signPassword - Password of the private key
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
NoPrivateKeyFoundException - No private key has been found with such Key Id
PGPException - OpenPGP signing error

signPublicKey

public void signPublicKey(java.lang.String keyUserId,
                          java.lang.String signKeyUserId,
                          java.lang.String signPassword)
                   throws PGPException
Signs a public key with a private key.

When you import keys into your KeyStore and are sure that trusted third party is really the person they claim, you can sign his/her keys. Signing a key certifies that you know the owner of the keys.

PGP command line(r) equivalent:
pgp --sign-key keyUserId --signer signKeyUserId --sig-type exportable

GnuPG equivalent command:
gpg --local-user signKeyUserId --sign-key keyUserId

Example usage:
 import com.didisoft.pgp.*;
 
 public class SignKeyDemo { 
  public static void main(String[] a) throws Exception {
      KeyStore keyStore = new KeyStore("mykeys.keystore", "password");
  
      String partnerUserId = "Partner Company ACM";
      long mySecretKeyUserId = "My Company my@company.com";
      
      keyStore.signPublicKey(partnerUserId, mySecretKeyUserId, "my secret key password");
  }
 } 
 

Parameters:
keyUserId - User Id of the public key to be signed
signKeyUserId - User Id of the private key to sign the public key with
signPassword - Password of the own private key
Throws:
PGPException

signPublicKeyAsTrustedIntroducer

public void signPublicKeyAsTrustedIntroducer(long keyId,
                                             long signKeyId,
                                             java.lang.String signPassword)
                                      throws PGPException
Signs a public key as trusted introducer

When you import keys into your KeyStore and are sure that the trusted third party is really the person they claim to be, you can sign his/her keys. Signing a key certifies that you know the owner of the keys.

PGP command line(r) equivalent:
pgp --sign-key keyId --signer signKeyId --sig-type trusted-introducer

Example usage:
 import com.didisoft.pgp.*;
 
 public class SignKeyDemo { 
  public static void main(String[] a) throws Exception {
      KeyStore keyStore = new KeyStore("mykeys.keystore", "password");
  
      long partnerKeyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
      long mySecretKeyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
      
      keyStore.signPublicKeyAsTrustedIntroducer(partnerKeyId, mySecretKeyId, "my secret key password");
  }
 } 
 

Parameters:
keyId - Key ID of the public key to be signed
signKeyId - Key ID of the private key to sign the public key with
signPassword - Password of the own private key
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
NoPrivateKeyFoundException - No private key has been found with such Key Id
PGPException - OpenPGP signing error

signPublicKeyAsTrustedIntroducer

public void signPublicKeyAsTrustedIntroducer(java.lang.String keyUserId,
                                             java.lang.String signKeyUserId,
                                             java.lang.String signPassword)
                                      throws PGPException
Signs a public key as a trusted introducer with a private key.

When you import keys into your KeyStore and are sure that trusted third party is really the person they claim, you can sign his/her keys. Signing a key certifies that you know the owner of the keys.

PGP command line(r) equivalent:
pgp --sign-key keyUserId --signer signKeyUserId --sig-type trusted-introducer

GnuPG equivalent command:
gpg --local-user signKeyUserId --sign-key keyUserId

Example usage:
 import com.didisoft.pgp.*;
 
 public class SignKeyDemo { 
  public static void main(String[] a) throws Exception {
      KeyStore keyStore = new KeyStore("mykeys.keystore", "password");
  
      String partnerUserId = "Partner Company ACM";
      long mySecretKeyUserId = "My Company my@company.com";
      
      keyStore.signPublicKey(partnerUserId, mySecretKeyUserId, "my secret key password");
  }
 } 
 

Parameters:
keyUserId - User Id of the public key to be signed
signKeyUserId - User Id of the private key to sign the public key with
signPassword - Password of the own private key
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
NoPrivateKeyFoundException - No private key has been found with such Key Id
PGPException - OpenPGP signing error

setTrust

public void setTrust(long keyId,
                     byte trustValue)
              throws PGPException,
                     NoPublicKeyFoundException
Sets an internal trust value for a public key, valid only in this KeyStore instance

PGP command line (r) equivalent:
pgp --set-trust keyId --trust trustValue

Parameters:
keyId - Key Id of the public key
trustValue - trust amount see TrustLevel for possible values
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
PGPException - OpenPGP signing error
See Also:
TrustLevel}, isTrusted(long)

setTrust

public void setTrust(java.lang.String keyUserId,
                     byte trustValue)
              throws PGPException,
                     NoPublicKeyFoundException
Sets an internal trust value for a public key, valid only in this KeyStore instance

PGP command line (r) equivalent:
pgp --set-trust keyUserId --trust trustValue

Parameters:
keyUserId - User Id of the public key
trustValue - trust amount see TrustLevel for possible values
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
PGPException - OpenPGP signing error
See Also:
TrustLevel}, isTrusted(long)

isTrusted

public boolean isTrusted(java.lang.String keyUserId)
                  throws PGPException
Returns is a public key with the supplied Key User Id trusted in this key store.

Parameters:
keyUserId - User Id of the key to be checked
Returns:
true if this key is trusted in this key store, false otherwise
Throws:
PGPException - General OpenPGP error
NoPublicKeyFoundException - No public key has been found with such Key Id
See Also:
#setTrust(long, byte)}, signPublicKey(long, long, String), signPublicKeyAsTrustedIntroducer(long, long, String), getKeyIdForKeyIdHex(String)

isTrusted

public boolean isTrusted(long keyId)
                  throws PGPException
Returns is a public key with the supplied Key Id trusted in this key store.

Parameters:
keyId - Key Id of the key to be checked
Returns:
true if this key is trusted in this key store, false otherwise
Throws:
NoPublicKeyFoundException - No public key has been found with such Key Id
PGPException - General OpenPGP error
See Also:
#setTrust(long, byte)}, signPublicKey(long, long, String), signPublicKeyAsTrustedIntroducer(long, long, String)

deleteKeyPair

public boolean deleteKeyPair(java.lang.String userId)
                      throws PGPException
Deletes the first public and private key pair from this key store that have the specified User Id.
If more than one key pair exist with the supplied User Id, only the first one is affected.
If no key exists with the specified userId, no changes to the key store occur.
This method is equivalent to the GnuPG commands:
gpg --delete-secret-key [userId]
gpg --delete-key [userId]

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class DeleteKeyPair {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // delete the key pair with this User Id
   ks.deleteKeyPair("test@gmail.com");
  }
 }
 

Parameters:
userId - User Id of the form "name (comment) <email address>"
Returns:
true if key pair is deleted, false if there is no key pair with the specified User Id
Throws:
PGPException

deletePrivateKey

public boolean deletePrivateKey(java.lang.String userId)
                         throws PGPException
Deletes the first private key with the specified User Id from this KeyStore.
If more than one key pair exist with the supplied User Id, only the first one is affected.
If no key exists, no changes are made to the KeyStore occur.
This method is equivalent to the GnuPG commands:
gpg --delete-secret-key [userId]

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class DeletePrivateKeyDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // delete the private key with this User Id
   ks.deletePrivateKey("test@gmail.com");
  }
 }
 

Parameters:
userId - User Id of the form "name (comment) <email address>"
Returns:
true if a key is deleted, false if there is no key with the specified User Id
Throws:
PGPException

deletePrivateKey

public boolean deletePrivateKey(long keyId)
                         throws PGPException
Deletes the first private key with the specified User Id from this KeyStore.
If more than one private key exist with the supplied User Id, only the first one is affected.
If no key exists, no changes are made to the KeyStore occur.
This method is equivalent to the GnuPG commands:
gpg --delete-secret-key [userId]

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class DeletePrivateKeyDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // delete the private key with this Key Id
   long privateKeyId = ks.getKeyIdForKeyIdHex("2EDE06AC");
   ks.deletePrivateKey(privateKeyId);
  }
 }
 

Parameters:
keyId - Key Id of the private key to be deleted
Returns:
true if a key is deleted, false if there is no key with the specified User Id
Throws:
PGPException

deletePublicKey

public boolean deletePublicKey(java.lang.String userId)
                        throws PGPException
Deletes the first public key with the specified User Id from this KeyStore.
If more than one public key exist with the supplied User Id, only the first one is affected.
If no key exists, no changes are made to the KeyStore.
This method is equivalent to the GnuPG commands:
gpg --delete-key [userId]

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class DeletePublicKeyDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // delete the public key with this User Id
   ks.deletePublicKey("test@gmail.com");
  }
 }
 

Parameters:
userId - User Id of the form "name (comment) <email address>"
Returns:
true if a key is deleted, false if there is no key with the specified User Id
Throws:
PGPException

deletePublicKey

public boolean deletePublicKey(long keyId)
                        throws PGPException
Deletes the first public key with the specified Key Id from this KeyStore.
If more than one key exist with the supplied Key Id, only the first one is affected.
If no key exists, no changes are made to the KeyStore.
This method is equivalent to the GnuPG commands:
gpg --delete-key [keyId]

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class DeletePublicKeyDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // delete the public key with this Key Id
   long privateKeyId = ks.getKeyIdForKeyIdHex("2EDE06AC");
   ks.deletePublicKey(privateKeyId);
  }
 }
 

Parameters:
keyId - Key Id of the public key to be deleted
Returns:
true if a key is deleted, false if there is no key with the specified User Id
Throws:
PGPException

deleteKeyPair

public void deleteKeyPair(long keyId)
                   throws PGPException
Deletes public and private key pair from this key store that have the specified Key Id.

This method is equivalent to the GnuPG commands:
gpg --delete-secret-key [keyId]
gpg --delete-key [keyId]

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class DeleteKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // delete the key pair with this Key Id
   long keyId = ks.getKeyIdForKeyIdHex("2EDE06AC");
   ks.deleteKeyPair(keyId);
  }
 }
 

Parameters:
keyId - Key ID of the key pair
Throws:
PGPException

changePrivateKeyPassword

public boolean changePrivateKeyPassword(java.lang.String userId,
                                        java.lang.String oldPassword,
                                        java.lang.String newPassword)
                                 throws WrongPasswordException,
                                        PGPException
Changes private key password.
If more than one key pairs exist with the supplied userId, only the first one is affected.

This method is equivalent to the GnuPG commands:
gpg --edit-key [userId]
Command>passwd

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class ChangePrivateKeyPasswordDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // change the key password
   ks.changePrivateKeyPassword("My Company", "old password", "new password");
  }
 }
 

Parameters:
userId - private key User Id of the form "name (comment) <email address>"
oldPassword - current password of the private key
newPassword - new password of the private key
Returns:
true if private key password is changed, false if there is no key with the specified userId
Throws:
WrongPasswordException - if the old password is incorrect
PGPException - general error

changePrivateKeyPassword

public void changePrivateKeyPassword(long keyId,
                                     java.lang.String oldPassword,
                                     java.lang.String newPassword)
                              throws NoPrivateKeyFoundException,
                                     WrongPasswordException,
                                     PGPException
Changes private key password.

This method is equivalent to the GnuPG commands:
gpg --edit-key [keyId]
Command>passwd

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class ChangePrivateKeyPasswordDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   // change the key password
   long keyId = ks.getKeyIdForKeyIdHex("2EDE06AC");
   ks.changePrivateKeyPassword(keyId, "old password", "new password");
  }
 }
 

Parameters:
keyId - Key Id of the private key
oldPassword - current password of the private key
newPassword - new password of the private key
Throws:
NoPrivateKeyFoundException - no private key with the specified Key Id has been found
WrongPasswordException - if the old password is incorrect
PGPException - general error
See Also:
getKeyIdForKeyIdHex(String), getKeyIdForUserId(String), getKeyIdForKeyIdHex(String)

addUserId

public void addUserId(long keyId,
                      java.lang.String privateKeyPassword,
                      java.lang.String newUserId)
               throws NoPublicKeyFoundException,
                      NoPrivateKeyFoundException,
                      WrongPasswordException,
                      PGPException
Appends an additional User Id signature to a key contained in this key store. Note that you must also have the corresponding private key in the same key store.


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.

Parameters:
keyId - target key Id
privateKeyPassword - the password of the corresponding private key
newUserId - the new user Id to be added
Throws:
NoPublicKeyFoundException - if there is no public key with the specified key Id
NoPrivateKeyFoundException - if there is no corresponding private key
WrongPasswordException - if the specified password for the private key is wrong
PGPException - general exception
See Also:
getKeyIdForUserId(String), getKeyIdForKeyIdHex(String)

deleteUserId

public boolean deleteUserId(long keyId,
                            java.lang.String userId)
                     throws NoPublicKeyFoundException,
                            PGPException
Removes a user Id signature from a key


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.

Parameters:
keyId - target key Id
userId - user Id to be removed
Returns:
true if the user id signature was removed, false if there was no such user id signature
Throws:
NoPublicKeyFoundException - if there is no public key with the specified key Id
PGPException - general exception
See Also:
getKeyIdForUserId(String), getKeyIdForKeyIdHex(String)

changeUserId

public boolean changeUserId(long keyId,
                            java.lang.String privateKeyPassword,
                            java.lang.String oldUserId,
                            java.lang.String newUserId)
                     throws NoPublicKeyFoundException,
                            NoPrivateKeyFoundException,
                            WrongPasswordException,
                            PGPException
Changes an existing user Id signature of a key with a new user Id


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.

Parameters:
keyId - target key Id
privateKeyPassword - the password of the corresponding private key
oldUserId - the old user Id to be changed
newUserId - the new user Id to be added
Returns:
true if the user id signature was changed, false if there was no such user id signature
Throws:
NoPublicKeyFoundException - if there is no public key with the specified key Id
NoPrivateKeyFoundException - if there is no corresponding private key
WrongPasswordException - if the specified password for the private key is wrong
PGPException - general exception
See Also:
getKeyIdForUserId(String), getKeyIdForKeyIdHex(String)

changePrimaryUserId

public void changePrimaryUserId(long keyId,
                                java.lang.String privateKeyPassword,
                                java.lang.String newUserId)
                         throws NoPublicKeyFoundException,
                                NoPrivateKeyFoundException,
                                WrongPasswordException,
                                PGPException
Changes the primary (first) user Id signature of a key with a new user Id


Example usage:
Check the file KeyStoreChangeUserId.java located in the examples folder in the library archive.

Parameters:
keyId - target key Id
privateKeyPassword - the password of the corresponding private key
newUserId - the new user Id to be added
Throws:
NoPublicKeyFoundException - if there is no public key with the specified key Id
NoPrivateKeyFoundException - if there is no corresponding private key
WrongPasswordException - if the specified password for the private key is wrong
PGPException - general exception
See Also:
getKeyIdForUserId(String), getKeyIdForKeyIdHex(String)

generateEccKeyPair

public KeyPairInformation generateEccKeyPair(java.lang.String ecCurve,
                                             java.lang.String userId,
                                             java.lang.String privateKeyPassword)
                                      throws PGPException
Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Default algorithms for the key are:
Symmetric cipher: AES-256, AES-192, AES-128
Hash: SHA-512, SHA-384, SHA-256
Compression: ZIP, ZLIB, BZIP2, Uncompressed

Parameters:
ecCurve - Elliptic curve of the key pair (see EcCurve for supported curves)
userId - user Id of this key
privateKeyPassword - password for the private key (can be empty string if none)
Returns:
a KeyPairInformation object representing the newly created key pair
Throws:
PGPException - if an error occurs

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateEccKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
         // EC curve for this key
   String curve = EcCurve.P384;
   // User Id for this key
   String userId = "My Company";
   
   KeyPairInformation newKey = ks.generateEccKeyPair(curve, userId, "my key password");
   
   // now the public key can be exported and sent to our partners
  }
 }
 

generateEccKeyPair

public KeyPairInformation generateEccKeyPair(java.lang.String ecCurve,
                                             java.lang.String userId,
                                             java.lang.String privateKeyPassword,
                                             long expirationAfterDays)
                                      throws PGPException
Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Default algorithms for the key are:
Symmetric cipher: AES-256, AES-192, AES-128
Hash: SHA-512, SHA-384, SHA-256
Compression: ZIP, ZLIB, BZIP2, Uncompressed

Parameters:
ecCurve - Elliptic curve of the key pair (see EcCurve for supported curves)
userId - user Id of this key
privateKeyPassword - password for the private key (can be empty string if none)
expirationAfterDays - the key validity period in days
Returns:
a KeyPairInformation object representing the newly created key pair
Throws:
PGPException - if an error occurs

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateEccKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
         // EC curve for this key
   String curve = EcCurve.P384;
   // User Id for this key
   String userId = "My Company";
   
   // the key will be valid for 1 year
   long keyExpiresAfter = 365; 
   
   KeyPairInformation newKey = ks.generateEccKeyPair(curve, 
                                                                                                        userId, 
                                                                                                        "my key password",
                                                                                                        keyExpiresAfter);
   
   // now the public key can be exported and sent to our partners
  }
 }
 

generateEccKeyPair

public KeyPairInformation generateEccKeyPair(java.lang.String ecCurve,
                                             java.lang.String userId,
                                             java.lang.String privateKeyPassword,
                                             java.lang.String[] compressionTypes,
                                             java.lang.String[] hashingAlgorithmTypes,
                                             java.lang.String[] cipherTypes)
                                      throws PGPException
Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Note: The generated key pair has no expiration date

Parameters:
ecCurve - Elliptic curve of the key pair (see EcCurve for supported curves)
userId - user Id of this key
privateKeyPassword - password for the private key (can be empty string if none)
compressionTypes - Compression algorithms supported by the key. (see CompressionAlgorithm)
hashingAlgorithmTypes - Hashing algorithms supported by the key. (see HashAlgorithm)
cipherTypes - Symmetric algorithms supported by the key. (see CypherAlgorithm)
Returns:
a KeyPairInformation object representing the newly created key pair
Throws:
PGPException - if an error occurs
java.lang.IllegalArgumentException - if the curve parameter or one of the preferred algorithms parameters is invalid

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateEccKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
         // EC curve for this key
   String curve = EcCurve.P384;
   // User Id for this key
   String userId = "My Company";
   
     // preferred compression algorithms
     String[] compressions = new String[]
                              {CompressionAlgorithm.ZIP,
                              CompressionAlgorithm.ZLIB,
                              CompressionAlgorithm.UNCOMPRESSED};
                              
     // preferred hashing algorithms
     String[] hashingAlgorithms = new String[]
                               {HashAlgorithm.SHA512,
                                HashAlgorithm.SHA256,
                                HashAlgorithm.SHA384};
  
     // preferred symmetric key algorithms
     String[] cyphers = new String[]
                       {CypherAlgorithm.AES_256,
                        CypherAlgorithm.AES_128,
                        CypherAlgorithm.AES_192};
                        
   KeyPairInformation newKey = ks.generateEccKeyPair(curve, 
                                                                                                        userId, 
                                                                                                        "my key password",
                                                                                                        compressions,
                                                                                                        hashingAlgorithms,
                                                                                                        cyphers);
   
   // now the public key can be exported and sent to our partners
  }
 }
 

generateEccKeyPair

public KeyPairInformation generateEccKeyPair(java.lang.String ecCurve,
                                             java.lang.String userId,
                                             java.lang.String privateKeyPassword,
                                             java.lang.String[] compressionTypes,
                                             java.lang.String[] hashingAlgorithmTypes,
                                             java.lang.String[] cipherTypes,
                                             long expirationAfterDays)
                                      throws PGPException
Generates an OpenPGP key pair with Elliptic Curve cryptography (ECC) asymmetric encryption algorithm

Parameters:
ecCurve - Elliptic curve of the key pair (see EcCurve for supported curves)
userId - user Id of this key
privateKeyPassword - password for the private key (can be empty string if none)
compressionTypes - Compression algorithms supported by the key. (see CompressionAlgorithm)
hashingAlgorithmTypes - Hashing algorithms supported by the key. (see HashAlgorithm)
cipherTypes - Symmetric algorithms supported by the key. (see CypherAlgorithm)
expirationAfterDays - the key validity period in days
Returns:
a KeyPairInformation object representing the newly created key pair
Throws:
PGPException - if an error occurs
java.lang.IllegalArgumentException - if the curve parameter or one of the preferred algorithms parameters is invalid

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateEccKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
         // EC curve for this key
   String curve = EcCurve.P384;
   // User Id for this key
   String userId = "My Company";
   
     // preferred compression algorithms
     String[] compressions = new String[]
                              {CompressionAlgorithm.ZIP,
                              CompressionAlgorithm.ZLIB,
                              CompressionAlgorithm.UNCOMPRESSED};
                              
     // preferred hashing algorithms
     String[] hashingAlgorithms = new String[]
                               {HashAlgorithm.SHA512,
                                HashAlgorithm.SHA256,
                                HashAlgorithm.SHA384};
  
     // preferred symmetric key algorithms
     String[] cyphers = new String[]
                       {CypherAlgorithm.AES_256,
                        CypherAlgorithm.AES_128,
                        CypherAlgorithm.AES_192};
                        
   // the key will be valid for 1 year
   long keyExpiresAfter = 365;
    
   KeyPairInformation newKey = ks.generateEccKeyPair(curve, 
                                                                                                        userId, 
                                                                                                        "my key password",
                                                                                                        compressions,
                                                                                                        hashingAlgorithms,
                                                                                                        cyphers,
                                                                                                        keyExpiresAfter);
   
   // now the public key can be exported and sent to our partners
  }
 }
 

generateRsaKeyPair

public KeyPairInformation generateRsaKeyPair(int keySize,
                                             java.lang.String userId,
                                             java.lang.String password)
                                      throws PGPException
Generates OpenPGP Key pair with RSA encryption and predefined values for compression, hashing and cypher like the ones generated with PGP Desktop(tm) key generation wizard.

Note: for key size larger than 2048 key generation will take a few moments.

Default algorithms for the key are:
Symmetric cipher: CAST-5, TRIPLE DES, AES-256, AES-192, AES-128, TWOFISH
Hash: SHA-256, SHA-384, SHA-521, SHA-1, MD-5
Compression: ZIP, Uncompressed, ZLIB, BZIP2

Parameters:
keySize - size of the keys
minimum suggested key size is 1024 bits
highest suggested key size is 4096 bits


Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class GenerateRSAKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   int keySize = 2048;
   // User Id for this key
   String userId = "My Company";
   KeyPairInformation newKey = ks.generateRsaKeyPair(keyId, userId, "key password");
   
   // now the public key can be exported and sent to our partners
  }
 }
 
userId - User Id of the form "name (comment) <email address>"
password - Secret key password
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error

generateElGamalKeyPair

public KeyPairInformation generateElGamalKeyPair(int keySize,
                                                 java.lang.String userId,
                                                 java.lang.String password)
                                          throws PGPException
Generates OpenPGP Key pair with ElGamal (DH/DSS) encryption and predefined values for compression, hashing and cypher like the ones generated with PGP Desktop(tm) key generation wizard.

Note: for key size larger than 2048 key generation will take a few moments.

Default algorithms for the key are:
Symmetric cipher: CAST-5, TRIPLE DES, AES-256, AES-192, AES-128, TWOFISH
Hash: SHA-256, SHA-384, SHA-521, SHA-1, MD-5
Compression: ZIP, Uncompressed, ZLIB, BZIP2

Parameters:
keySize - size of the keys
minimum suggested key size is 1024 bits
highest suggested key size is 4096 bits
userId - User Id of the form "name (comment) <email address>"
password - Secret key password

Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class GenerateRSAKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   int keySize = 2048;
   // User Id for this key
   String userId = "My Company";
   KeyPairInformation newKey = ks.generateElgamalKeyPair(keyId, userId, "key password");
   
   // now the public key can be exported and sent to our partners
  }
 }
 
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error

generateKeyPair

public KeyPairInformation generateKeyPair(int keySize,
                                          java.lang.String userId,
                                          java.lang.String password)
                                   throws PGPException
Generates OpenPGP Key pair with RSA encryption and predefined values for compression, hashing and cypher like the ones generated with PGP Desktop(tm) key generation wizard.
Note: for key size larger than 2048 key generation will take a few moments.

Parameters:
keySize - size of the keys
minimum key size is 512 bits
highest suggested key size is 4096 bits


Example usage:
 import com.didisoft.pgp.KeyStore;
 
 public class GenerateRSAKeyPairDemo {
  public static void main(String[] args) throws Exception{
   // initialize the KeyStore instance
   KeyStore ks = new KeyStore("pgp.keystore", "changeit");
 
   int keySize = 2048;
   // User Id for this key
   String userId = "My Company";
   KeyPairInformation newKey = ks.generateKeyPair(keyId, userId, "key password");
   
   // now the public key can be exported and sent to our partners
  }
 }
 
userId - User Id of the form "name (comment) <email address>"
password - Secret key password
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error

generateKeyPair

public KeyPairInformation generateKeyPair(int keySize,
                                          java.lang.String userId,
                                          java.lang.String keyAlgorithm,
                                          java.lang.String password,
                                          java.lang.String[] compressionTypes,
                                          java.lang.String[] hashingAlgorithmTypes,
                                          java.lang.String[] cipherTypes)
                                   throws PGPException
Generates OpenPGP key pair (public and private key).
The newly generated key is stored in this KeyStore instance.
Note: for key size larger than 2048 bits key generation will take a few moments.

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateKeyPairRSA {
  public static void main(String[] args) throws Exception {
     // initialize the KeyStore where the key will be generated
     KeyStore ks = new KeyStore("pgp.keystore", "changeit");
         
     // key primary user Id
     String userId = "demo2@didisoft.com";
         
     // preferred hashing algorithms
     String[] hashingAlgorithms = new String[]
                               {HashAlgorithm.SHA1,
                                HashAlgorithm.SHA256,
                                HashAlgorithm.SHA384,
                                HashAlgorithm.SHA512,
                                HashAlgorithm.MD5};
  
     // preferred compression algorithms
     String[] compressions = new String[]
                              {CompressionAlgorithm.ZIP,
                              CompressionAlgorithm.ZLIB,
                              CompressionAlgorithm.UNCOMPRESSED};
  
     // preferred symmetric key algorithms
     String[] cyphers = new String[]
                       {CypherAlgorithm.CAST5,
                        CypherAlgorithm.AES_128,
                        CypherAlgorithm.AES_192,
                        CypherAlgorithm.AES_256,
                        CypherAlgorithm.TWOFISH};
  
     String privateKeyPassword = "changeit";
  
     int keySizeInBits = 2048;
     ks.generateKeyPair(keySizeInBits, 
                      userId, 
                      KeyAlgorithm.RSA, 
                      privateKeyPassword, 
                      compressions, 
                      hashingAlgorithms, 
                      cyphers);       
  }
 }
 

Parameters:
keySize - Size of the keys in bits
minimum key size is 512
highest suggested key size is 4096 bits for RSA and 4096 for ELGAMAL
userId - User Id of the form "name (comment) <email address>"
keyAlgorithm - Key algorithm. Possible values: ELGAMAL, RSA
password - Secret key password.
compressionTypes - Compression algorithms supported by the key. (see CompressionAlgorithm)
hashingAlgorithmTypes - Hashing algorithms supported by the key. (see HashAlgorithm)
cipherTypes - Symmetric algorithms supported by the key. (see CypherAlgorithm)
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error CompressionAlgorithm

generateKeyPair

public KeyPairInformation generateKeyPair(int keySize,
                                          java.lang.String userId,
                                          java.lang.String keyAlgorithm,
                                          java.lang.String password,
                                          java.lang.String[] compressionTypes,
                                          java.lang.String[] hashingAlgorithmTypes,
                                          java.lang.String[] cipherTypes,
                                          long expirationAfterDays)
                                   throws PGPException
Generates OpenPGP key pair (public and private key).
The newly generated key is stored in this KeyStore instance.
Note: for key size larger than 2048 bits key generation will take a few moments.

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateKeyPairRSA {
  public static void main(String[] args) throws Exception {
     // initialize the KeyStore where the key will be generated
     KeyStore ks = new KeyStore("pgp.keystore", "changeit");
         
     // key primary user Id
     String userId = "demo2@didisoft.com";
         
     // preferred hashing algorithms
     String[] hashingAlgorithms = new String[]
                               {HashAlgorithm.SHA1,
                                HashAlgorithm.SHA256,
                                HashAlgorithm.SHA384,
                                HashAlgorithm.SHA512,
                                HashAlgorithm.MD5};
  
     // preferred compression algorithms
     String[] compressions = new String[]
                              {CompressionAlgorithm.ZIP,
                              CompressionAlgorithm.ZLIB,
                              CompressionAlgorithm.UNCOMPRESSED};
  
     // preferred symmetric key algorithms
     String[] cyphers = new String[]
                       {CypherAlgorithm.CAST5,
                        CypherAlgorithm.AES_128,
                        CypherAlgorithm.AES_192,
                        CypherAlgorithm.AES_256,
                        CypherAlgorithm.TWOFISH};
  
     String privateKeyPassword = "changeit";
  
     // The key will expire after 1 year 
     // set this to 0 if the key will never expire 
     long keyExpiresAfterDays = 365;  
  
     int keySizeInBits = 2048;
     ks.generateKeyPair(keySizeInBits, 
                      userId, 
                      KeyAlgorithm.RSA, 
                      privateKeyPassword, 
                      compressions, 
                      hashingAlgorithms, 
                      cyphers,
                      keyExpiresAfterDays);       
  }
 }
 

Parameters:
keySize - Size of the keys in bits
minimum key size is 512
highest suggested key size is 4096 bits for RSA and 4096 for ELGAMAL
userId - User Id of the form "name (comment) <email address>"
keyAlgorithm - Key algorithm. Possible values: ELGAMAL, RSA
password - Secret key password.
compressionTypes - Compression algorithms supported by the key. (see CompressionAlgorithm)
hashingAlgorithmTypes - Hashing algorithms supported by the key. (see HashAlgorithm)
cipherTypes - Symmetric algorithms supported by the key. (see CypherAlgorithm)
expirationAfterDays - key validity period in days
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error CompressionAlgorithm

generateKeyPair

public KeyPairInformation generateKeyPair(int keySize,
                                          java.lang.String userId,
                                          java.lang.String keyAlgorithm,
                                          java.lang.String password,
                                          java.lang.String compressionTypes,
                                          java.lang.String hashingAlgorithmTypes,
                                          java.lang.String cipherTypes)
                                   throws PGPException
Generates OpenPGP Key pair (public and private key).
The newly generated key is stored in this KeyStore instance.
Note: for key size larger than 2048 bits key generation will take a few moments.

Parameters:
keySize - Size of the keys in bits
minimum key size is 512
highest suggested key size is 4096 bits for RSA and 4096 for ELGAMAL
userId - User Id of the form "name (comment) <email address>"
keyAlgorithm - Key algorithm. Possible values: ELGAMAL, RSA
password - Secret key password.
compressionTypes - Compression algorithms supported by the key.
Comma separated list of one or more of: ZLIB, ZIP, UNCOMPRESSED, BZIP2
hashingAlgorithmTypes - Hashing algorithms supported by the key.
Comma separated list of one or more of: SHA256, SHA384, SHA512, SHA224, SHA1, MD5, RIPEMD160, MD2
cipherTypes - Symmetric algorithms supported by the key.
Comma separated list of one or more of: TRIPLE_DES, CAST5, BLOWFISH, AES_128, AES_192, AES_256, TWOFISH, DES, SAFER
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error

generateKeyPair

public KeyPairInformation generateKeyPair(int keySize,
                                          java.lang.String userId,
                                          java.lang.String keyAlgorithm,
                                          java.lang.String password,
                                          java.lang.String compressionTypes,
                                          java.lang.String hashingAlgorithmTypes,
                                          java.lang.String cipherTypes,
                                          long expirationAfterDays)
                                   throws PGPException
Generates OpenPGP Key pair (public and private key).
The newly generated key is stored in this KeyStore instance.
Note: for key size larger than 2048 bits key generation will take a few moments.

Example usage:
 import com.didisoft.pgp.*;
 
 public class GenerateKeyPairRSA {
  public static void main(String[] args) throws Exception {
     // initialize the KeyStore where the key will be generated
     KeyStore ks = new KeyStore("pgp.keystore", "changeit");
         
     // key primary user Id
     String userId = "demo2@didisoft.com";
         
     // preferred hashing algorithms
     String[] hashingAlgorithms = new String[]
                               {HashAlgorithm.SHA1,
                                HashAlgorithm.SHA256,
                                HashAlgorithm.SHA384,
                                HashAlgorithm.SHA512,
                                HashAlgorithm.MD5};
  
     // preferred compression algorithms
     String[] compressions = new String[]
                              {CompressionAlgorithm.ZIP,
                              CompressionAlgorithm.ZLIB,
                              CompressionAlgorithm.UNCOMPRESSED};
  
     // preferred symmetric key algorithms
     String[] cyphers = new String[]
                       CypherAlgorithm.CAST5,
                        CypherAlgorithm.AES_128,
                        CypherAlgorithm.AES_192,
                        CypherAlgorithm.AES_256,
                        CypherAlgorithm.TWOFISH};
  
     String privateKeyPassword = "changeit";
  
     // the key will be valid for 1 year
     long keyExpiresAfter = 365; 
  
     int keySizeInBits = 2048;
     ks.generateKeyPair(keySizeInBits, 
                      userId, 
                      KeyAlgorithm.RSA, 
                      privateKeyPassword, 
                      compressions, 
                      hashingAlgorithms, 
                      cyphers,
                      keyExpiresAfter);       
  }
 }
 

Parameters:
keySize - Size of the keys in bits
minimum key size is 512
highest suggested key size is 4096 bits for RSA and 3072 for ELGAMAL (DH/DSS)
userId - User Id of the form "name (comment) <email address>"
keyAlgorithm - Key algorithm. Possible values: RSA, ELGAMAL (equivalent of DS/DHH)
password - Secret key password.
compressionTypes - Compression algorithms supported by the key.
Comma separated list of one or more of: ZLIB, ZIP, UNCOMPRESSED, BZIP2
hashingAlgorithmTypes - Hashing algorithms supported by the key.
Comma separated list of one or more of: SHA256, SHA384, SHA512, SHA224, SHA1, MD5, RIPEMD160, MD2
cipherTypes - Symmetric algorithms supported by the key.
Comma separated list of one or more of: TRIPLE_DES, CAST5, BLOWFISH, AES_128, AES_192, AES_256, TWOFISH, DES, IDEA, SAFER
expirationAfterDays - Number of days the key will be valid. For example 365 for one year. Use 0 (zero) for no expiration date.
Returns:
KeyPairInformation object representing the generated key pair
Throws:
PGPException - Key generation error

exportKeyRing

public void exportKeyRing(java.lang.String fileName,
                          java.lang.String userId)
                   throws NoPublicKeyFoundException,
                          java.io.IOException
Exports Key ring (both public and private key) located in this Key store in one file.
The result file is in ASCII armored format. The private key is exported only if exists.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportKeyPairDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // export key pair with this User Id
         keyStore.exportKeyRing("keypair.asc", "demo@didisoft.com");     
     }
 }
 

Parameters:
fileName - File name where the key ring will be exported (absolute or relative path)
userId - User Id of the form "name (comment) <email address>"
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - I/O error saving the key ring

exportKeyRing

public void exportKeyRing(java.lang.String fileName,
                          java.lang.String userId,
                          boolean asciiArmor)
                   throws NoPublicKeyFoundException,
                          java.io.IOException
Exports Key ring (both public and private key) located in this Key store in one file.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportKeyPairDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("my.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         // export key pair with this User Id
         keyStore.exportKeyRing("keypair.asc", "demo@didisoft.com", asciiArmored);     
     }
 }
 

Parameters:
fileName - File name where the key ring will be exported (absolute or relative path)
userId - User Id of the form "name (comment) <email address>"
asciiArmor - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - I/O error saving the key ring

exportKeyRing

public void exportKeyRing(java.io.OutputStream outputStream,
                          java.lang.String userId,
                          boolean asciiArmor)
                   throws NoPublicKeyFoundException,
                          java.io.IOException
Exports Key ring (both public and private key) located in this Key store into a stream.
Note: The caller has the obligation to close the output stream

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportKeyPairDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("my.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         // export key pair with this User Id
         OutputStream keyData = new ByteArrayOutputStream();
         keyStore.exportKeyRing(keyData, "demo@didisoft.com", asciiArmored);
         // keyData has to be closed ...     
     }
 }
 

Parameters:
outputStream - OutputStream where the key data will be written
userId - User Id of the form "name (comment) <email address>"
asciiArmor - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - I/O error saving the key ring

exportKeyRing

public void exportKeyRing(java.io.OutputStream outputStream,
                          long keyId,
                          boolean asciiArmor)
                   throws NoPublicKeyFoundException,
                          java.io.IOException
Exports Key ring (both public and private key) located in this Key store into a stream.
Note: The caller has the obligation to close the output stream

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportKeyPairDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("my.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         
         // export key pair with this User Id
         OutputStream keyData = new ByteArrayOutputStream();
         keyStore.exportKeyRing(keyData, keyId, asciiArmored);
         // keyData has to be closed ...     
     }
 }
 

Parameters:
outputStream - OutputStream where the key data will be written
userId - User Id of the form "name (comment) <email address>"
asciiArmor - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - I/O error saving the key ring

exportKeyRing

public void exportKeyRing(java.lang.String fileName,
                          long keyId,
                          boolean asciiArmor)
                   throws NoPublicKeyFoundException,
                          java.io.IOException
Exports Key ring (both public and private key) located in this Key store in one file.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportKeyPairDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("my.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         // export key pair with this User Id
         keyStore.exportKeyRing("keypair.asc", keyId, asciiArmored);     
     }
 }
 

Parameters:
fileName - File name where the key ring will be exported (absolute or relative path)
keyId - Key Id of the keyring to be exported
asciiArmor - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - I/O error saving the key ring

exportPublicKey

public void exportPublicKey(java.lang.String fileName,
                            java.lang.String userId,
                            boolean asciiArmored)
                     throws NoPublicKeyFoundException,
                            java.io.IOException
Exports a public key from this KeyStore instance into a file.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPublicKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         // export the public key with this User Id
         keyStore.exportPublicKey("public_key.asc", "demo@didisoft.com", asciiArmored);     
     }
 }
 

Parameters:
fileName - File name where the public key will be exported (absolute or relative path)
userId - User Id of the form "name (comment) <email address>"
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPublicKey

public void exportPublicKey(java.io.OutputStream outputStream,
                            java.lang.String userId,
                            boolean asciiArmored)
                     throws NoPublicKeyFoundException,
                            java.io.IOException
Exports a public key from this KeyStore instance into a stream.
Note: The caller has the obligation to close the output stream

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPublicKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         // export the public key with this User Id
         OutputStream keyData = new ByteArrayOutputStream();
         keyStore.exportPublicKey(keyData, "demo@didisoft.com", asciiArmored);     
         // keyData has to be closed ...
     }
 }
 

Parameters:
outputStream - OutputStream where the key data will be written
userId - User Id of the form "name (comment) <email address>"
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPublicKey

public void exportPublicKey(java.io.OutputStream outputStream,
                            long keyId,
                            boolean asciiArmored)
                     throws NoPublicKeyFoundException,
                            java.io.IOException
Exports public key from this KeyStore instance into a file.
Note: The caller has the obligation to close the output stream

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPublicKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         // export key pair with this User Id
         OutputStream keyData = new ByteArrayOutputStream();
         keyStore.exportPublicKey(keyData, keyId, asciiArmored);     
     }
 }
 

Parameters:
outputStream - OutputStream where the key data will be written
keyId - Key Id of the Public Key
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPublicKey

public void exportPublicKey(java.lang.String fileName,
                            long keyId,
                            boolean asciiArmored)
                     throws NoPublicKeyFoundException,
                            java.io.IOException
Exports public key from this KeyStore instance into a file.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPublicKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         // export key pair with this User Id
         keyStore.exportPublicKey("public_key.asc", keyId, asciiArmored);     
     }
 }
 

Parameters:
fileName - File name where the public key will be exported (absolute or relative path)
keyId - Key Id of the Public Key
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPublicKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPrivateKey

public void exportPrivateKey(java.lang.String fileName,
                             java.lang.String userId,
                             boolean asciiArmored)
                      throws NoPrivateKeyFoundException,
                             java.io.IOException
Exports private key from this OpenPGP key store, into a file.
If more than one key pairs exist with the supplied userId, only the first one is exported.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPrivateKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         // export key pair with this User Id
         keyStore.exportPrivateKey("private_key.asc", "demo@didisoft.com", asciiArmored);     
     }
 }
 

Parameters:
fileName - File name where the key will be exported (absolute or relative path)
userId - User Id of the form "name (comment) <email address>"
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPrivateKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPrivateKey

public void exportPrivateKey(java.io.OutputStream outputStream,
                             java.lang.String userId,
                             boolean asciiArmored)
                      throws NoPrivateKeyFoundException,
                             java.io.IOException
Exports a private key from this OpenPGP key store into a stream.
If more than one key exist with the supplied userId, only the first one is exported.
Note: The caller has the obligation to close the output stream

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPrivateKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         // export key pair with this User Id
         OutputStream keyData = new ByteArrayOutputStream(); 
         keyStore.exportPrivateKey(keyData, "demo@didisoft.com", asciiArmored);
         // keyData has to be closed ...          
     }
 }
 

Parameters:
outputStream - OutputStream where the key data will be written
userId - User Id of the form "name (comment) <email address>"
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPrivateKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPrivateKey

public void exportPrivateKey(java.io.OutputStream outputStream,
                             long keyId,
                             boolean asciiArmored)
                      throws NoPrivateKeyFoundException,
                             java.io.IOException
Exports a private key from this KeyStore instance into a stream.
Note: The caller has the obligation to close the output stream

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPrivateKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         // export key pair with this User Id
         OutputStream keyData = new ByteArrayOutputStream(); 
         keyStore.exportPrivateKey(keyData, keyId, asciiArmored);
         // keyData has to be closed ...          
     }
 }
 

Parameters:
outputStream - OutputStream where the key data will be written
keyId - Key Id of the corresponding Public Key
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPrivateKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

exportPrivateKey

public void exportPrivateKey(java.lang.String fileName,
                             long keyId,
                             boolean asciiArmored)
                      throws NoPrivateKeyFoundException,
                             java.io.IOException
Exports private key from this KeyStore instance, into a file.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ExportPrivateKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // should the exported key be in ASCII form (true), or binary (false)
         boolean asciiArmored = true;
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         // export key pair with this User Id
         keyStore.exportPrivateKey("private_key.asc", keyId, asciiArmored);     
     }
 }
 

Parameters:
fileName - File name where the key will be exported (absolute or relative path)
keyId - Key Id of the corresponding Public Key
asciiArmored - if true the output is ASCII armored, when false it is binary
Throws:
NoPrivateKeyFoundException - if there is no such key
java.io.IOException - if an I/O error occurs.

importPublickKey

public void importPublickKey(java.lang.String publicKeyFileName)
                      throws java.io.IOException,
                             PGPException
Deprecated. Replaced by importPublicKey(String)

Imports Public key into this Key store instance. If the key store does not exist, it is created.

Parameters:
publicKeyFileName - FileName of the Public key to be imported (absolute or relative path)
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - if PGP object different from public or private key is found in this file
See Also:
importKeyRing(String), exportKeyRing(String, String)

importPublicKey

public KeyPairInformation[] importPublicKey(java.lang.String publicKeyFileName)
                                     throws java.io.IOException,
                                            PGPException,
                                            NoPublicKeyFoundException
Imports an OpenPGP public key into this KeyStore instance.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // import key 
         keyStore.importPublicKey("public_key.asc");     
     }
 }
 

Parameters:
publicKeyFileName - FileName of the Public key to be imported (absolute or relative path)
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - general PGP decoding/parsing error
NoPublicKeyFoundException - if the supplied file does not contain public key(s)

importPublicKey

public KeyPairInformation[] importPublicKey(java.io.InputStream publicKeyStream)
                                     throws java.io.IOException,
                                            PGPException,
                                            NoPublicKeyFoundException
Imports an OpenPGP public key into this KeyStore instance.

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         InputStream keyStream = new FileInputStream("public_key.asc");
         
         // import key 
         keyStore.importPublicKey(keyStream);
         
         keyStream.close();
     }
 }
 

Parameters:
publicKeyStream - stream containing the public key to be imported
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - general PGP decoding/parsing error
NoPublicKeyFoundException - if the supplied file does not contain public key(s)

importKeyRing

public KeyPairInformation[] importKeyRing(java.lang.String keyRingFileName)
                                   throws java.io.IOException,
                                          PGPException
Imports OpenPGP key ring into this KeyStore instance. If the KeyStore file does not exist, it is created.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // import key 
         keyStore.importKeyRing("mykey.asc");     
     }
 }
 

Parameters:
keyRingFileName - FileName of the key ring to be imported (absolute or relative path). Most common file name extensions are .asc, .pkr, .skr, .pgp, .pgpkey
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - if PGP object different from public or private key is found in this file
See Also:
exportKeyRing(String, String)

importKeyStore

public KeyPairInformation[] importKeyStore(KeyStore keyStore)
                                    throws java.io.IOException,
                                           PGPException
Imports the keys contained in another KeyStore object into the current instance.

Example:
 // The source KeyStore is located in a file 
 KeyStore ksSource = new KeyStore("my.keystore", "my password");
 
 // The destination KeyStore is in-memory 
 KeyStore ksDestination = new KeyStore();
 KeyPairInformation[] importedKeys = 
      ksDestination.importKeyStore( ksSource ); 
 

Parameters:
keyStore - source KeyStore to import from
Returns:
array of KeyPairInformation objects representing the imported keys
Throws:
java.io.IOException - I/O error
PGPException - error decoding key

importKeyRing

public KeyPairInformation[] importKeyRing(java.lang.String keyRingFileName,
                                          java.lang.String privateKeyPassword)
                                   throws java.io.IOException,
                                          PGPException
Imports OpenPGP key ring into this KeyStore instance. If the KeyStore file does not exist, it is created.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // import key 
         keyStore.importKeyRing("mykey.asc", "my password");     
     }
 }
 

Parameters:
keyRingFileName - FileName of the key ring to be imported (absolute or relative path). Most common file name extensions are .asc, .pgp, .pgpkey
privateKeyPassword - password of the private key component if exists, in the supplied file
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - if PGP object different from public or private key is found in this file
WrongPasswordException - if a private key component exists in the specified file and its password does not match
See Also:
exportKeyRing(String, String)

importKeyRing

public KeyPairInformation[] importKeyRing(java.io.InputStream keyStream)
                                   throws java.io.IOException,
                                          PGPException
Imports OpenPGP key ring stream into this KeyStore instance.

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         InputStream stream = new FileInputStream("mykey.asc");
         
         // import key 
         keyStore.importKeyRing(stream);
         
         stream.close();     
     }
 }
 

Parameters:
keyStream - OpenPGP key ring to be imported in stream format.
privateKeyPassword - password of the private key if exists
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - if PGP object different from public or private key is found in this file
WrongPasswordException - if a private key component exists in the specified file and its password does not match
See Also:
exportKeyRing(String, String)

importKeyRing

public KeyPairInformation[] importKeyRing(java.io.InputStream keyStream,
                                          java.lang.String privateKeyPassword)
                                   throws java.io.IOException,
                                          PGPException
Imports OpenPGP key ring stream into this KeyStore instance.

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         InputStream stream = new FileInputStream("mykey.asc");
         
         // import key 
         keyStore.importKeyRing(stream, "private key password");     
     }
 }
 

Parameters:
keyStream - Input stream obtained from an .asc key file or .pkr/.skr keyring source
privateKeyPassword - password of the private key if exists
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - if PGP object different from public or private key is found in this file
WrongPasswordException - if a private key component exists in the specified file and its password does not match
See Also:
exportKeyRing(String, String)

importPrivateKey

public KeyPairInformation[] importPrivateKey(java.lang.String privateKeyFileName)
                                      throws java.io.IOException,
                                             PGPException,
                                             NoPrivateKeyFoundException
Imports a private key file into this KeyStore instance. If the KeyStore file does not exist, it is created.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // import key 
         keyStore.importPrivateKey("mykey.asc");     
     }
 }
 

Parameters:
privateKeyFileName - File of the Private key to be imported (absolute or relative path)
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - general PGP decoding/parsing error
NoPrivateKeyFoundException - if the supplied file does not contain private key(s)

importPrivateKey

public KeyPairInformation[] importPrivateKey(java.lang.String privateKeyFileName,
                                             java.lang.String password)
                                      throws java.io.IOException,
                                             PGPException,
                                             NoPrivateKeyFoundException
Imports private key file into this KeyStore instance.

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         // import key 
         keyStore.importPrivateKey("mykey.asc", "key password");     
     }
 }
 

Parameters:
privateKeyFileName - File of the Private key to be imported (absolute or relative path)
password - Password of the private key
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - general PGP decoding/parsing error
NoPrivateKeyFoundException - if the supplied file does not contain private key(s)
WrongPasswordException - if the supplied private key password is incorrect

importPrivateKey

public KeyPairInformation[] importPrivateKey(java.io.InputStream privateKeyStream)
                                      throws java.io.IOException,
                                             PGPException,
                                             NoPrivateKeyFoundException
Imports private key stream into this KeyStore instance.
Note: The caller has the responsibility to close the stream

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         InputStream keyStream = new FileInputStream("mykey.asc");
         
         // import key 
         keyStore.importPrivateKey(keyStream);
         
         // the caller has to close the stream
         keyStream.close();     
     }
 }
 

Parameters:
privateKeyStream - Input stream containing the key to be imported
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - general PGP decoding/parsing error
NoPrivateKeyFoundException - if the supplied file does not contain private key(s)
WrongPasswordException - if the supplied private key password is incorrect

importPrivateKey

public KeyPairInformation[] importPrivateKey(java.io.InputStream privateKeyStream,
                                             java.lang.String password)
                                      throws java.io.IOException,
                                             PGPException,
                                             NoPrivateKeyFoundException
Imports private key stream into this KeyStore instance.
Note: The caller has the responsibility to close the stream

Example:
 import java.io.*;
 import com.didisoft.pgp.KeyStore;
 
 public class ImportKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         InputStream keyStream = new FileInputStream("mykey.asc");
         
         // import key 
         keyStore.importPrivateKey(keyStream, "key password");
         
         // the caller has to close the stream
         keyStream.close();     
     }
 }
 

Parameters:
privateKeyStream - Input stream containing the key to be imported
password - Password of the private key
Returns:
array of KeyPairInformation representing the imported keys
Throws:
java.io.IOException - if an I/O error occurs (for example file not found)
PGPException - general PGP decoding/parsing error
NoPrivateKeyFoundException - if the supplied file does not contain private key(s)
WrongPasswordException - if the supplied private key password is incorrect

getKeystoreFileName

public java.lang.String getKeystoreFileName()
Returns this Key store file name (absolute or relative path)


getKeystorePassword

public java.lang.String getKeystorePassword()
Returns The password of this KeyStore


listKeys

public KeyPairInformation[] listKeys()
Lists keys stored in this OpenPGP key store to the System.out

Example:
 import com.didisoft.pgp.KeyStore;
 import com.didisoft.pgp.PGPLib;
 
 public class ListKeys {
  public static void main(String[] args) throws Exception{
    KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");               
    keyStore.listKeys();
  }
 }
 

See Also:
getKeys()

getKey

public KeyPairInformation getKey(java.lang.String userId)
Returns the key pair with the specified User Id

Parameters:
userId - User Id or hexadecimal Key Id of the requested key pair
Returns:
KeyPairInformation object holding the specified key pair contained in this key store, null if there is no such key

getKey

public KeyPairInformation getKey(long keyId)
Returns the key pair with the specified Key Id

Parameters:
keyId - Key Id of the requested key pair
Returns:
KeyPairInformation object holding the specified key pair contained in this key store, null if there is no such key

getKeys

public KeyPairInformation[] getKeys()
Returns the key pairs stored in this OpenPGP key store.

Returns:
Array of KeyPairInformation objects holding the key rings contained in this key store.

containsPublicKey

public boolean containsPublicKey(java.lang.String userId)
Returns true if a public key with the specified User ID exists in this KeyStore

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ContainsPublicKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         boolean keyExists = keyStore.containsPublicKey("demo@didisoft.com");     
     }
 }
 

Parameters:
userId - User ID of the form "name (comment) <email address>"
Returns:
true if a public key with the specified User ID exists in this Key Store
See Also:
getKeyIdForUserId(String)

containsPrivateKey

public boolean containsPrivateKey(java.lang.String userId)
Returns true if a private key with the specified User ID exists in this KeyStore

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ContainsPrivateKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         boolean keyExists = keyStore.containsPrivateKey("demo@didisoft.com");     
     }
 }
 

Parameters:
userId - User ID of the form "name (comment) <email address>"
Returns:
true if a public key with the specified User ID exists in this Key Store
See Also:
getKeyIdForUserId(String)

containsKey

public boolean containsKey(java.lang.String userId)
Returns true if public or private key with the specified User ID exists in this KeyStore

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ContainsKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         boolean keyExists = keyStore.containsKey("demo@didisoft.com");     
     }
 }
 

Parameters:
userId - User ID of the form "name (comment) <email address>"
Returns:
true if a public or private key with the specified User ID exists in this Key Store
See Also:
getKeyIdForUserId(String)

containsKey

public boolean containsKey(long keyId)
Returns true if a public or private key with the specified Key Id exists in this KeyStore

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ContainsKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         boolean keyExists = keyStore.containsKey(keyId);     
     }
 }
 

Parameters:
keyId - Key Id of type long
Returns:
true if key with the specified Key Id exists in this Key Store
See Also:
getKeyIdForKeyIdHex(String)

containsPrivateKey

public boolean containsPrivateKey(long keyId)
Returns true if a private key with the specified Key Id exists in this KeyStore

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ContainsPrivateKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         boolean keyExists = keyStore.containsPrivateKey(keyId);     
     }
 }
 

Parameters:
keyId - Key Id of type long
Returns:
true if a private key with the specified Key Id exists in this Key Store
See Also:
getKeyIdForKeyIdHex(String)

containsPublicKey

public boolean containsPublicKey(long keyId)
Returns true if a public key with the specified Key Id exists in this KeyStore

Example:
 import com.didisoft.pgp.KeyStore;
 
 public class ContainsKeyDemo {
     public static void main(String[] args) throws Exception{
         // initialize the key store
         KeyStore keyStore = new KeyStore("pgp.keystore", "changeit");
         
         long keyId = keyStore.getKeyIdForKeyIdHex("2EDE06AC");
         boolean keyExists = keyStore.containsPublicKey(keyId);     
     }
 }
 

Parameters:
keyId - Key Id of type long
Returns:
true if a public key with the specified Key Id exists in this Key Store
See Also:
getKeyIdForKeyIdHex(String)

setAutoSave

public void setAutoSave(boolean save)
Sets the KeyStore to call save() automatically after each operation that modifies it (for example import key, delete key, etc.)

Parameters:
save - if true this KeyStore instance calls automatically it's save() method.
See Also:
save(), isAutoSave()

isAutoSave

public boolean isAutoSave()
Returns is auto save on. (true by default)

Returns:
true if auto save mode is on, otherwise false
See Also:
setAutoSave(boolean), save()

isBackupOnSave

public boolean isBackupOnSave()
Returns should backups be made on save. (true by default)

Returns:
true if backup file is created on save, otherwise false
See Also:
setBackupOnSave(boolean), save()

setBackupOnSave

public void setBackupOnSave(boolean backupOnSave)
Sets backup file be created (with extension .bak) for this KeyStore on save() operations.

Parameters:
backupOnSave - if true a backup file (with extension .bak) is created on each call to the save() method.
See Also:
isBackupOnSave(), save()

save

public void save()
          throws PGPException
Saves the backing file of this KeyStore instance to disk.

If isAutoSave() is true there is no need to be called explicitly, because it is called implicitly by all methods that change the state of this KeyStore instance.

Throws:
PGPException - error saving the state of this key store. Use the method getUnderlyingException() to see the cause.

isSkipLucasLehmerPrimeTest

public boolean isSkipLucasLehmerPrimeTest()
Will Lucas-Lehmer prime number check be skipped when generating prime numbers for ElGamal keys. Default is true

Returns:
Will Lucas-Lehmer prime number check be skipped for ElGamal keys

setSkipLucasLehmerPrimeTest

public void setSkipLucasLehmerPrimeTest(boolean skipLucasLehmerPrimeTest)
Sets should Lucas-Lehmer prime number check be skipped when generating prime numbers for ElGamal keys

Parameters:
skipLucasLehmerPrimeTest - if true the test will be skipped, otherwise it will be executed


Copyright © 2006-2013 DidiSoft Ltd. All Rights Reserved.