IPWorks OpenPGP 2020 macOS Edition

Questions / Feedback?

Key Type

The OpenPGP key being used.

Remarks

This type describes the current key. The key may be a public or secret key. The fields are used to identify or select the key.

Fields

curve
String

This property specifies the elliptic curve used in the ECDSA or EdDSA key. This property is only applicable if PublicKeyAlgorithm is ECDSA or EdDSA. Possible values are:

ValuePublicKeyAlgorithmDescription
secp256r1 ECDSA NIST curve P-256
secp384r1 ECDSA NIST curve P-384
secp521r1 ECDSA NIST curve P-521
Ed25519 EdDSA Ed25519
secp256k1 EdDSA Secp256k1

effectiveDate
String

The date when this key becomes valid. Prior to this it is not valid. The following is an example of a valid encoded date:

23-Jan-2000 15:00:00.

encodedB
Data

The key. This property is used to assign a specific key. The UserId properties may also be used to specify a key.

encoded
String

The key. This property is used to assign a specific key. The UserId properties may also be used to specify a key.

expirationDate
String

The date the key expires. After this date the key will no longer be valid. The following is an example of a valid encoded date:

23-Jan-2001 15:00:00.

fingerprint
String

The hex-encoded, 20-byte fingerprint of the key.

This is in the form:

5E70662EA810E768391A2FE8F7B7D49C89C9D7B1

id
String

The hex-encoded, 4-byte key Id. It is same as last 4 bytes of Fingerprint.

This is in the form:

89C9D7B1
The KeyIdLength setting may be set to a value of 8 to return the last 8 bytes instead of the last 4 bytes.

keyring
String

The location of the keyring.

If the keyring is stored in a directory, set this property to the directory. The directory must contain the files "secring.gpg" and "pubring.gpg". A keyring may also be stored in a single file. If the keyring is a file this property should be set to the path of the file.

When This property is set the class will read the keyring and populate the Key* properties with the first key found in the keyring. Set UserId to select a different key in the current keyring.

otherUserIds
String

If the specified key has alternate user Ids associated with it, this property returns a comma-separated list of the other user Ids.

passphrase
String

The passphrase for the key's secret key (if any). This must be specified before operations requiring the secret key are attempted. The passphrase may be supplied in this property or through the KeyPassphrase event, which will fire when a passphrase is required.

The passphrase is required when using the following methods in KeyMgr:

  • AddUserId
  • SignUserId
  • ChangeExpirationDate
  • ChangePassphrase

When using the OpenPGP class, or an email-based class, the following methods require a passphrase for the key:

  • Decrypt
  • Sign
  • SignAndEncrypt

publicKey
String

The public key of the key. The key is provided as ASCII armored data.

publicKeyAlgorithm
String

A text description of the public key algorithm of the key. Possible values are:

  • RSA
  • DSA
  • ECDSA
  • EdDSA
  • RSA-Legacy

publicKeyLength
Int32

The length of the public key in bits. Common values are 512, 1024, and 2048.

If the PublicKeyAlgorithm property is ECDSA or EcDSA the length of the public key is determined by the Curve. Possible lenghts are:

CurvePublic Key Length (bits)
secp256r1256
secp384r1384
secp521r1521
Ed25519 256
secp256k1256

revoked
Bool

Whether or not the key is revoked.

secretKey
String

The secret key of the key (if available). The key is provided as ASCII armored data.

secretKeyAvailable
Bool

Whether or not a secret key is available for the selected key.

usage
String

A text description of UsageFlags.

The value will be of one or more of the following strings, separated by commas:

  • Certifying Other Certificates
  • Signing Emails and Files
  • Encrypting Emails and Files
  • Split Key
  • Authenticate Against Servers
  • Group Key

usageFlags
Int32

Flags that show the intended use for the key. The default value is 0x0F. The value of UsageFlags is a combination of the following flags:

0x01This key may be used to certify other keys.
0x02This key may be used to sign data.
0x0CThis key may be used to encrypt communications and encrypt storage.
0x10The private component of this key may have been split by a secret-sharing mechanism.
0x20This key may be used for authentication.
0x80The private component of this key may be in the possession of more than one person.

Please refer to the Usage property for a text representation of UsageFlags.

userId
String

The user Id of the key. When a key is loaded this property is populated with the user Id associated with the key. This property may be set to load a key from the Keyring. When this property is set the class will search the Keyring for a key associated with the UserId specified.

When loading a key with multiple user Ids, this property will be populated with the UserId that was most recently added to the key. To discover all of the UserIds associated with a key query this property and OtherUserIds after loading the key.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

When using this property to select a key you may also specify the key's Id, or any of its subkeys' Ids, instead of a user Id. The class will then search for a key with a matching Id. This is helpful in situations where you do not have the UserId but still need to load the key, such as within the OpenPGP class's RecipientInfo event.

Constructors

public init(keyPath: String)

Reads the OpenPGP public key from the specified KeyPath . If multiple keys are present only the first one is used.

public init(keyData: Data)

Reads the OpenPGP key from the specified KeyData . Both binary-formatted and ASCII-armored data are accepted.

public init(keyPath: String, userId: String)

Searches the KeyPath for an OpenPGP key with a matching UserId . If UserId is set to "*" the first key will be used.

public init(keyData: Data, userId: String)

Searches the KeyData for an OpenPGP key with a matching UserId . If UserId is set to "*" the first key will be used.

Copyright (c) 2021 /n software inc. - All rights reserved.
IPWorks OpenPGP 2020 macOS Edition - Version 20.0 [Build 7941]