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

Unable to encrypt larger buffers #680

Closed
arvin4181 opened this issue Dec 6, 2017 · 2 comments
Closed

Unable to encrypt larger buffers #680

arvin4181 opened this issue Dec 6, 2017 · 2 comments

Comments

@arvin4181
Copy link

Previously, I used tpm2_rsaencrypt to encrypt larger buffers.Today, I installed tpm2-tools, tpm2-abrmd, tpm2-tss from latest sources and observe that tpm2_rsaencrypt does not encrypt buffers larger than 128 bit. This breaks all our use cases, any clues why such a limitation? Now, I'm wondering how to encrypt larger buffers, any suggestions ?

ERROR:
$tpm2_rsaencrypt keyfile -c context_load_out -o encryptfile
ERROR: File "keyfile" size is larger than buffer, got 4096 expected less than 512
ERROR: Data to be sealed larger than expected. Got 512 expected 1

@williamcroberts
Copy link
Member

williamcroberts commented Dec 6, 2017

@arvin4181 questions should be asked on the mailing list per the README.md on getting support. But ill play along on here.

What versions worked as you expected? Looking at version 2.1.1 and 1.1.1 it looks like TPM2B_PUBLIC_KEY_RSA has always been used to load the input data from the
file with size set to the buffer in that structure. Are you sure that data wasn't being tuncated
on the read before?

Per the spec it states that the message parameter is limited in size to the larges RSA keyhandle:

message to be encrypted
NOTE 1 The data type was chosen because it limits
the overall size of the input to no greater than
the size of the largest RSA public key. This
may be larger than allowed for keyHandle.

Note that this message size may be too big based on your key and padding scheme. If you choose RSA 256 and try and encrypt a 512 buffer, it will fail.

I think this is a case of the tools not reporting an error when one should have existed AFAICT.

@williamcroberts
Copy link
Member

I don't think this is a bug, working as expected.

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