1SMIME(3)              User Contributed Perl Documentation             SMIME(3)
2
3
4

NAME

6       Crypt::SMIME - S/MIME message signing, verification, encryption and
7       decryption
8

SYNOPSIS

10         use Crypt::SMIME;
11
12         my $plain = <<'EOF';
13         From: alice@example.org
14         To: bob@example.com
15         Subject: Crypt::SMIME test
16
17         This is a test mail. Please ignore...
18         EOF
19
20         my $smime = Crypt::SMIME->new();
21         $smime->setPrivateKey($privkey, $crt);
22         # $smime->setPublicKey([$icacert]); # if need be.
23
24         my $signed = $smime->sign($plain);
25         print $signed;
26

DESCRIPTION

28       This module provides a class for handling S/MIME messages. It can sign,
29       verify, encrypt and decrypt messages. It requires libcrypto
30       (<http://www.openssl.org>) to work.
31
32   METHODS
33       new()
34             my $smime = Crypt::SMIME->new();
35
36           The constructor takes no arguments.
37
38       setPrivateKey()
39             $smime->setPrivateKey($key, $crt);
40             $smime->setPrivateKey($key, $crt, $password);
41
42           Store a private key and its X.509 certificate into the instance.
43           The private key will be used for signing and decryption. Note that
44           this method takes a PEM string, not a name of a file which contains
45           a key or a certificate.
46
47           The private key and certificate must be encoded in PEM format. The
48           method dies if it fails to load the key.
49
50       setPublicKey()
51             $smime->setPublicKey($crt);
52             $smime->setPublicKey([$crt1, $crt2, ...]);
53
54           Store one or more X.509 certificates into the instance. The public
55           keys will be used for signing, verification and encryption.
56
57           The certificates must be encoded in PEM format. The method dies if
58           it fails to load the certificates.
59
60       sign()
61             $signed_mime = $smime->sign($raw_mime);
62
63           Sign a MIME message and return an S/MIME message. The signature is
64           always detached.
65
66           Any headers except "Content-*", "MIME-*" and "Subject" will be
67           moved to the top-level of the MIME message. "Subject" header will
68           be copied to both of the plain text part and the top-level for mail
69           clients which can't properly handle S/MIME messages.
70
71       signonly()
72             $sign = $smime->signonly($prepared_mime);
73
74           Generate a signature from a MIME message. The resulting signature
75           is encoded in Base64. The MIME message to be passed to this method
76           should be preprocessed beforehand by the prepareSmimeMessage()
77           method. You would rarely need to call this method directly.
78
79       prepareSmimeMessage()
80             ($prepared_mime, $outer_header)
81                 = $smime->prepareSmimeMessage($source_mime);
82
83           Preprocess a MIME message to be signed. $prepared_mime will be a
84           string containing the processed MIME message, and $outer_header
85           will be a string that is a list of headers to be moved to the top-
86           level of MIME message. You would rarely need to call this method
87           directly.
88
89           The entity body of $source_mime will be directly copied to
90           $prepared_mime. Any headers of $source_mime except "Content-*",
91           "MIME-*" and "Subject" will be copied to $prepared_mime, and those
92           excluded headers will be copied to $outer_header. Note that the
93           "Subject" header will be copied to both side exceptionally.
94
95       check()
96             $source_mime = $smime->check($signed_mime);
97
98           Verify a signature of S/MIME message and return a MIME message. The
99           method dies if it fails to verify it.
100
101       encrypt()
102             $encrypted_mime = $smime->encrypt($raw_mime);
103
104           Encrypt a MIME message and return a S/MIME message.
105
106           Any headers except "Content-*", "MIME-*" and "Subject" will be
107           moved to the top-level of the MIME message. "Subject" header will
108           be copied to both of the plain text part and the top-level for mail
109           clients which can't properly handle S/MIME messages.
110
111       decrypt()
112             $decrypted_mime = $smime->decrypt($encrypted_mime);
113
114           Decrypt an S/MIME and return a MIME message. This method dies if it
115           fails to decrypt it.
116
117       isSigned()
118             $is_signed = $smime->isSigned($mime);
119
120           Return true if the given string is a signed S/MIME message. Note
121           that if the message was encrypted after signing, this method
122           returns false because in that case the signature is hidden in the
123           encrypted message.
124
125       isEncrypted()
126             $is_encrypted = $smime->isEncrypted($mime);
127
128           Return true if the given string is an encrypted S/MIME message.
129           Note that if the message was signed with non-detached signature
130           after encryption, this method returns false because in that case
131           the encrypted message is hidden in the signature.
132

AUTHOR

134       Copyright 2006-2007 YMIRLINK Inc. All Rights Reserved.
135
136       This library is free software; you can redistribute it and/or modify it
137       under the same terms as Perl itself
138
139       Bug reports and comments to: tl@tripletail.jp
140
141
142
143perl v5.12.1                      2008-10-02                          SMIME(3)
Impressum