create Digest by name

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

create Digest by name

Hohwiller, Jörg
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


Reply | Threaded
Open this post in threaded view
|

Re: create Digest by name

David Hook-3

There's org.bouncycastle.jcajce.provider.util.DigestFactory - it might
be more general than you want though, so you might still want to
implement your own based on it.

Regards,

David

On 9/3/19 11:31 pm, Hohwiller, Jörg wrote:

> 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
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: create Digest by name

Hohwiller, Jörg
Hi David,

I digged in org.bouncycastle.crypto.util.DigestFactory before and missed
the one you suggested.

Thanks for pointing this out. This is what I need to solve my problem.

Cheers

  Jörg

Am 10.03.19 um 19:18 schrieb David Hook:
>
> There's org.bouncycastle.jcajce.provider.util.DigestFactory - it might
> be more general than you want though, so you might still want to
> implement your own based on it.
>
> Regards,
>
> David