Module upm::database [] [src]

Read and write Universal Password Manager version 3 databases. This code is meant to interoperate with the format used by the original UPM Java application.

Versions 1 and 2 of the UPM database format are not supported. Version 3 was introduced in 2011, so there may not be many cases where the older versions are still in use.

Database format

UPMv3 databases are stored in the following format:

  • A 3-byte magic field ("UPM").
  • A 1-byte version field. (This module only supports version 3.)
  • The 8-byte salt used to encrypt the remainder of the file.
  • The remainder of the file is encrypted using 256-bit AES-CBC (see the documentation for the [crypto] module for more details). When decrypted, the plaintext will contain a series of length-prefixed records in a format that the original UPM author refers to as "flatpack". The length prefix is four bytes of UTF-8 encoded decimal which specifies the size in bytes of the record payload which follows. The payload is always a UTF-8 string; integers are encoded as decimal digits.
    • The first three records are metadata:
      1. The database revision, a monotonically increasing number that is used when syncing with a remote database.
      2. The URL of the remote sync repository. This URL does not include the name of the database. It instead corresponds to a directory on the server which may include multiple UPM databases with different names.
      3. The name of the account, as included in this database, which contains the username and password to be used for HTTP Basic Authentication when accessing the remote sync repository.
    • The remaining records contain account data. Every five records represents the following data for a specific account:
      1. Account name
      2. Username
      3. Password
      4. URL
      5. Notes

Structs

Account

This struct represents a single UPM account, and provides an ordering based on the alphanumeric case-insensitive comparison of account names.

Database

This struct represents a UPM database, as read from a local file or a remote sync repository.