Class: SignaturePacket

SignaturePacket()

Implementation of the Signature Packet (Tag 2)

RFC4480 5.2: A Signature packet describes a binding between some public key and some data. The most common signatures are a signature of a file or a block of text, and a signature that is a certification of a User ID.

Constructor

new SignaturePacket()

Source:

Members

hashAlgorithm :enums.hash

Type:
  • enums.hash
Source:

publicKeyAlgorithm :enums.publicKey

Type:
  • enums.publicKey
Source:

signatureType :enums.signature

Type:
  • enums.signature
Source:

Methods

getExpirationTime() → {Date|Infinity}

Returns the expiration time of the signature or Infinity if signature does not expire

Source:
Returns:

Expiration time.

Type
Date | Infinity

isExpired(dateopt) → {Boolean}

Verifies signature expiration date

Parameters:
Name Type Attributes Description
date Date <optional>

Use the given date for verification instead of the current time

Source:
Returns:

True if expired.

Type
Boolean

read(bytes) → {SignaturePacket}

parsing function for a signature packet (tag 2).

Parameters:
Name Type Description
bytes String

Payload of a tag 2 packet

Source:
Returns:

Object representation.

Type
SignaturePacket

(async) sign(key, data, dateopt, detachedopt)

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

Parameters:
Name Type Attributes Default Description
key SecretKeyPacket

Private key used to sign the message.

data Object

Contains packets to be signed.

date Date <optional>

The signature creation time.

detached Boolean <optional>
false

Whether to create a detached signature

Source:
Throws:

if signing failed

Type
Error

(async) verify(key, signatureType, data, dateopt, detachedopt, configopt)

verifies the signature packet. Note: not all signature types are implemented

Parameters:
Name Type Attributes Default Description
key PublicSubkeyPacket | PublicKeyPacket | SecretSubkeyPacket | SecretKeyPacket

the public key to verify the signature

signatureType module:enums.signature

Expected signature type

data Uint8Array | Object

Data which on the signature applies

date Date <optional>

Use the given date instead of the current time to check for signature validity and expiration

detached Boolean <optional>
false

Whether to verify a detached signature

config Object <optional>

Full configuration, defaults to openpgp.config

Source:
Throws:

if signature validation failed

Type
Error

writeHashedSubPackets() → {Uint8Array}

Creates Uint8Array of bytes of all subpacket data except Issuer and Embedded Signature subpackets

Source:
Returns:

Subpacket data.

Type
Uint8Array

writeParams() → {Uint8Array|ReadableStream.<Uint8Array>}

Source:
Returns:
Type
Uint8Array | ReadableStream.<Uint8Array>

writeUnhashedSubPackets() → {Uint8Array}

Creates an Uint8Array containing the unhashed subpackets

Source:
Returns:

Subpacket data.

Type
Uint8Array