~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-updates

« back to all changes in this revision

Viewing changes to libavformat/asfcrypt.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-02-05 21:45:05 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090205214505-fvn0jkiv3lrkaaq4
Tags: 3:0.svn20090204-2ubuntu1+unstripped1
rebuild using a clean, uncrippled ffmpeg tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
}
137
137
 
138
138
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) {
 
139
    struct AVDES des;
 
140
    struct AVRC4 rc4;
139
141
    int num_qwords = len >> 3;
140
142
    uint64_t *qwords = (uint64_t *)data;
141
143
    uint64_t rc4buff[8];
150
152
    }
151
153
 
152
154
    memset(rc4buff, 0, sizeof(rc4buff));
153
 
    ff_rc4_enc(key, 12, (uint8_t *)rc4buff, sizeof(rc4buff));
 
155
    av_rc4_init(&rc4, key, 12 * 8, 1);
 
156
    av_rc4_crypt(&rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1);
154
157
    multiswap_init((uint8_t *)rc4buff, ms_keys);
155
158
 
156
159
    packetkey = qwords[num_qwords - 1];
157
160
    packetkey ^= rc4buff[7];
158
 
    packetkey = be2me_64(packetkey);
159
 
    packetkey = ff_des_encdec(packetkey, AV_RB64(key + 12), 1);
160
 
    packetkey = be2me_64(packetkey);
 
161
    av_des_init(&des, key + 12, 64, 1);
 
162
    av_des_crypt(&des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1, NULL, 1);
161
163
    packetkey ^= rc4buff[6];
162
164
 
163
 
    ff_rc4_enc((uint8_t *)&packetkey, 8, data, len);
 
165
    av_rc4_init(&rc4, (uint8_t *)&packetkey, 64, 1);
 
166
    av_rc4_crypt(&rc4, data, data, len, NULL, 1);
164
167
 
165
168
    ms_state = 0;
166
169
    for (i = 0; i < num_qwords - 1; i++, qwords++)