Adds configurable RSA key size#288
Open
NateSwanson7 wants to merge 1 commit into
Open
Conversation
…th used by Auth.generatePlatformKeyPair. Default remains 4096. Validates integer >= 2048 (LTI 1.3 spec minimum).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
configurable platform RSA
modulusLengthviaoptions.keySizeCloses #289
Summary
Adds a new
keySizeoption tolti.setup()that controls the RSA modulus length used byAuth.generatePlatformKeyPairwhen generating per-platform keypairs duringregisterPlatform(). Default behavior is unchanged (4096).Motivation, benchmarks, and spec context are in the linked issue. The short version: 4096-bit
generateKeyPairSyncis the dominant cost in dynamic registration on small instances (several seconds, with multiplicative variance into the double-digit-seconds range), 2048 is the LTI 1.3 spec minimum, and Canvas/Moodle/Blackboard all use 2048.What changed
Threading
keySizefrom setup → registerPlatform → Auth, with the same explicit-arg fallback pattern that the existingENCRYPTIONKEY/Database/getPlatformplumbing uses. This keeps the option working through both call paths:lti.registerPlatform({...})) —this === Provider, falls back to the configured#keySize.registerPlatformis invoked as a bare function reference wherethis !== Provider, so the service constructor receiveskeySizefrom the Provider at setup time and passes it explicitly into the call.Files touched:
src/Provider/Provider.js#keySize = 4096private field; newoptions.keySizevalidation insetup()(throwsINVALID_KEYSIZEfor non-integer or< 2048); JSDoc;registerPlatformsignature accepts optionalkeySize; passesthis.#keySizeinto theDynamicRegistrationconstructorsrc/Provider/Services/DynamicRegistration.jskeySize; stores on a private field; passes it through toregisterPlatformsrc/Utils/Auth.jsgeneratePlatformKeyPairacceptskeySize = 4096; uses it formodulusLength; JSDoctest/0-keysize.js(new)Auth.generatePlatformKeyPairwith default (4096) and explicit (2048)keySizetest/0-provider.jsProvider.setupvalidation (non-integer and< 2048both reject withINVALID_KEYSIZE)Backwards compatibility
Default value is unchanged (
4096). Consumers who do not passkeySizesee identical behavior. Validation only runs when the option is explicitly set.Tests
All existing tests pass. New tests:
Auth.generatePlatformKeyPairdefault produces a 4096-bit RSA modulusAuth.generatePlatformKeyPairwithkeySize: 2048produces a 2048-bit RSA modulusProvider.setuprejects non-integerkeySizewithINVALID_KEYSIZEProvider.setuprejectskeySize < 2048withINVALID_KEYSIZEModulus length is asserted via
crypto.createPublicKey(pem).asymmetricKeyDetails.modulusLength.