1
0
Fork
You've already forked widevine-rs
0
Rust implementation of Google's Widevine DRM CDM (Content Decryption Module)
  • Rust 89%
  • C 9.5%
  • Just 1.5%
Dobroslaw Kijowski b3833d285a fix: write init data length in Pssh::to_bytes()
* After this commit to_bytes() produces parsable psshs.
2025年06月06日 18:43:58 +02:00
.forgejo/workflows ci: disable renovate 2025年02月22日 23:01:48 +00:00
crates fix: write init data length in Pssh::to_bytes() 2025年06月06日 18:43:58 +02:00
.editorconfig initial commit 2024年11月25日 04:11:00 +01:00
.gitignore initial commit 2024年11月25日 04:11:00 +01:00
.pre-commit-config.yaml initial commit 2024年11月25日 04:11:00 +01:00
Cargo.toml chore: add Cargo metadata 2024年11月25日 15:23:22 +01:00
cliff.toml initial commit 2024年11月25日 04:11:00 +01:00
Justfile initial commit 2024年11月25日 04:11:00 +01:00
LICENSE feat: add GPL license 2024年11月25日 15:13:32 +01:00
README.md chore: add docs badge to README 2024年11月25日 15:30:21 +01:00
renovate.json ci: renovate: preserveSemverRanges 2025年02月03日 03:33:04 +01:00

widevine-rs

Current crates.io version License Docs CI status

Rust implementation of Google's Widevine DRM CDM (Content Decryption Module). The CDM allows you to build applications that can access DRM-protected media.

This is a port of the pywidevine library by rlaphoenix.

To use the CDM you need a valid Google-provisioned Private Key and Client Identification blob (plain or bundled as a *.wvd file).

Example:

Bitmovin DRM demo video: https://bitmovin.com/demos/drm

usestd::fs::File;usestd::io::BufReader;useisahc::ReadResponseExt;usehex_lit::hex;usewidevine::{Device,Cdm,Pssh,LicenseType};#letwvd_path=matchstd::env::var("WIDEVINE_DEVICE"){#Ok(wvd_path)=>wvd_path,#Err(_)=>return,#};// Instantiate a new CDM
letdevice=Device::read_wvd(BufReader::new(File::open(&wvd_path).unwrap())).unwrap();letcdm=Cdm::new(device);/// Create a new CDM request
letpssh=Pssh::from_b64("AAAAW3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADsIARIQ62dqu8s0Xpa7z2FmMPGj2hoNd2lkZXZpbmVfdGVzdCIQZmtqM2xqYVNkZmFsa3IzaioCSEQyAA==").unwrap();letrequest=cdm.open().get_license_request(pssh,LicenseType::STREAMING).unwrap();letchallenge=request.challenge().unwrap();// Send the request to the license server
letmutresp=isahc::post("https://cwip-shaka-proxy.appspot.com/no_auth",challenge).unwrap();letresp_data=resp.bytes().unwrap();// Decrypt the received keys and select the key with the required ID
letkeys=request.get_keys(&resp_data).unwrap();letkey=keys.content_key(&hex!("ccbf5fb4c2965be7aa130ffb3ba9fd73")).unwrap();assert_eq!(key.key,hex!("9cc0c92044cb1d69433f5f5839a159df"));