login support

This commit is contained in:
BruceChen 2022-08-24 12:37:22 +08:00
parent e150bd569b
commit af1485c753
11 changed files with 247 additions and 16 deletions

View file

@ -10,19 +10,20 @@ namespace MinecraftClient.Protocol.Keys
public class PublicKey
{
public byte[] Key { get; set; }
public byte[] Signature { get; set; }
public byte[]? Signature { get; set; }
public byte[]? SignatureV2 { get; set; }
private readonly RSA rsa;
public PublicKey(string pemKey, string sig, string? sigV2 = null)
public PublicKey(string pemKey, string? sig = null, string? sigV2 = null)
{
this.Key = KeyUtils.DecodePemKey(pemKey, "-----BEGIN RSA PUBLIC KEY-----", "-----END RSA PUBLIC KEY-----");
this.rsa = RSA.Create();
rsa.ImportSubjectPublicKeyInfo(this.Key, out _);
this.Signature = Convert.FromBase64String(sig);
if (!string.IsNullOrEmpty(sig))
this.Signature = Convert.FromBase64String(sig);
if (!string.IsNullOrEmpty(sigV2))
this.SignatureV2 = Convert.FromBase64String(sigV2!);