CDIGIDOC(1)
π NAME π
Okay so bestie, welcome to the cdigidoc manual page β that's the section 1 one, iykyk. π
cdigidoc reads, digitally signs, verifies files in XAdES format and encrypts, decrypts files in XMLENC format. That's the whole vibe. Periodt. β¨
π¦ SYNOPSIS π¦
cdigidoc <command(s)> [ -in <input-file> ] [ -out <output-file> ] [ -config <config-file> ]
πΈ DESCRIPTION πΈ
So cdigidoc is an utility that gives you a command line interface to the CDigiDoc library β and that library? It's written in C and it's lowkey carrying the whole operation. It gives you the functionality to:
- create files in supported DigiDoc formats
- digitally sign the DigiDoc files using smart cards or other supported cryptographic tokens
- add time marks and validity confirmations to digital signatures using OCSP protocol
- verify the digital signatures
- digitally encrypt and decrypt the DigiDoc files
And not just that β you can also use the cdigidoc utility as a CGI program in web applications created in environments that can't easily use the JDigiDoc library or call the DigiDocService webservice for digital signature functionality. Versatile icon behavior fr fr. π
For full documentation, see https://svn.eesti.ee/projektid/idkaart_public/branches/3.6/libdigidoc/doc/SK-CDD-PRG-GUIDE.pdf β go read it, it's giving homework but in a cute way. π
XAdES format: http://www.w3.org/TR/XAdES
XML-ENC format: http://www.w3.org/TR/xmlenc-core
β¨ OPTIONS β¨
-?,-helpβ Displays help about command syntax. Your little "what do I even do here" bestie. π«Ά-in <input-file>β Specifies the input file name. The recommendation is to pass the full path to the file in this parameter. Like, full path. Don't be shy with it. π-out <output-file>β Stores the newly created or modified document in a file. New baby goes here. πΈ-config <configuration-file>β Specifies the CDigiDoc configuration file name. If you leave it unspecified, then the configuration file is looked up from default locations. So if you don't say where, it'll go find it itself. Independent queen. β¨-check-cert <certificate-file-in-pem-format>β Checks the certificate validity status. Used for checking the chosen certificate's validity; returns an OCSP response from the certificate's CA's OCSP responder.
Bestie, heads up: the command is currently not being tested. π If the certificate is valid, then the return code's (RC) value is 0.
-new [format] [version]β Creates a new digidoc container with the specified format and version. The current digidoc format in the CDigiDoc library isDIGIDOC-XML, and the default version is1.3(the newest, the freshest, the main character π¦). By using the optional parameter βversionβ with this command, you can specify an alternative version to be created.
Note: the older SK-XML format is supported only for backward compatibility. It's giving legacy, not giving glow-up. π
-add <input-file> <mime-type> [<content-type>] [<charset>]β Adds a new data file to a digidoc document. If the digidoc doesn't exist, then it creates one in the default format. Self-sufficient tbh.- Input file (required) β Specifies the name of the data file (it is recommended to include the full path in this parameter; the path is removed when writing to the DigiDoc container file).
- Mime type (required) β Represents the MIME type of the original file like
"text/plain"or"application/msword". - Content type β Reflects how the original files are embedded in the container β
EMBEDDED_BASE64(used by default). In previous versions,cdigidocallowed content typeEMBEDDEDto sign pure xml or text. - Charset β
UTF-8encoding is supported and used by default. π
-sign <pin-code> [[[manifest] [[city] [state] [zip] [country]] [slot(0)] [ocsp(1)] [token-type(PKCS11)] [pkcs12-file-name]]β Adds a digital signature to the digidoc document. You can use it with the following parameters:- pin code β In case of Estonian ID cards, pin code2 is used for digital signing. If signing with a software token (PKCS#12 file), then the password of the PKCS#12 file should be entered here.
- manifest β Role or resolution of the signer.
- city β City where the signature is created.
- state β State or province where the signature is created.
- zip β Postal code of the place where the signature is created.
- country β Country of origin. ISO 3166-type 2-character country codes are used (e.g.
EE). - slot β Identifier of the signer's private key's slot on a smartcard. When operating, for example, with a single Estonian ID card, its signature key can be found in slot
1β which is used by default. The library makes some assumptions about PKCS#11 drivers and card layouts:- you have signature and/or authentication keys on the card
- both key and certificate are in one slot
- if you have many keys like 1 signature and 1 authentication key, then they are in different slots
- you can sign with a signature key that has a corresponding certificate with
"NonRepudiation"bit set.
You may need to specify a different slot to be used when, for example, operating with multiple smart cards on the same system. If the slot needs to be specified during signing, then the 5 previous optional parameters (manifest, city, state, zip, country) should be filled first (either with the appropriate data or as "" for no value). No skipping steps bestie. π
- ocsp β Specifies whether an OCSP confirmation is added to the signature that is being created. Possible values are
0β confirmation is not added;1β confirmation is added. By default, the value is set to1. Parameter value0can be used when creating a technical signature. Technical signature is a signature with no OCSP confirmation and no timestamp value. It's giving bare minimum, on purpose. π - token type β Specifies type of signature token to be used.
PKCS11β default value. Signs with a smart-card or software pkcs11 tokenCNGβ on windows platforms uses CSP/CNG for signingPKCS12β signs with a PKCS#12 key container that must be entered in the next parameter
- pkcs12 file name β Name of the PKCS#12 key container file to be used for signing.
-mid-sign <phone-no> <per-code> [[<country>(EE)] [<lang>(EST)] [<service>(Testing)] [<manifest>] [<city> <state> <zip>]]β Invokes mobile signing of a ddoc file using Mobile-ID and DigiDocService.
Mobile-ID is a service based on Wireless PKI providing for mobile authentication and digital signing, currently supported by all Estonian and some Lithuanian mobile operators. The Mobile-ID user gets a special SIM card with private keys on it. Hash to be signed is sent over the GSM network to the phone and the user shall enter PIN code to sign. The signed result is sent back over the air. π±β¨
DigiDocService is a SOAP-based web service; access to the service is IP-based and requires a written contract with provider of DigiDocService. You can use Mobile-ID signing with the following parameters:
- phone-no β Phone number of the signer with the country code in format
+xxxxxxxxx(for example+3706234566). - per-code β Identification number of the signer (personal national ID number).
- country β Country of origin. ISO 3166-type 2-character country codes are used (e.g. default is
EE). - lang β Language for user dialog in mobile phone. 3-character capitalized acronyms are used (e.g. default is
EST). - service β Name of the service β previously agreed with Application Provider and DigiDocService operator. Maximum length β 20 chars. (e.g. default is
Testing). - manifest β Role or resolution of the signer.
- city β City where the signature is created.
- state β State or province where the signature is created.
- zip β Postal code of the place where the signature is created.
-listβ Displays the data file and signature info of a DigiDoc document just read in; verifies all signatures. π₯- Returns Digidoc container data, in format:
SignedDoc | <format-identifier> | <version> - List of all data files, in format:
DataFile | <file identifier> | <file name> | <file size in bytes> | <mime type> | <data file embedding option> - List of all signatures (if existing), in format:
Signature | <signature identifier> | <signer's key info: last name, first name, personal code> | <verification return code> | <verification result> - Signer's certificate information.
- OCSP responder certificate information.
- Returns Digidoc container data, in format:
-verifyβ Returns signature verification results (if signatures exist):Signature | <signature identifier> | <signer's key info: last name, first name, personal code> | <verification return code> | <verification result>- Returns signer's certificate and OCSP Responder certificate information.
-extract <data-file-id> <output-file>β Extracts the selected data file from the DigiDoc container and stores it in a file. Data file id represents the ID for the data file to be extracted from inside the DigiDoc container (e.g.D0,D1β¦). Output file represents the name of the output file. Get that file out of there bestie, it's free now. π¦-denc-list <input-encrypted-file>β Displays the encrypted data and recipient's info of an encrypted document just read in. π-encrecv <certificate-file> [recipient] [KeyName] [CarriedKeyName]β okay so this one is the add-a-whole-new-recipient move π It adds a brand-new recipient certificate plus some extra metadata onto an encrypted document. The certificate file is required β that's the file the public key component gets fetched from, and that key is what encrypts your data. Heads up though: the decryption can only ever be done with the private key that matches that exact certificate, no substitutes π
The input certificate files you use for encryption must come from the file system β PEM encodings are supported β¨ Places you can go get those certificate files include: the Windows Certificate Store (look under "Other Persons"), LDAP directories, or an ID-card sitting in a smart-card reader π For example, the certificate files for Estonian ID card owners can be retrieved from an LDAP directory at ldap://ldap.sk.ee. You can run that query through your web browser (IE) in this format:
ldap://ldap.sk.ee:389/c=EE??sub?(serialNumber= xxxxxxxxxxx)
where serial Number is the recipient's personal identification number, e,g.38307240240 π
Other parameters include:
recipientβ if you leave this unspecified, then the program just assigns the CN value of the certificate passed as the first parameter. Later on, that's used as a command line option to identify the recipient whose key and smart card gets used to decrypt the data. Note: even though this parameter is optional, it's recommended that you pass on the entire CN value from the recipient's certificate as the recipient identifier here β especially when you're dealing with multiple recipients π―ββοΈKeyNameβ the sub-element<KeyName>can be added to better identify the key object. Optional, but it can be used to search for the right recipient's key or display its data in an application πCarriedKeyNameβ the sub-element<CarriedKeyName>can be added to better identify the key object. Also optional, also usable to search for the right recipient's key or display its data in an application π«Ά
-encrypt-sk <input-file>β this encrypts the data from the given input file and writes the completed encrypted document into a file. It's the recommended one, because it plays nice with other DigiDoc software components β cross-usability, bestie β¨ This command drops the data file you're encrypting into a new DigiDoc container, so handling those encrypted documents later with other DigiDoc applications is fully supported (think DigiDoc3 client) π The input file is required β it specifies the original data file to be encrypted.
Note: there are also alternative encryption commands, but they are not recommended if you want cross-usability with other DigiDoc software components:
-encrypt <input-file>β encrypts the data from the given input file and writes the completed encrypted document into a file. Should be used only for encrypting small documents that are already in DIGIDOC-XML format. The input file (required) specifies the original data file to be encrypted.-encrypt-file <input-file> <output-file>β encrypts the input file and writes to the output file. Should be used only for encrypting large documents that are already in DIGIDOC-XML format. Note that this command is not currently tested π The input file (required) specifies the original data file to be encrypted. The output file (required) specifies the name of the output file, which will be created in the current encrypted document format (ENCDOC-XML ver 1.0), with the file extension.cdoc.
-decrypt-sk <input-file> <pin> [pkcs12-file] [slot(0)]β decrypts and possibly decompresses the encrypted file that was just read in, and writes it to an output file. It expects the encrypted file to be inside a DigiDoc container π¦ The input file (required) specifies the input file's name. Pin (required) is the recipient's pin1 (in the context of Estonian ID cards).pkcs12-file(optional) specifies the PKCS#12 file if the decrypting is done with a software token. Theslotdefault is slot 0, which contains the Estonian ID cards authentication keypair β you can use this parameter to decrypt with a key from the second ID card attached to the computer, etc. π
Note: there are also alternative commands for decryption, depending on the encrypted file's format, size, and the certificate type used for decrypting it.
-decrypt <input-file> <pin> [pkcs12-file] [slot(0)]β offers the same functionality as-decrypt-sk, and should be used for decrypting small files (which do not need to be inside a DigiDoc container). The input file (required) specifies the input file's name. Pin (required) is the recipient's pin1 (in contexts of Estonian ID cards).pkcs12-file(optional) specifies the PKCS#12 file if the decrypting is done with a software token. Theslotdefault is slot 0, containing the Estonian ID cards authentication keypair β this parameter can be used to decrypt with a key from the second ID card attached to the computer, etc. πΈ-decrypt-file <input-file> <output-file> <pin> [pkcs12-file]β offers the same functionality as-decryptfor decrypting documents, and should be used for decrypting large files (which do not need to be inside a DigiDoc container). It expects the encrypted data not to be compressed. Note that this command is not currently tested π The input file (required) specifies the encrypted file to be decrypted. The output file (required) specifies the output file name. Pin (required) is the recipient's pin1 (in contexts of Estonian ID cards).pkcs12-file(optional) specifies the PKCS#12 file if the decrypting is done with a software token.
-calc-sign <cert-file> [<manifest>] [<city> <state> <zip> <country>]β this is the alternative to-signthat you'd use inside CGI programs π©βπ» It adds the signer's certificate in pem format, and optionally the manifest plus the signer's address, then calculates the final hash value that's gonna be signed. That value comes out hex-encoded and can now be sent to the user's computer to be signed using a web plugin π This command creates an incomplete signature β it lacks the actual RSA signature value. You have to store it in a temporary file and complete it later with the-add-sign-valuecommand.-IP "-add-sign-value <sign-value-file> <sign-id>"β offers an alternative to the-signcommand, for use in CGI programs. It adds an RSA signature hex-encoded value to an incomplete signature that was created with the-calc-signcommand. This signature is still missing the ocsp timemark, which you can now grab using the-get-confirmationcommand, producing a complete XAdES signature β¨
-get-confirmation <signature-id>β adds an OCSP confirmation to a DigiDoc file's signature. That's it, that's the whole job, and it slays π
π EXAMPLES π
cdigidoc -new DIGIDOC-XML 1.3 -add <input-file> <mime> -sign <pin2> -out <output-file>
Creates a new signed document in DIGIDOC-XML 1.3 format, adds one input file, signs with a smartcard using the default signature slot, and writes to a signed document file π
cdigidoc -in <signed-input-file> -list
Reads in a signed document, verifies signatures, and prints the results to the console π
cdigidoc -in <signed-input-file> -extract D0 <output-file>
Reads in a signed document, finds the first signed document, and writes it to the output file βοΈ
cdigidoc -encrecv <recipient1.pem> -encrecv <recipient2.pem> -encrypt-sk <file-to-encrypt> -out <output-file.cdoc>
Creates a new encrypted file by encrypting the input file β which is encrypted using AES-128 β and encrypts the generated random transport key using RSA for two possible recipients, identified by their certificates. The transport key is encrypted using RSA1.5 π
cdigidoc -decrypt-sk <input-file.cdoc> <pin1> -out <output-file>
Reads in an encrypted file and decrypts it with the smartcard's first keypair (the Estonian ID cards authentication key), then writes the decrypted data to the given output file π³
cdigidoc -decrypt-sk <input-file.cdoc> <password> <keyfile.p12d> -out <output-file>
Reads in an encrypted file and decrypts it with a PKCS#12 key-container, then writes the decrypted data to the given output file ποΈ
π AUTHORS π
AS Sertifitseerimiskeskus (Certification Centre Ltd.) β iconic, legendary, no notes π
π¦ SEE ALSO π¦
digidoc-tool(1)qesteidutil(1)qdigidocclient(1)qdigidoccrypto(1)
and that's the whole page bestie, you made it to the end π this edition is version 3.10.5.0, dated 20.05.2025, and it lives under the name CDIGIDOC(1) in the manual. go forth and encrypt responsibly, mwah πβ¨
π¦ where this page comes from
- ubuntu questing: libdigidoc-tools 3.10.5-6build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms