Skip to content

Commit a81d868

Browse files
committed
Adding Keyring API
1 parent 4ac1a9c commit a81d868

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""All provided keyrings."""
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""Base class interface for Keyrings."""
14+
15+
16+
class Keyring(object):
17+
def on_encrypt(self, encryption_materials):
18+
"""Generates a data key and encrypts it using all wrapping keys the Keyring is associated with.
19+
20+
:param encryption_materials: Contains signing key, encryption context and algorithm suite
21+
required to encrypt data key
22+
:type : aws_encryption_sdk.materials_managers.EncryptionMaterials
23+
:returns encryption_materials: Contains signing key, unencrypted data key, encrypted data keys,
24+
encryption context and algorithm suite required to encrypt data key
25+
:rtype : aws_encryption_sdk.materials_managers.EncryptionMaterials
26+
:raises AttributeError: if encryption materials not available
27+
"""
28+
raise NotImplementedError("Keyring does not implement on_encrypt function")
29+
30+
def on_decrypt(self, decryption_materials):
31+
"""Tries to decrypt one of the keys in the list of encrypted data keys using wrapping keys
32+
the Keyring is associated with.
33+
34+
:param decryption_materials: Contains verification key, list of encrypted data keys.
35+
:type : aws_encryption_sdk.materials_managers.DecryptionMaterials
36+
:returns decryption_materials: Contains verification key, list of encrypted data keys and decrypted data key.
37+
:rtype : aws_encryption_sdk.materials_managers.DecryptionMaterials
38+
:raises AttributeError: if decryption materials not available
39+
"""
40+
raise NotImplementedError("Keyring does not implement on_decrypt function")

src/aws_encryption_sdk/keyring/raw_keyring.py

Whitespace-only changes.

0 commit comments

Comments
 (0)