.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" 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" '' . ds C` . ds C' '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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" 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 "Crypt::Util 3pm" .TH Crypt::Util 3pm "2010-05-27" "perl v5.18.1" "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" Crypt::Util \- A lightweight Crypt/Digest convenience API .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Crypt::Util; # also has a Sub::Exporter to return functions wrapping a default instance \& \& my $util = Crypt::Util\->new; \& \& $util\->default_key("my secret"); \& \& # MAC or cipher+digest based tamper resistent encapsulation \& # (uses Storable on $data if necessary) \& my $tamper_resistent_string = $util\->tamper_proof( $data ); \& \& my $verified = $util\->thaw_tamper_proof( $untrusted_string, key => "another secret" ); \& \& # If the encoding is unspecified, base32 is used \& # (hex if base32 is unavailable) \& my $encoded = $util\->encode_string( $bytes ); \& \& my $hash = $util\->digest( $bytes, digest => "md5" ); \& \& die "baaaad" unless $util\->verify_hash( \& hash => $hash, \& data => $bytes, \& digest => "md5", \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides an easy, intuitive and forgiving \s-1API\s0 for wielding crypto-fu. .PP The \s-1API\s0 is designed as a cascade, with rich features built using simpler ones. this means that the option processing is uniform throughout, and the behaviors are generally predictable. .PP Note that Crypt::Util doesn't do any crypto on its own, but delegates the actual work to the various other crypto modules on the \s-1CPAN. \s0Crypt::Util merely wraps these modules, providing uniform parameters, and building on top of their polymorphism with higher level features. .SS "Priorities" .IX Subsection "Priorities" .IP "Ease of use" 4 .IX Item "Ease of use" This module is designed to have an easy \s-1API\s0 to allow easy but responsible use of the more low level Crypt:: and Digest:: modules on \s-1CPAN. \s0 Therefore, patches to improve ease-of-use are very welcome. .IP "Pluggability" 4 .IX Item "Pluggability" Dependency hell is avoided using a fallback mechanism that tries to choose an algorithm based on an overridable list. .Sp For \*(L"simple\*(R" use install Crypt::Util and your favourite digest, cipher and cipher mode (\s-1CBC, CFB,\s0 etc). .Sp To ensure predictable behavior the fallback behavior can be disabled as necessary. .SS "Interoperability" .IX Subsection "Interoperability" To ensure that your hashes and strings are compatible with Crypt::Util deployments on other machines (where different Crypt/Digest modules are available, etc) you should use \f(CW\*(C`disable_fallback\*(C'\fR. .PP Then either set the default ciphers, or always explicitly state the cipher. .PP If you are only encrypting and decrypting with the same installation, and new cryptographic modules are not being installed, the hashes/ciphertexts should be compatible without disabling fallback. .SH "EXPORTED API" .IX Header "EXPORTED API" \&\fB\s-1NOTE\s0\fR: nothing is exported by default. .PP Crypt::Util also presents an optional exported api using Sub::Exporter. .PP Unlike typical exported APIs, there is no class level default instance shared by all the importers, but instead every importer gets its own instance. .PP For example: .PP .Vb 2 \& package A; \& use Crypt::Util qw/:all/; \& \& default_key("moose"); \& my $ciphertext = encrypt_string($plain); \& \& \& package B; \& use Crypt::Util qw/:all/; \& \& default_key("elk"); \& my $ciphertext = encrypt_string($plain); .Ve .PP In this example every importing package has its own implicit instance, and the \&\f(CW\*(C`default_key\*(C'\fR function will in fact not share the value. .PP You can get the instance using the \f(CW\*(C`exported_instance\*(C'\fR function, which is just the identity method. .PP The export tags supported are: \f(CW\*(C`crypt\*(C'\fR (encryption and tamper proofing related functions), \f(CW\*(C`digest\*(C'\fR (digest and \s-1MAC\s0 related functions), \f(CW\*(C`encoding\*(C'\fR (various encoding and decoding functions), and \f(CW\*(C`params\*(C'\fR which give you functions for handling default values. .SH "METHODS" .IX Header "METHODS" .ie n .IP "tamper_proof( [ $data ], %params )" 4 .el .IP "tamper_proof( [ \f(CW$data\fR ], \f(CW%params\fR )" 4 .IX Item "tamper_proof( [ $data ], %params )" .PD 0 .ie n .IP "thaw_tamper_proof( [ $string ], %params )" 4 .el .IP "thaw_tamper_proof( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "thaw_tamper_proof( [ $string ], %params )" .ie n .IP "tamper_proof_string( $string, %params )" 4 .el .IP "tamper_proof_string( \f(CW$string\fR, \f(CW%params\fR )" 4 .IX Item "tamper_proof_string( $string, %params )" .ie n .IP "thaw_tamper_proof_string( $string, %params )" 4 .el .IP "thaw_tamper_proof_string( \f(CW$string\fR, \f(CW%params\fR )" 4 .IX Item "thaw_tamper_proof_string( $string, %params )" .ie n .IP "aead_tamper_proof_string( [ $string ], %params )" 4 .el .IP "aead_tamper_proof_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "aead_tamper_proof_string( [ $string ], %params )" .ie n .IP "mac_tamper_proof_string( [ $string ], %params )" 4 .el .IP "mac_tamper_proof_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "mac_tamper_proof_string( [ $string ], %params )" .PD The \f(CW\*(C`tamper_proof\*(C'\fR method is in an intermittent state, in that the \f(CW\*(C`data\*(C'\fR parameter's \s-1API\s0 is not completely finalized. .Sp It is safer to use \f(CW\*(C`tamper_proof_string\*(C'\fR; its \s-1API\s0 is expected to remain the same in future versions as well. .Sp See \*(L"\s-1TODO\*(R"\s0 for more information about the data types that will be supported in the future. .Sp When thawing, the \f(CW\*(C`authenticated_decrypt_string\*(C'\fR or \f(CW\*(C`verify_mac\*(C'\fR methods will be used, with \f(CW\*(C`fatal\*(C'\fR defaulting to on unless explicitly disabled in the parameters. .RS 4 .Sp .RS 4 This method accepts the following parameters: .Sp * encrypt .Sp By default this parameter is true, unless \f(CW\*(C`default_tamper_proof_unencrypted()\*(C'\fR, has been enabled. .Sp A true value implies that all the parameters which are available to \f(CW\*(C`authenticated_encrypt_string()\*(C'\fR are also available. If a negative value is specified, \s-1MAC\s0 mode is used, and the additional parameters of \f(CW\*(C`mac_digest_string()\*(C'\fR may also be specified to this method. .Sp * data .Sp The data to encrypt. If this is a reference Storable will be used to serialize the data. .Sp See \f(CW\*(C`pack_data\*(C'\fR for details. .RE .RE .RS 4 .Sp If the string is encrypted then all the parameters of \f(CW\*(C`encrypt_string\*(C'\fR and \&\f(CW\*(C`digest_string\*(C'\fR are also available. .Sp If the string is not encrypted, then all the parameters of \f(CW\*(C`mac_digest_string\*(C'\fR are also available. .RE .ie n .IP "encrypt_string( [ $string ], %params )" 4 .el .IP "encrypt_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "encrypt_string( [ $string ], %params )" .PD 0 .ie n .IP "decrypt_string( [ $string ], %params )" 4 .el .IP "decrypt_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "decrypt_string( [ $string ], %params )" .ie n .IP "authenticated_encrypt_string( [ $string ], %params )" 4 .el .IP "authenticated_encrypt_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "authenticated_encrypt_string( [ $string ], %params )" .ie n .IP "authenticated_decrypt_string( [ $string ], %params )" 4 .el .IP "authenticated_decrypt_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "authenticated_decrypt_string( [ $string ], %params )" .PD All of the parameters which may be supplied to \f(CW\*(C`process_key()\*(C'\fR, \&\f(CW\*(C`cipher_object\*(C'\fR and \f(CW\*(C`maybe_encode\*(C'\fR are also available to these methods. .Sp The \f(CW\*(C`authenticated\*(C'\fR variants ensure that an authenticated encryption mode (such as \s-1EAX\s0) is used. .Sp The following parameters may be used: .RS 4 .IP "\(bu" 4 string .Sp The string to be en/decrypted can either be supplied first, creating an odd number of arguments, or as a named parameter. .IP "\(bu" 4 nonce .Sp The cryptographic nonce to use. Only necessary for encryption, will be packed in the string as part of the message if applicable. .IP "\(bu" 4 header .Sp Not yet supported. .Sp In the future this will include a header for \s-1AEAD \s0(the \*(L"associated data\*(R" bit of \&\s-1AEAD\s0). .RE .RS 4 .RE .ie n .IP "process_key( [ $key ], %params )" 4 .el .IP "process_key( [ \f(CW$key\fR ], \f(CW%params\fR )" 4 .IX Item "process_key( [ $key ], %params )" The following arguments may be specified: .RS 4 .IP "\(bu" 4 literal_key .Sp This disables mungung. See also \f(CW\*(C`default_use_literal_key\*(C'\fR. .IP "\(bu" 4 key_size .Sp Can be used to force a key size, even if the cipher specifies another size. .Sp If not specified, the key size chosen will depend .IP "\(bu" 4 cipher .Sp Used to determine the key size. .RE .RS 4 .RE .ie n .IP "process_nonce( [ $nonce ], %params )" 4 .el .IP "process_nonce( [ \f(CW$nonce\fR ], \f(CW%params\fR )" 4 .IX Item "process_nonce( [ $nonce ], %params )" If a nonce is explicitly specified this method returns that, and otherwise uses Data::GUID to generate a unique binary string for use as a nonce/IV. .ie n .IP "pack_data( [ $data ], %params )" 4 .el .IP "pack_data( [ \f(CW$data\fR ], \f(CW%params\fR )" 4 .IX Item "pack_data( [ $data ], %params )" .PD 0 .ie n .IP "unpack_data( [ $data ], %params )" 4 .el .IP "unpack_data( [ \f(CW$data\fR ], \f(CW%params\fR )" 4 .IX Item "unpack_data( [ $data ], %params )" .PD Uses Storable and \f(CW\*(C`pack\*(C'\fR to create a string out of data. .Sp MooseX::Storage support will be added in the future. .Sp The format itself is versioned in order to facilitate future proofing and backwards compatibility. .Sp Note that it is not safe to call \f(CW\*(C`unpack_data\*(C'\fR on an untrusted string, use \&\f(CW\*(C`thaw_tamper_proof\*(C'\fR instead (it will authenticate the data and only then perform the potentially unsafe routines). .ie n .IP "cipher_object( %params )" 4 .el .IP "cipher_object( \f(CW%params\fR )" 4 .IX Item "cipher_object( %params )" Available parameters are: .RS 4 .IP "\(bu" 4 cipher .Sp The cipher algorithm to use, e.g. \f(CW\*(C`Rijndael\*(C'\fR, \f(CW\*(C`Twofish\*(C'\fR etc. .IP "\(bu" 4 mode .Sp The mode of operation. This can be real (\f(CW\*(C`cbc\*(C'\fR, \f(CW\*(C`cfb\*(C'\fR, \f(CW\*(C`ctr\*(C'\fR, \f(CW\*(C`ofb\*(C'\fR, \&\f(CW\*(C`eax\*(C'\fR) or symbolic (\f(CW\*(C`authenticated\*(C'\fR, \f(CW\*(C`block\*(C'\fR, \f(CW\*(C`stream\*(C'\fR). .Sp See for an explanation of this. .RE .RS 4 .RE .ie n .IP "cipher_object_eax( %params )" 4 .el .IP "cipher_object_eax( \f(CW%params\fR )" 4 .IX Item "cipher_object_eax( %params )" Used by \f(CW\*(C`cipher_object\*(C'\fR but accepts additional parameters: .RS 4 .IP "\(bu" 4 nonce .Sp The nonce is a value that should be unique in order to protect against replay attacks. It also ensures that the same plain text with the same key will produce different ciphertexts. .Sp The nonce is not included in the output ciphertext. See \&\f(CW\*(C`authenticated_encrypt_string\*(C'\fR for a convenience method that does include the nonce. .IP "\(bu" 4 header .Sp This is additional data to authenticate but not encrypt. .Sp See Crypt::EAX for more details. .Sp The header will not be included in the output ciphertext. .RE .RS 4 .RE .ie n .IP "digest_string( [ $string ], %params )" 4 .el .IP "digest_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "digest_string( [ $string ], %params )" Delegates to \f(CW\*(C`digest_object\*(C'\fR. All parameters which can be used by \&\f(CW\*(C`digest_object\*(C'\fR may also be used here. .Sp The following arguments are available: .RS 4 .IP "\(bu" 4 string .Sp The string to be digested can either be supplied first, creating an odd number of arguments, or as a named parameter. .RE .RS 4 .RE .ie n .IP "verify_digest( %params )" 4 .el .IP "verify_digest( \f(CW%params\fR )" 4 .IX Item "verify_digest( %params )" Delegates to \f(CW\*(C`digest_object\*(C'\fR. All parameters which can be used by \&\f(CW\*(C`digest_object\*(C'\fR may also be used here. .Sp The following parameters are accepted: .RS 4 .IP "\(bu" 4 hash .Sp A string containing the hash to verify. .IP "\(bu" 4 string .Sp The digested string. .IP "\(bu" 4 fatal .Sp If true, errors will be fatal. The default is false, which means that failures will return undef. .RE .RS 4 .Sp In addition, the parameters which can be supplied to \f(CW\*(C`digest_string()\*(C'\fR may also be supplied to this method. .RE .ie n .IP "digest_object( %params )" 4 .el .IP "digest_object( \f(CW%params\fR )" 4 .IX Item "digest_object( %params )" .RS 4 .PD 0 .IP "\(bu" 4 .PD digest .Sp The digest algorithm to use. .RE .RS 4 .Sp Returns an object using Digest. .RE .ie n .IP "encode_string( [ $string ], %params )" 4 .el .IP "encode_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "encode_string( [ $string ], %params )" .PD 0 .ie n .IP "decode_string( [ $string ], %params )" 4 .el .IP "decode_string( [ \f(CW$string\fR ], \f(CW%params\fR )" 4 .IX Item "decode_string( [ $string ], %params )" .PD The following parameters are accepted: .RS 4 .IP "\(bu" 4 encoding .Sp The encoding may be a symbolic type (uri, printable) or a concrete type (none, hex, base64, base32). .RE .RS 4 .RE .ie n .IP "mac_digest_string( [ $string ], %param )" 4 .el .IP "mac_digest_string( [ \f(CW$string\fR ], \f(CW%param\fR )" 4 .IX Item "mac_digest_string( [ $string ], %param )" Delegates to \f(CW\*(C`mac_object\*(C'\fR. All parameters which can be used by \f(CW\*(C`mac_object\*(C'\fR may also be used here. .RS 4 .IP "\(bu" 4 string .RE .RS 4 .RE .ie n .IP "verify_mac( %params )" 4 .el .IP "verify_mac( \f(CW%params\fR )" 4 .IX Item "verify_mac( %params )" Delegates to \f(CW\*(C`mac_object\*(C'\fR. All parameters which can be used by \f(CW\*(C`mac_object\*(C'\fR may also be used here. .Sp The following additional arguments are allowed: .RS 4 .IP "\(bu" 4 hash .Sp The \s-1MAC\s0 string to verify. .IP "\(bu" 4 string .Sp The digested string. .IP "\(bu" 4 fatal .Sp If true, errors will be fatal. The default is false, which means that failures will return undef. .RE .RS 4 .RE .ie n .IP "mac_object( %params )" 4 .el .IP "mac_object( \f(CW%params\fR )" 4 .IX Item "mac_object( %params )" .RS 4 .PD 0 .IP "\(bu" 4 .PD mac .Sp The \s-1MAC\s0 algorithm to use. Currently \f(CW\*(C`hmac\*(C'\fR and \f(CW\*(C`cmac\*(C'\fR are supported. .RE .RS 4 .RE .IP "maybe_encode" 4 .IX Item "maybe_encode" .PD 0 .IP "maybe_decode" 4 .IX Item "maybe_decode" .PD This method has no external \s-1API\s0 but is documented for the sake of its shared options. .Sp It is delegated to by the various encryption and digest method. .RS 4 .IP "\(bu" 4 encode .Sp Expects a bool. .IP "\(bu" 4 encoding .Sp Expects an algorithm name (symbolic (e.g. \f(CW\*(C`uri\*(C'\fR, \f(CW\*(C`alphanumeric\*(C'\fR), or concrete (e.g. \f(CW\*(C`base64\*(C'\fR, \f(CW\*(C`hex\*(C'\fR)). .RE .RS 4 .Sp If \f(CW\*(C`encode\*(C'\fR is explicitly supplied it will always determine whether or not the string will be encoded. Otherwise, if \f(CW\*(C`encoding\*(C'\fR is explicitly supplied then the string will always be encoded using the specified algorithm. If neither is supplied \f(CW\*(C`default_encode\*(C'\fR will be checked to determine whether or not to encode, and \f(CW\*(C`default_encoding\*(C'\fR or \f(CW\*(C`fallback_encoding\*(C'\fR will be used to determine the algorithm to use (see \*(L"\s-1HANDLING OF DEFAULT VALUES\*(R"\s0). .RE .ie n .IP "encode_string_alphanumerical( $string )" 4 .el .IP "encode_string_alphanumerical( \f(CW$string\fR )" 4 .IX Item "encode_string_alphanumerical( $string )" .PD 0 .ie n .IP "decode_string_alphanumerical( $string )" 4 .el .IP "decode_string_alphanumerical( \f(CW$string\fR )" 4 .IX Item "decode_string_alphanumerical( $string )" .ie n .IP "encode_string_uri( $string )" 4 .el .IP "encode_string_uri( \f(CW$string\fR )" 4 .IX Item "encode_string_uri( $string )" .ie n .IP "decode_string_uri( $string )" 4 .el .IP "decode_string_uri( \f(CW$string\fR )" 4 .IX Item "decode_string_uri( $string )" .ie n .IP "encode_string_printable( $string )" 4 .el .IP "encode_string_printable( \f(CW$string\fR )" 4 .IX Item "encode_string_printable( $string )" .ie n .IP "decode_string_printable( $string )" 4 .el .IP "decode_string_printable( \f(CW$string\fR )" 4 .IX Item "decode_string_printable( $string )" .PD The above methods encode based on a fallback list (see \*(L"\s-1HANDLING OF DEFAULT VALUES\*(R"\s0). .Sp The variations denote types of formats: \f(CW\*(C`alphanumerical\*(C'\fR is letters and numbers only (case insensitive), \f(CW\*(C`uri\*(C'\fR is safe for inclusions in URIs (without further escaping), and \f(CW\*(C`printable\*(C'\fR contains no control characters or whitespace. .ie n .IP "encode_string_hex( $string )" 4 .el .IP "encode_string_hex( \f(CW$string\fR )" 4 .IX Item "encode_string_hex( $string )" .PD 0 .ie n .IP "decode_string_hex( $string )" 4 .el .IP "decode_string_hex( \f(CW$string\fR )" 4 .IX Item "decode_string_hex( $string )" .PD Big endian hexadecimal (\f(CW\*(C`H*\*(C'\fR pack format). .ie n .IP "encode_string_uri_escape( $string )" 4 .el .IP "encode_string_uri_escape( \f(CW$string\fR )" 4 .IX Item "encode_string_uri_escape( $string )" .PD 0 .ie n .IP "decode_string_uri_escape( $string )" 4 .el .IP "decode_string_uri_escape( \f(CW$string\fR )" 4 .IX Item "decode_string_uri_escape( $string )" .PD URI::Escape based encoding. .ie n .IP "encode_string_base64( $string )" 4 .el .IP "encode_string_base64( \f(CW$string\fR )" 4 .IX Item "encode_string_base64( $string )" .PD 0 .ie n .IP "decode_string_base64( $string )" 4 .el .IP "decode_string_base64( \f(CW$string\fR )" 4 .IX Item "decode_string_base64( $string )" .ie n .IP "encode_string_base64_wrapped( $string )" 4 .el .IP "encode_string_base64_wrapped( \f(CW$string\fR )" 4 .IX Item "encode_string_base64_wrapped( $string )" .PD Requires MIME::Base64. .Sp The \f(CW\*(C`wrapped\*(C'\fR variant will introduce line breaks as per the MIME::Base64 default>. .IP "encode_string_uri_base64" 4 .IX Item "encode_string_uri_base64" .PD 0 .IP "decode_string_uri_base64" 4 .IX Item "decode_string_uri_base64" .PD Requires MIME::Base64. .Sp Implements the Base64 for URIs. See . .ie n .IP "encode_string_base32( $string )" 4 .el .IP "encode_string_base32( \f(CW$string\fR )" 4 .IX Item "encode_string_base32( $string )" .PD 0 .ie n .IP "decode_string_base32( $string )" 4 .el .IP "decode_string_base32( \f(CW$string\fR )" 4 .IX Item "decode_string_base32( $string )" .PD Requires MIME::Base32. .Sp (note\- unlike MIME::Base32 this is case insensitive). .SH "HANDLING OF DEFAULT VALUES" .IX Header "HANDLING OF DEFAULT VALUES" .IP "\fIdisable_fallback()\fR" 4 .IX Item "disable_fallback()" When true only the first item from the fallback list will be tried, and if it can't be loaded there will be a fatal error. .Sp Enable this to ensure portability. .PP For every parameter, there are several methods, where \s-1PARAMETER\s0 is replaced with the parameter name: .IP "\(bu" 4 \&\fIdefault_PARAMETER()\fR .Sp This accessor is available for the user to override the default value. .Sp If set to undef, then \f(CW\*(C`fallback_PARAMETER\*(C'\fR will be consulted instead. .Sp \&\fB\s-1ALL\s0\fR the default values are set to undef unless changed by the user. .IP "\(bu" 4 \&\fIfallback_PARAMETER()\fR .Sp Iterates the \f(CW\*(C`fallback_PARAMETER_list\*(C'\fR, choosing the first value that is usable (it's provider is available). .Sp If \f(CW\*(C`disable_fallback\*(C'\fR is set to a true value, then only the first value in the fallback list will be tried. .IP "\(bu" 4 \&\fIfallback_PARAMETER_list()\fR .Sp An ordered list of values to try and use as fallbacks. .Sp \&\f(CW\*(C`fallback_PARAMETER\*(C'\fR iterates this list and chooses the first one that works. .PP Available parameters are as follows: .IP "\(bu" 4 cipher .Sp The fallback list is \&\f(CW\*(C`Rijndael\*(C'\fR, \f(CW\*(C`Serpent\*(C'\fR, \f(CW\*(C`Twofish\*(C'\fR, \f(CW\*(C`RC6\*(C'\fR, \f(CW\*(C`Blowfish\*(C'\fR and \f(CW\*(C`RC5\*(C'\fR. .Sp Crypt::Rijndael is the \s-1AES\s0 winner, the next three are \s-1AES\s0 finalists, and the last two are well known and widely used. .IP "\(bu" 4 mode .Sp The mode in which to use the cipher. .Sp The fallback list is \f(CW\*(C`CFB\*(C'\fR, \f(CW\*(C`CBC\*(C'\fR, \f(CW\*(C`Ctr\*(C'\fR, and \f(CW\*(C`OFB\*(C'\fR. .IP "\(bu" 4 digest .Sp The fallback list is \f(CW\*(C`SHA\-1\*(C'\fR, \f(CW\*(C`SHA\-256\*(C'\fR, \f(CW\*(C`RIPEMD160\*(C'\fR, \&\f(CW\*(C`Whirlpool\*(C'\fR, \f(CW\*(C`MD5\*(C'\fR, and \f(CW\*(C`Haval256\*(C'\fR. .IP "\(bu" 4 encoding .Sp The fallback list is \f(CW\*(C`hex\*(C'\fR (effectively no fallback). .IP "\(bu" 4 alphanumerical_encoding .Sp The fallback list is \f(CW\*(C`base32\*(C'\fR and \f(CW\*(C`hex\*(C'\fR. .Sp MIME::Base32 is required for \f(CW\*(C`base32\*(C'\fR encoding. .IP "\(bu" 4 uri_encoding .Sp The fallback list is \f(CW\*(C`uri_base64\*(C'\fR. .IP "\(bu" 4 printable_encoding .Sp The fallback list is \f(CW\*(C`base64\*(C'\fR .SS "Defaults with no fallbacks" .IX Subsection "Defaults with no fallbacks" The following parameters have a \f(CW\*(C`default_\*(C'\fR method, as described in the previous section, but the \f(CW\*(C`fallback_\*(C'\fR methods are not applicable. .IP "\(bu" 4 encode .Sp Whether or not to encode by default (applies to digests and encryptions). .IP "\(bu" 4 key .Sp The key to use. Useful for when you are repeatedly encrypting. .IP "\(bu" 4 nonce .Sp The nonce/IV to use for cipher modes that require it. .Sp Defaults to the empty string, but note that some methods will generate a nonce for you (e.g. \f(CW\*(C`authenticated_encrypt_string\*(C'\fR) if none was provided. .IP "\(bu" 4 use_literal_key .Sp Whether or not to not hash the key by default. See \f(CW\*(C`process_key\*(C'\fR. .IP "\(bu" 4 tamper_proof_unencrypted .Sp Whether or not tamper resistent strings are by default unencrypted (just \s-1MAC\s0). .SS "Subclassing" .IX Subsection "Subclassing" You may safely subclass and override \f(CW\*(C`default_PARAMETER\*(C'\fR and \&\f(CW\*(C`fallback_PARAMETER_list\*(C'\fR to provide values from configurations. .SH "TODO" .IX Header "TODO" .IP "\(bu" 4 Crypt::SaltedHash support .IP "\(bu" 4 \&\s-1EMAC \s0(maybe, the modules are not \s-1OO\s0 and require refactoring) message authentication mode .IP "\(bu" 4 Bruce Schneier Fact Database . .Sp WWW::SchneierFacts .IP "\(bu" 4 Entropy fetching (get N weak/strong bytes, etc) from e.g. OpenSSL bindings, /dev/*random, and \s-1EGD.\s0 .IP "\(bu" 4 Additional data formats (streams/iterators, filehandles, generalized storable data/string handling for all methods, not just tamper_proof). .Sp Streams should also be able to used via a simple push api. .IP "\(bu" 4 IV/nonce/salt support for the various cipher modes, not just \s-1EAX \s0(\s-1CBC, CCM, GCM,\s0 etc) .IP "\(bu" 4 Crypt::Rijndael can do its own cipher modes .SH "SEE ALSO" .IX Header "SEE ALSO" Digest, Crypt::CBC, Crypt::CFB, . .SH "VERSION CONTROL" .IX Header "VERSION CONTROL" This module is maintained using Darcs. You can get the latest version from , and use \f(CW\*(C`darcs send\*(C'\fR to commit changes. .SH "AUTHORS" .IX Header "AUTHORS" Yuval Kogman, Ann Barcomb .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2006\-2008 by Yuval Kogman , Ann Barcomb .PP Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \*(L"Software\*(R"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: .PP The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. .PP \&\s-1THE SOFTWARE IS PROVIDED \*(L"AS IS\*(R", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\s0 .SH "POD ERRORS" .IX Header "POD ERRORS" Hey! \fBThe above document had some coding errors, which are explained below:\fR .IP "Around line 1163:" 4 .IX Item "Around line 1163:" You can't have =items (as at line 1167) unless the first thing after the =over is an =item .IP "Around line 1520:" 4 .IX Item "Around line 1520:" You forgot a '=back' before '=head1' .IP "Around line 1580:" 4 .IX Item "Around line 1580:" Expected '=item *' .IP "Around line 1589:" 4 .IX Item "Around line 1589:" Expected '=item *' .IP "Around line 1642:" 4 .IX Item "Around line 1642:" =back without =over .IP "Around line 1684:" 4 .IX Item "Around line 1684:" You forgot a '=back' before '=head1'