0

When I try to decrypt ciphertext using streaming aead primitive as part of google tink, I get the following error: java.io.IOException: No matching key found for the ciphertext in the stream

Below is my code:

ByteBuffer buffer = ByteBuffer.allocate(1000);
int bytesRead = 0;

StreamingAead saead = keysetHandle.getPrimitive(StreamingAead.class);
ReadableByteChannel ciphertextSource = Channels.newChannel(new ByteArrayInputStream(ciphertext));
ReadableByteChannel decryptingChannel = saead.newDecryptingChannel(ciphertextSource, associatedData);

while(bytesRead < 1000) {
  bytesRead += decryptingChannel.read(buffer);
}

The line where the error is shown is: bytesRead += decryptingChannel.read(buffer)

I've already referred here and here but the issue persists. I'm using tink version 1.6.0

Udit Gupta
  • 15
  • 1
  • 5

0 Answers0