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

AES GCM mode with SoftHSM2 fails to decrypt more than one block #160

Open
tstiemerling opened this issue Apr 5, 2024 Discussed in #159 · 0 comments
Open

AES GCM mode with SoftHSM2 fails to decrypt more than one block #160

tstiemerling opened this issue Apr 5, 2024 Discussed in #159 · 0 comments

Comments

@tstiemerling
Copy link

Hi, the SoftHSM2 implementation of GCM decrypt does not return any data until you call C_DecryptFinal (not sure if other P11 implementations are the same), so the final() method in decipher.ts is failing since it only allocates one block for the plaintext, but SoftHSM2 is expecting a buffer equal to the plaintext length.

public final(): Buffer {
const dec = Buffer.alloc(this.blockSize);

const res = this.lib.C_DecryptFinal(this.session.handle, dec);

return res;

}

Discussed in #159

Originally posted by tstiemerling April 3, 2024
Are there any examples of using AES GCM mode? I am trying to use graphene with SoftHSM2 (windows build) and I getting CKR_BUFFER_TOO_SMALL returned on decrypt (unit test). The offending SoftHSM code seems to be here:

c:\build\src\softhsm-2.5.0-x64\src\lib\softhsm.cpp(3256): Output buffer too short ulEncryptedDataLen: 0x10 output buffer size: 0x20 blockSize: 0x10 remainingSize: 0x100 maxSize: 0x110

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

1 participant