PGP Tool
This is the way I learnt to understand openpgpjs. I did one small step after the other, that's wha there are so many files and options:
System 1
System 2
- Generate and Secure Keys (AES 2.0) - Create and securely store a new PGP key pair using AES 2.0. Salt and IV are stored in Indexxeddb. Use this to decrypt the key.
- Generate and Secure Keys (User-Derived AES 2.0) - Use user-derived salt and IV to securely store a PGP key pair. Salt and IV are NOT stored. Use this to manually decrypt the key.
- Manual Debug Decryption for Generate and Secure Keys (User-Derived AES 2.0)
- Determenistic Encryption - Create and securely store a new PGP key pair using AES 2.0. Private key will be secured with AES, IV and salt will be generated from passphrase and email and not saved. Decrypt with this (manually) or with this (aautomatically).
- Determenistic Decryption - Decrypt deterministically encrypted key only with email and passphrase.
- Deterministic Decryption 2.0 - Decrypt deterministically, with loaded keys from indexxeddb
- Deterministic Encryption 3.0 - Generate and encrypt a private key deterministically, store it locally, and upload the encrypted private key to a server.
- Deterministic Encryption 4.0 - Generate and encrypt a key pair deterministically, store both keys locally, and upload the encrypted private and public key to a server.
- View SQLite Server Database - View all encrypted keys and email addresses stored in the server database.
- Login and load keys - Login and load keys from Server SQLite to local indexeddb
- Login, load keys and unlock key - Login and load keys from Server SQLite to local indexeddb
- Login 3.0: Login, load keys, unlock key and decrypt from memory - Login and load keys from Server SQLite to local indexeddb
- Encrypt 2.0: Get public key from server, encrypt - Encrypt while checking indexeddb and server database for public key
- Login 3.0 & Encrypt 2.0 - Last 2 combined, with session timeout (1 minute)
Working system - to integrate
This is what I suggest to integrate:
Deterministic Encryption 4.0: It generates a key pair. The secret key is encrypted with the passphrase. The seret key is then encrypted with AIS, for key and IV we use the email address (see code). The AES-encrypted private key is then stored in the local indexeddb (in the local browser) and uploaded to the server where is's stored in mySQL.
Login 3.0 & Encrypt 2.0: Login (without user password - just for simulation). It then loads the AES-encrypted private key from the server and saves it in the local indexeddb (in the local browser). After entering the passphrase, the key is AES-decrypted. Then the key (which is still PGP-encrypted with the prassphras) is decrypted with the passphrase. The decrypted version of the key (dangerous - with this you can decrypt without passphrase!) is only stored in a local JS variable.
When encrypting a message, the indexeddb is checked for a matching public key. In case there is no matching public key of the recipient, the server is checked. In case the server has the public is, it is send to encrypt the message.
The system also has an auto-logout function, activated after one minute of no user action (no mouse movement, no clicks).
Debug