vault/ui/app/components/transit-key-actions.hbs
Scott Miller 3c0656e4c4
Update marcellanz/transit_pkcs1v15 RSA encryption support (#25486)
* [transit-pkcs1v15] transit support for the pkcs1v15 padding scheme – without UI tests (yet).

* [transit-pkcs1v15] renamed padding_scheme parameter in transit documentation.

* [transit-pkcs1v15] add changelog file.

* [transit-pkcs1v15] remove the algorithm path as padding_scheme is chosen by parameter.

* Update ui/app/templates/components/transit-key-action/datakey.hbs

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>

* Update ui/app/templates/components/transit-key-action/datakey.hbs

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>

* Update ui/app/templates/components/transit-key-action/datakey.hbs

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>

* Update website/content/api-docs/secret/transit.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/api-docs/secret/transit.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/api-docs/secret/transit.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Add warnings to PKCS1v1.5 usage

* Update transit

* Update transit, including separating encrypt/decrypt paddings for rewrap

* Clean up factory use in the presence of padding

* address review feedback

* remove defaults

* lint

* more lint

* Some fixes for UI issues

 - Fix padding scheme dropdown console error by adding values
   to the transit-key-actions.hbs
 - Populate both padding scheme drop down menus within rewrap,
   not just the one padding_scheme
 - Do not submit a padding_scheme value through POST for non-rsa keys

* Fix Transit rewrap API to use decrypt_padding_scheme, encrypt_padding_scheme

 - Map the appropriate API fields for the RSA padding scheme to the
   batch items within the rewrap API
 - Add the ability to create RSA keys within the encrypt API endpoint
 - Add test case for rewrap api that leverages the padding_scheme fields

* Fix code linting issues

* simply padding scheme enum

* Apply suggestions from code review

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>

* Fix padding_scheme processing on data key api

 - The data key api was using the incorrect parameter name for
   the padding scheme
 - Enforce that padding_scheme is only used on RSA keys, we
   are punting on supporting it for managed keys at the moment.

* Add tests for parsePaddingSchemeArg

* Add missing copywrite headers

* Some small UI fixes

* Add missing param to datakey in api-docs

* Do not send padding_scheme for non-RSA key types within UI

* add UI tests for transit key actions form

---------

Co-authored-by: Marcel Lanz <marcellanz@n-1.ch>
Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
Co-authored-by: Steve Clark <steven.clark@hashicorp.com>
Co-authored-by: claire bontempo <cbontempo@hashicorp.com>
2024-10-09 09:30:14 -05:00

138 lines
5.3 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<div {{did-update this.updateProps @selectedAction}}>
<MessageError @errorMessage={{this.errors}} />
{{#if (eq @selectedAction "encrypt")}}
<TransitKeyAction::Encrypt
@key={{@key}}
@param={{this.props.param}}
@context={{this.props.context}}
@nonce={{this.props.nonce}}
@bits={{this.props.bits}}
@key_version={{this.props.key_version}}
@padding_scheme={{this.props.padding_scheme}}
@encodedBase64={{this.props.encodedBase64}}
@toggleEncodeBase64={{this.toggleEncodeBase64}}
@plaintext={{this.props.plaintext}}
@ciphertext={{this.props.ciphertext}}
@doSubmit={{perform this.doSubmit}}
@isModalActive={{this.isModalActive}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (eq @selectedAction "decrypt")}}
<TransitKeyAction::Decrypt
@key={{@key}}
@ciphertext={{this.props.ciphertext}}
@context={{this.props.context}}
@nonce={{this.props.nonce}}
@padding_scheme={{this.props.padding_scheme}}
@isModalActive={{this.isModalActive}}
@plaintext={{this.props.plaintext}}
@doSubmit={{perform this.doSubmit}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (eq @selectedAction "datakey")}}
<TransitKeyAction::Datakey
@key={{@key}}
@param={{this.props.param}}
@context={{this.props.context}}
@nonce={{this.props.nonce}}
@bits={{this.props.bits}}
@plaintext={{this.props.plaintext}}
@padding_scheme={{this.props.padding_scheme}}
@ciphertext={{this.props.ciphertext}}
@doSubmit={{perform this.doSubmit}}
@isModalActive={{this.isModalActive}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (eq @selectedAction "rewrap")}}
<TransitKeyAction::Rewrap
@key={{@key}}
@param={{this.props.param}}
@context={{this.props.context}}
@nonce={{this.props.nonce}}
@key_version={{this.props.key_version}}
@ciphertext={{this.props.ciphertext}}
@isModalActive={{this.isModalActive}}
@decrypt_padding_scheme={{this.props.decrypt_padding_scheme}}
@encrypt_padding_scheme={{this.props.encrypt_padding_scheme}}
@doSubmit={{perform this.doSubmit}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (eq @selectedAction "hmac")}}
<TransitKeyAction::Hmac
@key={{@key}}
@trackedInput={{this.props.input}}
@algorithm={{this.props.algorithm}}
@key_version={{this.props.key_version}}
@encodedBase64={{this.props.encodedBase64}}
@toggleEncodeBase64={{this.toggleEncodeBase64}}
@hmac={{this.props.hmac}}
@isModalActive={{this.isModalActive}}
@doSubmit={{perform this.doSubmit}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (eq @selectedAction "verify")}}
<TransitKeyAction::Verify
@key={{@key}}
@trackedInput={{this.props.input}}
@signature={{this.props.signature}}
@signature_algorithm={{this.props.signature_algorithm}}
@hmac={{this.props.hmac}}
@hash_algorithm={{this.props.hash_algorithm}}
@context={{this.props.context}}
@prehashed={{this.props.prehashed}}
@encodedBase64={{this.props.encodedBase64}}
@verification={{this.props.verification}}
@valid={{this.props.valid}}
@toggleEncodeBase64={{this.toggleEncodeBase64}}
@keyIsRSA={{this.keyIsRSA}}
@isModalActive={{this.isModalActive}}
@doSubmit={{perform this.doSubmit}}
@submitIsRunning={{this.doSubmit.isRunning}}
@clearSpecificProps={{this.clearSpecificProps}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (eq @selectedAction "sign")}}
<TransitKeyAction::Sign
@key={{@key}}
@trackedInput={{this.props.input}}
@hash_algorithm={{this.props.hash_algorithm}}
@signature={{this.props.signature}}
@signature_algorithm={{this.props.signature_algorithm}}
@key_version={{this.props.key_version}}
@context={{this.props.context}}
@prehashed={{this.props.prehashed}}
@encodedBase64={{this.props.encodedBase64}}
@toggleEncodeBase64={{this.toggleEncodeBase64}}
@isModalActive={{this.isModalActive}}
@doSubmit={{perform this.doSubmit}}
@submitIsRunning={{this.doSubmit.isRunning}}
data-test-transit-action={{@selectedAction}}
/>
{{else if (or (eq @selectedAction "export") (eq (get @key.supportedActions 0) "export"))}}
<TransitKeyAction::Export
@key={{@key}}
@keys={{this.props.keys}}
@trackedInput={{this.props.input}}
@hash_algorithm={{this.props.hash_algorithm}}
@signature={{this.props.signature}}
@signature_algorithm={{this.props.signature_algorithm}}
@key_version={{this.props.key_version}}
@context={{this.props.context}}
@prehashed={{this.props.prehashed}}
@encodedBase64={{this.props.encodedBase64}}
@exportKeyType={{this.props.exportKeyType}}
@exportKeyVersion={{this.props.exportKeyVersion}}
@wrappedToken={{this.props.wrappedToken}}
@wrappedTTL={{this.props.wrappedTTL}}
@toggleEncodeBase64={{this.toggleEncodeBase64}}
@isModalActive={{this.isModalActive}}
@doSubmit={{perform this.doSubmit}}
data-test-transit-action="export"
/>
{{/if}}
</div>