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

docs: add API usage examples templates #179

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mattsb42-aws
Copy link
Member

Issue #, if available:

#143

Description of changes:

NOTE: The specific Python code in these templates will change before keyrings are released. I suggest that either we hold this in limbo until those changes are finalized or we update the code in the template when we come back to update links from the keyring branch to the master branch.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mattsb42-aws mattsb42-aws self-assigned this Jul 20, 2020
@mattsb42-aws mattsb42-aws added this to In progress in Specification via automation Jul 20, 2020
Copy link
Contributor

@acioc acioc left a comment

Choose a reason for hiding this comment

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

Looks good. Only blocker is double checking the template paths.

# In this example, we use an AWS KMS customer master key (CMK),
# but you can use other key management options with the AWS Encryption SDK.
# For examples that demonstrate how to use other key management configurations,
# see the ``keyring`` and ``master_key_provider`` directories.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have these directories in the spec/will we? If not, should we link to something else here?

This applies to this doc page and others in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, for master_key_provider not all implementations support this.
We may want to try and remove it?

- **source plaintext** :
Plaintext to encrypt
- **AWS KMS CMK** :
The ARN of an AWS KMS CMK that protects data keys
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be good to link to AWS docs (for ARN)? Either way, might also be good to note if this can be an alias ARN.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or a link to the KMS examples?
We don't want any given example
to be so complete that it tries to explain everything.

# Changing the algorithm suite example

Implementations of this example MUST follow the rules defined in
[Example Templates](../../../examples.md#example-templates).
Copy link
Contributor

Choose a reason for hiding this comment

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

This applies here and in other documents in this PR.

I think this path isn't resolving properly.

Copy link
Contributor

@acioc acioc Jul 20, 2020

Choose a reason for hiding this comment

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

I think these might just need to be

[Example Templates](../../examples.md#example-templates).

Copy link
Member Author

Choose a reason for hiding this comment

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

doh; that is correct; I copy-pasted that from the raw keyring examples and they have at least one extra directory layer x_x

# In this example, we use an AWS KMS customer master key (CMK),
# but you can use other key management options with the AWS Encryption SDK.
# For examples that demonstrate how to use other key management configurations,
# see the ``keyring`` and ``master_key_provider`` directories.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, for master_key_provider not all implementations support this.
We may want to try and remove it?

# For examples that demonstrate how to use other key management configurations,
# see the ``keyring`` and ``master_key_provider`` directories.
#
# The default algorithm suite includes a message-level signature
Copy link
Contributor

Choose a reason for hiding this comment

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

If the "default algorithm suite" ever changes, how are we going to find all these places to update them?

- **source plaintext** :
Plaintext to encrypt
- **AWS KMS CMK** :
The ARN of an AWS KMS CMK that protects data keys
Copy link
Contributor

Choose a reason for hiding this comment

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

Or a link to the KMS examples?
We don't want any given example
to be so complete that it tries to explain everything.

1. Decrypt encrypted data.

```python
# Decrypt your encrypted data using the same keyring you used on encrypt.
Copy link
Contributor

Choose a reason for hiding this comment

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

Some of this language is getting copy/paste.
Not a blocker, but in the long run, some more tokenization may be in order.


```python
# Open the files you want to work with.
with open(source_plaintext_filename, "rb") as plaintext, open(ciphertext_filename, "wb") as ciphertext:
Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, I think that this is so language specific,
that maybe nothing is better?
(in the long run :) no need to block )

## Header

```python
# This example shows how to use the streaming encrypt and decrypt APIs on data in memory.
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea here,
but maybe a little more complicated example?
Like why are we doing this?
Is the idea like a proxy where
you take a network socket and decrypt
it on the fly and send it to some back end server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Specification
  
In progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants