Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
diegojfer committed Dec 18, 2019
2 parents 45e7aba + a69d54c commit 869dddf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/FPProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

Expand All @@ -15,15 +16,23 @@ public sealed class FPProvider
public string Name { get => this.Certificate.Subject; }
public byte[] Hash { get => this.Certificate.GetCertHash(); }

public FPProvider(X509Certificate certificate, RSAParameters key, byte[] ask)
public FPProvider(byte[] certificate, string password, byte[] ask)
{
ArgumentThrow.IfNull(certificate, "Invalid FairPlay Certificate. Certificate can not be null.", nameof(certificate));
ArgumentThrow.IfNull(key, "Invalid FairPlay Certificate Key. RSAParameters can not be null.", nameof(key));
ArgumentThrow.IfNull(password, "Invalid FairPlay Certificate passphrase. Passphrase can not be null.", nameof(password));
ArgumentThrow.IfLengthNot(ask, 16, "Invalid Application Secret Key. ASK buffer should be 16 bytes.", nameof(ask));

this.Certificate = certificate;
this.RSAKey = key;
this.ASKey = ask;
try {
X509Certificate2 X509 = new X509Certificate2(certificate, password, X509KeyStorageFlags.Exportable);

using (var rsa = X509.GetRSAPrivateKey()) {
this.Certificate = X509;
this.RSAKey = rsa.ExportParameters(true);
this.ASKey = ask;
}
} catch (Exception ex) {
throw new ArgumentException("Invalid FairPlay Certificate. Certificate can not be read.", nameof(certificate), ex);
}
}
}
}
2 changes: 1 addition & 1 deletion src/FPServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private async Task<IEnumerable<TLLVSlab>> GenerateCKC(DFunction derivator, IEnum
catch (Exception ex) { throw new FPInvalidContextException("EXC_0027", "Unable to process SPC. See 'innerException' for more information.", ex); }

if (MediaPlaybackPayload.CreationDate < DateTime.UtcNow.AddHours(-6)) throw new FPContextDateViolatedException("EXC_0036", "Unable to process SPC. Date range violated.");
if (MediaPlaybackPayload.CreationDate > DateTime.UtcNow.AddHours(-6)) throw new FPContextDateViolatedException("EXC_0037", "Unable to process SPC. Date range violated.");
if (MediaPlaybackPayload.CreationDate > DateTime.UtcNow.AddHours(6)) throw new FPContextDateViolatedException("EXC_0037", "Unable to process SPC. Date range violated.");

DurationCKPayload DurationContentKeyPayload = null;
try { DurationContentKeyPayload = new DurationCKPayload((UInt32)this.LicenseDuration, 0, DurationCKType.Rental); }
Expand Down

0 comments on commit 869dddf

Please sign in to comment.