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

Error: "flate: corrupt input before offset 1" when handling TripleDES encrypted assertions #203

Open
viotile opened this issue Dec 5, 2024 · 0 comments

Comments

@viotile
Copy link

viotile commented Dec 5, 2024

I encountered an issue while executing the following code:

assertions, err := sp.RetrieveAssertionInfo(samlResponse)

The code results in the following error:
error validating response: unable to create element from decrypted assertion bytes: flate: corrupt input before offset 1

Upon investigation, I found that the problem occurs because I receive a 16-byte block instead of the expected 8-byte block for the 3DES encryption method. This seems to be related to the encryption method handling in the DecryptSymmetricKey function.

Here’s the relevant code in the repository:
EncryptedKey.DecryptSymmetricKey

if MethodTripleDESCBC == ek.EncryptionMethod {
    // Use 3DES cipher for 8-byte blocks
    b, err := des.NewTripleDESCipher(pt)
    if err != nil {
        return nil, err
    }
} else {
    // Use AES cipher for 16-byte blocks
    b, err := aes.NewCipher(pt)
    if err != nil {
        return nil, err
    }
}

This change ensures proper decryption of TripleDES-encrypted assertions and avoids the "flate: corrupt input" error.

Would it be possible to include this fix in the library? Let me know if additional details or a pull request would be helpful.

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