EC Public key from public key bytes extracted from azure keyvault

EC Public key from public key bytes extracted from azure keyvault

如何从字节中获取 public 密钥?例如,我有 public 密钥(使用 EC 算法生成,曲线 "secp256r1")及其在 java 上的编码字节,如何在 c# 中从这些字节创建 public 密钥?

有多种方法可以从保管库中获取密钥。我使用了以下内容。

var secret = keyVaultClient.GetSecretAsync(vaultAddress, "Honeywellpkiofflinetokenprime256v1cert").GetAwaiter().GetResult();
 X509Certificate2Collection exportedCertCollection = new X509Certificate2Collection();
            exportedCertCollection.Import(Convert.FromBase64String(secret.Value));


            X509Certificate2 certFromSecret = exportedCertCollection.Cast<X509Certificate2>().Single(s => s.HasPrivateKey);
            var publickeybyte = certFromSecret.GetPublicKey();
            var publicekeybyte = certFromSecret.GetPublicKeyString();
            var PublicKeyCNG= certFromSecret.GetECDsaPublicKey();


            var privateECDsa = LoadPrivateKey(FromHexString(privateKey));
            var publiccECDsa = LoadPublicKey(FromHexString(publicKey));

现在您可以使用相同的密钥来验证您的签名信息。