We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
No description provided.
The text was updated successfully, but these errors were encountered:
func deriveECDHSharedSecret(c *pkcs11.Ctx, session pkcs11.SessionHandle, privateKey pkcs11.ObjectHandle, peerPublicKey []byte) ([]byte, error) { //formattedPubKey, err := formatECDHPublicKey(peerPublicKey) //if err != nil { // return nil, fmt.Errorf("failed to format peer public key: %v", err) //}
deriveTemplate := []*pkcs11.Attribute{ pkcs11.NewAttribute(pkcs11.CKA_TOKEN, false), pkcs11.NewAttribute(pkcs11.CKA_SENSITIVE, false), pkcs11.NewAttribute(pkcs11.CKA_PRIVATE, false), pkcs11.NewAttribute(pkcs11.CKA_ENCRYPT, true), pkcs11.NewAttribute(pkcs11.CKA_DECRYPT, true), pkcs11.NewAttribute(pkcs11.CKA_SIGN, true), pkcs11.NewAttribute(pkcs11.CKA_VERIFY, true), pkcs11.NewAttribute(pkcs11.CKA_WRAP, true), pkcs11.NewAttribute(pkcs11.CKA_UNWRAP, true), //pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_SECRET_KEY), pkcs11.NewAttribute(pkcs11.CKA_KEY_TYPE, pkcs11.CKK_DES3), pkcs11.NewAttribute(pkcs11.CKA_VALUE_LEN, 16), pkcs11.NewAttribute(pkcs11.CKA_DERIVE, true), } params := pkcs11.NewECDH1DeriveParams(pkcs11.CKD_NULL, nil, peerPublicKey) sharedSecret, err := c.DeriveKey(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_ECDH1_DERIVE, params)}, privateKey, deriveTemplate) if err != nil { return nil, fmt.Errorf("failed to derive key: %v", err) } template := []*pkcs11.Attribute{pkcs11.NewAttribute(pkcs11.CKA_VALUE, nil)} attributes, err := c.GetAttributeValue(session, sharedSecret, template) if err != nil { return nil, fmt.Errorf("failed to get shared secret value: %v", err) } if len(attributes) == 0 || attributes[0].Value == nil { return nil, fmt.Errorf("no value returned for shared secret") } return attributes[0].Value, nil
} always show error :pkcs11: 0x71: CKR_MECHANISM_PARAM_INVALID, how to do it
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: