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

Add a createOctKey convenience method and relevant options. #13522

Merged
merged 4 commits into from
Feb 2, 2021

Conversation

maorleger
Copy link
Member

What

  • Add createOctKey method to support creating keys of type oct and oct-HSM
  • Add createOctKeyOptions supporting hsm (keySize is already supported at the createKeyOptions interface)

Why

  • This adds the same convenience layer we have for createEcKey, createRsaKey, etc....

Callouts

  • Decided to use hsm to be compatible with the APIs we already shipped. Feel free to let me know if you want this to be hardwareProtected at the cost of being inconsistent with our other createKeyOptions.

resolves #12457

/**
* Whether to create a hardware-protected key in a hardware security module (HSM).
*/
hsm?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

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

I went with hsm because we already use hsm on createEcKeyOptions and createRsaKeyOptions - but feel free to let me know if we should break tradition here to use hardwareProtected

Copy link
Contributor

@sadasant sadasant left a comment

Choose a reason for hiding this comment

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

Love it! Thank you.

@maorleger maorleger force-pushed the create-oct-key-options branch from d489191 to 3c11811 Compare February 2, 2021 22:23
@check-enforcer
Copy link

check-enforcer bot commented Feb 2, 2021

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

@maorleger
Copy link
Member Author

maorleger commented Feb 2, 2021

/check-enforcer override

build passes, but there's a known issue with check enforcer

@maorleger maorleger merged commit d476db9 into Azure:master Feb 2, 2021
@maorleger maorleger deleted the create-oct-key-options branch February 2, 2021 22:46
@@ -42,6 +42,11 @@ export interface CreateKeyOptions extends coreHttp.OperationOptions {
};
}

// @public
export interface CreateOctKeyOptions extends CreateKeyOptions {
hsm?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

  1. This should've been hardwareProtected, but I see you shipped previously with hsm so that's fine. I guess this was missed in unification.
  2. What about keySize here? That's valid as well. See https://github.com/Azure/azure-sdk-for-net/blob/f8aabfa3cc1b0a7ae2b6a1c111ea96416b3a4f4d/sdk/keyvault/Azure.Security.KeyVault.Keys/src/CreateOctKeyOptions.cs#L27. In .NET we have optional "parameters" as read-write properties instead of constructor params (reserved for required "parameters" and their properties are typically read-only).

Copy link
Member

Choose a reason for hiding this comment

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

Opened #13545 for the second issue.

Copy link
Member Author

@maorleger maorleger Feb 2, 2021

Choose a reason for hiding this comment

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

  1. Agree on using hardwareProtected but yea I kept it hsm to be consistent across our APIs (see this comment: Add a createOctKey convenience method and relevant options. #13522 (comment))
  2. I was wondering as well, but noticed we already offer keySize in CreateKeyOptions which this extends. See here:

That change was before my time, but when I used this new options bag (CreateOctKeyOptions) in sample code keySize was available to me. Do you think I should move it to a few specific Create<KeyType>Options classes instead?

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. In the PR, I noticed that createRsaKeyOptions also defines it at

, which is what threw me. Probably can't change it now, but keySize probably shouldn't have been defined on the base; practically, though, I doubt it would never not be a parameter.

Copy link
Member Author

@maorleger maorleger Feb 3, 2021

Choose a reason for hiding this comment

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

Yea, not sure why it's overridden - might be a miss. But, since we can't remove createKeyOptions.keySize now maybe the thing to do is to remove the overrides since it's just debt at this point? I can reuse and update #13545 to reflect that.

maorleger added a commit that referenced this pull request Feb 10, 2021
We define `keySize` in `createRsaKeyOptions` but we don't have to since it's already
defined in `createKeyOptions` which this inherits from. Having it defined in two places
adds confusion (see #13522 (comment) as an example).

This commit just removes the redefined parameter and updates the base parameter's
doc comment to be clearer.

Fixes #13589
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this pull request Mar 23, 2021
Remove readonly for keyOps and keySize (Azure#13522)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CreateOctKeyOptions to Key Vault Keys
3 participants