I ʻOkakopa 1999, ua hoʻokuʻu aku kahi hui i alakaʻi ʻia e ka Norewai ʻo Jon Lech Johansen he 16 ona makahiki i ka papahana DeCSS e pale aku i ka pale pāʻani DVD Content Scramble System (CSS). Ua hoʻohana ʻo CSS i ka hoʻopāʻālua 40-bit, nā kī i hāʻawi ʻia i nā mea hana laikini, e kaupalena i ka pāʻani DVD. Ma muli o ka hāʻule ʻana o ka hāʻawi ʻana o ke code ma lalo o ka US DMCA a ua pāpā ʻia e ke kānāwai, ua ʻimi nā mea hoʻoikaika i nā ala e hūnā ai i ke code ma ke ʻano he mea makemakika.
A laila ua kūkulu ʻo Phil Carmody i kahi helu prime, i ka wā e unuhi ʻia ai i ka binary ma hope o ka gzip decompression, aia ke code kumu piha o DeCSS. Hiki ke hoʻokō ʻia ke kumu o ka algorithm DeCSS ma TypeScript penei, kahi e hoʻohālikelike pololei ai nā hana bit i ka logic decryption sector.:
function CSSdescramble(sec: Uint8Array, key: Uint8Array): void {
let t1: number, t2: number, t3: number, t4: number, t5: number, t6: number;
const end = 0x800;
t1 = (key[0] ^ sec[0x54]) | 0x100;
t2 = key[1] ^ sec[0x55];
const keyView = new DataView(key.buffer, key.byteOffset);
const secView = new DataView(sec.buffer, sec.byteOffset);
t3 = (keyView.getUint32(2, true) ^ secView.getUint32(0x56, true)) >>> 0;
t4 = t3 & 7;
t3 = (t3 * 2 + 8 - t4) >>> 0;
let offset = 0x80;
t5 = 0;
while (offset < end) {
t4 = CSStab2[t2] ^ CSStab3[t1];
t2 = t1 >>> 1;
t1 = ((t1 & 1) << 8) ^ t4;
t4 = CSStab5[t4];
t6 = (((((((t3 >>> 3) ^ t3) >>> 1) ^ t3) >>> 8) ^ t3) >>> 5) & 0xff;
t3 = (((t3 << 8) >>> 0) | t6) >>> 0;
t6 = CSStab4[t6];
t5 += t6 + t4;
sec[offset] = CSStab1[sec[offset]] ^ (t5 & 0xff);
t5 >>>= 8;
offset++;
}
}
ʻO ke kumumanaʻo ma hope o ka helu mua, ʻo ia ka wehewehe ʻana i ke code kumu holoʻokoʻa ma ke ʻano he helu piha hoʻokahi. ʻOiai ʻaʻohe faila i hāʻawi ʻia he helu mua, ua hoʻonui ʻia ka helu me nā byte hou aʻe (padding). Hoʻonui ʻia kēia padding i loko o kahi loop a hiki i kahi hoʻāʻo primality, e like me ka hoʻāʻo Miller-Rabin, e hōʻoia i ka helu mua. Hoʻohana ka mea hana ma hope i ke code DeCSS i wehewehe ʻia ma luna a ke ʻimi nei i kahi hōʻike helu mua e pili ana.:
import { isPrime } from 'crypto-utils-lib'; // Hypothetical library for primality testing
async function generateIllegalPrime(code: string): Promise<bigint | null> {
const encoder = new TextEncoder();
const bytes = encoder.encode(code);
let hexBase = Array.from(bytes)
.map(b => b.toString(16).padStart(2, '0'))
.join('');
// Start bei 1, da 0x00 immer gerade und damit keine Primzahl ist
for (let i = 1; i < 256; i++) {
const candidateHex = hexBase + i.toString(16).padStart(2, '0');
const candidateInt = BigInt('0x' + candidateHex);
if (await isPrime(candidateInt)) {
return candidateInt;
}
}
return null;
}
const source = `void CSSdescramble(unsigned char *sec, unsigned char *key) { ... }`;
generateIllegalPrime(source).then(p => console.log(p));
ʻAʻole loa i lilo ka hana hoʻopunipuni helu mua i kumuhana o kahi hihia hoʻokolokolo ʻokoʻa, ʻaʻole hoʻi pono. ʻOiai he 1401 mau huahelu ka helu mua mua o Carmody, ua liʻiliʻi loa ia no nā papa inoa kiʻekiʻe o nā helu mua nui loa i kēlā manawa. Ma hope mai, ua hana ʻo ia i kahi mana helu 1905, i hoʻopiha ʻia me nā byte null, e hoʻokō i kahi ʻumi ma ka helu ECPP . Ua hōʻike kēia holomua i ka hiki ʻole ke kāohi i ka makemakika maʻemaʻe, ʻoiai ua loaʻa i ka helu kona wahi ma ka papa inoa ma muli wale nō o kona mau waiwai makemakika.