miekg / pkcs11

pkcs11 wrapper for Go
BSD 3-Clause "New" or "Revised" License
375 stars 133 forks source link

How to implement something alike the Azure Key Vault wrapKey function using this library? #131

Closed rgl closed 2 years ago

rgl commented 4 years ago

Is there a way to implement something like Azure Key Vault wrapKey function using this library?

Essentially, in azure key vault I create a RSA key-pair then invoke the wrapKey function alike:

keyID, wrappedKey = azureKeyVault.wrapKey(keyName, "RSA-OAEP-256", key)

Where key is the plaintext (as a []byte) that we want to encrypt with the named keyName RSA public-key that is stored in azure key vault. And wrappedKey is the returned ciphertext that was encrypted with the RSA public-key.

I've tried to follow https://github.com/miekg/pkcs11/issues/94 but I'm still not seeing a way to implement this... maybe pkcs11.Ctx.WrapKey is not really equivalent to the Azure wrapKey function and what I really want to use is pkcs11.Ctx.Encrypt? if so, do you concur that the following is the way to implement this?

https://github.com/ThalesIgnite/crypto11/blob/3d83a0a5d480dbbc8a65be3a111e194b5275e58b/rsa_test.go#L204-L232

rgl commented 2 years ago

@miekg, can you please comment why you've closed this?