Skip to content

Instantly share code, notes, and snippets.

@vieirin
Created December 11, 2019 19:47
Show Gist options
  • Save vieirin/679c96428da44ed7e1b06cef046cbf82 to your computer and use it in GitHub Desktop.
Save vieirin/679c96428da44ed7e1b06cef046cbf82 to your computer and use it in GitHub Desktop.
// secp256r1 OBJECT IDENTIFIER ::= {
// iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3)
// prime(1) 7 }
//
marshaledOID, err := asn1.Marshal(asn1.ObjectIdentifier{1, 3, 132, 0, 33})
if err != nil {
return nil, nil, fmt.Errorf("Could not marshal OID [%s]", err.Error())
}
pubkeyT := []*pkcs11.Attribute{
pkcs11.NewAttribute(pkcs11.CKA_KEY_TYPE, pkcs11.CKK_EC),
pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_PUBLIC_KEY),
pkcs11.NewAttribute(pkcs11.CKA_TOKEN, !ephemeral),
pkcs11.NewAttribute(pkcs11.CKA_VERIFY, true),
pkcs11.NewAttribute(pkcs11.CKA_EC_PARAMS, marshaledOID),
pkcs11.NewAttribute(pkcs11.CKA_PRIVATE, false),
pkcs11.NewAttribute(pkcs11.CKA_ID, publabel),
pkcs11.NewAttribute(pkcs11.CKA_LABEL, publabel),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment