IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

demo.cms.ecc.keystore
Class SetupCMSEccKeyStore

java.lang.Object
  extended by demo.cms.ecc.keystore.SetupCMSEccKeyStore
All Implemented Interfaces:
CMSEccKeyStoreConstants

public class SetupCMSEccKeyStore
extends java.lang.Object
implements CMSEccKeyStoreConstants

Creates a test KeyStore ("cmsecc.keystore") in the current working directory. These keys are used by the ECC demos included in IAIK-CMS. The aliases and the password for accessing the keys and certificates can be found in CMSEccKeyStoreConstants.

See Also:
CMSEccKeyStoreConstants, CMSEccKeyStore

Field Summary
 
Fields inherited from interface demo.cms.ecc.keystore.CMSEccKeyStoreConstants
CA_ECDSA, ECDH_192_1, ECDH_192_2, ECDH_224_1, ECDH_224_2, ECDH_256_1, ECDH_256_2, ECDH_384_1, ECDH_384_2, ECDH_521_1, ECDH_521_2, ECDH_BRAINPOOL_192_1, ECDH_BRAINPOOL_192_2, ECDH_BRAINPOOL_224_1, ECDH_BRAINPOOL_224_2, ECDH_BRAINPOOL_256_1, ECDH_BRAINPOOL_256_2, ECDH_BRAINPOOL_384_1, ECDH_BRAINPOOL_384_2, ECDH_BRAINPOOL_512_1, ECDH_BRAINPOOL_512_2, ECDH_X25519, ECDH_X448, ECDSA_192, ECDSA_224, ECDSA_256, ECDSA_384, ECDSA_521, ECDSA_BRAINPOOL_192, ECDSA_BRAINPOOL_224, ECDSA_BRAINPOOL_256, ECDSA_BRAINPOOL_384, ECDSA_BRAINPOOL_512, EDDSA_ED25519, EDDSA_ED448, KS_DIRECTORY, KS_FILENAME, KS_PASSWORD
 
Constructor Summary
SetupCMSEccKeyStore()
          Default Constructor.
 
Method Summary
 void addToKeyStore(java.security.KeyPair keyPair, iaik.x509.X509Certificate[] chain, java.lang.String alias)
          Adds the private key and the certificate chain to the key store.
static iaik.x509.X509Certificate createCertificate(iaik.asn1.structures.Name subject, java.security.PublicKey publicKey, iaik.asn1.structures.Name issuer, java.security.PrivateKey privateKey, iaik.asn1.structures.AlgorithmID algorithm, byte[] keyID, boolean forSigning)
          Creates a certificate from the given values.
 void generateCertificates()
          Generates the certificates.
static java.security.KeyPair generateEccKeyPair(java.lang.String algorithm, java.lang.String curveName)
          Generates an ECC key pair for a curve with a certain name
 java.security.KeyPair generateKeyPair(java.lang.String algorithm, int bitLength)
          Generates a key pair for a curve with a certain name
static void main(java.lang.String[] arg)
          Creates the test certificates.
static void start()
          Starts the keystore setup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetupCMSEccKeyStore

public SetupCMSEccKeyStore()
Default Constructor.

Method Detail

generateKeyPair

public java.security.KeyPair generateKeyPair(java.lang.String algorithm,
                                             int bitLength)
                                      throws java.security.NoSuchAlgorithmException,
                                             java.security.NoSuchProviderException
Generates a key pair for a curve with a certain name

Parameters:
algorithm - the key algorithm
bitLength - the length of the key (in bits).
Returns:
the generated key pair
Throws:
java.security.NoSuchAlgorithmException - if ECDSA KeyPairGenerator is not available
java.security.NoSuchProviderException - if provider IAIK_ECC is not installed

generateEccKeyPair

public static java.security.KeyPair generateEccKeyPair(java.lang.String algorithm,
                                                       java.lang.String curveName)
                                                throws java.lang.Exception
Generates an ECC key pair for a curve with a certain name

Parameters:
algorithm - the key algorithm
curveName - the name of the curve to be used.
Returns:
the generated key pair
Throws:
java.lang.Exception - if the KeyPair cannot be generated

createCertificate

public static iaik.x509.X509Certificate createCertificate(iaik.asn1.structures.Name subject,
                                                          java.security.PublicKey publicKey,
                                                          iaik.asn1.structures.Name issuer,
                                                          java.security.PrivateKey privateKey,
                                                          iaik.asn1.structures.AlgorithmID algorithm,
                                                          byte[] keyID,
                                                          boolean forSigning)
Creates a certificate from the given values.

Parameters:
subject - the subject of the certificate
publicKey - the public key to include
issuer - the issuer of the certificate
privateKey - the private key for signing the certificate
algorithm - the signature algorithm to use
keyID - the key id for the AuthotityKeyIdentifier extension
forSigning - if the certificate to be created shall be used for signing or encryption
Returns:
the certificate just created

addToKeyStore

public void addToKeyStore(java.security.KeyPair keyPair,
                          iaik.x509.X509Certificate[] chain,
                          java.lang.String alias)
                   throws java.security.KeyStoreException
Adds the private key and the certificate chain to the key store.

Parameters:
keyPair - the key pair with the private key to be added
chain - the certificate chain to be added
alias - the alias for the keystore entry
Throws:
java.security.KeyStoreException - if an error occurs when trying to add the key

generateCertificates

public void generateCertificates()
Generates the certificates.


start

public static void start()
Starts the keystore setup.


main

public static void main(java.lang.String[] arg)
                 throws java.io.IOException
Creates the test certificates.

Throws:
java.io.IOException

IAIK CMS/SMIME Toolkit Demo API Documentation
Version 6.1

v6.1
(c) 2002 IAIK, (c) 2003 - 2025 SIC