Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Moved to new lib for random gen of the key.
Browse files Browse the repository at this point in the history
New way to ingest key to appinsights
  • Loading branch information
xpouyat committed Jul 29, 2022
1 parent 5981361 commit ed5bd97
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AMSExplorer/AMSExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Management.Media" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.15.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.17.4-preview" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="24.0.0" />
<PackageReference Include="Microsoft.Azure.Storage.DataMovement" Version="2.0.4" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.45.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private void GenerateSymKey()
radioButtonContentKeyBase64.Checked = true;

byte[] TokenSigningKey = new byte[40];
RNGCryptoServiceProvider rng = new();
var rng = RandomNumberGenerator.Create();
rng.GetBytes(TokenSigningKey);
textBoxSymKey.Text = Convert.ToBase64String(new ContentKeyPolicySymmetricTokenKey(TokenSigningKey).KeyValue);
}
Expand Down
4 changes: 2 additions & 2 deletions AMSExplorer/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ private static TelemetryClient GetAppInsightsClient()
{
var config = new TelemetryConfiguration()
{
InstrumentationKey = TelemetryKeyProd,
ConnectionString = "InstrumentationKey=" + TelemetryKeyProd,
TelemetryChannel = new Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel(),
};
config.TelemetryChannel.DeveloperMode = Debugger.IsAttached;
#if DEBUG
config.InstrumentationKey = TelemetryKeyDev;
config.ConnectionString = "InstrumentationKey=" + TelemetryKeyDev;
config.TelemetryChannel.DeveloperMode = true;
#endif
TelemetryClient client = new(config);
Expand Down
8 changes: 4 additions & 4 deletions AMSExplorer/Utils/Drm/DynamicEncryption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class DynamicEncryption
public static byte[] GetRandomBuffer(int size)
{
byte[] randomBytes = new byte[size];
using (RNGCryptoServiceProvider rng = new())
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(randomBytes);
}
Expand Down Expand Up @@ -116,15 +116,15 @@ public static byte[] GeneratePlayReadyContentKey(byte[] keySeed, Guid keyId)
//
// Create sha_A_Output buffer. It is the SHA of the truncatedKeySeed and the keyIdAsBytes
//
SHA256Managed sha_A = new();
var sha_A = SHA256.Create();
sha_A.TransformBlock(truncatedKeySeed, 0, truncatedKeySeed.Length, truncatedKeySeed, 0);
sha_A.TransformFinalBlock(keyIdAsBytes, 0, keyIdAsBytes.Length);
byte[] sha_A_Output = sha_A.Hash;
//
// Create sha_B_Output buffer. It is the SHA of the truncatedKeySeed, the keyIdAsBytes, and
// the truncatedKeySeed again.
//
SHA256Managed sha_B = new();
var sha_B = SHA256.Create();
sha_B.TransformBlock(truncatedKeySeed, 0, truncatedKeySeed.Length, truncatedKeySeed, 0);
sha_B.TransformBlock(keyIdAsBytes, 0, keyIdAsBytes.Length, keyIdAsBytes, 0);
sha_B.TransformFinalBlock(truncatedKeySeed, 0, truncatedKeySeed.Length);
Expand All @@ -133,7 +133,7 @@ public static byte[] GeneratePlayReadyContentKey(byte[] keySeed, Guid keyId)
// Create sha_C_Output buffer. It is the SHA of the truncatedKeySeed, the keyIdAsBytes,
// the truncatedKeySeed again, and the keyIdAsBytes again.
//
SHA256Managed sha_C = new();
var sha_C = SHA256.Create();
sha_C.TransformBlock(truncatedKeySeed, 0, truncatedKeySeed.Length, truncatedKeySeed, 0);
sha_C.TransformBlock(keyIdAsBytes, 0, keyIdAsBytes.Length, keyIdAsBytes, 0);
sha_C.TransformBlock(truncatedKeySeed, 0, truncatedKeySeed.Length, truncatedKeySeed, 0);
Expand Down

0 comments on commit ed5bd97

Please sign in to comment.