/// <summary> /// Initializes a token /// </summary> /// <param name="soPin">SO's initial PIN</param> /// <param name="label">Label of the token</param> public void InitToken(string soPin, string label) { byte[] soPinValue = null; uint soPinValueLen = 0; if (soPin != null) { soPinValue = ConvertUtils.Utf8StringToBytes(soPin); soPinValueLen = Convert.ToUInt32(soPinValue.Length); } byte[] tokenLabel = ConvertUtils.Utf8StringToBytes(label, 32, 0x20); CKR rv = _p11.C_InitToken(_slotId, soPinValue, soPinValueLen, tokenLabel); if (rv != CKR.CKR_OK) { throw new Pkcs11Exception("C_InitToken", rv); } }
/// <summary> /// Initializes a token /// </summary> /// <param name="soPin">SO's initial PIN</param> /// <param name="label">Label of the token</param> public void InitToken(string soPin, string label) { _logger.Debug("Slot({0})::InitToken1", _slotId); byte[] soPinValue = null; NativeULong soPinValueLen = 0; if (soPin != null) { soPinValue = ConvertUtils.Utf8StringToBytes(soPin); soPinValueLen = ConvertUtils.UInt32FromInt32(soPinValue.Length); } byte[] tokenLabel = ConvertUtils.Utf8StringToBytes(label, 32, 0x20); CKR rv = _p11.C_InitToken(_slotId, soPinValue, soPinValueLen, tokenLabel); if (rv != CKR.CKR_OK) { throw new Pkcs11Exception("C_InitToken", rv); } }