/// <summary>Constructor for OpenPGP keyring files.</summary> public PgpToken(byte[] abKeyBytes, List <PgpToken> ltTokens, EncryptionServices Cryptography) : this(Cryptography) { bool isPublicKey = true; int iPgpPacketPointer = 0; PgpPacket DecodedPgpPacket, RawPgpPacket; if (abKeyBytes != null) { _eStatus = nStatus.OK; while ((_eStatus == nStatus.OK) && (iPgpPacketPointer < abKeyBytes.Length - 2)) { RawPgpPacket = new PgpPacket(abKeyBytes, iPgpPacketPointer); if (RawPgpPacket.eStatus == PgpPacketBase.nStatus.OK) { switch (RawPgpPacket.ePacketTag) { case PgpPacket.nPacketTag.PrivateKey: case PgpPacket.nPacketTag.PrivateSubkey: DecodedPgpPacket = ParsePrivateKeyPacket(RawPgpPacket); break; case PgpPacket.nPacketTag.PublicKey: case PgpPacket.nPacketTag.PublicSubkey: DecodedPgpPacket = ParsePublicKeyPacket(RawPgpPacket); break; case PgpPacket.nPacketTag.Signature: DecodedPgpPacket = ParseSignaturePacket(RawPgpPacket, ltTokens); break; case PgpPacket.nPacketTag.UserId: DecodedPgpPacket = ParseUserIdPacket(RawPgpPacket); break; default: DecodedPgpPacket = null; Console.WriteLine("not implemented: ePacketTag=" + RawPgpPacket.ePacketTag.ToString()); break; } if ((DecodedPgpPacket == null) || (DecodedPgpPacket.eStatus != PgpPacketBase.nStatus.OK)) { _eStatus = nStatus.ParseErrorSub; } // else // Console.WriteLine(" Found ePacketTag=" + RawPgpPacket.ePacketTag.ToString() + " iHeaderLength=" + RawPgpPacket.iHeaderLength.ToString() + ", iDataLength=" + RawPgpPacket.iDataLength.ToString()); iPgpPacketPointer += (RawPgpPacket.iHeaderLength + RawPgpPacket.iPartialHeaders + RawPgpPacket.iDataLength); } else { _eStatus = nStatus.ParseErrorRaw; } } if (((_eStatus == nStatus.OK) && (iPgpPacketPointer != abKeyBytes.Length)) || (_ltSubkeys == null) || (_ltSubkeys.Count == 0)) { _eStatus = nStatus.ParseErrorRaw; } else { foreach (PgpSignature Subkey in _ltSubkeys) { isPublicKey = isPublicKey && (Subkey.PrivateKeyPacket == null); // one private key packet flags the whole token as private } _eType = isPublicKey ? nType.Public : nType.Private; } } }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> public BackgroundMessage(nType eType) { _eType = eType; _abKeyOrPassword = _abSignatureOrSalt = null; _eReturn = nReturn.Empty; _iValue = _iProgressMaximum = 0; _sText = string.Empty; _TimeStamp = DateTime.MinValue; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> public BackgroundMessage(nType eType) { _eType = eType; _eReturnCode = nReturnCode.Empty; _iValue = _iProgressMaximum = 0; _sText = string.Empty; _TimeStamp = DateTime.MinValue; _DriveProperty = null; _PairProperty = null; }
/// <summary>Base constructor for initialisation.</summary> private PgpToken(EncryptionServices Cryptography) { _eStatus = nStatus.Undefined; _eType = nType.Undefined; _sSlotName = string.Empty; _TokenInfo = null; _UserIdPacket = null; _Cryptography = Cryptography; _KeyPacket = null; _ltSubkeys = new List <PgpSignature>(); }
public void AddPublicKey(ISlotInfo SlotInfo, byte[] abId, PgpKeyFlags.nFlags eKeyFlags, byte[] abModulus, byte[] abExponent) { PgpSignature NewSignature = new PgpSignature(SlotInfo, abId, eKeyFlags, abModulus, abExponent, _Cryptography); if (NewSignature.eStatus == PgpPacketBase.nStatus.OK) { _eType = nType.Public; _sSlotName = NewSignature.PublicKeyPacket.sSlotDescription.Replace("Nitrokey Nitrokey", "Nitrokey").Replace(" 0", ""); // cosmetics _ltSubkeys.Add(NewSignature); SortSubkeys(); } }
/// <summary> /// Function for converting from direction to delta tuple. /// </summary> /// <param name="direction">Input direction enumerable.</param> /// <returns>Returns input's representation as delta tuple of two integers.</returns> public Tuple <int, int> DirectionToTuple(nType direction) { switch (direction) { case nType.DOWN: return(new Tuple <int, int>(1, 0)); case nType.UP: return(new Tuple <int, int>(-1, 0)); case nType.LEFT: return(new Tuple <int, int>(0, -1)); case nType.RIGHT: return(new Tuple <int, int>(0, 1)); default: return(new Tuple <int, int>(0, 0)); } }
/// <summary> /// Class's constructor. /// </summary> /// <param name="state">Entity's state such as Player1, Player2, Hostile....</param> /// <param name="tsc">Tile Map Size in Columns.</param> /// <param name="tsr">Tile Map Size in Rows.</param> public DefaultAI(nType state, int tsc, int tsr) { State = state; fieldSizeInColumns = tsc; fieldSizeInRows = tsr; }
/// <summary> /// Function for conversion between string representation of tile states and enumerable. /// </summary> /// <param name="tile">string representation of tile state.</param> /// <returns>Returns coresponding tile state.</returns> public Tile(string tile) { switch (tile) { case " ": this.tile = nType.FREE; break; case "X": this.tile = nType.GATE; break; case ".": this.tile = nType.DOT; break; case "o": this.tile = nType.POWERDOT; break; case "DWL": this.tile = nType.LWALLDOUBLE; break; case "DWR": this.tile = nType.RWALLDOUBLE; break; case "DWT": this.tile = nType.TWALLDOUBLE; break; case "DWB": this.tile = nType.BWALLDOUBLE; break; case "SWL": this.tile = nType.LWALLSINGLE; break; case "SWR": this.tile = nType.RWALLSINGLE; break; case "SWT": this.tile = nType.TWALLSINGLE; break; case "SWB": this.tile = nType.BWALLSINGLE; break; case "DCTL": this.tile = nType.TLCURVEDOUBLE; break; case "DCTR": this.tile = nType.TRCURVEDOUBLE; break; case "DCBR": this.tile = nType.BRCURVEDOUBLE; break; case "DCBL": this.tile = nType.BLCURVEDOUBLE; break; case "SCTL": this.tile = nType.TLCURVESINGLE; break; case "SCTR": this.tile = nType.TRCURVESINGLE; break; case "SCBR": this.tile = nType.BRCURVESINGLE; break; case "SCBL": this.tile = nType.BLCURVESINGLE; break; case "VTBDTILE": this.tile = nType.VTBDTILE; break; case "HTBDTILE": this.tile = nType.HTBDTILE; break; default: this.tile = nType.TILE; break; } }
/// <summary> /// Constructor for tile map deep copying. /// </summary> /// <param name="tileType">Source tile type.</param> public Tile(nType tileType) { this.tile = tileType; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, byte[] abKeyOrPassword, byte[] abSignatureOrSalt) : this(eType) { _eReturn = eReturn; _abKeyOrPassword = abKeyOrPassword; _abSignatureOrSalt = abSignatureOrSalt; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, nReturn eReturn) : this(eType) { _eReturn = eReturn; _TimeStamp = DateTime.Now; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, int iValue, string sText) : this(eType) { _iValue = iValue; _sText = sText; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, string sText) : this(eType) { _sText = sText; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, int iValue, int iProgressMaximum = 0) : this(eType) { _iValue = iValue; _iProgressMaximum = iProgressMaximum; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, PairOfFiles PairProperty) : this(eType) { _PairProperty = PairProperty; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, Drive DriveProperty, int iValue) : this(eType) { _DriveProperty = DriveProperty; _iValue = iValue; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, nReturnCode eReturnCode, string sText) : this(eType) { _eReturnCode = eReturnCode; _sText = sText; _TimeStamp = DateTime.Now; }
/// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary> /// <param name=""></param> /// <param name=""></param> public BackgroundMessage(nType eType, nReturnCode eReturnCode) : this(eType) { _eReturnCode = eReturnCode; _TimeStamp = DateTime.Now; }