コード例 #1
0
        private static KeyMarker GetKeyMarker(BigInteger modulus)
        {
            lock (markers)
            {
                KeyMarker marker;
                WeakReference <KeyMarker> existingRef;
                if (markers.TryGetValue(modulus, out existingRef))
                {
                    if (existingRef.TryGetTarget(out marker))
                    {
                        return(marker);
                    }

                    marker = new KeyMarker(modulus);
                    existingRef.SetTarget(marker);
                }
                else
                {
                    marker = new KeyMarker(modulus);
                    markers.Add(modulus, new WeakReference <KeyMarker>(marker));
                }

                return(marker);
            }
        }
コード例 #2
0
 internal AsymmetricRsaKey(Algorithm algorithm, BigInteger modulus)
 {
     this.approvedModeOnly = CryptoServicesRegistrar.IsInApprovedOnlyMode();
     this.algorithm        = algorithm;
     this.keyMarker        = GetKeyMarker(modulus);
     this.modulus          = keyMarker.modulus;
     this.rsaAlgIdentifier = DEF_ALG_ID;
 }
コード例 #3
0
    void GenerateKeysToParts()
    {
        for (int i = 0; i < attachedParts.Count; i++)
        {
            if (attachedParts [i].interactive)
            {
                KeyCode        keyToUse = GenerateRandomKeyCode();
                AttachablePart part     = attachedParts[i];

                activeParts.Add(new Part(keyToUse, part));
                GameObject keyMarker = Instantiate(keyMarkerCanvas, attachedParts [i].transform.position, Quaternion.identity) as GameObject;
                keyMarker.transform.SetParent(attachedParts [i].gameObject.transform);
                keyMarker.transform.localPosition = new Vector3(0f, 0f, 2.0f);
                KeyMarker keyMark = keyMarker.GetComponent <KeyMarker>();
                keyMark.markerText.text = keyToUse.ToString();

                if (part is Thruster)
                {
                    Thruster thruster = (Thruster)part;

                    // Lateral thrusters will have x or y thrust
                    if (thruster.thrustAxis.x != 0 || thruster.thrustAxis.y != 0)
                    {
                        keyMark.markerText.color = Color.yellow;
                    }
                    else
                    {
                        keyMark.markerText.color = Color.green;
                    }
                }
                else if (part is TurretScript)
                {
                    keyMark.markerText.color = Color.red;
                }
            }
        }
    }
コード例 #4
0
        internal AsymmetricRsaKey(Algorithm algorithm, AlgorithmIdentifier rsaAlgIdentifier, BigInteger modulus)
        {
            DerObjectIdentifier keyAlgorithm = rsaAlgIdentifier.Algorithm;

            if (!rsaOids.Contains(keyAlgorithm))
            {
                throw new ArgumentException("Unknown algorithm type: " + keyAlgorithm);
            }

            this.approvedModeOnly = CryptoServicesRegistrar.IsInApprovedOnlyMode();
            this.algorithm        = algorithm;
            this.rsaAlgIdentifier = rsaAlgIdentifier;
            this.keyMarker        = GetKeyMarker(modulus);
            this.modulus          = keyMarker.modulus;

            if (keyAlgorithm.Equals(PkcsObjectIdentifiers.IdRsassaPss))
            {
                keyMarker.CanBeUsed(Usage.SignOrVerify);
            }
            else if (keyAlgorithm.Equals(PkcsObjectIdentifiers.IdRsaesOaep))
            {
                keyMarker.CanBeUsed(Usage.EncryptOrDecrypt);
            }
        }