mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Refactoring to asynchronous. (partially completed)
This commit is contained in:
parent
7ee08092d4
commit
096ea0c70c
72 changed files with 6033 additions and 5080 deletions
|
|
@ -1,15 +1,20 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json.Serialization;
|
||||
using MinecraftClient.Protocol.Message;
|
||||
|
||||
namespace MinecraftClient.Protocol.ProfileKey
|
||||
{
|
||||
public class PrivateKey
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("Key")]
|
||||
public byte[] Key { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
private readonly RSA rsa;
|
||||
|
||||
[JsonIgnore]
|
||||
private byte[]? precedingSignature = null;
|
||||
|
||||
public PrivateKey(string pemKey)
|
||||
|
|
@ -20,6 +25,14 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
rsa.ImportPkcs8PrivateKey(Key, out _);
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public PrivateKey(byte[] Key)
|
||||
{
|
||||
this.Key = Key;
|
||||
rsa = RSA.Create();
|
||||
rsa.ImportPkcs8PrivateKey(Key, out _);
|
||||
}
|
||||
|
||||
public byte[] SignData(byte[] data)
|
||||
{
|
||||
return rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue