Exemplo n.º 1
0
        /// <summary>
        /// Import pkcs8 RSA private key
        /// </summary>
        /// <param name="rsa"></param>
        /// <param name="privateKey"></param>
        /// <param name="bytesRead"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public static void ImportPkcs8PrivateKey(this RSA rsa, ReadOnlySpan <byte> privateKey, out int bytesRead)
        {
            if (rsa is null)
            {
                throw new ArgumentNullException(nameof(rsa));
            }
            bytesRead = privateKey.Length;
            var key = Convert.ToBase64String(privateKey.ToArray());

            rsa.FromPkcs8PrivateString(key, out _);
        }