.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mail::DKIM::Signature 3pm" .TH Mail::DKIM::Signature 3pm "2013-02-07" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::DKIM::Signature \- represents a DKIM\-Signature header .SH "CONSTRUCTORS" .IX Header "CONSTRUCTORS" .SS "\fInew()\fP \- create a new signature from parameters" .IX Subsection "new() - create a new signature from parameters" .Vb 12 \& my $signature = Mail::DKIM::Signature\->new( \& [ Algorithm => "rsa\-sha1", ] \& [ Signature => $base64, ] \& [ Method => "relaxed", ] \& [ Domain => "example.org", ] \& [ Identity => \*(Aquser@example.org\*(Aq, ] \& [ Headers => "from:subject:date:message\-id", ] \& [ Query => "dns", ] \& [ Selector => "alpha", ] \& [ Timestamp => time(), ] \& [ Expiration => time() + 86400, ] \& ); .Ve .SS "\fIparse()\fP \- create a new signature from a DKIM-Signature header" .IX Subsection "parse() - create a new signature from a DKIM-Signature header" .Vb 3 \& my $sig = Mail::DKIM::Signature\->parse( \& "DKIM\-Signature: a=rsa\-sha1; b=yluiJ7+0=; c=relaxed" \& ); .Ve .PP Constructs a signature by parsing the provided DKIM-Signature header content. You do not have to include the header name (i.e. \*(L"DKIM-Signature:\*(R") but it is recommended, so the header name can be preserved and returned the same way in \fIas_string()\fR. .PP Note: The input to this constructor is in the same format as the output of the as_string method. .SH "METHODS" .IX Header "METHODS" .SS "\fIalgorithm()\fP \- get or set the algorithm (a=) field" .IX Subsection "algorithm() - get or set the algorithm (a=) field" The algorithm used to generate the signature. Should be either \*(L"rsa\-sha1\*(R", an RSA-signed \s-1SHA\-1\s0 digest, or \*(L"rsa\-sha256\*(R", an RSA-signed \s-1SHA\-256\s0 digest. .PP See also \fIhash_algorithm()\fR. .SS "\fIas_string()\fP \- the signature header as a string" .IX Subsection "as_string() - the signature header as a string" .Vb 1 \& print $signature\->as_string . "\en"; .Ve .PP outputs .PP .Vb 1 \& DKIM\-Signature: a=rsa\-sha1; b=yluiJ7+0=; c=relaxed .Ve .PP As shown in the example, the as_string method can be used to generate the DKIM-Signature that gets prepended to a signed message. .SS "\fIas_string_without_data()\fP \- signature without the signature data" .IX Subsection "as_string_without_data() - signature without the signature data" .Vb 1 \& print $signature\->as_string_without_data . "\en"; .Ve .PP outputs .PP .Vb 1 \& DKIM\-Signature: a=rsa\-sha1; b=; c=relaxed .Ve .PP This is similar to the \fIas_string()\fR method, but it always excludes the \*(L"data\*(R" part. This is used by the \s-1DKIM\s0 canonicalization methods, which require incorporating this part of the signature into the signed message. .SS "\fIbody_count()\fP \- get or set the body count (l=) field" .IX Subsection "body_count() - get or set the body count (l=) field" .Vb 1 \& my $i = $signature\->body_count; .Ve .PP Informs the verifier of the number of bytes in the body of the email included in the cryptographic hash, starting from 0 immediately following the \s-1CRLF\s0 preceding the body. Also known as the l= tag. .PP When creating a signature, this tag may be either omitted, or set after the selected canonicalization system has received the entire message body (but before it canonicalizes the DKIM-Signature). .SS "\fIbody_hash()\fP \- get or set the body hash (bh=) field" .IX Subsection "body_hash() - get or set the body hash (bh=) field" .Vb 1 \& my $bh = $signature\->body_hash; .Ve .PP The hash of the body part of the message. Whitespace is ignored in this value. This tag is required. .PP When accessing this value, whitespace is stripped from the tag for you. .SS "\fIcanonicalization()\fP \- get or set the canonicalization (c=) field" .IX Subsection "canonicalization() - get or set the canonicalization (c=) field" .Vb 1 \& $signature\->canonicalization("relaxed", "simple"); \& \& ($header, $body) = $signature\->canonicalization; .Ve .PP Message canonicalization (default is \*(L"simple/simple\*(R"). This informs the verifier of the type of canonicalization used to prepare the message for signing. .PP In scalar context, this returns header/body canonicalization as a single string separated by /. In list context, it returns a two element array, containing first the header canonicalization, then the body. .SS "\fIdata()\fP \- get or set the signature data (b=) field" .IX Subsection "data() - get or set the signature data (b=) field" .Vb 2 \& my $base64 = $signature\->data; \& $signature\->data($base64); .Ve .PP The signature data. Whitespace is automatically stripped from the returned value. The data is Base64\-encoded. .SS "\fIdomain()\fP \- get or set the domain (d=) field" .IX Subsection "domain() - get or set the domain (d=) field" .Vb 2 \& my $d = $signature\->domain; # gets the domain value \& $signature\->domain("example.org"); # sets the domain value .Ve .PP The domain of the signing entity, as specified in the signature. This is the domain that will be queried for the public key. .PP If using an \*(L"internationalized domain name\*(R", the domain name must be converted to \s-1ASCII\s0 (following section 4.1 of \s-1RFC\s0 3490) before passing it to this method. .SS "\fIexpiration()\fP \- get or set the signature expiration (x=) field" .IX Subsection "expiration() - get or set the signature expiration (x=) field" Signature expiration (default is undef, meaning no expiration). The signature expiration, if defined, is an unsigned integer identifying the standard Unix seconds\-since\-1970 time when the signature will expire. .SS "\fIget_public_key()\fP \- fetches the public key referenced by this signature" .IX Subsection "get_public_key() - fetches the public key referenced by this signature" .Vb 1 \& my $pubkey = $signature\->get_public_key; .Ve .PP Public key to fetch is determined by the protocol, selector, and domain fields. .PP This method caches the result of the fetch, so subsequent calls will not require additional \s-1DNS\s0 queries. .PP This method will \f(CW\*(C`die\*(C'\fR if an error occurs. .SS "\fIget_tag()\fP \- access the raw value of a tag in this signature" .IX Subsection "get_tag() - access the raw value of a tag in this signature" .Vb 1 \& my $raw_identity = $signature\->get_tag("i"); .Ve .PP Use this method to access a tag not already supported by Mail::DKIM, or if you want to bypass decoding of the value by Mail::DKIM. .PP For example, the raw i= (identity) tag is encoded in quoted-printable form. If you use the \fIidentity()\fR method, Mail::DKIM will decode from quoted-printable before returning the value. But if you use get_tag(\*(L"i\*(R"), you can access the encoded quoted-printable form of the value. .SS "\fIhash_algorithm()\fP \- access the hash algorithm specified in this signature" .IX Subsection "hash_algorithm() - access the hash algorithm specified in this signature" .Vb 1 \& my $hash = $signature\->hash_algorithm; .Ve .PP Determines what hashing algorithm is used as part of the signature's specified algorithm. .PP For algorithm \*(L"rsa\-sha1\*(R", the hash algorithm is \*(L"sha1\*(R". Likewise, for algorithm \*(L"rsa\-sha256\*(R", the hash algorithm is \*(L"sha256\*(R". If the algorithm is not recognized, undef is returned. .SS "\fIheaderlist()\fP \- get or set the signed header fields (h=) field" .IX Subsection "headerlist() - get or set the signed header fields (h=) field" .Vb 1 \& $signature\->headerlist("a:b:c"); \& \& my $headerlist = $signature\->headerlist; \& \& my @headers = $signature\->headerlist; .Ve .PP Signed header fields. A colon-separated list of header field names that identify the header fields presented to the signing algorithm. .PP In scalar context, the list of header field names will be returned as a single string, with the names joined together with colons. In list context, the header field names will be returned as a list. .SS "\fIidentity()\fP \- get or set the signing identity (i=) field" .IX Subsection "identity() - get or set the signing identity (i=) field" .Vb 1 \& my $i = $signature\->identity; .Ve .PP Identity of the user or agent on behalf of which this message is signed. The identity has an optional local part, followed by \*(L"@\*(R", then a domain name. The domain name should be the same as or a subdomain of the domain returned by the \f(CW\*(C`domain\*(C'\fR method. .PP Ideally, the identity should match the identity listed in the From: header, or the Sender: header, but this is not required to have a valid signature. Whether the identity used is \*(L"authorized\*(R" to sign for the given message is not determined here. .PP If using an \*(L"internationalized domain name\*(R", the domain name must be converted to \s-1ASCII\s0 (following section 4.1 of \s-1RFC\s0 3490) before passing it to this method. .PP Identity values are encoded in the signature in quoted-printable format. Using this method will translate to/from quoted-printable as necessary. If you want the raw quoted-printable version of the identity, use \&\f(CW$signature\fR\->get_tag(\*(L"i\*(R"). .SS "\fIkey()\fP \- get or set the private key object" .IX Subsection "key() - get or set the private key object" .Vb 1 \& my $key = $signature\->key; \& \& $signature\->key(Mail::DKIM::PrivateKey\->load(File => "private.key")); .Ve .PP The private key is used for signing messages. It is not used for verifying messages. .PP The key object can be any object that implements the \&\fIsign_digest()\fR method. (Providing your own object can be useful if your actual keys are stored out-of-process.) .SS "\fImethod()\fP \- get or set the canonicalization (c=) field" .IX Subsection "method() - get or set the canonicalization (c=) field" Message canonicalization (default is \*(L"simple\*(R"). This informs the verifier of the type of canonicalization used to prepare the message for signing. .SS "\fIprotocol()\fP \- get or set the query methods (q=) field" .IX Subsection "protocol() - get or set the query methods (q=) field" A colon-separated list of query methods used to retrieve the public key (default is \*(L"dns\*(R"). Each query method is of the form \*(L"type[/options]\*(R", where the syntax and semantics of the options depends on the type. .SS "\fIresult()\fP \- get or set the verification result" .IX Subsection "result() - get or set the verification result" .Vb 1 \& my $result = $signature\->result; \& \& $signature\->result("pass"); \& \& # to set the result with details \& $signature\->result("invalid", "no public key"); .Ve .SS "\fIresult_detail()\fP \- access the result, plus details if available" .IX Subsection "result_detail() - access the result, plus details if available" .Vb 1 \& my $detail = $signature\->result_detail; .Ve .PP An explanation of possible detail messages can be found in the documentation for \*(L"\fIresult_detail()\fR\*(R" in Mail::DKIM::Verifier. .SS "\fIselector()\fP \- get or set the selector (s=) field" .IX Subsection "selector() - get or set the selector (s=) field" The selector subdivides the namespace for the \*(L"d=\*(R" (domain) tag. .ie n .SS "\fIprettify()\fP \- alters the signature to look ""nicer"" as an email header" .el .SS "\fIprettify()\fP \- alters the signature to look ``nicer'' as an email header" .IX Subsection "prettify() - alters the signature to look nicer as an email header" .Vb 1 \& $signature\->prettify; .Ve .PP This method may alter the signature in a way that breaks signatures, so it should be done \s-1ONLY\s0 when the signature is being generated, \s-1BEFORE\s0 being fed to the canonicalization algorithm. .PP See also \fIprettify_safe()\fR, which will not break signatures. .SS "\fIprettify_safe()\fP \- same as \fIprettify()\fP but only touches the b= part" .IX Subsection "prettify_safe() - same as prettify() but only touches the b= part" .Vb 1 \& $signature\->prettify_safe; .Ve .PP This method will not break the signature, but it only affects the b= part of the signature. .SS "\fItimestamp()\fP \- get or set the signature timestamp (t=) field" .IX Subsection "timestamp() - get or set the signature timestamp (t=) field" Signature timestamp (default is undef, meaning unknown creation time). This is the time that the signature was created. The value is an unsigned integer identifying the number of standard Unix seconds\-since\-1970. .SS "\fIversion()\fP \- get or set the \s-1DKIM\s0 specification version (v=) field" .IX Subsection "version() - get or set the DKIM specification version (v=) field" This is the version of the \s-1DKIM\s0 specification that applies to this signature record. .SH "SEE ALSO" .IX Header "SEE ALSO" Mail::DKIM::DkSignature for DomainKey-Signature headers .SH "AUTHOR" .IX Header "AUTHOR" Jason Long, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2006\-2007 by Messiah College .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.