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

use 'algorithm' instead of 'hash-algorithm' for HMAC #4604

Merged
merged 2 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/app/components/transit-key-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { get, set } = Ember;

const TRANSIT_PARAMS = {
hash_algorithm: 'sha2-256',
algorithm: 'sha2-256',
signature_algorithm: 'pss',
bits: 256,
bytes: 32,
Expand Down Expand Up @@ -31,7 +32,7 @@ const TRANSIT_PARAMS = {
const PARAMS_FOR_ACTION = {
sign: ['input', 'hash_algorithm', 'key_version', 'prehashed', 'signature_algorithm'],
verify: ['input', 'hmac', 'signature', 'hash_algorithm', 'prehashed'],
hmac: ['input', 'hash_algorithm', 'key_version'],
hmac: ['input', 'algorithm', 'key_version'],
encrypt: ['plaintext', 'context', 'nonce', 'key_version'],
decrypt: ['ciphertext', 'context', 'nonce'],
rewrap: ['ciphertext', 'context', 'nonce', 'key_version'],
Expand Down
12 changes: 6 additions & 6 deletions ui/app/templates/components/transit-key-action/hmac.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form {{action 'doSubmit' (hash input=input hash_algorithm=hash_algorithm key_version=key_version) on="submit"}}>
<form {{action 'doSubmit' (hash input=input algorithm=algorithm key_version=key_version) on="submit"}}>
{{#if hmac}}
<div class="box is-sideless is-fullwidth is-marginless">
<div class="field">
Expand Down Expand Up @@ -42,16 +42,16 @@
</div>
</div>
<div class="field">
<label for="hash_algorithm" class="is-label">Hash Algorithm</label>
<label for="algorithm" class="is-label">Hash Algorithm</label>
<div class="control is-expanded">
<div class="select is-fullwidth">
<select
name="hash_algorithm"
id="hash_algorithm"
onchange={{action (mut hash_algorithm) value="target.value"}}
name="algorithm"
id="algorithm"
onchange={{action (mut algorithm) value="target.value"}}
>
{{#each (sha2-digest-sizes) as |algo|}}
<option selected={{if hash_algorithm (eq hash_algorithm algo)}} value={{algo}}>
<option selected={{if algorithm (eq algorithm algo)}} value={{algo}}>
<code>{{algo}}</code>
</option>
{{/each}}
Expand Down
24 changes: 24 additions & 0 deletions ui/tests/integration/components/transit-key-actions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,27 @@ test('it can export a key: unwrapped, single version', function(assert) {
'passes expected args to the adapter'
);
});

test('it includes algorithm param for HMAC', function(assert) {
this.set('key', {
backend: 'transit',
id: 'akey',
supportedActions: ['hmac'],
validKeyVersions: [1],
});
this.render(hbs`{{transit-key-actions key=key}}`);
this.$('#algorithm').val('sha2-384').change();
this.$('button:submit').click();
assert.deepEqual(
this.get('storeService.callArgs'),
{
action: 'hmac',
backend: 'transit',
id: 'akey',
payload: {
algorithm: "sha2-384"
},
},
'passes expected args to the adapter'
);
});