NAME

iTunes::Sid -- Apple iTunes SC Info common user database file interface

SYNOPSIS

DESCRIPTION

This module allows reading and writing of Apple iTunes type 
I<SC info.sid> databases, including the sidb and sidd files 
used by iTunes for storage of keys and certificates.

METHODS

new
my $sid = iTunes::Sid( file => "sidb", $key => 'FIND', $iv => 'FIND'  );

Create an iTunes::Sid object. The file => $filename named argument specifies a 
data file to be read. The $key and $iv arguments are for decryption, if needed.
DESTROY
Not to be called directly-- this cleans up circular references, if any.
ReadFile
Read a file in for parsing.
ParseBuffer
Parse the data in the buffer.
WriteFile
$sid->WriteFile( file => "sidb2", $key => 'FIND', $iv => 'FIND'  );
Write the (possibly modified) file to the filename given. $key and $iv
are as in the new() method.
WriteFileEncrypted
$sid->WriteFileEncrypted( file => "sidb2", $key => 'FIND', $iv => 'FIND'  );
Write the (possibly modified) file to the filename given.  The file is encrypted
before writing (default is to use the key and iv used to decrypt originally).  
ParseSidContainer
Parse a container in the buffer position given.
SidType
Return the iTunes::Sid file type (sidb or sidd, etc).
AtomTree
Return an html tree structure for the Sid.
DumpTree
Dump data tree to a file, or to standard output by default.
FindAtom
my @list = $sid->FindAtom("key ");

Find any or all atoms in the sid of a given type.
encrypt
decrypt
mac
Get or set hardware ID (the MAC address OR a derived machine signature).
iv
Get or set iv.
key
Get or set key.
sid_version
Version of the sid file, from the vers atom.
find_veggie_for_userID
Find the veeggie table and special shuffle case for the key's key.
fetch_all_user_keys
   Find and decode all the keys in the SC Info.sidb file.
write_all_user_keys_to_drms_dir
Write all the decoded keys to files in the user's .drms directory 
file for use by VLC and compatible media players.

PUBLIC FUNCTIONS (function interfaces only)

check_encrypted_sid
my $ok_check = check_encrypted_sid( $encrypted_sid_buffer );

Check an encrypted sid (in memory) for correct form to attemy decryption.
process_encrypted
process_encrypted( $buf_ref, $key, $iv );
process_encrypted( $buf_ref, 'FIND', 'FIND' );

Process the memory referred to by the scalar reference $buf_ref to
decrypt it using $key and $iv.  Attempt to find $key and $iv if 'FIND'
is specified, using iTunes 7 algorithms and local machine data.
get_sid_key
my $key = get_sid_key( $mac );

Using iTunes / QuickTime based algorithms based on characteristics of the
local machine, try to calculate the shuffled key for AES cryptography .
get_sid_iv
my $iv = get_sid_iv();

Return the default iTunes / QuickTime based iv for SC Info databases.

SEE ALSO

Audio::M4P::QuickTime
iTunes::Sid::Atom

BUGS

Lots. Windows Vista dual boot compatibility seems flawed.

AUTHOR

William Herrera ( wherrera@skylightview.com ).

SUPPORT

Questions, feature requests and bug reports should go to <wherrera@skylightview.com>.

NOTES

Regarding the US DMCA Law

 The U.S. Digital Millenum Copyright Act states in section 102, part (f):

-----------------------------------------------------------------------
  `(f) REVERSE ENGINEERING- (1) Notwithstanding the provisions of subsection
       (a)(1)(A), a person who has lawfully obtained the right to use a copy 
       of a computer program may circumvent a technological measure that 
       effectively controls access to a particular portion of that program 
       for the sole purpose of identifying and analyzing those elements of 
       the program that are necessary to achieve interoperability of an 
       independently created computer program with other programs, and that 
       have not previously been readily available to the person engaging 
       in the circumvention, to the extent any such acts of identification 
       and analysis do not constitute infringement under this title.

       `(2) Notwithstanding the provisions of subsections (a)(2) and (b), 
       a person may develop and employ technological means to circumvent a 
       technological measure, or to circumvent protection afforded by a 
       technological measure, in order to enable the identification and 
       analysis under paragraph (1), or for the purpose of enabling 
       interoperability of an independently created computer program with 
       other programs, if such means are necessary to achieve such 
       interoperability, to the extent that doing so does not constitute 
       infringement under this title.

       `(3) The information acquired through the acts permitted under 
       paragraph (1), and the means permitted under paragraph (2), may be 
       made available to others if the person referred to in paragraph (1) 
       or (2), as the case may be, provides such information or means solely 
       for the purpose of enabling interoperability of an independently 
       created computer program with other programs, and to the extent 
       that doing so does not constitute infringement under this title or 
       violate applicable law other than this section.

      ----------------------------------------------------------------------

Our take on why this code is an example of free and protected speech:

The portion of the DMCA quoted above allows usage of protected content to 
enable interoperability beween Linux and other systems.  Therefore, since 
this package and related Perl code are primarily designed to allow Linux, 
Solaris, and Unix systems to achieve interoperability with iTunes and the 
iTunes Music Store, they ARE legal under the DMCA. We are somewhat 
concerned about the word "solely" in the text above, since this package 
works under OS X and Windows as well as Linux.  For that reason, please 
also see the COPYRIGHT below.

COPYRIGHT

  Copyright (c) 2008 William Herrera. All rights reserved.  

  Licensing Terms

  a) The terms of Perl itself, plus the following:

  b) UNDER NO CIRCUMSTANCES CAN THIS CODE BE USED FOR CIRCUMVENTION OF ANY 
  TECHNOLOGICAL MEASURE WHICH EFFECTIVELY CONTROLS A PROTECTED MEDIA WORK 
  UNDER THE DCMA (USA, 1998) OR EU COPYRIGHT DIRECTIVE (EUCD, ARTICLE 6, 
  OF 2001), UNDER ANY OPERATING SYSTEM PLATFORM SUPPORTED BY APPLE COMPUTER 
  CORPORATION FOR ITS ITUNES OR IPOD PLAYER SOFTWARE IN ANY APPLE CORPORATION 
  DISTRIBUTED BINARY FORMAT OF ITUNES FOR THE PLATFORM UNDER WHICH THAT MEDIA 
  IS TO BE PLAYED. AS OF 2008, PROHIBITED PLATFORMS INCLUDE THE IPOD, IPHONE, 
  APPLE OS X, AND MICROSOFT WINDOWS, BUT NOT LINUX, BSD, OR SOLARIS.  UNDER NO 
  CIRCUMSTANCES CAN THE AUTHOR(S) OF THIS CODE BE HELD LIABLE FOR ANY 
  INFRINGEMENT INVOLVING THE PROHIBITED PLATFORMS ABOVE.

  c) Use, storage, or distribution of this code implies that you accept that 
  its intended purpose is legal and legitimate under any applicable US or EU 
  law, as above, and agree that any and all risk as to the quality, 
  performance, and legality of this code lies with you.