-
Notifications
You must be signed in to change notification settings - Fork 122
Master Key to Keyring API Evolution #150
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
Comments
I think that any way we go about this, we are going to have to introduce breaking changes. The question in my mind is how can we make it as simple as possible for our customers to adapt to those changes so that we don't end up with customers sticking with old, unsupported, versions of the ESDK. I think that the things that we need to optimize for, in order of importance, are:
In light of those priorities, IMO the new major version that effectively forks the codebase is a non-starter. It creates a large amount of friction for all of our customers customers AND creates a large amount of ongoing maintenance burden for us, for what seems to me to be a marginal value to our customers. What I would like to propose is that we approach this from a few different angles: We have four basic objectives: we want to remove the dependence on master key providers (MKPs) in the return values, we want to enable use of keyrings for configuration, we want to set the groundwork for the eventual deprecation of MKPs, and we want to reduce the proliferation of entry methods. remove MKPs from CryptoResult[/etc]I think this is just something we need to do. It's a breaking change, but we can do what we can to make it simple. Any code change that a customer needs to make should be as minimal as possible, and preferably deterministic. For example, the primary reason we expect customers to use By not changing the return type, we avoid the requirement for people to change type signatures simply because they start using keyrings. The question remains, though, how can we make this worth the time for a user to update? If the MKP helper method lets them look for specific actions, that might be worth it. prepare for MKP deprecationThis is, in my mind, less a "what should we do" and more a "what should we not do". We should not introduce anything that will need to again later be changed when we deprecate MKPs. reduce API method proliferationThis looks initially like purely a benefit for us, since its primary goal is to reduce the code we need to maintain. However, it also adds benefit for the user, both in understanding documentation and in attempting to navigate our code. Something that seems to me like it might help in this regard is if we change what we expect as an input. If we were to change One problem I have with this idea is that while I can see the long-term value to customers in the form of simpler, easier to navigate, documentation and code, I'm having a hard time coming up with a compelling short-term value that would convince me (as a customer) to go and change my existing codebase to use it. |
I agree that eventually we will need to introduce breaking changes, but I wouldn't say that it is necessary that we introduce breaking changes immediately. While I like the idea of removing MKPs from CryptoResult, just the fact that it is breaking at all (however small in scope) leads me to believe if we do that we will effectively have to support two versions of the ESDK and back port any future bug fixes to the MKP version. What do you think of the backward-compatible approach of adding keyring traces to CryptoResult, and just marking getMasterKeys and getMasterKeyIds as deprecated (as well as marking MKP methods in AwsCrypto as deprecated)? This way customers will not have to make any change immediately, but can begin to shift away from MKPs towards Keyrings at their leisure. Also, I'd like your thoughts on the Master Key Provider Keyring, as my current thinking is that this does not make sense to provide to our customers, as it violates the tenet of "We should not be asking our customers to change any parts of their code that they will need to change again when we deprecate MKPs." Wrapping an MKP into a MKP-Keyring doesn't really give much benefit and will be thrown away once MKPs are deleted. |
I've been thinking about this, and I think you're right; the backwards-compatible I do think we should add something, and this might be something that we should add to the spec: Aside from constructing the MKPs/keyrings, the crux of this migration issue is how a user can check the results to see what a given MKP/keyring did. I don't remember if we've looked at this yet for keyrings, but if we can make whatever that is (I'm thinking a helper function that takes a keyring trace and a keyring) work with master keys as well, that might help ease the migration.
The way that I've been thinking the MKP-keyring would manifest is that the user's code calling |
I've started implementing a version of AwsCrypto with new methods that look like: One issue I'm foreseeing is that even if a customer fully commits to use Keyrings now, and doesn't call getMasterKeys or getMasterKeyIds on CryptoResult, they will still have to make a code change when we fully remove MasterKeys. The reason is because CryptoResult is defined as: Removing the second generic parameter will require all customers to update their code, even those customers that are already using Keyrings. This again violates the "We should not be asking our customers to change any parts of their code that they will need to change again when we deprecate MKPs" tenet, and even worse we would effectively be punishing the customers that proactively migrate to Keyrings. So what am thinking again is defining a new return type (maybe AwsCryptoResult) that is returned by all the new AwsCryptoConfig based methods. This will also require new versions of CryptoInputStream and CryptoOutputStream, as those are similarly defined as: |
Reading over this, |
Introduction
The Java version of the AWS Encryption SDK, having been developed prior to all other language variants of the AWS Encryption SDK, contains configuration and API constructs that do not exist in the more recently developed versions. Namely, the Master Key/Master Key Provider (MKP) construct has been replaced by Keyrings in the C, Javascript, and all future versions of the ESDK. To bring the Java ESDK in line with the other ESDKs, Keyring support is currently being added (see #102 ). However, since Master Key Providers are present in both the input and output of the Java ESDK, the process of introducing Keyrings while minimizing disruption to existing customers is complicated. This issue summarizes the current state of Master Key Providers in the Java ESDK and raises the following questions regarding the evolution of the Java ESDK API:
Current State
The AwsCrypto class serves as the primary entry-point to the Java ESDK. This class contains 30 public methods interacting with Master Key Providers, which are overloaded variations of the following 4 methods:
encryptString/decryptString, deprecated methods for encrypting/decrypting stringsEach of these methods use either a MasterKeyProvider or a CryptoMaterialsManager to perform its encryption/decryption objective. When a MasterKeyProvider is specified, the given MKP is wrapped in the DefaultCryptoMaterialsManager and handed off to the corresponding CryptoMaterialsManager based method. All of these methods (save for estimateCiphertextSize which returns a long) return a CryptoResult or a CryptoInputStream/CryptoOutputStream that wraps a CryptoResult. CryptoResult is a generic type that is parameterized with the MasterKey type that was specified to the method. CryptoResult contains a getMasterKeys method that in the case of encryption returns all the MasterKeys used to encrypt the ciphertext, and in the case of decryption returns the single MasterKey used to decrypt the ciphertext.
Should we provide a Master Key Provider Keyring?
The Master Key Provider Keyring is a Keyring that wraps a MasterKeyProvider that customers have developed so it can be used with the new methods in AwsCrypto that support Keyrings. Supplying this Keyring to customers has benefits, but also some drawbacks, and in particular has implications regarding the long term support plan for Master Key Providers. These benefits and drawbacks are delineated below:
Benefits:
Drawbacks
How should the result object be updated to support Keyrings?
Given that the current CryptoResult provides access to Master Keys, this class will need to be updated or augmented to support Keyrings. Possible solutions involve removing Master Keys from the CryptoResult in favor of the Keyring trace, introducing a new result type used exclusively for when a Keyring is being used, or only populating MasterKeys in CryptoResult when a MKP is in use. These options are discussed below:
Option 1: Remove Master Keys from CryptoResult
The getMasterKeys and getMasterKeyIds methods are removed from CryptoResult and the generic MasterKey parameter is removed. A method for accessing the Keyring trace is added.
Benefits:
Drawbacks:
Option 2: New result type for Keyrings
A new result type (KeyringCryptoResult for example) is created that is returned by all the AwsCrypto methods that work with Keyrings. The new type would include a Keyring Trace instead of MasterKeys. Existing methods in AwsCrypto would continue to return CryptoResult.
Benefits:
Drawbacks:
Option 3: Only populate Master Keys in CryptoResult when a MKP is used
The Master Key methods in CryptoResult remain the same, but only return a result if a Master Key Provider is being used. A method for accessing the Keyring trace is added to CryptoResult, which would only return a result if a Keyring is used.
Benefits:
Drawbacks:
Should a new major version be introduced?
Another alternative to both the MasterKeyProviderKeyring and updates to the CryptoResult is introducing a new, non-backward compatible major version of the Java ESDK that removes all references to Master Keys and Master Key Providers in favor of Keyrings while marking the old version of the Java ESDK as deprecated. While the introduction of Keyrings is likely not sufficiently beneficial to customers to warrant such an action, the benefits and drawbacks are nonetheless presented below for completeness:
Benefits:
Drawbacks:
The text was updated successfully, but these errors were encountered: