项目作者: diegojfer

项目描述 :
FairPlay - Key Server Module - NETCore
高级语言: C#
项目地址: git://github.com/diegojfer/FairPlay-KSM.git
创建时间: 2019-07-23T13:03:05Z
项目社区:https://github.com/diegojfer/FairPlay-KSM

开源协议:GNU General Public License v3.0

下载


FairPlay - Key Security Module

What is FairPlay-KSM?

FairPlay-KSM is a NETCore implementation of Apple DRM protocol. According to Apple, FairPlay Streaming (FPS) securely delivers keys to Apple mobile devices, Apple TV, and Safari on macOS, which will enable playback of encrypted video content.

This implementation can be used as license expeditor or spc-ckc debugger (partially implemented).

Where can I download the library?

NuGet

FairPlay has been packaged as NuGet package, so you only have to include the FoolishTech.FairPlay package in your project.

dotnet add package FoolishTech.FairPlay

How can I use the library?

Before using the module, you must Request Deployment Package to Apple.

After that, you can run your own HTTP license server. Check-out our examples.

Very simple License Expeditor

  1. using System;
  2. using System.Text;
  3. using System.Threading.Tasks;
  4. using FoolishTech.FairPlay;
  5. using FoolishTech.FairPlay.Models;
  6. using FoolishTech.FairPlay.Interfaces;
  7. using FoolishTech.FairPlay.Exceptions;
  8. namespace FoolishTech.SimpleExpeditor
  9. {
  10. public class HardcodedKeyLocator: IContentKeyLocator
  11. {
  12. Task<IContentKey> IContentKeyLocator.FetchContentKey(byte[] contentId, object info /* Object passed on GenerateCKC */)
  13. {
  14. string id = Encoding.UTF8.GetString(contentId);
  15. if (id.Equals("twelve")) return Task.FromResult<IContentKey>(new FPStaticKey("3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C", "D5FBD6B82ED93E4EF98AE40931EE33B7"));
  16. else throw new ArgumentOutOfRangeException(nameof(contentId), $"We can't find key for content id ${contentId}");
  17. }
  18. }
  19. public class SimpleFairPlay
  20. {
  21. public async Task<byte[]> Resolve(byte[] spc)
  22. {
  23. try {
  24. FPProvider provider = new FPProvider(new byte[] { /* Certificate+PrivKey P12 */ }, "" /* P12 Passphrase */, new byte[] { /* ASK */ });
  25. IContentKeyLocator locator = new HardcodedKeyLocator();
  26. FPServer server = new FPServer(provider, locator);
  27. return await server.GenerateCKC(spc, new Object());
  28. } catch (FPKeyLocatorException) {
  29. // Exception throwed on IContentKeyLocator
  30. } catch (Exception) {
  31. // Any other exception.
  32. }
  33. return null;
  34. }
  35. }
  36. }

Can I contribute to FairPlay-KSM?

Yes! Open pull request. :D

Authors

Diego Fernández - me@diegofer.com