security3Add my vote for this tag create new tag
, view all tags


Encrypt parts of a topic for privacy and add digital signatures to topics


TWiki has no efficient way to restrict topic viewing from a list of users or a list of groups. Moreover one may want to forbid only parts of a topic to some users and not the whole page (e.g. hide some columns of a table). The goal of this plugin is to allow to crypt some parts of a topic when storing it into the file system of the hosting machine and offers the possibility to attach a digital signature for the topic content. The encrypted parts are automatically decrypted before viewing or editing the topic. The advantage of this method is to defeat the use of some directives such as SEARCH for accessing to hidden (encrypted) parts. Its direct drawback is that the hidden (encrypted) parts cannot be taken into account by directives such as SEARCH which use direct access to the topic and then will find the encrypted version of texts even when running for authorized users.

Syntax Rules

There are 3 main directives for handling topic encrypting. A directive to set general encrypting options, a directive to set table encrypting options and a directive to encrypt a text. There are also 3 directives used for the digital signature.


The directive for options is %CRYPT_OPTIONS{...}% and can occur in the beginning of the topic to have effect on all crypting directives. This header directive can be overrided by another %CRYPT_OPTIONS{...}% placed at the beginning of a line, this directive apply to all encrypting directives in the same line. The list of settings controlled by a %CRYPT_OPTIONS{...}% is given in the following table:

Setting Description Default
method method to use to encrypt the text base64
aclmode precise the behavior of ACL options append
allowtextread users and groups allowed to view encrypted text (or * as a wildcard for everybody) initial user who typed the text to be encrypted
allowtextchange users and groups allowed to modify encrypted text (or * as a wildcard for everybody) initial user who typed the text to be encrypted
denytextread users and groups that cannot view encrypted text void
denytextchange users and groups that cannot modify encrypted text void
begin shortcut delimiter for encrypted text beginning {{
end shortcut delimiter for encrypted text ending }}
alt an alternative string to be displayed when user is not allowed to decrypt text void string

You can only specify base64 or rsa_xxx as crypting methods (where "xxx" stands for the name of a symmetric key encryption algorithm; you ca choose between "rc4" or "rijndael"). The base64 method is totally insecure (a mere base64 encoding) and is used only for demonstration and trial purposes. For production you must use the rsa_xxx method (for each text to be encrypted, a key is generated and used to crypt the text, both this encrypted text and the symmetric key ciphered using the global RSA key - see below in Settings section - are saved into the topic).

The lists of users and groups are comma separated lists. The list is appended to lists defined by previous setting directives unless the aclmode is set to override.


This directive is used for setting encrypting options for a table. It should appear in a line previous to the table itself.This feature allows a user to specify a special column in a table by inserting the following HTML comment in the column name <!--UserIDCol-->. Each field of this column will contain a list of twiki ids. The encrypted directives found on the rows of the table will be encrypted with view permission only for the users specified in this column. The edit permissions of the the encrypted texts from the table will be those set in the %CRYPT_TABLE_OPTIONS{...}% or the global ones.

The %CRYPT_TABLE_OPTIONS{...}% directive is intended so that a user can specify who is allowed to edit the encrypted texts from the table or the alt option (an alternative string to be displayed when user is not allowed to decrypt text).


A text to be encrypted must be enclosed between the directives %CRYPT_BEGIN{...}% and %CRYPT_END%. The %CRYPT_BEGIN{...}% directive can take the same options as directive %CRYPT_SETTINGS{...}%. Another way to specify a text to be encrypted is to use the shortcuts which default to {{ and }} but it is not possible with this method to alter the encrypting settings.

When one is allowed to edit a topic (by standard TWiki access control methods) and not allowed to edit some encrypted texts, these texts appear in encrypted form into a <verbatim>...</verbatim> directive. If the user delete or change the textual order of one of these directives it will not be allowed to save its changes.

When viewing a topic, the encrypted texts a user is not allowed to see are replaced by an alternative text which default to a void string.


When inserted in the edit box this directive generates a "Sign" button. When pressed, a hash of the topic text is added in the page meta data.


This directives are expanded into: "Valid Signatures: signature(date time),..." and "Outdated Signatures: signature(date time),...". This directives are intended to be used in the skin templates (for example view.pattern.tmpl) by the admin of TWiki site, so the signatures can't be modified by users.


The text below is encrypted. You should see it only if you are authorized to decrypt it:

{{crypted text}}
{{other crypted text}}
%CRYPT_OPTIONS{allowtextread="titi"}%{{another other crypted text}}

|{{line1,col0,(view 1,2)}}|TestUser2, TestUser1|{{line1,col2,(view 1,2)}}|
|{{line2,col0,(view 1,3)}}|TestUser3, TestUser1|{{line2,col2,(view 1,3)}}|

TopicCryptPlugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %TOPICCRYPTPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Encrypt parts of a topic for privacy and add digital signatures to topics

  • The default crypting method to use (change to rsa_rca4 if you want this plugin to be useful):
    • Set DEFAULT_METHOD = rsa_rc4

  • Maximum number of signatures on a topic: (See output in data/debug.txt)
    • Set MAX_SIGNATURES = 5

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

  • For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.

  • Or, follow these manual installation steps:

    • Download the tarball file from the Plugin web (see below)
    • Untar TopicCryptPlugin.tgz in your twiki installation directory. Content:
      File: Description:
      data/TWiki/TopicCryptPlugin.txt Plugin topic
      lib/TWiki/Plugins/TopicCryptPlugin.pm Plugin Perl module
      lib/TWiki/Plugins/TopicCryptPlugin/Config.spec Settings for configure script
    • Install the following CPAN modules:
      • Mime::Base64
      • Crypt::CBC
      • Crypt::Rijndael_PP
      • Crypt::RC4
      • Crypt::OpenSSL::RSA

  • The following applies to both manual, as well as to automatic install
    • Create your asymetric key with openssl (currently only RSA key is supported):
      openssl genrsa -out /var/lib/twiki/cryptkey.priv 2048
    • Be sure to configure the variable PRIVKEY_FILE in lib/LocalSite.cfg with the platform specific location of the private key file . The default is:

Plugin Info

Plugin Author: TWiki:Main.XavierRedon, TWiki:Main.AlexIancu
Copyright: © 2006, TWiki:Main.AlexIancu
© 2008-2011 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Plugin Version: 21437 (2011-06-07)
Change History:  
2011-06-07: TWikibug:Item6721: Fix problem with recognizing valid named users in list -- TWiki:Main.DipuDeshmukh
2011-06-04: TWikibug:Item6727: Fix page mangling, evident in pulldown menu corruption -- TWiki:Main.DipuDeshmukh
2011-05-15: TWikibug:Item6701: Doc improvements -- TWiki:Main.PeterThoeny
14 May 2011: TWikibug:Item6721: Initial import into SVN; integrate patch tcp_patch422. Move configuration of key file location to LocalSite.cfg -- TWiki:Main.DipuDeshmukh
14 May 2006: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: Mime::Base64, Crypt::CPC, Crypt::Rijndael_PP, Crypt::RC4, Crypt::OpenSSL::RSA
Other Dependencies: none
Perl Version: 5.005
TWiki:Plugins/Benchmark: GoodStyle 99%, FormattedSearch 98%, TopicCryptPlugin nn%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/TopicCryptPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/TopicCryptPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/TopicCryptPluginAppraisal

Related Topics: TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 TopicCryptPlugin.md5 r4 r3 r2 r1 manage 0.2 K 2011-06-07 - 19:05 DipuDeshmukh  
Compressed Zip archivetgz TopicCryptPlugin.tgz r4 r3 r2 r1 manage 18.2 K 2011-06-07 - 19:05 DipuDeshmukh  
Compressed Zip archivezip TopicCryptPlugin.zip r16 r15 r14 r13 r12 manage 20.5 K 2011-06-07 - 19:04 DipuDeshmukh  
Unknown file formatEXT TopicCryptPlugin_installer r1 manage 3.6 K 2011-06-07 - 19:05 DipuDeshmukh  
Edit | Attach | Watch | Print version | History: r28 < r27 < r26 < r25 < r24 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r28 - 2013-10-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.