Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:29:25+00:00 2026-05-31T00:29:25+00:00

I am writing a procedure about key renewing for my application. This procedure will

  • 0

I am writing a procedure about key renewing for my application. This procedure will be executed by a sysadmin every year or so.

In my application, there is a symmetric key used to cipher some data before storing it in the database. This key is stored in a Java keystore.

When the application must store some data in the database in a ciphered way, the key alias to use is read from a configuration file, the key is read from the Java keystore with this key alias, the data is ciphered with the key and I store everything in the database: the key alias, the Initialization Vector and the ciphered data, all separated with semi-colons.

So the procedure to use another key is straightforward:

  1. generate a new symmetric key in the Java Keystore with another alias
  2. change the configuration file to use this new key alias

But I do not know any command-line tool that can create a symmetric key in a Java keystore. The java keytool utility can only create key pairs.

Is there a command line tool to generate symmetric keys in a Java keystore or should I develop my own tool?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:29:27+00:00Added an answer on May 31, 2026 at 12:29 am

    keytool is able to generate a secret key since Java 6 with the -genseckey command. Here is an excerpt of the Java 6 keytool documentation:

    -genseckey {-alias alias} {-keyalg keyalg}
           {-keysize keysize} [-keypass keypass]
           {-storetype storetype} {-keystore keystore}
           [-storepass storepass]
           {-providerClass provider_class_name {-providerArg provider_arg}}
           {-v} {-protected} {-Jjavaoption}
    

    Generates a secret key and stores it in a new KeyStore.SecretKeyEntry identified by alias.

    keyalg specifies the algorithm to be used to generate the secret key, and keysize specifies the size of the key to be generated. keypass is a password used to protect the secret key. If no password is provided, the user is prompted for it. If you press RETURN at the prompt, the key password is set to the same password as that used for the keystore. keypass must be at least 6 characters long.

    So the following command will generate a new AES 128 bits key

    keytool -genseckey -alias mykey -keyalg AES -keysize 128 \
        -storetype jceks -keystore mykeystore.jks
    

    The keytool command has a typo bug that hides the help information about -genseckey:

    % keytool -help
    [...]
    -genkeypair  [-v] [-protected]
             [-alias <alias>]
             [-keyalg <keyalg>] [-keysize <taille_clé>]
             [-sigalg <sigalg>] [-dname <nomd>]
             [-validity <joursVal>] [-keypass <mot_passe_clé>]
             [-keystore <keystore>] [-storepass <mot_passe_store>]
             [-storetype <storetype>] [-providername <name>]
             [-providerclass <provider_class_name> [-providerarg <arg>]] ...
             [-providerpath <pathlist>]
    
    -genkeypair  [-v] [-protected]
             [-alias <alias>] [-keypass <keypass>]
             [-keyalg <keyalg>] [-keysize <taille_clé>]
             [-keystore <keystore>] [-storepass <mot_passe_store>]
             [-storetype <storetype>] [-providername <name>]
             [-providerclass <provider_class_name> [-providerarg <arg>]] ...
             [-providerpath <pathlist>] 
    

    The -genkeypair command appears twice. In fact the second -genkeypair should be read -genseckey. That’s why I did not notice the command.

    I have encountered this typo bug with Java 1.6.0_26. I have checkd with the latest Java 6 available (1.6.0_31) and it has the same problem. I have also checked with the latest Java 7 and the documentation problem is fixed:

    % java -version
    java version "1.7.0_03"
    Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
    Java HotSpot(TM) Server VM (build 22.1-b02, mixed mode)
    % keytool -help
     [...]
     -genkeypair         Generates a key pair
     -genseckey          Generates a secret key
     [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a stored procedure that when completed will be used to scan
This problem is about Javascript writing HTML code for video player. I think there
I am writing a stored procedure for displaying month and year. It is working,
I'm writing a stored procedure that will bring back a lot of project information.
I'm writing a password salt/hash procedure for my .NET application, largely following the guide
I was just writing a procedure that is looking for a newline and I
I am writing a procedure where each call it needs to get a single
I am writing a stored procedure where I have an input parameter called my_size
I'm writing a stored procedure that needs to have a lot of conditioning in
I am writing a stored procedure where i m using try catch block. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.