Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateKey throws NullPointerException on empty byte array #1370

Closed
loosebazooka opened this issue Apr 5, 2023 · 2 comments
Closed

CreateKey throws NullPointerException on empty byte array #1370

loosebazooka opened this issue Apr 5, 2023 · 2 comments
Assignees

Comments

@loosebazooka
Copy link

  @Test
  void test() throws IOException {
    PublicKeyFactory.createKey(new byte[0]);
  }

The root cause of this appears to be in ASN1Primitive#fromByteArray(byte[] data) where the ASN1inputstream immediately returns -1 on read() and so the call to readObject() return null.

This is a bit unexpected as the null comes from deeper in the system. The input itself is not null. I don't have a good suggestion right now on the correct behavior. Perhaps it should throw an IOException?

@dghgit
Copy link
Contributor

dghgit commented Apr 10, 2023

This should be dealt with in BC 1.73. Thanks for raising the issue with us.

vanitasvitae pushed a commit to pgpainless/bc-java that referenced this issue Apr 11, 2023
@dghgit
Copy link
Contributor

dghgit commented May 20, 2023

Fixed in 1.73.

@dghgit dghgit closed this as completed May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants