Skip to content

Commit

Permalink
feature(EncryptionTransport): log hardware acceleration status
Browse files Browse the repository at this point in the history
  • Loading branch information
mischa authored and miwarnec committed Oct 12, 2024
1 parent 4dd3f1e commit 8f5bf7b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Assets/Mirror/Transports/Encryption/EncryptionTransport.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Mirror.BouncyCastle.Crypto;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Serialization;
Expand Down Expand Up @@ -176,6 +177,19 @@ private bool HandleClientValidateServerPubKey(PubKeyInfo pubKeyInfo)
}
}

void Awake()
{
// check if encryption via hardware acceleration is supported.
// this can be useful to know for low end devices.
//
// hardware acceleration requires netcoreapp3.0 or later:
// https://github.com/bcgit/bc-csharp/blob/449940429c57686a6fcf6bfbb4d368dec19d906e/crypto/src/crypto/AesUtilities.cs#L18
// because AesEngine_x86 requires System.Runtime.Intrinsics.X86:
// https://github.com/bcgit/bc-csharp/blob/449940429c57686a6fcf6bfbb4d368dec19d906e/crypto/src/crypto/engines/AesEngine_X86.cs
// which Unity does not support yet.
Debug.Log($"EncryptionTransport: IsHardwareAccelerated={AesUtilities.IsHardwareAccelerated}");
}

public override bool Available() => inner.Available();

public override bool ClientConnected() => _client != null && _client.IsReady;
Expand Down

0 comments on commit 8f5bf7b

Please sign in to comment.