Pkcs12Info.VerifyMac Method

Definition

Attempts to verify the integrity of the AuthenticatedSafe contents with a password.

Overloads

VerifyMac(ReadOnlySpan<Char>)

Attempts to verify the integrity of the AuthenticatedSafe contents with a password represented by a System.ReadOnlySpan{System.Char}.

VerifyMac(String)

Attempts to verify the integrity of the AuthenticatedSafe contents with a password represented by a String.

Remarks

It's not possible to distinguish the error due to the password being incorrect from the error due to the contents having been altered.

It's usually the case that a password-protected PFX uses the same password for the MAC algorithm providing integrity and the encryption algorithm providing confidentiality, but the file format doesn't make that a requirement. Therefore, there is no guarantee that a password which results in a true return from this method will succeed on a call to Decrypt.

VerifyMac(ReadOnlySpan<Char>)

Attempts to verify the integrity of the AuthenticatedSafe contents with a password represented by a System.ReadOnlySpan{System.Char}.

public:
 bool VerifyMac(ReadOnlySpan<char> password);
public bool VerifyMac (ReadOnlySpan<char> password);
member this.VerifyMac : ReadOnlySpan<char> -> bool
Public Function VerifyMac (password As ReadOnlySpan(Of Char)) As Boolean

Parameters

password
ReadOnlySpan<Char>

The password to use to attempt to verify integrity.

Returns

true if the password successfully verifies the integrity of the AuthenticatedSafe contents; false if the password is not correct or the contents have been altered.

Exceptions

The hash algorithm option specified by the PKCS#12 PFX contents could not be identified or is not supported by this platform.

Remarks

In the PKCS#12 specification, a distinction is made between a null password and an "empty" password, and that difference is reflected in the return value of this method. ReadOnlySpan<Char>.Empty represents the null password and String.Empty.AsSpan() represents the "empty" password. If one of those two values returns true, the other won't.

VerifyMac(String)

Attempts to verify the integrity of the AuthenticatedSafe contents with a password represented by a String.

public:
 bool VerifyMac(System::String ^ password);
public bool VerifyMac (string password);
member this.VerifyMac : string -> bool
Public Function VerifyMac (password As String) As Boolean

Parameters

password
String

The password to use to attempt to verify integrity.

Returns

true if the password successfully verifies the integrity of the AuthenticatedSafe contents; false if the password is not correct or the contents have been altered.

Exceptions

The hash algorithm option specified by the PKCS#12 PFX contents could not be identified or is not supported by this platform.

Remarks

In the PKCS#12 specification, a distinction is made between a null password and an "empty" password, and that difference is reflected in the return value of this method. If the null string returns true, then String.Empty returns false, and vice versa.

Applies to