# Module: packet/signature

## packet/signature

#### new require("packet/signature")()

  Source:
    - packet/signature.js, line 36

Source:
  - packet/signature.js, line 18

### Methods

#### isExpired() → {Boolean}

  Verifies signature expiration date
  Source:
    - packet/signature.js, line 626

  ##### Returns:

  true if expired
  Type
    Boolean

#### read(bytes, position, len) → {module:packet/signature}

  parsing function for a signature packet (tag 2).

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `bytes` | String | payload of a tag 2 packet
  `position` | Integer | position to start reading from the bytes string
  `len` | Integer | length of the packet or the remaining length of bytes at position

  Source:
    - packet/signature.js, line 88

  ##### Returns:

  object representation
  Type
    module:packet/signature

#### sign(key, data)

  Signs provided data. This needs to be done prior to serialization.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `key` | module:packet/secret_key | private key used to sign the message.
  `data` | Object | Contains packets to be signed.

  Source:
    - packet/signature.js, line 188

#### verify(data, key) → {boolean}

  verifys the signature packet. Note: not signature types are implemented

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `data` | String | Object | data which on the signature applies
  `key` | module:packet/public_subkey | module:packet/public_key | the public key to verify the signature

  Source:
    - packet/signature.js, line 588

  ##### Returns:

  True if message is verified, else false.
  Type
    boolean

#### write_all_sub_packets() → {String}

  Creates string of bytes with all subpacket data
  Source:
    - packet/signature.js, line 222

  ##### Returns:

  a string-representation of a all subpacket data
  Type
    String

#### <inner> write_sub_packet(type, data) → {String}

  creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `type` | Integer | subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2
  `data` | String | data to be included

  Source:
    - packet/signature.js, line 335

  ##### Returns:

  a string-representation of a sub signature packet (See RFC 4880 5.2.3.1)
  Type
    String