ECAlgorithm.ImportSubjectPublicKeyInfo Method

Definition

Imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object

public override void ImportSubjectPublicKeyInfo (ReadOnlySpan<byte> source, out int bytesRead);

Parameters

source
ReadOnlySpan<Byte>

The bytes of an X.509 SubjectPublicKeyInfo structure in the ASN.1-DER encoding.

bytesRead
Int32

When this method returns, contains a value that indicates the number of bytes read from source. This parameter is treated as uninitialized.

Exceptions

A derived class has not provided an implementation for ImportParameters(ECParameters).

The contents of source do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure.

-or-

The contents of source indicate the key is for an algorithm other than the algorithm represented by this instance.

-or-

The contents of source represent the key in a format that is not supported.

-or-

The algorithm-specific key import failed.

Remarks

This method only supports the binary (DER) encoding of SubjectPublicKeyInfo. If the value is Base64-encoded, the caller must Base64-decode the contents before calling this method. If this value is PEM-encoded, ImportFromPem(ReadOnlySpan<Char>) should be used.

Applies to

Product Versions
.NET 7, 8, 9