Example #1
0
 public VolumeInfo(ulong _volumeSize, FlashAccessMode _accessMode, CKU _volumeOwner, ulong _flags)
 {
     this._volumeSize  = (NativeULong)_volumeSize;
     this._accessMode  = _accessMode;
     this._volumeOwner = _volumeOwner;
     this._flags       = (NativeULong)_flags;
 }
Example #2
0
        public void FormatDrive(CKU userType,
                                string pin, IEnumerable <IVolumeFormatInfoExtended> initParams)
        {
            if (pin == null)
            {
                throw new ArgumentNullException(nameof(pin));
            }

            if (initParams == null)
            {
                throw new ArgumentNullException(nameof(initParams));
            }

            byte[] pinArray = ConvertUtils.Utf8StringToBytes(pin);

            var formatParams = new List <LowLevelAPI40.CK_VOLUME_FORMAT_INFO_EXTENDED>();

            foreach (var initParam in initParams)
            {
                formatParams.Add(((VolumeFormatInfoExtended)initParam).CkVolumeFormatInfoExtended);
            }

            CKR rv = ((LowLevelAPI40.RutokenPkcs11Library)_pkcs11Library).C_EX_FormatDrive(_slotId, (NativeULong)userType,
                                                                                           pinArray, formatParams.ToArray());

            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_EX_FormatDrive", rv);
            }
        }
Example #3
0
        public void ChangeVolumeAttributes(CKU userType, string pin,
                                           ulong volumeId, FlashAccessMode newAccessMode, bool permanent)
        {
            if (pin == null)
            {
                throw new ArgumentNullException(nameof(pin));
            }

            byte[] pinArray = ConvertUtils.Utf8StringToBytes(pin);
            string serial   = null;

            if (permanent == true)
            {
                serial = GetTokenInfo().SerialNumber;
            }

            CKR rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_EX_ChangeVolumeAttributes(_slotId, (NativeULong)userType,
                                                                                                      pinArray, (NativeULong)(volumeId), newAccessMode, permanent);

            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_EX_ChangeVolumeAttributes", rv);
            }
            if (permanent == true)
            {
                UpdateSlotId(serial);
            }
        }
Example #4
0
        public void Login(CKU userType, string pin)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            if (_authenticatedSession != null)
            {
                throw new Exception("Authenticated session already exists");
            }

            _authenticatedSession = _slot.OpenSession(SessionType.ReadWrite);

            try
            {
                _authenticatedSession.Login(userType, pin);
            }
            catch (Exception)
            {
                _authenticatedSession.Dispose();
                _authenticatedSession = null;
                throw;
            }
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hSession"></param>
        /// <param name="userType"></param>
        /// <param name="pin"></param>
        public void Login(uint hSession, CKU userType, string pin)
        {
            C_Login proc = (C_Login)DelegateUtil.GetDelegate(this.hLib, typeof(C_Login));

            byte[] pinBytes = System.Text.Encoding.UTF8.GetBytes(pin);

            checkCKR(proc(hSession, userType, pinBytes, (uint)pinBytes.Length));
        }
Example #6
0
 public static void Change <TOperation>(Slot slot,
                                        string oldPin, string newPin, CKU loginType) where TOperation : BaseTokenOperation <PinChangeOperationParams>, new()
 {
     new TOperation().Invoke(slot, new PinChangeOperationParams
     {
         LoginType = loginType,
         OldPin    = oldPin,
         NewPin    = newPin
     });
 }
 public VolumeFormatInfoExtended(ulong volumeSize, FlashAccessMode accessMode,
                                 CKU volumeOwner, ulong flags)
 {
     CkVolumeFormatInfoExtended = new CK_VOLUME_FORMAT_INFO_EXTENDED
     {
         VolumeSize  = (NativeULong)volumeSize,
         AccessMode  = (NativeULong)accessMode,
         VolumeOwner = (NativeULong)volumeOwner,
         Flags       = (NativeULong)flags
     };
 }
 public static void Login(this ISession session, CKU userType, SecureString securePin)
 {
     if (securePin == null)
     {
         session.Login(userType, pin: null as byte[]);
     }
     else
     {
         SecureStringHelper.ExecuteWithSecureString(securePin, Encoding.UTF8, pin => session.Login(userType, pin));
     }
 }
Example #9
0
        public ChangePinDialog(Pkcs11Slot slot, CKU userType)
        {
            InitializeComponent();
            this.Icon = Properties.Resources.Pkcs11Admin;

            _slot     = slot;
            _userType = userType;

            Text = ((_userType == CKU.CKU_USER) || (_userType == CKU.CKU_CONTEXT_SPECIFIC)) ? "Change user PIN" : "Change SO PIN";

            UpdateStatusStrip();
        }
Example #10
0
        /// <summary>
        /// Converts CKU enum member to string that can be logged
        /// </summary>
        /// <param name="userType">CKU enum member</param>
        /// <returns>String value representing CKU enum member</returns>
        public static string ToString(CKU userType)
        {
            switch (userType)
            {
            case CKU.CKU_SO:
                return("security officer");

            case CKU.CKU_USER:
                return("normal user");

            case CKU.CKU_CONTEXT_SPECIFIC:
                return("context specific user");

            default:
                return(userType.ToString());
            }
        }
        public IObjectHandle GetPinPolicyObject(CKU userType)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            CKR rv;

            CK_ATTRIBUTE[] pinPolicyTemplate = new CK_ATTRIBUTE[3];

            pinPolicyTemplate[0] = CkaUtils.CreateAttribute(CKA.CKA_CLASS, CKO.CKO_HW_FEATURE);
            pinPolicyTemplate[1] = CkaUtils.CreateAttribute(CKA.CKA_HW_FEATURE_TYPE, (NativeULong)Extended_CKH.CKH_VENDOR_PIN_POLICY);
            pinPolicyTemplate[2] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_USER_TYPE, (NativeULong)userType);

            NativeULong foundObjectCount = 0;

            NativeULong[] foundObjectIds = new NativeULong[1];

            rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_FindObjectsInit(_sessionId, pinPolicyTemplate, (NativeULong)(pinPolicyTemplate.Length));
            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_FindObjectsInit", rv);
            }

            rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_FindObjects(_sessionId, foundObjectIds, (NativeULong)(foundObjectIds.Length), ref foundObjectCount);
            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_FindObjects", rv);
            }

            rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_FindObjectsFinal(_sessionId);
            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_FindObjectsFinal", rv);
            }

            if (foundObjectCount != 1)
            {
                throw new Exception("Pin policy object not found");
            }

            return(new Net.Pkcs11Interop.HighLevelAPI81.ObjectHandle(foundObjectIds[0]));
        }
        public bool PinPolicySupports(CKU userType)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            CKR           rv;
            IObjectHandle pinPolicyObj = GetPinPolicyObject(userType);

            CK_ATTRIBUTE[] pinPolicyTemplate = new CK_ATTRIBUTE[1];
            pinPolicyTemplate[0] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_SUPPORTED_PIN_POLICIES);

            rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_GetAttributeValue(_sessionId, (NativeULong)(pinPolicyObj.ObjectId), pinPolicyTemplate, (NativeULong)(pinPolicyTemplate.Length));
            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_GetAttributeValue", rv);
            }

            return(pinPolicyTemplate[0].valueLen != 0);
        }
Example #13
0
 /// <summary>
 /// Converts CKU to UInt32
 /// </summary>
 /// <param name="value">CKU that should be converted</param>
 /// <returns>UInt32 with value from CKU</returns>
 public static UInt32 UInt32FromCKU(CKU value)
 {
     return(Convert.ToUInt32(value));
 }
Example #14
0
 /// <summary>
 /// Converts CKU to UInt64
 /// </summary>
 /// <param name="value">CKU that should be converted</param>
 /// <returns>UInt64 with value from CKU</returns>
 public static UInt64 UInt64FromCKU(CKU value)
 {
     return(Convert.ToUInt64(value));
 }
Example #15
0
 /// <summary>
 /// Converts CKU to NativeULong
 /// </summary>
 /// <param name="value">CKU that should be converted</param>
 /// <returns>NativeULong with value from CKU</returns>
 public static NativeULong ConvertFromCKU(CKU value)
 {
     return(Convert.ToUInt64(value));
 }
        public void SetPinPolicy(PinPolicy pinPolicy, CKU userType)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            CKR           rv;
            IObjectHandle pinPolicyObj = GetPinPolicyObject(userType);


            CK_ATTRIBUTE[] pinPolicyTemplate = new CK_ATTRIBUTE[10];
            NativeULong    len = 0;

            if (pinPolicy.MinPinLength != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_MIN_LENGTH, new byte[] { Convert.ToByte(pinPolicy.MinPinLength) });
            }
            if (pinPolicy.PinHistoryDepth != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_HISTORY_DEPTH, new byte[] { Convert.ToByte(pinPolicy.PinHistoryDepth) });
            }
            if (pinPolicy.AllowDefaultPinUsage != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_ALLOW_DEFAULT_PIN_USAGE, new byte[] { Convert.ToByte(pinPolicy.AllowDefaultPinUsage) });
            }
            if (pinPolicy.PinContainsDigit != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_DIGIT_REQUIRED, new byte[] { Convert.ToByte(pinPolicy.PinContainsDigit) });
            }
            if (pinPolicy.PinContainsUpperLetter != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_UPPERCASE_REQUIRED, new byte[] { Convert.ToByte(pinPolicy.PinContainsUpperLetter) });
            }
            if (pinPolicy.PinContainsLowerLetter != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_LOWERCASE_REQUIRED, new byte[] { Convert.ToByte(pinPolicy.PinContainsLowerLetter) });
            }
            if (pinPolicy.PinContainsSpecChar != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_SPEC_CHAR_REQUIRED, new byte[] { Convert.ToByte(pinPolicy.PinContainsSpecChar) });
            }
            if (pinPolicy.RestrictOneCharPin != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_DIFF_CHARS_REQUIRED, new byte[] { Convert.ToByte(pinPolicy.RestrictOneCharPin) });
            }
            if (pinPolicy.AllowChangePinPolicy != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute(CKA.CKA_MODIFIABLE, Convert.ToBoolean(pinPolicy.AllowChangePinPolicy));
            }
            if (pinPolicy.RemovePinPolicyAfterFormat != null)
            {
                pinPolicyTemplate[len++] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICIES_DELETABLE, Convert.ToBoolean(pinPolicy.RemovePinPolicyAfterFormat));
            }

            rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_SetAttributeValue(_sessionId, (NativeULong)(pinPolicyObj.ObjectId), pinPolicyTemplate, len);
            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_GetAttributeValue", rv);
            }
        }
        public PinPolicy GetPinPolicy(CKU userType)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            CKR           rv;
            PinPolicy     pinPolicy    = new PinPolicy();
            IObjectHandle pinPolicyObj = GetPinPolicyObject(userType);

            CK_ATTRIBUTE[] pinPolicyTemplate = new CK_ATTRIBUTE[10];
            pinPolicyTemplate[0] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_MIN_LENGTH, new byte[1]);
            pinPolicyTemplate[1] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_HISTORY_DEPTH, new byte[1]);
            pinPolicyTemplate[2] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_ALLOW_DEFAULT_PIN_USAGE, new byte[1]);
            pinPolicyTemplate[3] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_DIGIT_REQUIRED, new byte[1]);
            pinPolicyTemplate[4] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_UPPERCASE_REQUIRED, new byte[1]);
            pinPolicyTemplate[5] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_LOWERCASE_REQUIRED, new byte[1]);
            pinPolicyTemplate[6] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_SPEC_CHAR_REQUIRED, new byte[1]);
            pinPolicyTemplate[7] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICY_DIFF_CHARS_REQUIRED, new byte[1]);
            pinPolicyTemplate[8] = CkaUtils.CreateAttribute(CKA.CKA_MODIFIABLE, new bool());
            pinPolicyTemplate[9] = CkaUtils.CreateAttribute((CKA)Extended_CKA.CKA_VENDOR_PIN_POLICIES_DELETABLE, new bool());

            rv = ((LowLevelAPI81.RutokenPkcs11Library)_pkcs11Library).C_GetAttributeValue(_sessionId, (NativeULong)(pinPolicyObj.ObjectId), pinPolicyTemplate, (NativeULong)(pinPolicyTemplate.Length));
            if (rv != CKR.CKR_OK)
            {
                throw new Pkcs11Exception("C_GetAttributeValue", rv);
            }

            byte[] minPolicyLength;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[0], out minPolicyLength);
            pinPolicy.MinPinLength = minPolicyLength[0];

            byte[] pinHistoryDepth;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[1], out pinHistoryDepth);
            pinPolicy.PinHistoryDepth = pinHistoryDepth[0];

            byte[] allowDefaultPinUsage;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[2], out allowDefaultPinUsage);
            pinPolicy.AllowDefaultPinUsage = allowDefaultPinUsage[0] != 0;

            byte[] pinContainsDigit;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[3], out pinContainsDigit);
            pinPolicy.PinContainsDigit = pinContainsDigit[0] != 0;

            byte[] pinContainsUpperLetter;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[4], out pinContainsUpperLetter);
            pinPolicy.PinContainsUpperLetter = pinContainsUpperLetter[0] != 0;

            byte[] pinContainsLowerLetter;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[5], out pinContainsLowerLetter);
            pinPolicy.PinContainsLowerLetter = pinContainsLowerLetter[0] != 0;

            byte[] pinContainsSpecChar;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[6], out pinContainsSpecChar);
            pinPolicy.PinContainsSpecChar = pinContainsSpecChar[0] != 0;

            byte[] restrictOneCharPin;
            CkaUtils.ConvertValue(ref pinPolicyTemplate[7], out restrictOneCharPin);
            pinPolicy.RestrictOneCharPin = restrictOneCharPin[0] != 0;

            bool allowChangePinPolicy;

            CkaUtils.ConvertValue(ref pinPolicyTemplate[8], out allowChangePinPolicy);
            pinPolicy.AllowChangePinPolicy = allowChangePinPolicy;

            bool removePinPolicyAfterFormat;

            CkaUtils.ConvertValue(ref pinPolicyTemplate[9], out removePinPolicyAfterFormat);
            pinPolicy.RemovePinPolicyAfterFormat = removePinPolicyAfterFormat;

            return(pinPolicy);
        }
 public IVolumeInfoExtended Create(ulong volumeId, ulong VolumeSize, FlashAccessMode AccessMode, CKU VolumeOwner, ulong Flags)
 {
     return(new VolumeInfoExtended(volumeId, VolumeSize, AccessMode, VolumeOwner, Flags));
 }
Example #19
0
 internal VolumeInfoExtended(ulong volumeId, ulong volumeSize, FlashAccessMode accessMode, CKU volumeOwner, ulong flags)
     : base(volumeSize, accessMode, volumeOwner, flags)
 {
     _volumeId = (NativeULong)volumeId;
 }
Example #20
0
        /// <summary>
        /// Logs a user into a token
        /// </summary>
        /// <param name="userType">Type of user</param>
        /// <param name="pin">Pin of user</param>
        public void Login(CKU userType, byte[] pin)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            if (Platform.UnmanagedLongSize == 4)
            {
                if (Platform.StructPackingSize == 0)
                    _session40.Login(userType, pin);
                else
                    _session41.Login(userType, pin);
            }
            else
            {
                if (Platform.StructPackingSize == 0)
                    _session80.Login(userType, pin);
                else
                    _session81.Login(userType, pin);
            }
        }
Example #21
0
        /// <summary>
        /// Logs a user into a token
        /// </summary>
        /// <param name="session">The session's handle</param>
        /// <param name="userType">The user type</param>
        /// <param name="pin">User's PIN or null to use protected authentication path (pinpad)</param>
        /// <param name="pinLen">Length of user's PIN</param>
        /// <returns>CKR_ARGUMENTS_BAD, CKR_CRYPTOKI_NOT_INITIALIZED, CKR_DEVICE_ERROR, CKR_DEVICE_MEMORY, CKR_DEVICE_REMOVED, CKR_FUNCTION_CANCELED, CKR_FUNCTION_FAILED, CKR_GENERAL_ERROR, CKR_HOST_MEMORY, CKR_OK, CKR_OPERATION_NOT_INITIALIZED, CKR_PIN_INCORRECT, CKR_PIN_LOCKED, CKR_SESSION_CLOSED, CKR_SESSION_HANDLE_INVALID, CKR_SESSION_READ_ONLY_EXISTS, CKR_USER_ALREADY_LOGGED_IN, CKR_USER_ANOTHER_ALREADY_LOGGED_IN, CKR_USER_PIN_NOT_INITIALIZED, CKR_USER_TOO_MANY_TYPES, CKR_USER_TYPE_INVALID</returns>
        public CKR C_Login(ulong session, CKU userType, byte[] pin, ulong pinLen)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            ulong rv = _delegates.C_Login(session, Convert.ToUInt64(userType), pin, pinLen);
            return (CKR)Convert.ToUInt32(rv);
        }
 public IVolumeFormatInfoExtended Create(ulong volumeSize, FlashAccessMode accessMode,
                                         CKU volumeOwner, ulong flags)
 {
     return(new VolumeFormatInfoExtended(volumeSize, accessMode, volumeOwner, flags));
 }
Example #23
0
        /// <summary>
        /// Logs a user into a token
        /// </summary>
        /// <param name="session">The session's handle</param>
        /// <param name="userType">The user type</param>
        /// <param name="pin">User's PIN or null to use protected authentication path (pinpad)</param>
        /// <param name="pinLen">Length of user's PIN</param>
        /// <returns>CKR_ARGUMENTS_BAD, CKR_CRYPTOKI_NOT_INITIALIZED, CKR_DEVICE_ERROR, CKR_DEVICE_MEMORY, CKR_DEVICE_REMOVED, CKR_FUNCTION_CANCELED, CKR_FUNCTION_FAILED, CKR_GENERAL_ERROR, CKR_HOST_MEMORY, CKR_OK, CKR_OPERATION_NOT_INITIALIZED, CKR_PIN_INCORRECT, CKR_PIN_LOCKED, CKR_SESSION_CLOSED, CKR_SESSION_HANDLE_INVALID, CKR_SESSION_READ_ONLY_EXISTS, CKR_USER_ALREADY_LOGGED_IN, CKR_USER_ANOTHER_ALREADY_LOGGED_IN, CKR_USER_PIN_NOT_INITIALIZED, CKR_USER_TOO_MANY_TYPES, CKR_USER_TYPE_INVALID</returns>
        public CKR C_Login(uint session, CKU userType, byte[] pin, uint pinLen)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            uint rv = _delegates.C_Login(session, (uint)userType, pin, pinLen);
            return (CKR)rv;
        }
Example #24
0
 public IVolumeInfo Create(ulong VolumeSize, FlashAccessMode AccessMode, CKU VolumeOwner, ulong Flags)
 {
     return(_factory.Create(VolumeSize, AccessMode, VolumeOwner, Flags));
 }
Example #25
0
        /// <summary>
        /// Logs a user into a token
        /// </summary>
        /// <param name="userType">Type of user</param>
        /// <param name="pin">Pin of user</param>
        public void Login(CKU userType, byte[] pin)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            byte[] pinValue = null;
            ulong pinValueLen = 0;
            if (pin != null)
            {
                pinValue = pin;
                pinValueLen = Convert.ToUInt64(pin.Length);
            }
            
            CKR rv = _p11.C_Login(_sessionId, userType, pinValue, pinValueLen);
            if (rv != CKR.CKR_OK)
                throw new Pkcs11Exception("C_Login", rv);
        }
Example #26
0
        /// <summary>
        /// Logs a user into a token
        /// </summary>
        /// <param name="userType">Type of user</param>
        /// <param name="pin">Pin of user</param>
        public void Login(CKU userType, string pin)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            byte[] pinValue = null;
            uint pinValueLen = 0;
            if (pin != null)
            {
                pinValue = ConvertUtils.Utf8StringToBytes(pin);
                pinValueLen = Convert.ToUInt32(pinValue.Length);
            }

            CKR rv = _p11.C_Login(_sessionId, userType, pinValue, pinValueLen);
            if (rv != CKR.CKR_OK)
                throw new Pkcs11Exception("C_Login", rv);
        }