示例#1
0
        /// <summary>
        /// The public constructor.
        /// </summary>
        /// <param name="comGeneric">An already connected COM object of type KryptoniteCOM.Generic.</param>
        /// <param name="comCrypto">An already connected COM object of type KryptoniteCOM.Crypto.</param>
        /// <param name="handlePartner">The name of the communication-partner to bind the instance to.</param>
        /// <param name="userIO">The interface used for communication with the user.</param>
        public SessionExternalComm(KryptoniteCOM.Generic comGeneric, KryptoniteCOM.Crypto comCrypto, String handlePartner, IUserIO userIO)
        {
            this.comGeneric = comGeneric;
            this.comCrypto = comCrypto;

            this.handlePartner = handlePartner;
            this.userIO = userIO;

            this.secure = false;
        }
示例#2
0
        /// <inheritdoc />
        public bool setUp()
        {
            int retVal;
            try
            {
                retVal = DllInstall(true, "user");
            }
            catch (DllNotFoundException)
            {
                Logger.log(TLogLevel.logUser, "Error: Kryptonite.dll or a runtime library required by it was not found, unable to proceed!");
                return false;
            }

            if (retVal != 0)
            {
                Logger.log(TLogLevel.logUser, "Error: Failed to load Kryptonite.dll.");
                return false;
            }

            //seems like Kryptonite.dll was loaded successfully
            comGeneric = new KryptoniteCOM.Generic();
            comCrypto = new KryptoniteCOM.Crypto();

            ActionType nextAction = (ActionType)comCrypto.init(handleSelf, workingDir);

            switch (nextAction)
            {
                case ActionType.NOTHING:
                    //everything's fine
                    break;

                case ActionType.POLL_GENERIC:
                    //further action needs to be done
                    Logger.log(TLogLevel.logDebug, "Info: Further action required to successfully init the crypto module.");
                    if (handleNextAction(nextAction) != true)
                    {
                        return false;
                    }
                    break;
                default:
                    Logger.log(TLogLevel.logUser, "Error: Failed to initialize crypto module.");
                    return false;
            }

            //display own fingerprint to the user
            String fingerprint;
            if (comCrypto.getOwnFingerprint(out fingerprint) != 1)
            {
                Logger.log(TLogLevel.logUser, "Fatal Error: Failed to get fingerprint of own private key.");
                Logger.log(TLogLevel.logDebug, "\tHere comes the log:");
                Logger.log(TLogLevel.logDebug, (String[])comGeneric.getLog());
                return false;
            }
            userIO.displayOwnFingerprint(fingerprint);

            return true;
        }