|
libcdoc 0.5.1
|
The libcdoc library includes a command-line tool, cdoc-tool (or cdoc-tool.exe on Windows), which can be used to encrypt and decrypt files, as well as view the locks in an encrypted container. The tool is compatible with Windows, macOS, and Linux platforms.
The general syntax for encrypting files for one or more recipients is the following:
To re-encrypt a file for a different recipient(s) or with a different encryption method, use the re-encrypt switch instead of encrypt. For that both decryption and encryption options have to be specified.
). In all other cases, CDOC ver. 2 format container is created. Tool gives an error if the option is used with any other encryption method.
). In Windows the tool uses API provided by Windows. In all other cases the option is ignored.
One or more recipients must be specified, each with its own encryption method.
| Form | Description |
|---|---|
| [label]:cert:CERTIFICATE_HEX | Encryption public-key from certificate. The certificate must be provided as hex-encoded string |
| [label]:skey:SECRET_KEY_HEX | Symmetric encryption with AES key. The key must be provided as hex-encoded string |
| [label]:pkey:SECRET_KEY_HEX | Encryption with public-key. The key must be provided as hex-encoded string |
| [label]:pfkey:PUB_KEY_FILE | Encryption with public-key. The key (secp384r1 or secp256r1) is read from the DER-encoded file. |
| [label]:pw:PASSWORD | Encryption with derive key using PWBKDF |
| [label]:p11sk:SLOT:[PIN]:[PKCS11 ID]:[PKCS11 LABEL] | Encryption with AES key from PKCS11 module |
| [label]:p11pk:SLOT:[PIN]:[PKCS11 ID]:[PKCS11 LABEL] | Encryption with public key from PKCS11 module |
| [label]:share:ID | use key share server with given ID (personal code) |
If the label is omitted then the --genlabel option must be specified at command-line. Otherwise, the tool generates an error. If both, label and --genlabel option are provided then depending on encryption method, the label may be ignored, but may be also used a part of machine-readable label, like in encrypting with symmetric key and password case. Refer Appendix D section of CDOC2 container format specification for examples of machine-readable key-labels.
Encrypt a file with a password
Encrypt the file abc.txt with the password Test123. The resulting container is abc.txt-pw.cdoc.
Encrypt a file with a public key from an ID card
Encrypt the file abc.txt using a public key from an Estonian ID card. The resulting container is abc.txt-p11pk.cdoc. To use the ID card a PKCS11 library has to be specified, the exact location depends on the operating system and installed software.
Encrypt a file with a public key from a file
Encrypt the file abc.txt using a public key from the file ec-secp384r1-pub.der. The resulting container is abc.txt-pfkey.cdoc.
Encrypt a file with an AES key
Encrypt the file abc.txt using an AES key provided via the command line. The resulting container is abc.txt-aes.cdoc.
Encrypt a file with a public key from an ID card and use key server
Encrypt the file abc.txt using a public key from an Estonian ID card and use the RIA key server. The resulting container is abc.txt-ks.cdoc.
The syntax for decrypting an encrypted file is the following:
Following options are supported:
Decrypt a file with a password
Decrypt the file abc.txt-pw.cdoc using the key with label Test and password Test123.
Decrypt a file with an ID card
Decrypt the file abc.txt-p11pk.cdoc using the key from lock 1 and an Estonian ID card with PIN code 1234.
Decrypt a file with an ID card and use key server
Decrypt the file abc.txt-ks.cdoc using the key with label Test and a private key from an ID card, using the RIA key server.
To view the locks in a container, use the following syntax:
This command does not have any options. The only argument is the encrypted container file whose locks will be displayed.
Display the locks of the file abc.txt-aes.cdoc: