Method: PKCS11::Session#C_GenerateKey

Defined in:
lib/pkcs11/session.rb

#C_GenerateKey(mechanism, template = {}) ⇒ PKCS11::Object Also known as: generate_key

Generates a secret key Object or set of domain parameters, creating a new Object.

Examples:

generate 112 bit DES key

key = session.generate_key(:DES2_KEY_GEN,
  {ENCRYPT: true, WRAP: true, DECRYPT: true, UNWRAP: true})

Parameters:

  • mechanism (Hash, Symbol, Integer, PKCS11::CK_MECHANISM)

    used mechanism

  • template (Hash) (defaults to: {})

    Attributes of the key to create.

Returns:

[View source]

653
654
655
656
# File 'lib/pkcs11/session.rb', line 653

def C_GenerateKey(mechanism, template={})
  obj = @pk.C_GenerateKey(@sess, to_mechanism(mechanism), to_attributes(template))
  Object.new @pk, @sess, obj
end