Keys lost from BKS file without deleteKey command

Arun Prasad <[email protected]>
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <CAAUqC-ypEREBUBuKPRuCz8wsxekNVQcekzWOSQHvkYN+KRin6g@mail.gmail.com>
Hi,

I use a keystore (BKS format) in my android app to store public private
keypairs. The app was used over a long time and had 10+ public private key
pairs. All of a sudden, one of the app's major functionality stopped
working. Root cause was found out to be the following:

Only one public private keypair is remaining in the BKS file. All other
keypairs are lost. I verified in the code that
KeyStore.deleteEntry(alias) is not called anywhere in the app. The only
place where I could find if something would have gone wrong is  following:

We create a keypair and set it using:
KeyStore.setKeyEntry(keyId, keyPair.getPrivate(), getKeyStorePassword(),
certChain);

The javadoc of above method states the following:
If the given alias already exists, the keystore information associated with
it is overridden by the given key (and possibly certificate chain).

Normally, a string obtained from server which is a UUID is used as alias to
set a new KeyPair in KeyStore. So, the possibility of new alias being same
as one which is already present in keystore is very unlikely. Even if
that's the case, it would have just overridden one key pair. But, in this
case, around 10+ key pairs are lost.

Does anyone know of any known issues which result in this kind of key-pair
loss?

Thanks,
Arun
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.