Beispiel #1
0
        /// <summary>
        /// Open a logical channel with the secure element, selecting the Applet represented by the given application ID (AID).
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>The SmartcardChannel object for the logical channel.</returns>
        /// <param name="aid">The byte array containing the Application ID(AID) to be selected on the given channel.</param>
        /// <param name="p2">P2 byte of the SELECT command if executed.</param>
        /// <exception cref="NotSupportedException">Thrown when the Smartcard is not supported.</exception>
        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
        public SmartcardChannel OpenLogicalChannel(byte[] aid, byte p2)
        {
            int ret = Interop.Smartcard.Session.SessionOpenLogicalChannel(_sessionHandle, aid, aid.Length, p2, out _logicalChannel);

            if (ret != (int)SmartcardError.None)
            {
                Log.Error(Globals.LogTag, "Failed to open logical channel, Error - " + (SmartcardError)ret);
                SmartcardErrorFactory.ThrowSmartcardException(ret);
            }
            SmartcardChannel logicalChannel = new SmartcardChannel(this, _logicalChannel);

            _logicalChannelList.Add(logicalChannel);

            return(logicalChannel);
        }
Beispiel #2
0
        /// <summary>
        /// Gets an access to the basic channel, as defined in the ISO/IEC 7816-4 specification (the one that has number 0).
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>The SmartcardChannel object for the basic channel.</returns>
        /// <param name="aid">The byte array containing the Application ID(AID) to be selected on the given channel.</param>
        /// <param name="p2">P2 byte of the SELECT command if executed.</param>
        /// <exception cref="NotSupportedException">Thrown when the Smartcard is not supported.</exception>
        /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
        public SmartcardChannel OpenBasicChannel(byte[] aid, byte p2)
        {
            int aidLen = (aid == null ? 0 : aid.Length);
            int ret    = Interop.Smartcard.Session.SessionOpenBasicChannel(_sessionHandle, aid, aidLen, p2, out _basicChannel);

            if (ret != (int)SmartcardError.None)
            {
                Log.Error(Globals.LogTag, "Failed to open basic channel, Error - " + (SmartcardError)ret);
                SmartcardErrorFactory.ThrowSmartcardException(ret);
            }
            SmartcardChannel basicChannel = new SmartcardChannel(this, _basicChannel);

            _basicChannelList.Add(basicChannel);

            return(basicChannel);
        }