Metadata-Version: 2.1
Name: cmssign
Version: 0.0.3
Summary: Tool for cms signature
License: Apache
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >= 3.6
Requires-Dist: pip (>=21.0)
Requires-Dist: cryptography (>=36.0.0)
Requires-Dist: asn1crypto (>=1.3.0)

Introduce
=========

This tool is used sign file with Cryptographic Message Syntax. And add a Timestamp Reply to the cms file optionally.

Installation
============

To install using ``pip``,::

    python -m pip install --upgrade pip
    python -m pip install cmssign

This tool depend on ``cryptographic`` and ``asn1crypto``

Notice
======

The version 0.0.1 have some bug, it should not be used.

Use with GUI
==============

.. code-block:: sh

    cmssignui


Use within Command line
=======================

cmssign sign
~~~~~~~~~~~~

.. code-block:: sh

    Usage: cmssign sign [-h] --cafile CAFILE --cakey CAKEY [--tsca TSACA] [--tskey TSAKEY] --in INFILE [--out OUTFILE]

--signer        signer certificate file

--key           signer private key file

--tssigner      timestamp signer certificate file

--tskey         timestamp signer private key file

--timestamp     time stamp. use system time if not set. format must like '20220101' or '20220101123000'

--in            file to sign

--out           specific the file to save the cms signature, if not set the "infile.cms" will be used 

If the tssigner and tskey is set correctly, the timestamp reply will be add to the unsigned attributes section at the end of the cms file

cmssign combine
~~~~~~~~~~~~~~~

This command will add the timestamp reply to  the unsigned attributes section at the end of the cms file

.. code-block:: sh

    Usage: cmssign combine [-h] --cmsfile CMSFILE --tsfile TSFILE --out OUTFILE

--cmsfile       cms file

--tsfile        timestamp reply file

--out           specific the file to save the output


Example:
~~~~~~~~

.. code-block:: sh

    // Sign file with timestamp
    cmssign sign --signer rootCA.crt --key rootCA.pem --tssigner tsa.crt --tskey tsa.pem --in file_go_sign --out output_cms_file

    // Sign file without timestamp
    cmssign sign --signer rootCA.crt --key rootCA.pem  --in file_go_sign --out output_cms_file

Currently the timestamp signer certificate and private key only support PEM format


Reference
=========

* Cryptographic Message Syntax https://www.rfc-editor.org/rfc/rfc5652.html
* Time-Stamp Protocol https://www.rfc-editor.org/rfc/rfc3161.txt
