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

JWE For Encryption, Custom Provider for Decryption? #113

Open
pavgup opened this issue Jul 26, 2024 · 5 comments
Open

JWE For Encryption, Custom Provider for Decryption? #113

pavgup opened this issue Jul 26, 2024 · 5 comments

Comments

@pavgup
Copy link

pavgup commented Jul 26, 2024

Heyyo! I've got a curious question, I'm working on scenarios where I'd like to use the public half of an RSA key to encrypt content with skopeo as the runner (e.g., skopeo copy --encryption-key jwe:mymagicprivkey.key oci:alpine oci:encrypted) and then use a custom provider to handle decryption (e.g., skopeo copy --decryption-key provider:mysimpleprovider oci:encrypted oci:decrypted) with a configuraiton that looks a little like:

{
    "key-providers": {
        "mysimpleprovider": {
            "cmd": {
                "path":"/bin/mysimpleprovider",
                "args": []
            }
        }
    }
} 

Naturally, when ocicrypt sees the encrypted content, it sees it with the jwe scheme and thusly finds no match to decrypt when the only option is mysimpleprovider.

Can I have a mismatched encryption/decryption scenario?

@stefanberger
Copy link
Collaborator

Can I have a mismatched encryption/decryption scenario?

I am not sure whether it would work, likely that not. Though why would the built-in decryption provider not be sufficient?

@pavgup
Copy link
Author

pavgup commented Jul 29, 2024

It's a somewhat special case where the private half of a key is only available remotely in an HSM to decrypt content and requires a series of programatic steps to authenticate. The public half of the key, is however, easily available.

I also wonder if there's a scenario that would allow the direct use of an symmetric key with ocicrypt, but this doesn't seem to exist as far as I can tell...

@stefanberger
Copy link
Collaborator

I also wonder if there's a scenario that would allow the direct use of an symmetric key with ocicrypt, but this doesn't seem to exist as far as I can tell...

At least not with any of the provided crypto implementations. All of them rely on public key crypto.

It's a somewhat special case where the private half of a key is only available remotely in an HSM to decrypt content and requires a series of programatic steps to authenticate. The public half of the key, is however, easily available.

That's like pkcs11, but pkcs11 is also handled internally.

Likely you solution would have to rely on your own external provider handling both the encryption and the decryption.

@pavgup
Copy link
Author

pavgup commented Jul 29, 2024

Likely you solution would have to rely on your own external provider handling both the encryption and the decryption.

Would this project be open to a PR that would enable the scenario where a built-in provider can be swapped out for a custom provider in either the encryption or decryption scenario? This would enable a class of RATS-style interactions inside a confidential computing context that are otherwise hard for users to implement.

For example, if I wanted to override the internal JWE implementation for decryption, I'd first attempt to use the internal JWE implementation, but before failing, I'd allow a specific attempt to override an internal provider that looked something like this:

{
    "key-providers": {
        "jwe": {
            "cmd": {
                "path":"/bin/mycustomjwe",
                "args": []
            }
        }
    }
} 

Similarly, if I brought a custom provider.jwe in to encrypt content, but I couldn't provide this in a decryption context for whatever eason, I'd first attempt to find this provider.jwe, and if that failed, I'd make an attempt to use the internal jwe provider before failing.

Thoughts?

@stefanberger
Copy link
Collaborator

Would this project be open to a PR that would enable the scenario where a built-in provider can be swapped out for a custom provider in either the encryption or decryption scenario?

Sure, you can send the PR. I am currently out of the office...

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

No branches or pull requests

2 participants