コード例 #1
1
        public ValueVersion(UInt64 ve, string ss, byte[] va, int ec, ProcessStatus status, Int64 start, Int64 stop)
        {
            version = ve;
            shortStatus = ss;
            value = va;
            exitCode = ec;
            startTime = start;
            stopTime = stop;
            switch (status)
            {
                case ProcessStatus.Queued:
                    processStatus = "Queued";
                    break;

                case ProcessStatus.Running:
                    processStatus = "Running";
                    break;

                case ProcessStatus.Canceling:
                    processStatus = "Canceling";
                    break;

                default:
                    processStatus = "Completed";
                    break;
            }
        }
コード例 #2
1
ファイル: OnException.cs プロジェクト: vlaci/Anotar
 public object WithRefsWithReturn(
     ref string param1,
     ref int param2,
     ref short param3,
     ref long param4,
     ref uint param5,
     ref ushort param6,
     ref ulong param7,
     ref bool param8,
     ref double param9,
     ref decimal param10,
     ref int? param11,
     ref object param12,
     ref char param13,
     ref DateTime param14,
     ref Single param15,
     ref IntPtr param16,
     ref UInt16 param17,
     ref UInt32 param18,
     ref UInt64 param19,
     ref UIntPtr param20
     )
 {
     throw new Exception("Foo");
 }
コード例 #3
0
ファイル: Chunk.cs プロジェクト: flecoqui/Windows10
 /// <summary>
 /// Initializes a Chunk with the specified values.
 /// </summary>
 /// <param name="id">Chunk number.</param>
 /// <param name="time">Chunk timestamp.</param>
 /// <param name="duration">Chunk duration.</param>
 public Chunk(int? id, UInt64? time, ulong? duration)
 {
     this.Id = id;
     this.Time = time;
     this.Duration = duration;
     this.Repeat = 1;
 }
コード例 #4
0
ファイル: IGraphExtensions.cs プロジェクト: subbuballa/Walkyr
        public static INode AddNode(this IGraph myIGraph, UInt64 myUInt64Id)
        {
            if (myIGraph == null)
                throw new ArgumentNullException("myIGraph must not be null!");

            return myIGraph.AddNode(myUInt64Id.ToString());
        }
コード例 #5
0
 /**
  * @since 3.0
  */
 public DistortionData(UInt64 version, float width, float height, float[] data)
 {
   Version = version;
   Width = width;
   Height = height;
   Data = data;
 }
コード例 #6
0
		public NvparseFragmentProgram( ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual, IManualResourceLoader loader )
			: base( parent, name, handle, group, isManual, loader )
		{

			// create a display list
			programId = Gl.glGenLists( 1 );
		}
コード例 #7
0
ファイル: LookupKey.cs プロジェクト: somdoron/NetLevelDB
        // Initialize *this for looking up user_key at a snapshot with
        // the specified sequence number.
        public LookupKey(Slice user_key, UInt64 sequence)
        {
            int usize = user_key.Size;
            int needed = usize + 13;  // A conservative estimate
            ByteArrayPointer dst;

            if (needed <= space_.Length)
            {
                dst = new ByteArrayPointer(space_);
            }
            else
            {
                dst = new ByteArrayPointer(needed);
            }

            start_ = dst;
            dst = Coding.EncodeVarint32(dst, (uint)(usize + 8));
            kstart_ = dst;

            user_key.Data.CopyTo(dst, usize);

            dst += usize;

            Coding.EncodeFixed64(dst, Global.PackSequenceAndType(sequence ,Global.kValueTypeForSeek));
            end_ = dst + 8;
        }
コード例 #8
0
ファイル: ClientPacket.cs プロジェクト: sguphil/GameProject
 public void Read(ReadBufferHelper bh)
 {
     nRetCode = bh.ReadUint16();
     dwAccountID = bh.ReadUint32();
     u64CharID = bh.ReadUint64();
     return ;
 }
コード例 #9
0
		/// <summary>
		/// Reverses the bytes.
		/// </summary>
		/// <returns>The bytes.</returns>
		/// <param name="value">Value.</param>
		private static UInt64 ReverseBytes(UInt64 value)
		{
			return (value & 0x00000000000000FFUL) << 56 | (value & 0x000000000000FF00UL) << 40 |
				(value & 0x0000000000FF0000UL) << 24 | (value & 0x00000000FF000000UL) << 8 |
				(value & 0x000000FF00000000UL) >> 8 | (value & 0x0000FF0000000000UL) >> 24 |
				(value & 0x00FF000000000000UL) >> 40 | (value & 0xFF00000000000000UL) >> 56;
		}
コード例 #10
0
ファイル: Converter.cs プロジェクト: kevincwq/Cross.Drawing
 public static UInt64 Reverse(UInt64 i)
 {
     return (i & 0x00000000000000FFUL) << 56 | (i & 0x000000000000FF00UL) << 40 |
            (i & 0x0000000000FF0000UL) << 24 | (i & 0x00000000FF000000UL) << 8 |
            (i & 0x000000FF00000000UL) >> 8 | (i & 0x0000FF0000000000UL) >> 24 |
            (i & 0x00FF000000000000UL) >> 40 | (i & 0xFF00000000000000UL) >> 56;
 }
コード例 #11
0
 public Result(UInt64 number, UInt64 skip, UInt64 first, bool includeTotalCount)
 {
     this._number = number;
     this._skip = skip;
     this._first = first;
     this._includeTotalCount = includeTotalCount;
 }
コード例 #12
0
ファイル: ShellcodeTest.cs プロジェクト: killbug2004/unicorn
        public static void RunTest(Byte[] code, UInt64 address)
        {
            var u = new Unicorn(Common.UC_ARCH_X86, Common.UC_MODE_32);
            Console.WriteLine("Unicorn version: {0}", u.Version());

            // map 2MB of memory for this emulation
            Utils.CheckError(u.MemMap(address, new UIntPtr(2 * 1024 * 1024), Common.UC_PROT_ALL));

            // write machine code to be emulated to memory
            Utils.CheckError(u.MemWrite(address, code));

            // initialize machine registers
            Utils.CheckError(u.RegWrite(X86.UC_X86_REG_ESP, Utils.Int64ToBytes(address + 0x200000)));

            // tracing all instructions by having @begin > @end
            Utils.CheckError(u.AddCodeHook(CodeHookCallback, null, 1, 0).Item1);

            // handle interrupt ourself
            Utils.CheckError(u.AddInterruptHook(InterruptHookCallback, null).Item1);

            // handle SYSCALL
            Utils.CheckError(u.AddSyscallHook(SyscallHookCallback, null).Item1);

            Console.WriteLine(">>> Start tracing linux code");

            // emulate machine code in infinite time
            u.EmuStart(address, address + (UInt64)code.Length, 0u, new UIntPtr(0));

            Console.WriteLine(">>> Emulation Done!");
        }
コード例 #13
0
ファイル: CCFileData.cs プロジェクト: CartBlanche/cocos2d-xna
 public bool Reset(string pszFileName, string pszMode)
 {
     m_pBuffer = null;
     m_uSize = 0;
     //m_pBuffer = CCFileUtils.getFileData(pszFileName, pszMode, m_uSize);
     return (m_pBuffer != null) ? true : false;
 }
コード例 #14
0
 public PackageMissingException(string name, string arch, UInt64 version, string publicKeyToken)
 {
     Name = name;
     Arch = arch;
     Version = version;
     PublicKeyToken = publicKeyToken;
 }
コード例 #15
0
 public SftpWriteRequest(uint requestId, byte[] handle, UInt64 offset, byte[] data, Action<SftpStatusResponse> statusAction)
     : base(requestId, statusAction)
 {
     this.Handle = handle;
     this.Offset = offset;
     this.Data = data;
 }
コード例 #16
0
 public static string getAddDepartmentQuery(UInt32 hospitalID, UInt64 departmentID, string departmentName)
 {
     StringBuilder query = new StringBuilder();
     query.Append("Insert into hospital_departments values(").Append(departmentID).Append(", ");
     query.Append(hospitalID).Append(", \'").Append(departmentName).Append("\')");
     return query.ToString();
 }
コード例 #17
0
 public static string getAssignDepartmentToDoctorQuery(UInt64 departmentID, UInt64 doctorID)
 {
     StringBuilder query = new StringBuilder();
     query.Append("Insert into doctors(dr_id, dept_id) values(").Append(doctorID).Append(", ");
     query.Append(departmentID).Append(")");
     return query.ToString();
 }
コード例 #18
0
ファイル: Mdhd.cs プロジェクト: socialpercon/subtitleedit
        public Mdhd(FileStream fs, ulong size)
        {
            Buffer = new byte[size - 4];
            fs.Read(Buffer, 0, Buffer.Length);
            int languageIndex = 20;
            int version = Buffer[0];
            if (version == 0)
            {
                CreationTime = GetUInt(4);
                ModificationTime = GetUInt(8);
                TimeScale = GetUInt(12);
                Duration = GetUInt(16);
                Quality = GetWord(22);
            }
            else
            {
                CreationTime = GetUInt64(4);
                ModificationTime = GetUInt64(12);
                TimeScale = GetUInt(16);
                Duration = GetUInt64(20);
                languageIndex = 24;
                Quality = GetWord(26);
            }

            // language code = skip first byte, 5 bytes + 5 bytes + 5 bytes (add 0x60 to get ascii value)
            int languageByte = ((Buffer[languageIndex] << 1) >> 3) + 0x60;
            int languageByte2 = ((Buffer[languageIndex] & 0x3) << 3) + (Buffer[languageIndex + 1] >> 5) + 0x60;
            int languageByte3 = (Buffer[languageIndex + 1] & 0x1f) + 0x60;
            char x = (char)languageByte;
            char x2 = (char)languageByte2;
            char x3 = (char)languageByte3;
            Iso639ThreeLetterCode = x.ToString(CultureInfo.InvariantCulture) + x2.ToString(CultureInfo.InvariantCulture) + x3.ToString(CultureInfo.InvariantCulture);
        }
コード例 #19
0
ファイル: Partition.cs プロジェクト: ChrisJamesSadler/Cosmos
		public Partition(BlockDevice aHost, UInt64 aStartingSector, UInt64 aSectorCount)
		{
			mHost = aHost;
			mStartingSector = aStartingSector;
			mBlockCount = aSectorCount;
			mBlockSize = aHost.BlockSize;
		}
コード例 #20
0
ファイル: KDate.cs プロジェクト: tmbx/etkwm
 /// <summary>
 /// Translate a Teambox data timestamp to a DateTime object in UTC.
 /// </summary>
 public static DateTime KDateToDateTimeUTC(UInt64 _date)
 {
     DateTime date = new DateTime((long)_date * TimeSpan.TicksPerSecond);
     DateTime epochStartTime = Convert.ToDateTime("1/1/1970 00:00:00 AM");
     TimeSpan t = new TimeSpan(date.Ticks + epochStartTime.Ticks);
     return new DateTime(t.Ticks);
 }
コード例 #21
0
ファイル: ARBGpuProgram.cs プロジェクト: ryan-bunker/axiom3d
		public ARBGpuProgram( ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual,
		                      IManualResourceLoader loader )
			: base( parent, name, handle, group, isManual, loader )
		{
			// generate a new program
			Gl.glGenProgramsARB( 1, out programId );
		}
コード例 #22
0
ファイル: DirectoryEntry.cs プロジェクト: TheByte/sones
        /// <summary>
        /// A constructor of a directory entry setting the internal ObjectStreamsList
        /// to the given ObjectStream and INodePositions.
        /// </summary>
        public DirectoryEntry(String myObjectStream, IEnumerable<ExtendedPosition> myINodePositions)
        {
            #region INodePosition

            _INodePositions = new HashSet<ExtendedPosition>();
            _estimatedSize += EstimatedSizeConstants.HashSet;

            foreach (var aInodePosition in myINodePositions)
            {
                _INodePositions.Add(aInodePosition);
                _estimatedSize += EstimatedSizeConstants.ExtendedPosition;
            }

            #endregion

            #region InlineData

            _InlineData = null;

            #endregion

            #region ObjectStreamList

            _ObjectStreamsList = new HashSet<String> { myObjectStream };

            _estimatedSize += EstimatedSizeConstants.HashSet + EstimatedSizeConstants.Char * EstimatedSizeConstants.EstimatedObjectStreamNameLength;

            #endregion

            _estimatedSize += GetClassBaseSize();
        }
コード例 #23
0
 public ArpGenericData(UInt64 destinationEthernetAddress, ArpOperation arpOperation, UInt64 targetPhysicalAddress, UInt32 targetProtocolAddress)
 {
     this.DestinationEthernetAddress = destinationEthernetAddress;
     this.ArpOperaton = arpOperation;
     this.TargetPhysicalAddress = targetPhysicalAddress;
     this.TargetProtocolAddress = targetProtocolAddress;
 }
コード例 #24
0
ファイル: Tweak.cs プロジェクト: sriramk/nskein
        internal static Tweak EncodeTweak(UInt64 position, bool bitPad, TweakType type, bool first, bool final)
        {
            //
            // Takes tweak parameters and encodes them in a 128 bit value. The lower half of the 128 byte value (only the position)
            // is stuck in low64 and the high half in stuck in high64.
            //
            // N.B SimpleSkeinManaged specifies that position can be upto 2^96 but we support only 2^64. We could add support by rolling our own BigInteger
            //
            // The encoding is as follows (ASCII art not to scale)
            //
            // 128             120                   112            96                                    0
            // --------------------------------------------------------------------------------------------
            // F1|F2|    Type   |B|       TreeLevel   |   reserved  |      Position                       |
            //   |  |           | |                   |             |                                     |
            // --------------------------------------------------------------------------------------------
            //  F1 = First
            //  F2 = Final
            //  B  - BitPad
            //

            Tweak tweak = new Tweak(0,0);
            tweak.high64 = 0;

            //
            // The shift numbers are calculated using 64 - (128 - end-byte-from-diagram-above)
            //
            if (final) tweak.high64 |= (UInt64)1L << 63; // Set F1 in diagram above
            if (first) tweak.high64 |= (UInt64)1L << 62; // Set F2 in diagram above
            tweak.high64 |= (UInt64)type << 56; // Set type
            if (bitPad) tweak.high64 |= (UInt64)1L << 55; // Set bit pad

            tweak.low64 = position;
            return tweak;
        }
コード例 #25
0
 static BtctradeHelper()
 {
     api_key = SQL.get_value("btctrade_api_key");
     secret_key = SQL.get_value("btctrade_secret_key");
     hash_mark = new HMACSHA512(Encoding.ASCII.GetBytes(SQL.get_value("btctrade_hash_key")));
     nonce = UnixTime.unix_now;
 }
コード例 #26
0
ファイル: Account.cs プロジェクト: life02/kbengine-cocos2dx
        public void onRemoveAvatar(UInt64 dbid)
        {
            Dbg.DEBUG_MSG("Account::onRemoveAvatar: dbid=" + dbid);

            avatars.Remove(dbid);
            Event.fire("onRemoveAvatar", new object[]{dbid});
        }
コード例 #27
0
ファイル: RabinFingerPrint.cs プロジェクト: quartz12345/c
 /// <summary>
 /// Compute the fingerprint
 /// </summary>
 /// <param name="source">String to compute</param>
 /// <returns>Hash key</returns>
 public static UInt64 ComputeFingerPrint(string source)
 {
     byte[] table = Encoding.Unicode.GetBytes(source);
     UInt64[] values = new UInt64[table.LongLength];
     ConvertBytes(ref table, ref values);
     return Compute(values);
 }
コード例 #28
0
 internal static object AddImpl(UInt64 left, UInt64 right)
 {
     if (left > UInt64.MaxValue - right) {
         return BigInteger.Create(left) + BigInteger.Create(right);
     }
     return left + right;
 }
コード例 #29
0
ファイル: TTable.cs プロジェクト: abcus/connect4_v2
        // Store entry into TTable
        public void storeTTable(UInt64 key, TTEntry entry)
        {
            int index = (int) (key % Constants.TT_SIZE);

            // If entry in bucket has same hash key, then replace
            for (int i = index; i < index + Constants.BUCKET_SIZE; i++) {
                if (this.transpositionTable[i].key == key) {
                    this.transpositionTable[i] = entry;
                    return;
                }
            }
            // If there is an empty spot in the bucket, then store it there
            for (int i = index; i < index + Constants.BUCKET_SIZE; i++) {
                if (this.transpositionTable[i].key == 0) {
                    this.transpositionTable[i] = entry;
                    return;
                }
            }
            // If all spots full, then replace entry with lowest depth
            int shallowestDepth = Constants.INF;
            int indexOfShallowestEntry = -1;
            for (int i = index; i < index + Constants.BUCKET_SIZE; i++) {
                if (this.transpositionTable[i].depth < shallowestDepth) {
                    shallowestDepth = this.transpositionTable[i].depth;
                    indexOfShallowestEntry = i;
                }
            }
            this.transpositionTable[indexOfShallowestEntry] = entry;
        }
コード例 #30
0
 public WebSocketBinaryFrame(byte[] data, UInt64 pos, UInt64 length, bool isFinal)
 {
     this.Data = data;
     this.Pos = pos;
     this.Length = length;
     this.IsFinal = isFinal;
 }
コード例 #31
0
 static Int rotl(Int x, int k)
 {
     return((x << k) | (x >> (64 - k)));
 }
コード例 #32
0
 void OnMailNextUp(TDBID mailId)
 {
     LoggerHelper.Debug(mailId);
     OnMailGridUp(mailId);
 }
コード例 #33
0
ファイル: ComponentBuffer.cs プロジェクト: raizam/minECS
 public bool Matches(EntFlags flags)
 {
     return((flags & Flag) != 0);
 }
コード例 #34
0
ファイル: ComponentBuffer.cs プロジェクト: raizam/minECS
 public ComponentMatcher(ulong flag)
 {
     Flag = flag;
 }
コード例 #35
0
 private static extern void _gameCenterReportScore(System.Int64 score, System.UInt64 context, string leaderboardId);
コード例 #36
0
 public void SetReceiver(System.UInt64 receiverID, string recevierName)
 {
     m_curReceiver          = receiverID;
     labelReceiverName.text = recevierName;
 }
コード例 #37
0
 public JSONObject AddField(string name, System.UInt64 val)
 {
     return(AddField(name, Create(val)));
 }
コード例 #38
0
 public void Add(System.UInt64 val)
 {
     Add(Create(val));
 }
コード例 #39
0
 void OnDetailMailDeleteUp(TDBID mailId)
 {
     MailManager.Instance.MailDelReq(mailId);
 }
コード例 #40
0
 void OnMailDetailGetItemUp(TDBID mailId)
 {
     MailManager.Instance.MailAttachGetReq(mailId);
 }
コード例 #41
0
 void OnMailGridUp(TDBID mailId)
 {
     LoggerHelper.Debug("MailGridUp " + mailId);
     MailManager.Instance.MailReadReq(mailId);
 }
コード例 #42
0
 void OnDeleteMailGrid(TDBID mailId)
 {
     MailManager.Instance.MailDelReq(mailId);
 }
コード例 #43
0
 /// <summary>
 /// 获取偶像
 /// </summary>
 /// <param name="selfIdol"></param>
 public void SelfIdolResp(TDBID selfIdol)
 {
     SelfIdolTDBID = selfIdol;
 }
コード例 #44
0
ファイル: DictionaryHelper.cs プロジェクト: gitshuaidong/MJ
    public static System.UInt64 ReadUInt64(Dictionary <string, object> inDict, string inVariableName, System.UInt64 inDefaultValue = DefaultInt)
    {
        System.UInt64 returnVal = inDefaultValue;

        if (inDict.ContainsKey(inVariableName) == true)
        {
            returnVal = JSONTools.ReadUInt64(inDict[inVariableName]);
        }

        return(returnVal);
    }
コード例 #45
0
 /// <summary>
 /// 是否可以变更偶像
 /// </summary>
 /// <param name="tdbID"></param>
 void OnIsIdolChangedTodayReq(TDBID tdbID)
 {
     m_bOnChangeIdolReq = false;
     theOwner.RpcCall("IsIdolChangedTodayReq", tdbID);
 }
コード例 #46
0
 /// <summary>
 /// 请求变更偶像
 /// </summary>
 /// <param name="tdbID"></param>
 void OnChangeIdolReq(TDBID tdbID)
 {
     m_bOnChangeIdolReq = true;
     theOwner.RpcCall("ChangeIdolReq", tdbID);
 }
コード例 #47
0
ファイル: LoginProxy.cs プロジェクト: Avatarchik/card
 public void selectAvatarGame(System.UInt64 dbid)
 {
     GameProxy.Instance.GotoMainCity();
 }
コード例 #48
0
 /// <summary>
 /// 请求玩家数据
 /// </summary>
 /// <param name="tdbID"></param>
 void OnRankAvatarInfoReq(TDBID tdbID)
 {
     MogoGlobleUIManager.Instance.ShowWaitingTip(true);
     theOwner.RpcCall("RankAvatarInfoReq", tdbID);
 }
コード例 #49
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern Int GetTime(LinkIndex link);
コード例 #50
0
 public void setIndex(System.UInt64 _Index)
 {
     Index = _Index;
 }
コード例 #51
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern LinkIndex UpdateLink(LinkIndex link, LinkIndex newSource, LinkIndex newLinker, LinkIndex newTarget);
コード例 #52
0
ファイル: Helpers.cs プロジェクト: nam2608/Pkcs11Interop
        /// <summary>
        /// Generates asymetric key pair.
        /// </summary>
        /// <param name='pkcs11'>Initialized PKCS11 wrapper</param>
        /// <param name='session'>Read-write session with user logged in</param>
        /// <param name='pubKeyId'>Output parameter for public key object handle</param>
        /// <param name='privKeyId'>Output parameter for private key object handle</param>
        /// <returns>Return value of C_GenerateKeyPair</returns>
        public static CKR GenerateKeyPair(Pkcs11 pkcs11, NativeULong session, ref NativeULong pubKeyId, ref NativeULong privKeyId)
        {
            CKR rv = CKR.CKR_OK;

            // The CKA_ID attribute is intended as a means of distinguishing multiple key pairs held by the same subject
            byte[] ckaId = new byte[20];
            rv = pkcs11.C_GenerateRandom(session, ckaId, ConvertUtils.UInt64FromInt32(ckaId.Length));
            if (rv != CKR.CKR_OK)
            {
                return(rv);
            }

            // Prepare attribute template of new public key
            CK_ATTRIBUTE[] pubKeyTemplate = new CK_ATTRIBUTE[10];
            pubKeyTemplate[0] = CkaUtils.CreateAttribute(CKA.CKA_TOKEN, true);
            pubKeyTemplate[1] = CkaUtils.CreateAttribute(CKA.CKA_PRIVATE, false);
            pubKeyTemplate[2] = CkaUtils.CreateAttribute(CKA.CKA_LABEL, Settings.ApplicationName);
            pubKeyTemplate[3] = CkaUtils.CreateAttribute(CKA.CKA_ID, ckaId);
            pubKeyTemplate[4] = CkaUtils.CreateAttribute(CKA.CKA_ENCRYPT, true);
            pubKeyTemplate[5] = CkaUtils.CreateAttribute(CKA.CKA_VERIFY, true);
            pubKeyTemplate[6] = CkaUtils.CreateAttribute(CKA.CKA_VERIFY_RECOVER, true);
            pubKeyTemplate[7] = CkaUtils.CreateAttribute(CKA.CKA_WRAP, true);
            pubKeyTemplate[8] = CkaUtils.CreateAttribute(CKA.CKA_MODULUS_BITS, 1024);
            pubKeyTemplate[9] = CkaUtils.CreateAttribute(CKA.CKA_PUBLIC_EXPONENT, new byte[] { 0x01, 0x00, 0x01 });

            // Prepare attribute template of new private key
            CK_ATTRIBUTE[] privKeyTemplate = new CK_ATTRIBUTE[9];
            privKeyTemplate[0] = CkaUtils.CreateAttribute(CKA.CKA_TOKEN, true);
            privKeyTemplate[1] = CkaUtils.CreateAttribute(CKA.CKA_PRIVATE, true);
            privKeyTemplate[2] = CkaUtils.CreateAttribute(CKA.CKA_LABEL, Settings.ApplicationName);
            privKeyTemplate[3] = CkaUtils.CreateAttribute(CKA.CKA_ID, ckaId);
            privKeyTemplate[4] = CkaUtils.CreateAttribute(CKA.CKA_SENSITIVE, true);
            privKeyTemplate[5] = CkaUtils.CreateAttribute(CKA.CKA_DECRYPT, true);
            privKeyTemplate[6] = CkaUtils.CreateAttribute(CKA.CKA_SIGN, true);
            privKeyTemplate[7] = CkaUtils.CreateAttribute(CKA.CKA_SIGN_RECOVER, true);
            privKeyTemplate[8] = CkaUtils.CreateAttribute(CKA.CKA_UNWRAP, true);

            // Specify key generation mechanism (needs no parameter => no unamanaged memory is needed)
            CK_MECHANISM mechanism = CkmUtils.CreateMechanism(CKM.CKM_RSA_PKCS_KEY_PAIR_GEN);

            // Generate key pair
            rv = pkcs11.C_GenerateKeyPair(session, ref mechanism, pubKeyTemplate, ConvertUtils.UInt64FromInt32(pubKeyTemplate.Length), privKeyTemplate, ConvertUtils.UInt64FromInt32(privKeyTemplate.Length), ref pubKeyId, ref privKeyId);

            // In LowLevelAPI we have to free unmanaged memory taken by attributes
            for (int i = 0; i < privKeyTemplate.Length; i++)
            {
                UnmanagedMemory.Free(ref privKeyTemplate[i].value);
                privKeyTemplate[i].valueLen = 0;
            }

            for (int i = 0; i < pubKeyTemplate.Length; i++)
            {
                UnmanagedMemory.Free(ref pubKeyTemplate[i].value);
                pubKeyTemplate[i].valueLen = 0;
            }

            return(rv);
        }
コード例 #53
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern void SetMappedLink(Int mappedIndex, LinkIndex linkIndex);
コード例 #54
0
ファイル: Helpers.cs プロジェクト: nam2608/Pkcs11Interop
        /// <summary>
        /// Finds slot containing the token that matches criteria specified in Settings class
        /// </summary>
        /// <param name='pkcs11'>Initialized PKCS11 wrapper</param>
        /// <returns>Slot containing the token that matches criteria</returns>
        public static NativeULong GetUsableSlot(Pkcs11 pkcs11)
        {
            CKR rv = CKR.CKR_OK;

            // Get list of available slots with token present
            NativeULong slotCount = 0;

            rv = pkcs11.C_GetSlotList(true, null, ref slotCount);
            if (rv != CKR.CKR_OK)
            {
                Assert.Fail(rv.ToString());
            }

            Assert.IsTrue(slotCount > 0);

            NativeULong[] slotList = new NativeULong[slotCount];

            rv = pkcs11.C_GetSlotList(true, slotList, ref slotCount);
            if (rv != CKR.CKR_OK)
            {
                Assert.Fail(rv.ToString());
            }

            // Return first slot with token present when both TokenSerial and TokenLabel are null...
            if (Settings.TokenSerial == null && Settings.TokenLabel == null)
            {
                return(slotList[0]);
            }

            // First slot with token present is OK...
            NativeULong?matchingSlot = slotList[0];

            // ...unless there are matching criteria specified in Settings class
            if (Settings.TokenSerial != null || Settings.TokenLabel != null)
            {
                matchingSlot = null;

                foreach (NativeULong slot in slotList)
                {
                    CK_TOKEN_INFO tokenInfo = new CK_TOKEN_INFO();
                    rv = pkcs11.C_GetTokenInfo(slot, ref tokenInfo);
                    if (rv != CKR.CKR_OK)
                    {
                        if (rv == CKR.CKR_TOKEN_NOT_RECOGNIZED || rv == CKR.CKR_TOKEN_NOT_PRESENT)
                        {
                            continue;
                        }
                        else
                        {
                            Assert.Fail(rv.ToString());
                        }
                    }

                    if (!string.IsNullOrEmpty(Settings.TokenSerial))
                    {
                        if (0 != string.Compare(Settings.TokenSerial, ConvertUtils.BytesToUtf8String(tokenInfo.SerialNumber, true), StringComparison.Ordinal))
                        {
                            continue;
                        }
                    }

                    if (!string.IsNullOrEmpty(Settings.TokenLabel))
                    {
                        if (0 != string.Compare(Settings.TokenLabel, ConvertUtils.BytesToUtf8String(tokenInfo.Label, true), StringComparison.Ordinal))
                        {
                            continue;
                        }
                    }

                    matchingSlot = slot;
                    break;
                }
            }

            Assert.IsTrue(matchingSlot != null, "Token matching criteria specified in Settings class is not present");
            return(matchingSlot.Value);
        }
コード例 #55
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern LinkIndex CreateLink(LinkIndex source, LinkIndex linker, LinkIndex target);
コード例 #56
0
 public static extern IntPtr gst_app_sink_try_pull_sample(IntPtr appsink,
                                                          GstClockTime timeout);
コード例 #57
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern LinkIndex ReplaceLink(LinkIndex link, LinkIndex replacement);
コード例 #58
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern LinkIndex SearchLink(LinkIndex source, LinkIndex linker, LinkIndex target);
コード例 #59
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern LinkIndex GetFirstRefererByTargetIndex(LinkIndex link);
コード例 #60
0
ファイル: Link.cs プロジェクト: linksplatform/Data.Triplets
 private static extern void DeleteLink(LinkIndex link);