pub struct Entry { /* private fields */ }
Expand description

Entry represents a single entry in a keycard and contains both fields and authentication strings, which can be a digital signature or a cryptographic hash.

Implementations

Creates a new entry given the value held in the passed string. As if this writing only “Organization”, “User”, or “” are valid, the last of which creating an Entry of type None.

Creates a new entry based on the type given

Creates a new entry from the text data given it. The format of an entry is documented in the Mensago Identity Services design document.

Returns true if the entry has a specific field

Gets the specified field for an entry. Naming for the field exactly matches the spec.

Sets an entry field. Naming for the field exactly matches the spec.

Sets multiple entry fields from a list of type-value mappings

Deletes a field from the entry

Checks the formatting of the regular fields in the entry and returns false if a field does not comply. This method is usually called to ensure that the data in an entry is valid before proceeding with the signing and hashing process.

Returns false if the entry has any compliance issues, including missing or bad hashes and/or signatures. This method performs all the checks made in is_data_compliant() and more. Note that only the format of signatures and hashes are checked. The validity of a hash or signature must be checked using verify() or verify_chain().

For an entry to be compliant, an organization entry MUST have the following fields:

  • Type
  • Index
  • Name
  • Contact-Admin
  • Primary-Verification-Key
  • Encryption-Key
  • Time-To-Live“
  • Expires
  • Timestamp

Organizational entries may also have any of the following optional fields:

  • Contact-Abuse
  • Contact-Support
  • Language
  • Secondary-Verification-Key

User entries MUST have the following fields:

  • Type
  • Index
  • Workspace-ID
  • Domain
  • Contact-Request-Verification-Key
  • Contact-Request-Encryption-Key
  • Verification-Key
  • Encryption-Key
  • Time-To-Live“
  • Expires
  • Timestamp

User entries MAY also have a Name or User-ID field, although these are optional.

Additionally, any entry MUST also have signatures and hashes applied in the order specified in the description for get_full_text().

Sets the expiration date for the entry. The maximum number of days for entries is 1095 (~3 years). The recommended value are 365 for an organization entry and 90 for a user entry.

Returns true if the entry has exceeded its expiration date

Returns the body text of the entry

Returns the full text of the entry, including signatures, up to but not including the one specified. Passing an empty string as the signature level will result in the entire entry being returned.

The order for organization entries:

  • Custody-Signature
  • Previous-Hash
  • Hash
  • Organization-Signature

The order for user entries:

  • Custody-Signature
  • Organization-Signature
  • Previous-Hash
  • Hash
  • User-Signature

Returns true if the supplied AuthStr is populated and valid

Returns the specified authentication string

Sets the specified authentication string to the value passed. NOTE: no validation of the authentication string is performed by this call. The primary use for this method is to set the Previous-Hash for the entry

Creates the requested signature. Requirements for this call vary with the entry implementation. ErrOutOfOrderSignature is returned if a signature is requested before another required authentication string has been set. ErrBadValue is returned for a signature type not used by the specific implementation.

Verifies the requested signature. ErrBadValue is returned for a signature type not used by the specific implementation. ErrVerificationFailure is returned if the signature fails to verify

Calculates the hash for the entry text using the specified algorithm. For information on signature order, please see get_full_text(). All signatures are required except for Custody-Signature and Previous-Hash, which are not required for an organization’s root keycard entry. ErrOutOfOrderSignature is returned if a hash is requested before another required authentication string has been set.

Verifies the data of the entry with the hash currently assigned. Returns Ok on success and ErrHashMismatch on failure.

Creates a new Entry object with new keys and a custody signature. It requires the contact request signing keypair used for the entry so that the Custody-Signature field is generated correctly. For handling of expiration date, see set_expiration().

Verifies the chain of custody between the provided entry and the current one. If either card is invalid, ErrInvalidKeycard is returned. If the index of entry is not the immediate successor to the previous one, ErrBadValue is returned.

This method is called when the current entry must be revoked because one or more keys were compromised. A new root entry is created with a Revoke field containing the hash of the current one and an Index which is, like chain(), one greater than the current entry. For handling of the expiration interval, see set_expiration().

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.