Net.Pkcs11Interop.HighLevelAPI81.Session.SetPin C# (CSharp) Method

SetPin() public method

Modifies the PIN of the user that is currently logged in, or the CKU_USER PIN if the session is not logged in.
public SetPin ( string oldPin, string newPin ) : void
oldPin string Old PIN value
newPin string New PIN value
return void
        public void SetPin(string oldPin, string newPin)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            byte[] oldPinValue = null;
            ulong oldPinValueLen = 0;
            if (oldPin != null)
            {
                oldPinValue = ConvertUtils.Utf8StringToBytes(oldPin);
                oldPinValueLen = Convert.ToUInt64(oldPinValue.Length);
            }

            byte[] newPinValue = null;
            ulong newPinValueLen = 0;
            if (newPin != null)
            {
                newPinValue = ConvertUtils.Utf8StringToBytes(newPin);
                newPinValueLen = Convert.ToUInt64(newPinValue.Length);
            }

            CKR rv = _p11.C_SetPIN(_sessionId, oldPinValue, oldPinValueLen, newPinValue, newPinValueLen);
            if (rv != CKR.CKR_OK)
                throw new Pkcs11Exception("C_SetPIN", rv);
        }

Same methods

Session::SetPin ( byte oldPin, byte newPin ) : void