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

CryptographyClient support #4415

Closed
sophiajt opened this issue Jul 24, 2019 · 1 comment · Fixed by #4434
Closed

CryptographyClient support #4415

sophiajt opened this issue Jul 24, 2019 · 1 comment · Fixed by #4434
Assignees
Labels
Client This issue points to a problem in the data-plane of the library.
Milestone

Comments

@sophiajt
Copy link
Contributor

sophiajt commented Jul 24, 2019

Based on Azure/azure-sdk-for-net#7004 we'd like to bring a new CryptographyClient to TypeScript/JavaScript.

The CryptographyClient will be similar to clients like SecretClient and KeysClient, in that it will be a standalone client that can independently connect to the KeyVault service. It will also be able to optionally offload cryptography related tasks to Node and browser-based crypto. It will use this as an optimization to both speed up cryptography tasks and ease service usage.

Outline

A rough outline of the new client would be something like this:

export class CryptographyClient {
  public static getDefaultPipeline(
    credential: ServiceClientCredentials | TokenCredential,
    pipelineOptions: NewPipelineOptions = {}
  ): Pipeline { ... }

  constructor(
    urlOrKey: string | Key,
    credential: ServiceClientCredentials | TokenCredential,
    pipelineOrOptions: Pipeline | NewPipelineOptions = {}
  ) { ... }

  public async getKey(options?: RequestOptions): Promise<Key> { ... }

  public async encrypt(plaintext: Uint8Array, iv: Uint8Array, algorithm: JsonWebKeyEncryptionAlgorithm, authenticationData?: Uint8Array, options?: RequestOptions): Promise<KeyOperationResult> { ... }
  
  public async decrypt(ciphertext: Uint8Array, iv: Uint8Array,  algorithm: JsonWebKeyEncryptionAlgorithm, authenticationData?: Uint8Array, authenticationTag?: Uint8Array,  options?: RequestOptions): Promise<KeyOperationResult>  { ... }

  public async wrapKey(key: Uint8Array, algorithm: JsonWebKeyEncryptionAlgorithm, options?: RequestOptions): Promise<KeyOperationResult> { ... }

  public async unwrapKey(encryptedKey: Uint8Array, algorithm: JsonWebKeyEncryptionAlgorithm, options?: RequestOptions): Promise<KeyOperationResult> { ... }

  public async sign(digest: Uint8Array, algorithm: JsonWebKeySignatureAlgorithm, options?: RequestOptions): Promise<KeyOperationResult> { ... }

  public async verify(digest: Uint8Array, signature: Uint8Array, algorithm: JsonWebKeySignatureAlgorithm, options?: RequestOptions): Promise<boolean> { ... }

  public async signData(data: Uint8Array, algorithm: JsonWebKeySignatureAlgorithm, options?: RequestOptions): Promise<KeyOperationResult> { ... }

  public async verifyData(data: Uint8Array, signature: Uint8Array, algorithm: JsonWebKeySignatureAlgorithm, options?: RequestOptions): Promise<bool> { ... }
}

Note: Cancellation is handled through abortSignal in the RequestOptions.

Local optimization

Browser

This table shows a possible point of reference for what is allowed, though we'd need to test each browser.

Node

Tested and available on Node 8:

Encrypt/Decrypt

  • RSA1_5
    • 256
  • RSA-OAEP
    • 256
  • RSA_OAEP-256
    • 256

Sign/Verify

  • RS256

Note: EC would require a later Node version. We could explore optionally supporting it if it's available.

Wrap/Unwrap

Todo

  • Note: there may be better ways to set up the constructor and will need investigation.
  • The API above does not have stream support. We will need to investigate what streams are available for node and the browser to see if it makes sense to add them
  • Scott's original design has iv buffers as defaulted, but here I have them required. We'll want to work through which is better for people using the SDK.
@sophiajt sophiajt self-assigned this Jul 24, 2019
@sophiajt sophiajt added the Client This issue points to a problem in the data-plane of the library. label Jul 24, 2019
@sophiajt sophiajt added this to the Sprint 156 milestone Jul 24, 2019
@sadasant
Copy link
Contributor

@jonathandturner Just to confirm, a Key will be in the shape of a JWK key, is that correct?

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library.
Projects
None yet
2 participants