Crypt-AppleTwoFish

 view release on metacpan or  search on metacpan

lib/Crypt/AppleTwoFish.pm  view on Meta::CPAN

        38,  187, 139, 140, 202, 162, 193, 26,  196, 205, 165, 7,   136, 185,
        56,  121, 55,  52,  94,  61,  152, 174, 203, 53,  22,  248, 123, 4,
        9,   129, 120, 27,  87,  44,  137, 201, 222, 15,  198, 72,  244, 220,
        124, 6,   3,   254, 112, 235, 218, 64,  151, 225, 160, 81,  5,   10,
        181, 25,  250, 122, 247, 32,  69,  66,  67,  78,  88,  0,   231, 167,
        239, 144, 182, 211, 70,  49,  180, 178, 159, 108, 241, 84,  11,  16,
        161, 41,  158, 216, 145, 253, 251, 33,  116, 77,  104, 13,  119, 19,
        191, 204, 170, 206, 31,  107, 93,  240, 186, 210, 17,  73,  46,  155,
        100, 2,   40,  188,
    ],
    radish => [
        68,  94,  16,  181, 225, 234, 166, 157, 57,  78,  106, 62,  158, 52,
        201, 211, 10,  88,  87,  193, 191, 194, 38,  243, 169, 253, 204, 95,
        152, 31,  76,  241, 147, 131, 221, 29,  50,  163, 86,  232, 216, 127,
        197, 233, 214, 173, 164, 224, 145, 123, 167, 92,  49,  215, 160, 161,
        44,  80,  3,   17,  61,  120, 144, 110, 151, 178, 6,   89,  250, 71,
        99,  226, 190, 19,  183, 26,  236, 200, 125, 230, 112, 34,  2,   235,
        205, 247, 65,  217, 22,  149, 227, 67,  46,  82,  208, 240, 5,   195,
        251, 90,  138, 121, 101, 117, 115, 32,  207, 129, 206, 107, 244, 126,
        220, 218, 45,  185, 242, 134, 43,  72,  189, 177, 136, 20,  79,  150,
        7,   24,  30,  27,  0,   202, 25,  60,  14,  248, 159, 70,  182, 223,
        102, 114, 245, 11,  12,  73,  93,  40,  51,  156, 56,  55,  142, 8,
        21,  48,  198, 254, 135, 13,  84,  41,  239, 176, 238, 85,  255, 168,
        128, 228, 180, 59,  213, 219, 222, 53,  47,  231, 209, 122, 137, 187,
        15,  83,  109, 39,  174, 192, 141, 58,  9,   113, 28,  116, 1,   103,
        75,  210, 153, 165, 172, 140, 111, 130, 199, 196, 42,  118, 74,  91,
        37,  23,  146, 252, 64,  203, 108, 98,  96,  63,  179, 69,  246, 4,
        188, 81,  104, 162, 124, 54,  171, 237, 132, 133, 249, 148, 139, 18,
        77,  170, 154, 100, 119, 186, 33,  155, 212, 66,  175, 97,  105, 35,
        36,  184, 143, 229,
    ],
    garlic => [
        64,  125, 53,  199, 27,  95,  196, 166, 146, 139, 238, 67,  98,  239,
        158, 85,  255, 180, 66,  204, 150, 112, 163, 236, 216, 226, 74,  90,
        73,  47,  171, 54,  41,  108, 22,  75,  51,  227, 229, 44,  93,  11,
        164, 113, 96,  38,  59,  220, 176, 23,  88,  182, 173, 230, 133, 21,
        42,  121, 107, 179, 198, 8,   170, 242, 246, 50,  245, 135, 29,  68,
        80,  76,  48,  91,  141, 177, 203, 45,  190, 186, 213, 62,  195, 30,
        222, 52,  253, 55,  148, 254, 243, 5,   202, 123, 117, 58,  153, 120,
        56,  234, 144, 14,  24,  140, 126, 178, 212, 20,  157, 210, 69,  110,
        127, 1,   240, 183, 237, 3,   197, 191, 15,  241, 231, 78,  156, 102,
        10,  128, 167, 206, 218, 60,  28,  181, 247, 37,  81,  71,  134, 49,
        248, 0,   97,  94,  217, 89,  215, 228, 131, 4,   205, 132, 40,  36,
        63,  116, 145, 159, 82,  46,  143, 18,  165, 100, 223, 147, 65,  192,
        9,   39,  225, 168, 32,  154, 233, 136, 194, 169, 7,   235, 12,  103,
        209, 87,  25,  119, 26,  31,  252, 172, 201, 188, 57,  249, 130, 250,
        17,  79,  70,  6,   35,  211, 61,  72,  142, 214, 122, 232, 101, 84,
        16,  105, 137, 155, 193, 224, 208, 86,  138, 118, 152, 161, 151, 124,
        104, 184, 187, 34,  160, 207, 13,  175, 83,  185, 77,  19,  219, 244,
        109, 92,  251, 43,  221, 149, 33,  162, 200, 2,   174, 115, 111, 106,
        129, 189, 99,  114,
    ],
);

=head1 NAME

Crypt::AppleTwoFish -- two Apple iTMS/iTunes key descrambling algorithms

=head1 DESCRIPTION

The first algorithm appears to have only cursory resemblance to Bruce Schneier's 
blowfish and twofish algorithms in that it too has a table-based decoder.

The second algorithm is more standard encryption using S-box type permutations
and lookup tables, and might have started out something like Twofish or Blowfish.

=head1 SYNOPSIS

    for iTMS usages:

    use Crypt::AppleTwoFish;
    
    my $scrambled_key = '=sixteen uchars=';
    
    my $apple_twofish = new Crypt::AppleTwoFish(key => $scrambled_key);
    
    my $descrambled_key = $apple_twofish->decrypted_for_iTMS;
    
    my $descrambled_another_way = $apple_twofish->decrypted_for_DRMS;
    

    ..and for iTunes 7 compatible usages:
    
    Functions cloned from lower level compiled code which was likely intended
    to be difficult to reconstruct cannot easily be given sensible names. Ada 
    Pro is good, but dull.  We chose to be amused during the tedium by coming 
    up with function names from a vegetable farm. 
    
    For actual usage, see also:
    
L<iTunes::Sid>.

=head1 METHODS

=over 4

=item B<new>

Call with the key as a scalar argument. When passed (LWP simulating iTunes) over iTMS, 
encrypted M4P keys for your purchased music are currently 16 unsigned chars in length.

=item B<decrypted_for_iTMS>

Returns the unscrambled key for use with the Apple Music Store.

=item B<decrypted_for_DRMS>

Returns the unscrambled key for use with iTunes/iPod DRM.

=item B<key>

    Get/set initial key.

=item B<int_table>

    Get/set veggie integer table.

=item B<byte_table>

    Get/set veggie byte table.



( run in 0.439 second using v1.01-cache-2.11-cpan-39bf76dae61 )