Exemplo n.º 1
0
        public override bool TryExportEncryptedPkcs8PrivateKey(
            ReadOnlySpan <char> password,
            PbeParameters pbeParameters,
            Span <byte> destination,
            out int bytesWritten)
        {
            if (pbeParameters == null)
            {
                throw new ArgumentNullException(nameof(pbeParameters));
            }

            PasswordBasedEncryption.ValidatePbeParameters(
                pbeParameters,
                password,
                ReadOnlySpan <byte> .Empty);

            if (CngPkcs8.IsPlatformScheme(pbeParameters))
            {
                return(TryExportEncryptedPkcs8(
                           password,
                           pbeParameters.IterationCount,
                           destination,
                           out bytesWritten));
            }

            return(CngPkcs8.TryExportEncryptedPkcs8PrivateKey(
                       this,
                       password,
                       pbeParameters,
                       destination,
                       out bytesWritten));
        }
Exemplo n.º 2
0
        public override byte[] ExportEncryptedPkcs8PrivateKey(
            ReadOnlySpan <char> password,
            PbeParameters pbeParameters)
        {
            ArgumentNullException.ThrowIfNull(pbeParameters);

            PasswordBasedEncryption.ValidatePbeParameters(
                pbeParameters,
                password,
                ReadOnlySpan <byte> .Empty);

            if (CngPkcs8.IsPlatformScheme(pbeParameters))
            {
                return(ExportEncryptedPkcs8(password, pbeParameters.IterationCount));
            }

            return(CngPkcs8.ExportEncryptedPkcs8PrivateKey(
                       this,
                       password,
                       pbeParameters));
        }