JCE clear room implementation missing some code lines

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

JCE clear room implementation missing some code lines

Atanas Walks
Hi Peter (and everyone),

I've noticed that the source (and binary) code of the clear room JCE is missing some code lines. Is this intentional ?

In my case I've noticed that the original (bc-git/bc-java)
org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi

    protected PublicKey engineGeneratePublic(
        KeySpec keySpec)
        throws InvalidKeySpecException
    {
        if (keySpec instanceof ECPublicKeySpec)
        {
            return new BCECPublicKey(algorithm, (ECPublicKeySpec)keySpec, configuration);
        }
        else if (keySpec instanceof java.security.spec.ECPublicKeySpec)
        {
            return new BCECPublicKey(algorithm, (java.security.spec.ECPublicKeySpec)keySpec, configuration);
        }

        return super.engineGeneratePublic(keySpec);
    }

whereas the source of the clear room JCE is only:

    protected PublicKey engineGeneratePublic(
        KeySpec keySpec)
        throws InvalidKeySpecException
    {
        try
        {
            if (keySpec instanceof ECPublicKeySpec)
            {
                return new BCECPublicKey(algorithm, (ECPublicKeySpec)keySpec, configuration);
            }
            // missing (keySpec instanceof java.security.spec.ECPublicKeySpec)
        }
        catch (Exception e)
        {
            throw new InvalidKeySpecException("invalid KeySpec: " + e.getMessage());
        }

        return super.engineGeneratePublic(keySpec);
    }


PS. The same applies for the engineGeneratePrivate() method!

Best Regards,
Atanas Krachev
Reply | Threaded
Open this post in threaded view
|

Re: JCE clear room implementation missing some code lines

David Hook-3

Yes, it is intentional - the early Java environments don't have the Java
EC classes available in the API. Our EC classes date back to well before
Java 1.5, so you'll find in the code for the older VMs only the BC EC
classes are referenced.

Regards,

David

On 15/07/17 05:15, Atanas Walks wrote:

> Hi Peter (and everyone),
>
> I've noticed that the source (and binary) code of the clear room JCE
> is missing some code lines. Is this intentional ?
>
> In my case I've noticed that the original (bc-git/bc-java)
> org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi
>
>     protected PublicKey engineGeneratePublic(
>         KeySpec keySpec)
>         throws InvalidKeySpecException
>     {
>         if (keySpec instanceof ECPublicKeySpec)
>         {
>             return new BCECPublicKey(algorithm,
> (ECPublicKeySpec)keySpec, configuration);
>         }
>         else if (keySpec instanceof java.security.spec.ECPublicKeySpec)
>         {
>             return new BCECPublicKey(algorithm,
> (java.security.spec.ECPublicKeySpec)keySpec, configuration);
>         }
>
>         return super.engineGeneratePublic(keySpec);
>     }
>
> whereas the source of the clear room JCE is only:
>
>     protected PublicKey engineGeneratePublic(
>         KeySpec keySpec)
>         throws InvalidKeySpecException
>     {
>         try
>         {
>             if (keySpec instanceof ECPublicKeySpec)
>             {
>                 return new BCECPublicKey(algorithm,
> (ECPublicKeySpec)keySpec, configuration);
>             }
>             // missing (keySpec instanceof
> java.security.spec.ECPublicKeySpec)
>         }
>         catch (Exception e)
>         {
>             throw new InvalidKeySpecException("invalid KeySpec: " +
> e.getMessage());
>         }
>
>         return super.engineGeneratePublic(keySpec);
>     }
>
>
> PS. The same applies for the engineGeneratePrivate() method!
>
> Best Regards,
> Atanas Krachev