Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

markanderstam/clearkey-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClearKey Server

ClearKey server that can be used to test DRM functionality in a Net Insight SYE installation.

Requests are passed to the server using HTTP POST. Requests and responses are JSON objects.

It is possible to request keys for one or many crypto periods, which means encryption key rotation is supported.

Start server

Start the ClearKey server on port 8000

const clearkeyServer = require('@trulive/clearkey-server')

clearkeyServer.listen(8000, () => {
    console.log('ClearKey Server listening on port 8000');
})

API

There are two public APIs in the server: get_content_key() and get_license().

Get Content Key

This API is typically used by the SYE Ingress in order to get encryption keys for a channel.

It is possible to request keys for one or many crypto periods (two in the example below).

It is possible to request keys for one or many track types (two in the example below).

get_content_key is guaranteed to always return the same kid and key for a specific combination of contentId, cryptoPeriod and track type.

Request

{
    "contentId": "tv1",
    "cryptoPeriodIndex": 424214,
    "cryptoPeriodCount": 2,
    "tracks": [{
        "type": "SD"
    }, {
        "type": "4K"
    }]
}

Response

{
    "contentId": "tv1",
    "cryptoPeriods": [{
        "cryptoPeriod": 424214,
        "tracks": [{
            "type": "SD",
            "kid": "MTIzNDU2NzgxMjM0NTY3OAo",
            "key": "YmNkNjM4NTA5MTI3ODM3Ngo",
            "pssh": [{
                "systemId": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
                "pssh": "aDM0aDM0MjNrMDAyODVtb"
            },
            {
                "systemId": "edef8ba979d64acea3c827dcd51d21ed",
                "pssh": "nZzMyNDM0MmRmYWRm"
            }]
        },
        {
            "type": "4K",
            "kid": "MTIzNDU2NzgxMjM0NTY3OAo",
            "key": "YmNkNjM4NTA5MTI3ODM3Ngo",
            "pssh": [{
                "systemId": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
                "pssh": "aDM0aDM0MjNrMDAyODVtb"
            },
            {
                "systemId": "edef8ba979d64acea3c827dcd51d21ed",
                "pssh": "nZzMyNDM0MmRmYWRm"
            }]
        }]
    },
    {
        "cryptoPeriod": 424215,
        "tracks": [{
            "type": "SD",
            "kid": "MTIzNDU2NzgxMjM0NTY3OAo",
            "key": "YmNkNjM4NTA5MTI3ODM3Ngo",
            "pssh": [{
                "systemId": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
                "pssh": "aDM0aDM0MjNrMDAyODVtb"
            },
            {
                "systemId": "edef8ba979d64acea3c827dcd51d21ed",
                "pssh": "nZzMyNDM0MmRmYWRm"
            }]
        },
        {
            "type": "SD",
            "kid": "MTIzNDU2NzgxMjM0NTY3OAo",
            "key": "YmNkNjM4NTA5MTI3ODM3Ngo",
            "pssh": [{
                "systemId": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
                "pssh": "aDM0aDM0MjNrMDAyODVtb"
            },
            {
                "systemId": "edef8ba979d64acea3c827dcd51d21ed",
                "pssh": "nZzMyNDM0MmRmYWRm"
            }]
        }]
    }]
}

cURL example

curl -i -d '{"contentId":"tv1","cryptoPeriodIndex":10,"cryptoPeriodCount":2,"tracks":[{"type": "SD"},{"type":"4K"}]}' -H "Content-Type: application/json" http://localhost:8000/get_content_key

Get License

This API is typically used by a CDM within a client application and follow w3.org example: https://www.w3.org/TR/encrypted-media/

Request

{
    "kids": [
        "NTdhNzlhZmM0NmEyMzcxMA==",
        "MjEwNzhiN2EwNjYxZTE4Yg=="
    ]
}

Response

{
    "keys": [{
        "kid": "NTdhNzlhZmM0NmEyMzcxMA==",
        "k": "ZDBlMzE3OWFhN2QyMTg5Yg==",
        "kty": "oct"
    }, {
        "kid": "MjEwNzhiN2EwNjYxZTE4Yg==",
        "k": "M2VhNDc3M2Q3M2IxY2NiYg==",
        "kty": "oct"
    }]
}

cURL example

curl -i -d '{"kids": ["NTdhNzlhZmM0NmEyMzcxMA==", "MjEwNzhiN2EwNjYxZTE4Yg=="]}' -H "Content-Type: application/json" http://localhost:8000/get_license

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published