create Digest by name

Hohwiller, Jörg <joerg.hohwiller-gM/[email protected]> Sat, 9 Mar 2019 13:31:21 +0100
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <[email protected]>
Hi there,

I am looking for a way how to create a BC Digest by name. It seems this
use-case is not addressed. I can create a MessageDigest with BC Provider
by name but can not unwrap it via official API.

However, I want to create an ECDSASigner with a HMacDSAKCalculator and
that requires a BC Digest. It seems that due to design flaws and
limitations of JCE there is a partial mess what can be done via official
Java APIs and what has to be done via BC proprietary APIs and in such
case this makes it unnecessary difficult.

Of course I could use reflection hacks or put an own class in your
org.bouncycastle.jcajce.provider.digest package to unwrap the Digest
from BCMessageDigest but this does not seem to be a reliable or elegant
way.

Otherwise I might end up with some ugly switch case statement that then
is very unflexible for digest algorithms I have not covered in my code
(that may be even added in the future without me maintaining the code).

Any ideas how to solve this properly? What am I missing?

Thank you so much

  Jörg