Created
February 13, 2015 07:45
-
-
Save keithballdotnet/a379b1d61a6e7e717f26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aesKeyTemplate := []*pkcs11.Attribute{ | |
pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_SECRET_KEY), | |
pkcs11.NewAttribute(pkcs11.CKA_KEY_TYPE, pkcs11.CKK_AES), | |
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_TOKEN, true), | |
pkcs11.NewAttribute(pkcs11.CKA_PRIVATE, false), | |
pkcs11.NewAttribute(pkcs11.CKA_VALUE, 16), /* KeyLength */ | |
pkcs11.NewAttribute(pkcs11.CKA_LABEL, "My First AES Key"), /* Name of Key */ | |
} | |
aesKey, err := p.CreateObject(session, aesKeyTemplate) | |
//aesKey, err := p.GenerateKey(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_AES_KEY_GEN, nil)}, aesKeyTemplate) | |
if err != nil { | |
panic(fmt.Sprintf("GenerateKey() failed %s\n", err)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment