1
0
镜像来自 https://github.com/chris124567/hulu synced 2025-07-18 17:22:05 +00:00

update private key

This commit is contained in:
Christopher Tarry 2021-12-27 21:20:27 -05:00
父節點 c3bbd3beb2
當前提交 01066e973b
共有 2 個文件被更改,包括 38 次插入33 次删除

查看文件

@ -37,13 +37,19 @@ type Key struct {
// Creates a new CDM object with the specified device information.
func NewCDM(privateKey string, clientID []byte, initData []byte) (CDM, error) {
block, _ := pem.Decode([]byte(privateKey))
if block == nil || block.Type != "PRIVATE KEY" {
if block == nil || (block.Type != "PRIVATE KEY" && block.Type != "RSA PRIVATE KEY") {
return CDM{}, errors.New("failed to decode device private key")
}
keyParsed, err := x509.ParsePKCS8PrivateKey(block.Bytes)
keyParsed, err := x509.ParsePKCS1PrivateKey(block.Bytes)
if err != nil {
// if PCKS1 doesn't work, try PCKS8
pcks8Key, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
return CDM{}, err
}
keyParsed = pcks8Key.(*rsa.PrivateKey)
}
var widevineCencHeader WidevineCencHeader
if len(initData) < 32 {
@ -67,7 +73,7 @@ func NewCDM(privateKey string, clientID []byte, initData []byte) (CDM, error) {
}()
return CDM{
privateKey: keyParsed.(*rsa.PrivateKey),
privateKey: keyParsed,
clientID: clientID,
widevineCencHeader: widevineCencHeader,

File diff suppressed because one or more lines are too long