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

Add CK_RSA_AES_KEY_WRAP_PARAMS to params.go #155

Open
cryptojerp opened this issue Jan 20, 2022 · 6 comments
Open

Add CK_RSA_AES_KEY_WRAP_PARAMS to params.go #155

cryptojerp opened this issue Jan 20, 2022 · 6 comments

Comments

@cryptojerp
Copy link

I'm building a tool that calls the WrapKey/UnwrapKey. I'm able to perform Wrapping/Unwrapping against:

  1. An AES key with RSA Keypair.
  2. An RSA Private Key with AES Key.

But I'm unable to perform Wrapping/Unwrapping of an RSA Private Key with another RSA Key Pair. According to the PKCS 11 documentation (both 2.40 and 3.0 versions), section called "RSA AES KEY WRAP mechanism parameters" requires the use of parameter called "CK_RSA_AES_KEY_WRAP_PARAMS".

Could the "CK_RSA_AES_KEY_WRAP_PARAMS" be added to the library?

@miekg
Copy link
Owner

miekg commented Jan 20, 2022 via email

@cryptojerp
Copy link
Author

I was thinking more on creating a new type in params.go. Like GMCParams or OAEPParams. Something like the following:

// ----------- suggested changes in param.go -----------
// RsaAesKeyWrapParams represents the parameters for the CKM_RSA_AES_KEY_WRAP mechanism.
type RsaAesKeyWrapParams struct {
	aesKeyBits uint
	params  *OAEPParams
}

// NewRsaAesKeyWrapParams creates a CK_RSA_AES_KEY_WRAP_PARAMS structure suitable for use with the CKM_RSA_AES_KEY_WRAP mechanism.
func NewRsaAesKeyWrapParams(aesKeySize, hashAlg, mgf, sourceType uint, sourceData []byte) *RsaAesKeyWrapParams {
	return &RsaAesKeyWrapParams{
		aesKeyBits:    aesKeySize,
		params  :        NewGCMParams(hashAlg, mgf, sourceType, sourceData),
	}
}

func cRsaAesKeyWrapParams(p *RsaAesKeyWrapParams) []byte {
// TODO: Rest of code.

And then:

// ----------- suggested changes in types.go -----------
func cMechanism(mechList []*Mechanism) (arena, *C.CK_MECHANISM) {
// add existing code.
	case *RsaAesKeyWrapParams:
		param = cRsaAesKeyWrapParams(p)
// add existing code.

Does this make sence?

@miekg
Copy link
Owner

miekg commented Jan 21, 2022 via email

@cryptojerp
Copy link
Author

The wrap mechanism denoted CKM_RSA_AES_KEY_WRAP, has the parameter CK_RSA_AES_KEY_WRAP_PARAMS structure.

Without this parameter, I'm unable to use this mechanism.

@miekg
Copy link
Owner

miekg commented Jan 26, 2022 via email

@varder
Copy link
Contributor

varder commented Jan 31, 2023

Please have a look at the PR
#166

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

3 participants