NAME
Crypt::HSM::Object - A PKCS11 object
VERSION
version 0.025
SYNOPSIS
my ($key) = $session->find_objects({ label => $label, encrypt => 1 });
if (not $key) {
my %attrs = { label => $label, sensitive => 1, "value-len" => 32 };
$key = $session->generate_key('aes-key-gen', \%attrs);
}
$session->encrypt('aes-gcm', $key, $plaintext, $nonce);
DESCRIPTION
This class represents an object (usually a key) in the HSM's database. The type of the object us stored in the class attribute, this type will define what other attributes are available for it.
It's returned by Crypt::HSM::Session methods like find_object and generate_key, and used in methods such as encrypt, decrypt, sign and verify.
METHODS
copy_object($attributes = {})
Copy the object, optionally adding/modifying the given attributes.
destroy_object()
This deletes this object from the slot.
get_attribute($attribute_name)
This returns the value of the named attribute of the object.
get_attributes(\@attribute_list)
This returns a hash with the attributes of the object that are asked for.
object_size()
This returns the size of this object.
set_attributes($attributes)
This sets the $attributes on this object.
ATTRIBUTES
Universal attributes
Only one attribute is present in all objects:
classThis enum value van be one of
data,certificate,public-key,private-key,secret-key,hw-feature,domain-parameters,mechanism,profile, orvendor-defined.
Storage objects
All certificate, key, en data objects are storage objects and contain the following attributes:
tokenTrue if the object is a token object, false if the object is a session object.
privateIf true, a user may not access the object until the user has been authenticated to the token.
modifiableIf true (the default) the object can be modified.
labelDescription of the object (default empty).
copyableTrue if object can be copied using
copy_object. Defaults to true. Can’t be set to true once it is set to false.destroyableTrue if the object can be destroyed using destroy_object. Default is true.
unique-idThe unique identifier assigned to the object.
Of these attributes, only label may be modified after the object is created.
Certificates
Several attributes are shared between all certificate types:
certificate-typeThis can be any of
x-509,x-509-attr-cert,wtlsorvendor-defined.trustedTrue if the certificate can be trusted for the application that it was created. It MUST be set by a token initialization application or by the token’s SO. Trusted certificates cannot be modified.
certificate-categoryThis can be any of
unspecified,token-user,authorityorother-entity.check-valueThe checksum of the certificate.
start-dateStart date for the certificate.
end-dateEnd date for the certificate.
public-key-infoDER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate.
X509 certificates
subjectDER-encoding of the certificate subject name.
idKey identifier for public/private key pair.
issuerDER-encoding of the certificate issuer name.
serial-numberDER-encoding of the certificate serial number.
valueBER-encoding of the certificate. MUST be non-empty if
urlis empty.urlIf not empty this attribute gives the URL where the complete certificate can be obtained. MUST be non-empty if
valueis empty.hash-of-subject-public-keyHash of the subject public key (default empty). Hash algorithm is defined by
name-hash-algorithm.hash-of-issuer-public-keyHash of the issues public key (default empty). Hash algorithm is defined by
name-hash-algorithm.java-midp-security-domainJava MIDP security domain. This must be one of
unspecified,manufacturer,operatororthird-party.name-hash-algorithmDefines the mechanism used to calculate
hash-of-subject-public-keyandhash-of-issues-public-key. If the attribute is not present then the type defaults to SHA-1.
WTLS certificates
subjectDER-encoding of the certificate subject name.
issuerDER-encoding of the certificate issuer name.
valueWTLS-encoding of the certificate. MUST be non-empty if
urlis empty.urlIf not empty this attribute gives the URL where the complete certificate can be obtained. MUST be non-empty if
valueis empty.hash-of-subject-public-keyHash of the subject public key (default empty). Hash algorithm is defined by
name-hash-algorithm.hash-of-issuer-public-keyHash of the issues public key (default empty). Hash algorithm is defined by
name-hash-algorithm.name-hash-algorithmDefines the mechanism used to calculate
hash-of-subject-public-keyandhash-of-issues-public-key. If the attribute is not present then the type defaults to SHA-1.
X509 attribute certificates
ownerDER-encoding of the attribute certificate's subject field. This is distinct from the
subjectattribute contained in X509 certificates because the ASN.1 syntax and encoding are different.ac-issuerDER-encoding of the attribute certificate's issuer field. This is distinct from the
issuerattribute contained in X509 certificates because the ASN.1 syntax and encoding are different.serial-numberDER-encoding of the certificate serial number.
attr-typesBER-encoding of a sequence of object identifier values corresponding to the attribute types contained in the certificate. When present, this field offers an opportunity for applications to search for a particular attribute certificate without fetching and parsing the certificate itself. (default empty).
valueBER-encoding of the certificate.
Key objects
All key types share the following attributes:
key-typeThe type of the key (e.g.
aes).idKey identifier for key.
start-dateStart date for the key.
end-dateEnd date for the key.
deriveTrue if key supports key derivation (i.e., if other keys can be derived from this one).
localTrue only if key was either:
Generated locally (i.e., on the token) with a
generate_keyorgenerate_keypaircall.Created with a C_CopyObject call as a copy of a key which had its
localattribute set to true.
key-gen-mechanismThe mechanism used to generate a new value of this key type.
allowed-mechanismsAn arrayref of mechanisms that can be used with this key type.
Public key objects
subjectDER-encoding of the key subject name.
encryptTrue if key supports encryption.
verifyTrue if key supports verification where the signature is an appendix to the data.
verify-recoverTrue if key supports verification where the data is recovered from the signature.
wrapTrue if key supports wrapping (i.e., can be used to wrap other keys).
trustedThe key can be trusted for the application that it was created.
The wrapping key can be used to wrap keys with
wrap-with-trustedset to true.wrap-templateFor wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. Keys that do not match cannot be wrapped.
public-key-infoDER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate.
Private key objects
subjectDER-encoding of certificate subject name.
sensitiveTrue if key is sensitive.
decryptTrue if key supports
decrypt.signTrue if key supports
sign.sign-recoverTrue if key supports
sign_recover.unwrapTrue if key supports
unwrap.extractableTrue if key is extractable and can be wrapped.
always-sensitiveTrue if key has always had the
sensitiveattribute set to true.never-extractableTrue if key has never had the
extractableattribute set to true.wrap-with-trustedTrue if the key can only be wrapped with a wrapping key that has
trustedset to true.unwrap-templateFor wrapping keys. The attribute template to apply to any keys unwrapped using this wrapping key. Any user supplied template is applied after this template as if the object has already been created.
always-authenticateIf true, the user has to supply the PIN for each use (sign or decrypt) with the key. Default is false.
public-key-infoDER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate.
c<derive-template>
For deriving keys. The attribute template to match against any keys derived using this derivation key. Any user supplied template is applied after this template as if the object has already been created.
RSA private key objects
modulusModulus n
public-exponentPublic exponent e.
private-exponentPrivate exponent d.
prime-1Prime p.
prime-2Prime q.
exponent-1Private exponent d modulo p-1.
exponent-2Private exponent d modulo q-1.
coefficientCRT coefficient q-1 mod p.
Secret key objects
sensitiveTrue if key is sensitive.
encryptTrue if key supports
encrypt.decryptTrue if key supports
decrypt.signTrue if key supports
sign.verifyTrue if key supports
verify(i.e., of authentication codes) where the signature is an appendix to the data.wrapTrue if key supports
wrap(i.e., can be used to wrap other keys).unwrapTrue if key supports
unwrap(i.e., can be used to unwrap other keys).extractableTrue if key is extractable and can be wrapped.
always-sensitiveTrue if key has always had the
sensitiveattribute set to true.never-extractableTrue if key has never had the
extractableattribute set to true.check-valueKey checksum.
wrap-with-trustedTrue if the key can only be wrapped with a wrapping key that has
trustedset to true.trustedThe wrapping key can be used to wrap keys with
wrap-with-trustedset to true.wrap-templateFor wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. Keys that do not match cannot be wrapped.
unwrap-templateFor wrapping keys. The attribute template to apply to any keys unwrapped using this wrapping key. Any user supplied template is applied after this template as if the object has already been created.
c<derive-template>
For deriving keys. The attribute template to match against any keys derived using this derivation key. Any user supplied template is applied after this template as if the object has already been created.
Data objects
applicationDescription of the application that manages the object.
object-idDER-encoding of the object identifier indicating the data object type.
valueValue of the object.
Domain parameter objects
key-typeType of key the domain parameters can be used to generate.
localTrue only if key was either:
Generated locally (i.e., on the token) with a
generate_keyorgenerate_keypaircall.Created with a
copy-objectcall as a copy of a key which had itslocalattribute set to true.
Mechanism objects
mechanism-typeThe mechanism object.
profile-idThis can be
baseline-provider,extended-provider,authentication-token,public-certificates-token,complete-provider,hkdf-tls-token,vendor-provided, orinvalid-id.
Hardware objects
hardware-feature-typeThis can be one of
monotonic-counter,clock,user-interface,vendor-defined.
Monotonic counter
reset-on-initThe value of the counter will reset to a previously returned value if the token is initialized using
init-token.has-resetThe value of the counter has been reset at least once at some point in time.
valueThe current version of the monotonic counter. The value is returned in big endian order.
Clock
valueCurrent time as a character-string of length 16, represented in the format YYYYMMDDhhmmssxx (4 characters for the year; 2 characters each for the month, the day, the hour, the minute, and the second; and 2 additional reserved ‘0’ characters).
User Interface
pixel-xScreen resolution (in pixels) in X-axis (e.g. 1280).
pixel-yScreen resolution (in pixels) in Y-axis (e.g. 1024).
resolutionDPI, pixels per inch.
char-rowsFor character-oriented displays; number of character rows (e.g. 24).
char-columnsFor character-oriented displays: number of character columns (e.g. 80). If display is of proportional-font type, this is the width of the display in “em”-s (letter “M”).
colorColor support.
bits-per-pixelThe number of bits of color or grayscale information per pixel.
char-setsString indicating supported character sets, as defined by IANA MIBenum sets (www.iana.org). Supported character sets are separated with “;”. E.g. a token supporting iso-8859-1 and US-ASCII would set the attribute value to “4;3”.
encoding-methodsString indicating supported content transfer encoding methods, as defined by IANA (www.iana.org). Supported methods are separated with “;”. E.g. a token supporting 7bit, 8bit and base64 could set the attribute value to “7bit;8bit;base64”.
mime-typesString indicating supported (presentable) MIME-types, as defined by IANA (www.iana.org). Supported types are separated with “;”. E.g. a token supporting MIME types "a/b", "a/c" and "a/d" would set the attribute value to “a/b;a/c;a/d”.
AUTHOR
Leon Timmermans <fawaka@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.