-
Notifications
You must be signed in to change notification settings - Fork 85
Expose keyring trace in results #224
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
Changes from all commits
f9999fc
aba80d8
0d44f26
f285a34
32cb56a
375b910
fdf0657
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,12 @@ | |
from aws_encryption_sdk.identifiers import Algorithm, ContentType, KeyringTraceFlag, ObjectType, SerializationVersion | ||
from aws_encryption_sdk.internal.str_ops import to_bytes, to_str | ||
|
||
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules | ||
from typing import Tuple # noqa pylint: disable=unused-import | ||
except ImportError: # pragma: no cover | ||
# We only actually need these imports when running the mypy checks | ||
pass | ||
|
||
|
||
@attr.s(hash=True) | ||
class MasterKeyInfo(object): | ||
|
@@ -107,8 +113,7 @@ class KeyringTrace(object): | |
.. versionadded:: 1.5.0 | ||
|
||
:param MasterKeyInfo wrapping_key: Wrapping key used | ||
:param flags: Actions performed | ||
:type flags: set of :class:`KeyringTraceFlag` | ||
:param Set[KeyringTraceFlag] flags: Actions performed | ||
""" | ||
|
||
wrapping_key = attr.ib(validator=instance_of(MasterKeyInfo)) | ||
|
@@ -120,19 +125,14 @@ class MessageHeader(object): | |
# pylint: disable=too-many-instance-attributes | ||
"""Deserialized message header object. | ||
|
||
:param version: Message format version, per spec | ||
:type version: SerializationVersion | ||
:param type: Message content type, per spec | ||
:type type: ObjectType | ||
:param algorithm: Algorithm to use for encryption | ||
:type algorithm: Algorithm | ||
:param SerializationVersion version: Message format version, per spec | ||
:param ObjectType type: Message content type, per spec | ||
:param AlgorithmSuite algorithm: Algorithm to use for encryption | ||
:param bytes message_id: Message ID | ||
:param dict encryption_context: Dictionary defining encryption context | ||
:param encrypted_data_keys: Encrypted data keys | ||
:type encrypted_data_keys: set of :class:`aws_encryption_sdk.structures.EncryptedDataKey` | ||
:param content_type: Message content framing type (framed/non-framed) | ||
:type content_type: ContentType | ||
:param bytes content_aad_length: empty | ||
:param Dict[str,str] encryption_context: Dictionary defining encryption context | ||
:param Sequence[EncryptedDataKey] encrypted_data_keys: Encrypted data keys | ||
:param ContentType content_type: Message content framing type (framed/non-framed) | ||
:param int content_aad_length: empty | ||
:param int header_iv_length: Bytes in Initialization Vector value found in header | ||
:param int frame_length: Length of message frame in bytes | ||
""" | ||
|
@@ -152,3 +152,41 @@ class MessageHeader(object): | |
content_aad_length = attr.ib(hash=True, validator=instance_of(six.integer_types)) | ||
header_iv_length = attr.ib(hash=True, validator=instance_of(six.integer_types)) | ||
frame_length = attr.ib(hash=True, validator=instance_of(six.integer_types)) | ||
|
||
|
||
@attr.s | ||
class CryptoResult(object): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any value in calling this AwsCryptoResult to match Java? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO no, but I'm willing to be convinced otherwise. My reasoning is that aside from the name/branding and the AWS KMS keyring, nothing about the ESDK is AWS-specific. As such, I've tried to avoid including "AWS" in the names of things except where they specifically relate to AWS (ex: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm fine with keeping it. As you know we changed the name more out of necessity than because it was a better name. |
||
"""Result container for one-shot cryptographic API results. | ||
|
||
.. versionadded:: 1.5.0 | ||
|
||
.. note:: | ||
|
||
For backwards compatibility, | ||
this container also unpacks like a 2-member tuple. | ||
This allows for backwards compatibility with the previous outputs. | ||
|
||
:param bytes result: Binary results of the cryptographic operation | ||
:param MessageHeader header: Encrypted message metadata | ||
:param Tuple[KeyringTrace] keyring_trace: Keyring trace entries | ||
""" | ||
|
||
result = attr.ib(validator=instance_of(bytes)) | ||
header = attr.ib(validator=instance_of(MessageHeader)) | ||
keyring_trace = attr.ib(validator=deep_iterable(member_validator=instance_of(KeyringTrace))) | ||
|
||
def __attrs_post_init__(self): | ||
"""Construct the inner tuple for backwards compatibility.""" | ||
self._legacy_container = (self.result, self.header) | ||
|
||
def __len__(self): | ||
"""Emulate the inner tuple.""" | ||
return self._legacy_container.__len__() | ||
|
||
def __iter__(self): | ||
"""Emulate the inner tuple.""" | ||
return self._legacy_container.__iter__() | ||
|
||
def __getitem__(self, key): | ||
"""Emulate the inner tuple.""" | ||
return self._legacy_container.__getitem__(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will be updated once it's shipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. That's out standard placeholder for "this release hasn't shipped yet".