From owner-freebsd-multimedia Tue Jan 4 17:42:44 2000 Delivered-To: freebsd-multimedia@freebsd.org Received: from poboxer.pobox.com (ferg5200-2-102.cpinternet.com [208.149.16.102]) by hub.freebsd.org (Postfix) with ESMTP id 0B50B14D29 for ; Tue, 4 Jan 2000 17:42:27 -0800 (PST) (envelope-from alk@poboxer.pobox.com) Received: (from alk@localhost) by poboxer.pobox.com (8.9.3/8.9.1) id TAA29243; Tue, 4 Jan 2000 19:41:22 -0600 (CST) (envelope-from alk) From: Anthony Kimball MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 4 Jan 2000 19:41:21 -0600 (CST) X-Face: \h9Jg:Cuivl4S*UP-)gO.6O=T]]@ncM*tn4zG);)lk#4|lqEx=*talx?.Gk,dMQU2)ptPC17cpBzm(l'M|H8BUF1&]dDCxZ.c~Wy6-j,^V1E(NtX$FpkkdnJixsJHE95JlhO 5\M3jh'YiO7KPCn0~W`Ro44_TB@&JuuqRqgPL'0/{):7rU-%.*@/>q?1&Ed Reply-To: alk@pobox.com To: efknight@bellsouth.net Cc: multimedia@freebsd.org Subject: DeCSS References: <38729EF1.B336C84A@bellsouth.net> X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14450.41202.750383.328359@avalon.east> Sender: owner-freebsd-multimedia@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Quoth Ted Knight on Tue, 4 January: : : Any comments, suggestions or success stories? : Success: --- css-auth/dvdinfo.c Thu Nov 4 20:25:13 1999 +++ css-auth.alk/dvdinfo.c Fri Dec 24 02:38:12 1999 @@ -5,13 +5,8 @@ #include #include -#if defined(__OpenBSD__) -# include -#elif defined(__linux__) -# include -#else -# error "Need the DVD ioctls" -#endif +#include +#include #include #include @@ -19,53 +14,55 @@ int GetASF(int fd) { - dvd_authinfo ai; + struct dvd_authinfo ai; - ai.type = DVD_LU_SEND_ASF; - ai.lsasf.agid = 0; - ai.lsasf.asf = 0; + ai.format = DVD_REPORT_ASF; + ai.agid = 0; + ai.asf = 0; - if (ioctl(fd, DVD_AUTH, &ai)) { + if (ioctl(fd, DVDIOCREPORTKEY, &ai)) { printf("GetASF failed\n"); return 0; } - printf("%sAuthenticated\n", (ai.lsasf.asf) ? "" : "not "); + printf("%sAuthenticated\n", (ai.asf) ? "" : "not "); return 1; } int GetPhysical(int fd) { - dvd_struct d; + struct dvd_struct d; int layer = 0, layers = 4; - d.physical.type = DVD_STRUCT_PHYSICAL; + d.format = DVD_STRUCT_PHYSICAL; while (layer < layers) { - d.physical.layer_num = layer; + struct dvd_layer *lp = (struct dvd_layer *)&d.data[0]; + + d.layer_num = layer; - if (ioctl(fd, DVD_READ_STRUCT, &d)<0) + if (ioctl(fd, DVDIOCREADSTRUCTURE, &d)<0) { printf("Could not read Physical layer %d\n", layer); return 0; } - layers = d.physical.layer[layer].nlayers + 1; + layers = lp->nlayers + 1; printf("Layer %d[%d]\n", layer, layers); - printf(" Book Version: %d\n", d.physical.layer[layer].book_version); - printf(" Book Type: %d\n", d.physical.layer[layer].book_type); - printf(" Min Rate: %d\n", d.physical.layer[layer].min_rate); - printf(" Disk Size: %d\n", d.physical.layer[layer].disc_size); - printf(" Layer Type: %d\n", d.physical.layer[layer].layer_type); - printf(" Track Path: %d\n", d.physical.layer[layer].track_path); - printf(" Num Layers: %d\n", d.physical.layer[layer].nlayers); - printf(" Track Density: %d\n", d.physical.layer[layer].track_density); - printf(" Linear Density: %d\n", d.physical.layer[layer].linear_density); - printf(" BCA: %d\n", d.physical.layer[layer].bca); - printf(" Start Sector %#x\n", d.physical.layer[layer].start_sector); - printf(" End Sector %#x\n", d.physical.layer[layer].end_sector); - printf(" End Sector L0 %#x\n", d.physical.layer[layer].end_sector_l0); + printf(" Book Version: %d\n", lp->book_version); + printf(" Book Type: %d\n", lp->book_type); + printf(" Max Rate: %d\n", lp->max_rate); + printf(" Disk Size: %d\n", lp->disc_size); + printf(" Layer Type: %d\n", lp->layer_type); + printf(" Track Path: %d\n", lp->track_path); + printf(" Num Layers: %d\n", lp->nlayers); + printf(" Track Density: %d\n", lp->track_density); + printf(" Linear Density: %d\n", lp->linear_density); + printf(" BCA: %d\n", lp->bca); + printf(" Start Sector %#x\n", lp->start_sector); + printf(" End Sector %#x\n", lp->end_sector); + printf(" End Sector L0 %#x\n", lp->end_sector_l0); ++layer; } @@ -75,18 +72,18 @@ int GetCopyright(int fd) { - dvd_struct d; + struct dvd_struct d; - d.copyright.type = DVD_STRUCT_COPYRIGHT; - d.copyright.layer_num = 0; + d.format = DVD_STRUCT_COPYRIGHT; + d.layer_num = 0; - if (ioctl(fd, DVD_READ_STRUCT, &d)<0) + if (ioctl(fd, DVDIOCREADSTRUCTURE, &d)<0) { printf("Could not read Copyright Struct\n"); return 0; } - printf("Copyright: CPST=%d, RMI=%#02x\n", d.copyright.cpst, d.copyright.rmi); + printf("Copyright: CPST=%d, RMI=%#02x\n", d.cpst, d.rmi); return 1; } --- css-auth/reset.c Thu Nov 4 20:25:13 1999 +++ css-auth.alk/reset.c Fri Dec 24 02:41:54 1999 @@ -4,13 +4,8 @@ #include #include -#if defined(__OpenBSD__) -# include -#elif defined(__linux__) -# include -#else -# error "Need the DVD ioctls" -#endif +#include +#include #include #include @@ -20,7 +15,7 @@ int main(int ac, char **av) { - dvd_authinfo ai; + struct dvd_authinfo ai; char *device = DVD; int i; @@ -30,15 +25,15 @@ fd = open(device, O_RDONLY | O_NONBLOCK); if (fd < 0) { - printf("unable to open dvd drive (%s).\n", device); - return 1; + perror("open"); + errx(1,"unable to open dvd drive (%s).\n", device); } for (i = 0; i < 4; i++) { memset(&ai, 0, sizeof(ai)); - ai.type = DVD_INVALIDATE_AGID; - ai.lsa.agid = i; - ioctl(fd, DVD_AUTH, &ai); + ai.format = DVD_INVALIDATE_AGID; + ai.agid = i; + ioctl(fd, DVDIOCREPORTKEY, &ai); } return 0; --- css-auth/tstdvd.c Tue Nov 9 04:46:23 1999 +++ css-auth.alk/tstdvd.c Fri Dec 24 02:35:38 1999 @@ -27,13 +27,8 @@ #include #include #include -#if defined(__OpenBSD__) -# include -#elif defined(__linux__) -# include -#else -# error "Need the DVD ioctls" -#endif +#include +#include #include "css-auth.h" byte Challenge[10]; @@ -94,23 +89,23 @@ int GetDiscKey(int fd, int agid, char *key) { - dvd_struct s; + struct dvd_struct s; int index, fdd; - s.type = DVD_STRUCT_DISCKEY; - s.disckey.agid = agid; - memset(s.disckey.value, 0, 2048); - if (ioctl(fd, DVD_READ_STRUCT, &s)<0) + s.format = DVD_STRUCT_DISCKEY; + s.agid = agid; + memset(s.data, 0, 2048); + if (ioctl(fd, DVDIOCREADSTRUCTURE, &s)<0) { printf("Could not read Disc Key\n"); return 0; } printf ("Received Disc Key:\t"); - for (index=0; indextype) { - /* Host data receive (host changes state) */ - case DVD_LU_SEND_AGID: - printf("AGID %d\n", ai->lsa.agid); - ai->type = DVD_HOST_SEND_CHALLENGE; - break; - - case DVD_LU_SEND_KEY1: - printf("LU sent key1: "); print_key(ai->lsk.key); printf("\n"); - if (!authenticate_drive(ai->lsk.key)) { - ai->type = DVD_AUTH_FAILURE; - return -EINVAL; - } - ai->type = DVD_LU_SEND_CHALLENGE; - break; - - case DVD_LU_SEND_CHALLENGE: - for (i = 0; i < 10; ++i) - Challenge[i] = ai->hsc.chal[9-i]; - printf("LU sent challenge: "); print_challenge(Challenge); printf("\n"); - CryptKey2(varient, Challenge, &Key2); - ai->type = DVD_HOST_SEND_KEY2; - break; - - /* Host data send */ - case DVD_HOST_SEND_CHALLENGE: - for (i = 0; i < 10; ++i) - ai->hsc.chal[9-i] = Challenge[i]; - printf("Host sending challenge: "); print_challenge(Challenge); printf("\n"); - /* Returning data, let LU change state */ - break; - - case DVD_HOST_SEND_KEY2: - for (i = 0; i < 5; ++i) - ai->hsk.key[4-i] = Key2.b[i]; - printf("Host sending key 2: "); print_key(Key2.b); printf("\n"); - /* Returning data, let LU change state */ - break; - - default: - printf("Got invalid state %d\n", ai->type); - return -EINVAL; - } - - return 0; -} - -int authenticate(int fd, int title, int lba) -{ - dvd_authinfo ai; - dvd_struct dvds; + struct dvd_authinfo ai; + struct dvd_struct dvds; int i, rv, tries, agid; memset(&ai, 0, sizeof (ai)); @@ -248,14 +189,14 @@ /* Init sequence, request AGID */ for (tries = 1, rv = -1; rv == -1 && tries < 4; ++tries) { printf("Request AGID [%d]...\t", tries); - ai.type = DVD_LU_SEND_AGID; - ai.lsa.agid = 0; - rv = ioctl(fd, DVD_AUTH, &ai); + ai.format = DVD_REPORT_AGID; + ai.agid = 0; + rv = ioctl(fd, DVDIOCREPORTKEY, &ai); if (rv == -1) { perror("N/A, invalidating"); - ai.type = DVD_INVALIDATE_AGID; - ai.lsa.agid = 0; - ioctl(fd, DVD_AUTH, &ai); + ai.format = DVD_INVALIDATE_AGID; + ai.agid = 0; + ioctl(fd, DVDIOCREPORTKEY, &ai); } } if (tries == 4) { @@ -266,57 +207,54 @@ for (i = 0; i < 10; ++i) Challenge[i] = i; - /* Send AGID to host */ - if (hostauth(&ai) < 0) { - printf("Send AGID to host failed\n"); - return -1; - } + printf("AGID %d\n", ai.agid); + agid = ai.agid; /* Get challenge from host */ - if (hostauth(&ai) < 0) { - printf("Get challenge from host failed\n"); - return -1; - } - agid = ai.lsa.agid; + ai.format = DVD_SEND_CHALLENGE; + for (i = 0; i < 10; ++i) + ai.keychal[9-i] = Challenge[i]; + printf("Host sending challenge: "); print_challenge(Challenge); printf("\n"); /* Send challenge to LU */ - if (ioctl(fd, DVD_AUTH, &ai) < 0) { + if (ioctl(fd, DVDIOCSENDKEY, &ai) < 0) { printf("Send challenge to LU failed\n"); return -1; } /* Get key1 from LU */ - if (ioctl(fd, DVD_AUTH, &ai) < 0) { + ai.format = DVD_REPORT_KEY1; + if (ioctl(fd, DVDIOCREPORTKEY, &ai) < 0) { printf("Get key1 from LU failed\n"); return -1; } /* Send key1 to host */ - if (hostauth(&ai) < 0) { + printf("LU sent key1: "); print_key(ai.keychal); printf("\n"); + if (!authenticate_drive(ai.keychal)) { printf("Send key1 to host failed\n"); return -1; } /* Get challenge from LU */ - if (ioctl(fd, DVD_AUTH, &ai) < 0) { + ai.format = DVD_REPORT_CHALLENGE; + if (ioctl(fd, DVDIOCREPORTKEY, &ai) < 0) { printf("Get challenge from LU failed\n"); return -1; } /* Send challenge to host */ - if (hostauth(&ai) < 0) { - printf("Send challenge to host failed\n"); - return -1; - } + for (i = 0; i < 10; ++i) + Challenge[i] = ai.keychal[9-i]; + printf("LU sent challenge: "); print_challenge(Challenge); printf("\n"); + CryptKey2(varient, Challenge, &Key2); /* Get key2 from host */ - if (hostauth(&ai) < 0) { - printf("Get key2 from host failed\n"); - return -1; - } + ai.format = DVD_SEND_KEY2; + for (i = 0; i < 5; ++i) + ai.keychal[4-i] = Key2.b[i]; + printf("Host sending key 2: "); print_key(Key2.b); printf("\n"); /* Send key2 to LU */ - if (ioctl(fd, DVD_AUTH, &ai) < 0) { + if (ioctl(fd, DVDIOCSENDKEY, &ai) < 0) { printf("Send key2 to LU failed (expected)\n"); return -1; } - if (ai.type == DVD_AUTH_ESTABLISHED) - printf("DVD is authenticated\n"); - else if (ai.type == DVD_AUTH_FAILURE) - printf("DVD authentication failed\n"); + printf("DVD will most likely be authenticated soon...\n"); + GetASF(fd); memcpy(Challenge, Key1.b, 5); memcpy(Challenge+5, Key2.b, 5); @@ -331,7 +269,7 @@ GetASF(fd); if (title) - GetTitleKey(fd, agid, lba, KeyCheck.b); + GetTitleKey(fd, agid, lba_fd, KeyCheck.b); else GetDiscKey(fd, agid, KeyCheck.b); @@ -366,7 +304,7 @@ int main(int ac, char **av) { char *device; - int fd, title = 0, lba = 0; + int fd, title = 0, lba_fd = 0; if (ac < 2) { fprintf(stderr, "usage: tstdvd [title_path]\n"); @@ -379,10 +317,13 @@ exit(1); } if (ac == 3) { - lba = path_to_lba(av[2]); + if ((lba_fd = open(av[2], O_RDONLY)) == -1) { + perror(av[2]); + exit(1); + } title = 1; } - authenticate(fd, title, lba); + authenticate(fd, title, lba_fd); close(fd); return 0; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-multimedia" in the body of the message