Skip to content

Support AES-GCM encryption algorithms#129

Merged
mitchellhenke merged 8 commits intomainfrom
mitchellhenke/support-gcm-encryption
Dec 4, 2024
Merged

Support AES-GCM encryption algorithms#129
mitchellhenke merged 8 commits intomainfrom
mitchellhenke/support-gcm-encryption

Conversation

@mitchellhenke
Copy link

@mitchellhenke mitchellhenke commented Dec 3, 2024

closes https://gitlab.login.gov/lg-teams/Melba/protocols-backlog/-/issues/139

xmlenc added support for AES-GCM in version 0.8.0 in August 2021. It doesn't appear that upstream saml_idp supports AES-GCM either.

This PR adds support for using AES-GCM in the block_encryption option.

I did some light testing locally with our sample SAML service provider, and it everything seemed to work as expected.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/support-gcm-encryption branch from bb0b3b1 to 2651d43 Compare December 3, 2024 23:07
Comment on lines +49 to +51
encrypted_doc = Nokogiri::XML::Document.parse(encrypted_xml)
encrypted_data = Xmlenc::EncryptedData.new(encrypted_doc.at_xpath('//xenc:EncryptedData',
Xmlenc::NAMESPACES))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth doing an xml query for the specific xml namespace like http://www.w3.org/2009/xmlenc11#aes256-gcm from the other method what was edited?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a controller spec (like this one)to ensure that that encryption/decryption of responses works with different encryption algos?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added specs. It doesn't seem like tripledes-cbc works at all due to a potential issue in upstream xmlenc or how saml_idp integrates with it, so I've removed it.

when 'aes256-gcm'
'http://www.w3.org/2009/xmlenc11#aes256-gcm'
else
"http://www.w3.org/2009/xmlenc11##{block_encryption}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have an else here? or should we throw if it's not an expected encryption algorithm? (the block_encryption value is derived from the service provider in the database)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we definitely could, xmlenc will throw anyway:

Xmlenc::UnsupportedError - Unsupported encryption method http://www.w3.org/2001/04/xmlenc#abc-haha

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to raise a ValidationError

Copy link

@Sgtpluck Sgtpluck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple questions, worth nothing that actually wiring this up to be accessible to partners will require an update of the partner portal and the config script (which currently just ignores the attribute in the data transformation and hardcodes the block encryption to aes256-cbc if it's 'none')

we probably want to identify a default as well, since we want to discourage/disallow partners from turning it off in production. historically it's been aes256-cbc since that was the only value ... do we want to use aes256-gcm?

Mitchell Henke and others added 5 commits December 4, 2024 09:27
@ajfarkas
Copy link

ajfarkas commented Dec 4, 2024

we probably want to identify a default as well, since we want to discourage/disallow partners from turning it off in production. historically it's been aes256-cbc since that was the only value ... do we want to use aes256-gcm?

I'm trying to figure out if Salesforce supports GCM. If that's the case, I'd vote for defaulting to that, so we can get a whole bunch of SP's to add encryption.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/support-gcm-encryption branch from d2baeec to 45352a0 Compare December 4, 2024 17:27
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

Successfully merging this pull request may close these issues.

4 participants