Gjsify LogoGjsify Logo

A builder for a set of attributes. Add attributes to a builder, and then use [methodBuilder.end] to get the completed [structAttributes].

The fields of #GckBuilder are private and not to be accessed directly.

record

Hierarchy

  • Builder

Index

Constructors

  • Create a new GckBuilder not allocated on the stack, so it can be shared across a single scope, and referenced / unreferenced.

    Normally a GckBuilder is created on the stack, and simply initialized.

    If the %GCK_BUILDER_SECURE_MEMORY flag is specified then non-pageable memory will be used for the various values of the attributes in the builder

    Parameters

    Returns Gck.Builder

Properties

name: string

Methods

  • Add all the attrs attributes to the builder. The attributes are added uncondititionally whether or not attributes with the same types already exist in the builder.

    As an optimization, the attribute memory values are automatically shared between the attributes and the builder.

    Parameters

    Returns void

  • Add an attribute to the builder. The attribute is added unconditionally whether or not an attribute with the same type already exists on the builder.

    The attr attribute must have been created or owned by the Gck library. If you call this function on an arbitrary GckAttribute that is allocated on the stack or elsewhere, then this will result in undefined behavior.

    As an optimization, the attribute memory value is automatically shared between the attribute and the builder.

    Parameters

    Returns void

  • addBoolean(attrType: number, value: boolean): void
  • Add a new attribute to the builder for the boolean value. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Parameters

    • attrType: number

      the new attribute type

    • value: boolean

      the attribute value

    Returns void

  • addData(attrType: number, value: Uint8Array): void
  • Add a new attribute to the builder with an arbitrary value. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    The memory in value is copied by the builder.

    %NULL may be specified for the value argument, in which case an empty attribute is created. [constINVALID] may be specified for the length, in which case an invalid attribute is created in the PKCS#11 style.

    Parameters

    • attrType: number

      the new attribute type

    • value: Uint8Array

      the new attribute memory

    Returns void

  • addDate(attrType: number, value: GLib.Date): void
  • Add a new attribute to the builder for the date value. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Parameters

    • attrType: number

      the new attribute type

    • value: GLib.Date

      the attribute value

    Returns void

  • addEmpty(attrType: number): void
  • Add a new attribute to the builder that is empty. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Parameters

    • attrType: number

      the new attribute type

    Returns void

  • addInvalid(attrType: number): void
  • Add a new attribute to the builder that is invalid in the PKCS#11 sense. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Parameters

    • attrType: number

      the new attribute type

    Returns void

  • addOnly(attrs: Attributes, onlyTypes: number[]): void
  • Add the attributes with the types in only_types from attrs to the builder. The attributes are added uncondititionally whether or not attributes with the same types already exist in the builder.

    // Add the CKA_ID and CKA_CLASS attributes from attrs to builder
    gulong only[] = { CKA_ID, CKA_CLASS };
    gck_builder_add_onlyv (builder, attrs, only, 2);

    As an optimization, the attribute memory values are automatically shared between the attributes and the builder.

    Parameters

    • attrs: Attributes

      the attributes to add

    • onlyTypes: number[]

      the types of attributes to add

    Returns void

  • addString(attrType: number, value: string): void
  • Add a new attribute to the builder for the string value or %NULL. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Parameters

    • attrType: number

      the new attribute type

    • value: string

      the attribute value

    Returns void

  • addUlong(attrType: number, value: number): void
  • Add a new attribute to the builder for the unsigned long value. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Parameters

    • attrType: number

      the new attribute type

    • value: number

      the attribute value

    Returns void

  • clear(): void
  • Clear the builder and release all allocated memory. The builder may be used again to build another set of attributes after this function call.

    If memory is shared between this builder and other attributes, then that memory is only freed when both of them are cleared or unreferenced.

    Returns void

  • Make a copy of the builder and its state. The new builder is allocated with [ctorBuilder.new] and should be freed with gck_builder_unref().

    Attribute value memory is automatically shared between the two builders, and is only freed when both are gone.

    Returns Gck.Builder

  • Complete the #GckBuilder, and return the attributes contained in the builder. The #GckBuilder will be cleared after this function call, and it is no longer necessary to use [methodBuilder.clear] on it, although it is also permitted. The builder may be used again to build another set of attributes after this function call.

    The returned set of attributes is floating, and should either be passed to another gck library function which consumes this floating reference, or if you wish to keep these attributes around you should ref them with gck_attributes_ref_sink() and unref them later with gck_attributes_unref().

    Returns Attributes

  • Find an attribute in the builder. Both valid and invalid attributes (in the PKCS#11 sense) are returned. If multiple attributes exist for the given attribute type, then the first one is returned.

    The returned [structAttribute] is owned by the builder and may not be modified in any way. It is only valid until another attribute is added to or set on the builder, or until the builder is cleared or unreferenced.

    Parameters

    • attrType: number

      the type of attribute to find

    Returns Gck.Attribute

  • findBoolean(attrType: number): [boolean, boolean]
  • Find a boolean attribute in the builder that has the type attr_type, is of the correct boolean size, and is not invalid in the PKCS#11 sense. If multiple attributes exist for the given attribute type, then the first
    one is returned.

    Parameters

    • attrType: number

      the type of attribute to find

    Returns [boolean, boolean]

  • findDate(attrType: number): [boolean, GLib.Date]
  • Find a date attribute in the builder that has the type attr_type, is of the correct date size, and is not invalid in the PKCS#11 sense. If multiple attributes exist for the given attribute type, then the first one is returned.

    Parameters

    • attrType: number

      the type of attribute to find

    Returns [boolean, GLib.Date]

  • findString(attrType: number): [boolean, string]
  • Find a string attribute in the builder that has the type attr_type, has a non %NULL value pointer, and is not invalid in the PKCS#11 sense. If multiple attributes exist for the given attribute type, then the first one is returned.

    Parameters

    • attrType: number

      the type of attribute to find

    Returns [boolean, string]

  • findUlong(attrType: number): [boolean, number]
  • Find a unsigned long attribute in the builder that has the type attr_type, is of the correct unsigned long size, and is not invalid in the PKCS#11 sense. If multiple attributes exist for the given attribute type, then the first one is returned.

    Parameters

    • attrType: number

      the type of attribute to find

    Returns [boolean, number]

  • init(): void
  • Initialize a stack allocated builder, with the default flags.

    This is equivalent to initializing a builder variable with the %GCK_BUILDER_INIT constant, or setting it to zeroed memory.

    // Equivalent ways of initializing a GckBuilder
    GckBuilder builder = GCK_BUILDER_INIT;
    GckBuilder builder2;
    GckBuilder builder3;

    gck_builder_init (&builder2);

    memset (&builder3, 0, sizeof (builder3));

    Returns void

  • Initialize a stack allocated builder, with the appropriate flags.

    If the %GCK_BUILDER_SECURE_MEMORY flag is specified then non-pageable memory will be used for the various values of the attributes in the builder

    Parameters

    Returns void

  • Add a reference to a builder that was created with [ctorBuilder.new]. The builder must later be unreferenced again with gck_builder_unref().

    It is an error to use this function on builders that were allocated on the stack.

    Returns Gck.Builder

  • Set all the attrs attributes to the builder. If any attributes with the same types are already present in the builder, then those attributes are changed to the new values.

    As an optimization, the attribute memory values are automatically shared between the attributes and the builder.

    Parameters

    Returns void

  • setBoolean(attrType: number, value: boolean): void
  • Set an attribute on the builder for the boolean value. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    Parameters

    • attrType: number

      the new attribute type

    • value: boolean

      the attribute value

    Returns void

  • setData(attrType: number, value: Uint8Array): void
  • Set a new attribute to the builder with an arbitrary value. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    The memory in value is copied by the builder.

    %NULL may be specified for the value argument, in which case an empty attribute is created. [constINVALID] may be specified for the length, in which case an invalid attribute is created in the PKCS#11 style.

    Parameters

    • attrType: number

      the attribute type

    • value: Uint8Array

      the new attribute memory

    Returns void

  • setDate(attrType: number, value: GLib.Date): void
  • Set an attribute on the builder for the date value. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    Parameters

    • attrType: number

      the new attribute type

    • value: GLib.Date

      the attribute value

    Returns void

  • setEmpty(attrType: number): void
  • Set an attribute on the builder that is empty. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    Parameters

    • attrType: number

      the attribute type

    Returns void

  • setInvalid(attrType: number): void
  • Set an attribute on the builder that is invalid in the PKCS#11 sense. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    Parameters

    • attrType: number

      the attribute type

    Returns void

  • setString(attrType: number, value: string): void
  • Set an attribute on the builder for the string value or %NULL. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    Parameters

    • attrType: number

      the new attribute type

    • value: string

      the attribute value

    Returns void

  • setUlong(attrType: number, value: number): void
  • Set an attribute on the builder for the unsigned long value. If an attribute with attr_type already exists in the builder then it is changed to the new value, otherwise an attribute is added.

    Parameters

    • attrType: number

      the new attribute type

    • value: number

      the attribute value

    Returns void

  • Take the attributes that have been built in the #GckBuilder. The builder will no longer contain any attributes after this function call.

    The returned set of attributes is a full reference, not floating.

    Returns Attributes

  • takeData(attrType: number, value: Uint8Array): void
  • Add a new attribute to the builder with an arbitrary value. Unconditionally adds a new attribute, even if one with the same attr_type already exists.

    Ownership of the value memory is taken by the builder, may be reallocated, and is eventually freed with g_free(). The memory must have been allocated using the standard GLib memory allocation routines.

    %NULL may be specified for the value argument, in which case an empty attribute is created. [constINVALID] may be specified for the length, in which case an invalid attribute is created in the PKCS#11 style.

    Parameters

    • attrType: number

      the new attribute type

    • value: Uint8Array

      the new attribute memory

    Returns void

  • Create a new GckBuilder not allocated on the stack, so it can be shared across a single scope, and referenced / unreferenced.

    Normally a GckBuilder is created on the stack, and simply initialized.

    If the %GCK_BUILDER_SECURE_MEMORY flag is specified then non-pageable memory will be used for the various values of the attributes in the builder

    Parameters

    Returns Gck.Builder

  • unref(builder: object): void
  • Unreferences a builder. If this was the last reference then the builder is freed.

    It is an error to use this function on builders that were allocated on the stack.

    Parameters

    • builder: object

      the builder

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method