Generate the Keys for Importing and Exporting Data with Partners
Source:R/import_export_crypto.R
episodic_import_export_keygen.RdRun this once per instance. It writes two key pairs into path:
Value
Invisibly, a list with the four file paths
(encryption_secret, encryption_public, signing_secret,
signing_public) and the two public keys' fingerprints
(encryption_fingerprint, signing_fingerprint).
Details
- An encryption key pair
episodic_import_export_encryption.key(secret) andepisodic_import_export_encryption.pub(public). A partner encrypts the files meant for you to the public key; only the secret key opens them. PointEPISODIC_IMPORT_KEYat the secret key file.- A signing key pair
episodic_import_export_signing.key(secret) andepisodic_import_export_signing.pub(public). Every file you export is signed with the secret key; a partner pins your public key and refuses any file it does not verify. PointEPISODIC_EXPORT_SIGNING_KEYat the secret key file.
Give your partners the two .pub files and your instance identifier
(episodic_instance_id()), and never the .key files. The secret key
files are written readable by their owner only; on Windows, which
keeps no such permission bits, keep them in a directory only the
account running EpiSODIC can read.
Keys never belong in the configuration file: they would enter a stored configuration export, and whoever reads that could read or forge every file.
Examples
dir <- tempfile()
keys <- episodic_import_export_keygen(dir)
basename(unlist(keys[1:4]))
#> [1] "episodic_import_export_encryption.key"
#> [2] "episodic_import_export_encryption.pub"
#> [3] "episodic_import_export_signing.key"
#> [4] "episodic_import_export_signing.pub"
unlink(dir, recursive = TRUE)