update hmac form and component to use 'algorithm' instead of 'hash-algorithm' (#4604)

This commit is contained in:
madalynrose 2018-05-21 14:50:54 -04:00 committed by GitHub
parent fb04064967
commit e42a99ced3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 7 deletions

View File

@ -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,
@ -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'],

View File

@ -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">
@ -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}}

View File

@ -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'
);
});