/// <summary>
        /// Sets the binder for a slot.
        /// </summary>
        /// <param name="slot">The slot.</param>
        /// <param name="binder">The binder.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="slot"/>
        /// or <paramref name="binder"/> is null.</exception>
        public void SetSlotBinder(ISlotInfo slot, IDataBinder binder)
        {
            if (slot == null)
                throw new ArgumentNullException("slot");
            if (binder == null)
                throw new ArgumentNullException("binder");

            slotBinders[slot] = binder;
        }
Beispiel #2
0
        public void _02_BasicSlotListAndInfoTest()
        {
            using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType))
            {
                // Get list of available slots
                List <ISlot> slots = pkcs11Library.GetSlotList(SlotsType.WithOrWithoutTokenPresent);

                // Do something interesting with slots
                Assert.IsNotNull(slots);
                Assert.IsTrue(slots.Count > 0);

                // Analyze first slot
                ISlotInfo slotInfo = slots[0].GetSlotInfo();

                // Do something interesting with slot info
                Assert.IsNotNull(slotInfo.ManufacturerId);
            }
        }
Beispiel #3
0
        public void AddSaveRecord(string saveFile)
        {
            BuildLookup();

            ISlotInfo slotInfo = GameObject.FindGameObjectWithTag("Player").GetComponent <ISlotInfo>();
            var       state    = (Dictionary <string, string>)slotInfo.CaptureState();

            SaveRecord newRecord = new SaveRecord();

            newRecord.playerName = state["name"];
            newRecord.rank       = state["rank"];
            newRecord.time       = state["time"];
            newRecord.quest      = state["quest"];
            newRecord.location   = state["location"];
            newRecord.scene      = state["scene"];

            saveLookup[saveFile] = newRecord;
        }
Beispiel #4
0
        public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
        {
            if (!checkBox2.Checked || !Remote.Bot.Connected)
            {
                return;
            }
            if (slot is not SlotInfoBox b)
            {
                return;
            }
            if (!type.IsContentChange())
            {
                return;
            }
            int box     = b.Box;
            int slotpkm = b.Slot;

            Remote.Bot.SendSlot(RamOffsets.WriteBoxData(Remote.Bot.Version) ? pkm.EncryptedBoxData : pkm.EncryptedPartyData, box, slotpkm);
        }
Beispiel #5
0
    public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk)
    {
        int index = GetViewIndex(slot);

        if (index < 0)
        {
            return;
        }

        if (type == SlotTouchType.Delete)
        {
            ResetSlots();
            return;
        }

        var pb = SlotPictureBoxes[index];

        SlotUtil.UpdateSlot(pb, slot, pk, SAV, FlagIllegal, type);
    }
Beispiel #6
0
        public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
        {
            if (!checkBox2.Checked || !Remote.Bot.Connected)
            {
                return;
            }
            if (!(slot is SlotInfoBox b))
            {
                return;
            }
            if (!type.IsContentChange())
            {
                return;
            }
            int box     = b.Box;
            int slotpkm = b.Slot;

            Remote.Bot.SendSlot(pkm.EncryptedPartyData, box, slotpkm);
        }
Beispiel #7
0
        public void AddSaveRecord(string saveFile)
        {
            if (saveLookup == null)
            {
                BuildLookup();
            }

            ISlotInfo slotInfo = GameObject.FindGameObjectWithTag("GameController").GetComponent <ISlotInfo>();
            var       state    = (Dictionary <string, string>)slotInfo.CaptureState();

            SaveRecord newRecord = new SaveRecord();

            newRecord.playerName = state["name"];
            newRecord.money      = state["money"];
            newRecord.energy     = state["energy"];
            newRecord.location   = state["location"];
            newRecord.scene      = state["scene"];

            saveLookup[saveFile] = newRecord;
        }
Beispiel #8
0
        public PgpSignature(ISlotInfo SlotInfo, byte[] abId, PgpKeyFlags.nFlags eKeyFlags, byte[] abModulus, byte[] abExponent, EncryptionServices Cryptography) : base(nPacketTag.Signature)
        {
            PgpSignatureSubpacket NewSubpacket;

            Initialise((eKeyFlags & PgpKeyFlags.nFlags.Sign) == 0 ? nSignatureType.SubkeyBinding : nSignatureType.PositiveCertification);

            if ((SlotInfo == null) || (abId == null) || (abModulus == null) || (abExponent == null) || (Cryptography == null))
            {
                _eStatus = nStatus.MissingArgument;
            }
            else
            {
                _eStatus         = nStatus.OK;
                _Cryptography    = Cryptography;
                _PublicKeyPacket = new PgpPublicKey(SlotInfo, abId, (eKeyFlags & PgpKeyFlags.nFlags.Sign) == 0 ? nPacketTag.PublicSubkey : nPacketTag.PublicKey, DateTime.Now, nPublicKeyAlgorithm.RsaEncryptOrSign, abModulus, abExponent);

                NewSubpacket = new PgpKeyFlags(eKeyFlags);
                _ltSubpackets.Add(NewSubpacket);
                _eTranslatedKeyFlags = TranslateKeyFlags();
            }
        }
        /// <summary>
        /// Obtains a list of all PKCS#11 URI matching slots
        /// </summary>
        /// <param name="pkcs11Uri">PKCS#11 URI</param>
        /// <param name="pkcs11Library">High level PKCS#11 wrapper</param>
        /// <param name="slotsType">Type of slots to be obtained</param>
        /// <returns>List of slots matching PKCS#11 URI</returns>
        public static List<ISlot> GetMatchingSlotList(Pkcs11Uri pkcs11Uri, IPkcs11Library pkcs11Library, SlotsType slotsType)
        {
            if (pkcs11Uri == null)
                throw new ArgumentNullException("pkcs11Uri");

            if (pkcs11Library == null)
                throw new ArgumentNullException("pkcs11Library");

            List<ISlot> matchingSlots = new List<ISlot>();

            ILibraryInfo libraryInfo = pkcs11Library.GetInfo();
            if (!Matches(pkcs11Uri, libraryInfo))
                return matchingSlots;

            List<ISlot> slots = pkcs11Library.GetSlotList(SlotsType.WithOrWithoutTokenPresent);
            if ((slots == null) || (slots.Count == 0))
                return matchingSlots;

            foreach (ISlot slot in slots)
            {
                ISlotInfo slotInfo = slot.GetSlotInfo();
                if (Matches(pkcs11Uri, slotInfo))
                {
                    if (slotInfo.SlotFlags.TokenPresent)
                    {
                        ITokenInfo tokenInfo = slot.GetTokenInfo();
                        if (Matches(pkcs11Uri, tokenInfo))
                            matchingSlots.Add(slot);
                    }
                    else
                    {
                        if (slotsType == SlotsType.WithOrWithoutTokenPresent && Pkcs11UriSharedUtils.Matches(pkcs11Uri, null, null, null, null))
                            matchingSlots.Add(slot);
                    }
                }
            }

            return matchingSlots;
        }
Beispiel #10
0
 public SlotViewInfo(ISlotInfo slot, ISlotViewer <T> view)
 {
     Slot = slot;
     View = view;
 }
Beispiel #11
0
 public PartyReversion(ISlotInfo info, SaveFile s) : base(info) => Party = s.PartyData;
Beispiel #12
0
 public SingleSlotReversion(ISlotInfo info, SaveFile sav) : base(info) => PKM = info.Read(sav);
 /// <summary>
 /// Verifies that the attribute is being used correctly.
 /// </summary>
 /// <param name="scope">The scope.</param>
 /// <param name="slot">The slot.</param>
 /// <exception cref="PatternUsageErrorException">Thrown if the attribute is being used incorrectly.</exception>
 protected virtual void Validate(IPatternScope scope, ISlotInfo slot)
 {
     if (!scope.IsTestParameterDeclaration || slot == null)
         ThrowUsageErrorException("This attribute can only be used on a test parameter.");
 }
Beispiel #14
0
 protected SlotReversion(ISlotInfo info) => Info = info;
Beispiel #15
0
 private void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm) => Publisher.NotifySlotChanged(slot, type, pkm);
 /// <summary>
 /// Applies decorations to a <see cref="PatternTestParameter" />.
 /// </summary>
 /// <remarks>
 /// <para>
 /// A typical use of this method is to augment the test parameter with additional metadata
 /// or to add additional behaviors to the test parameter.
 /// </para>
 /// </remarks>
 /// <param name="slotScope">The slot scope.</param>
 /// <param name="slot">The slot.</param>
 protected virtual void DecorateTestParameter(IPatternScope slotScope, ISlotInfo slot)
 {
 }
        /// <summary>
        /// Initializes a test parameter after it has been added to the containing test.
        /// </summary>
        /// <param name="testParameterScope">The test parameter scope.</param>
        /// <param name="slot">The slot.</param>
        protected virtual void InitializeTestParameter(IPatternScope testParameterScope, ISlotInfo slot)
        {
            int index = slot.Position;
            var parameter = slot as IParameterInfo;
            if (parameter != null)
            {
                // For generic methods, we offset the position of the parameter
                // by the number of generic method parameters.  That way
                // we can assign each parameter in the method a unique index
                // by reading all parameters left to right, starting with the
                // generic parameters and moving onwards to the method parameters.
                IMethodInfo method = parameter.Member as IMethodInfo;
                if (method != null && method.IsGenericMethodDefinition)
                    index += method.GenericArguments.Count;
            }
            testParameterScope.TestDataContextBuilder.ImplicitDataBindingIndexOffset = index;

            string xmlDocumentation = slot.GetXmlDocumentation();
            if (xmlDocumentation != null)
                testParameterScope.TestParameterBuilder.AddMetadata(MetadataKeys.XmlDocumentation, xmlDocumentation);

            testParameterScope.TestParameterBuilder.TestParameterActions.BindTestParameterChain.After((state, value) =>
            {
                state.SlotValues.Add(slot, value);
            });

            testParameterScope.Process(slot);
        }
Beispiel #18
0
        public void ListForTreeview()
        {
            try
            {
                Node Tree = new Node();

                // Show general information about loaded library
                ILibraryInfo libraryInfo = PKCS11Library.GetInfo();
                Node         Library     = new Node()
                {
                    Header = "PKCS11 Library " + libraryInfo.LibraryDescription, IconURI = "resm:PKCS11Explorer.Assets.baseline_layers_grey_18dp.png"
                };
                Library.Children.Add(new Node()
                {
                    Header = "Filepath: " + LibraryFilePath, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                });
                Library.Children.Add(new Node()
                {
                    Header = "Manufacturer: " + libraryInfo.ManufacturerId, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                });
                Library.Children.Add(new Node()
                {
                    Header = "Description: " + libraryInfo.LibraryDescription, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                });
                Library.Children.Add(new Node()
                {
                    Header = "Version: " + libraryInfo.LibraryVersion, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                });
                var assets = AvaloniaLocator.Current.GetService <IAssetLoader>();
                Tree.Children.Add(Library);
                // Get list of all available slots
                foreach (ISlot slot in PKCS11Library.GetSlotList(SlotsType.WithOrWithoutTokenPresent))
                {
                    // Show basic information about slot
                    ISlotInfo slotInfo = slot.GetSlotInfo();
                    Node      Slot;
                    if (slotInfo.SlotFlags.TokenPresent)
                    {
                        Slot = new Node()
                        {
                            Header = "Slot " + slot.GetSlotInfo().SlotId, IconURI = "resm:PKCS11Explorer.Assets.baseline_scanner_green_18dp.png"
                        }
                    }
                    ;
                    else
                    {
                        Slot = new Node()
                        {
                            Header = "Slot " + slot.GetSlotInfo().SlotId, IconURI = "resm:PKCS11Explorer.Assets.baseline_scanner_red_18dp.png"
                        }
                    };
                    Slot.Children.Add(new Node()
                    {
                        Header = "Manufacturer: " + slotInfo.ManufacturerId, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                    });
                    Slot.Children.Add(new Node()
                    {
                        Header = "Description: " + slotInfo.SlotDescription, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                    });
                    Slot.Children.Add(new Node()
                    {
                        Header = "Token present: " + slotInfo.SlotFlags.TokenPresent, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                    });

                    if (slotInfo.SlotFlags.TokenPresent)
                    {
                        // Show basic information about token present in the slot
                        ITokenInfo tokenInfo = slot.GetTokenInfo();

                        Node Token = new Node()
                        {
                            Header = "Token " + tokenInfo.SerialNumber, IconURI = "resm:PKCS11Explorer.Assets.baseline_sim_card_green_18dp.png"
                        };
                        Token.Children.Add(new Node()
                        {
                            Header = "Manufacturer: " + tokenInfo.ManufacturerId, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                        });
                        Token.Children.Add(new Node()
                        {
                            Header = "Model: " + tokenInfo.Model, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                        });
                        Token.Children.Add(new Node()
                        {
                            Header = "Serial number: " + tokenInfo.SerialNumber, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                        });
                        Token.Children.Add(new Node()
                        {
                            Header = "Label: " + tokenInfo.Label, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_blue_18dp.png"
                        });

                        /*
                         * if (tokenInfo.FreePublicMemory != uint.MaxValue)
                         *  Token.Children.Add(new Node() { Header = "Available public objects memory: " + tokenInfo.FreePublicMemory + " / " + tokenInfo.TotalPublicMemory, IconURI = "resm:PKCS11Explorer.Assets.baseline_memory_black_18dp.png" });
                         * if (tokenInfo.TotalPrivateMemory != uint.MaxValue)
                         *  Token.Children.Add(new Node() { Header = "Available private objects memory: " + tokenInfo.FreePrivateMemory + " / " + tokenInfo.TotalPrivateMemory, IconURI = "resm:PKCS11Explorer.Assets.baseline_memory_black_18dp.png" });
                         */

                        // Show public keys name
                        Node pubkeyNode = new Node()
                        {
                            Header = "Public keys", IconURI = "resm:PKCS11Explorer.Assets.baseline_search_grey_18dp.png"
                        };
                        using (ISession session = slot.OpenSession(SessionType.ReadOnly))
                        {
                            // Do something interesting in RO session
                            var attrList = new List <IObjectAttribute>();
                            attrList.Add(Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_PUBLIC_KEY));
                            attrList.Add(Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true));
                            var objects = session.FindAllObjects(attrList);
                            foreach (var obj in objects)
                            {
                                if (obj.ObjectId != CK.CK_INVALID_HANDLE)
                                {
                                    var        objectHandle = Factories.ObjectHandleFactory.Create(obj.ObjectId);
                                    List <CKA> attributes   = new List <CKA>();
                                    attributes.Add(CKA.CKA_LABEL);
                                    List <IObjectAttribute> objectAttributes = session.GetAttributeValue(objectHandle, attributes);
                                    pubkeyNode.Children.Add(new Node()
                                    {
                                        Header = objectAttributes[0].GetValueAsString(), IconURI = "resm:PKCS11Explorer.Assets.baseline_vpn_key_green_18dp.png"
                                    });
                                    Console.WriteLine("Found: " + objectAttributes[0].GetValueAsString());
                                }
                            }
                            session.CloseSession();
                        }
                        Token.Children.Add(pubkeyNode);


                        // Show private keys name

                        /*Node privkeyNode = new Node() { Header = "Private keys", IconURI = "resm:PKCS11Explorer.Assets.baseline_search_black_18dp.png" };
                         * using (ISession session = slot.OpenSession(SessionType.ReadOnly))
                         * {
                         *  session.Login(CKU.CKU_USER, "");
                         *  // Do something interesting in RO session
                         *  var attrList = new List<IObjectAttribute>();
                         *  attrList.Add(factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_PRIVATE_KEY));
                         *  attrList.Add(factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true));
                         *  var objects = session.FindAllObjects(attrList);
                         *  foreach (var obj in objects)
                         *  {
                         *      if (obj.ObjectId != CK.CK_INVALID_HANDLE)
                         *      {
                         *          var objectHandle = factories.ObjectHandleFactory.Create(obj.ObjectId);
                         *          List<CKA> attributes = new List<CKA>();
                         *          attributes.Add(CKA.CKA_LABEL);
                         *          List<IObjectAttribute> objectAttributes = session.GetAttributeValue(objectHandle, attributes);
                         *          privkeyNode.Children.Add(new Node() { Header = objectAttributes[0].GetValueAsString(), IconURI = "resm:PKCS11Explorer.Assets.baseline_vpn_key_black_18dp.png" });
                         *          Console.WriteLine("Found: " + objectAttributes[0].GetValueAsString());
                         *      }
                         *  }
                         *  session.Logout();
                         *  session.CloseSession();
                         * }
                         * Token.Children.Add(privkeyNode);
                         */

                        // Show certs name
                        Node certsNode = new Node()
                        {
                            Header = "Certificates", IconURI = "resm:PKCS11Explorer.Assets.baseline_search_grey_18dp.png"
                        };
                        using (ISession session = slot.OpenSession(SessionType.ReadOnly))
                        {
                            // Do something interesting in RO session
                            var attrList = new List <IObjectAttribute>();
                            attrList.Add(Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_CERTIFICATE));
                            attrList.Add(Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true));
                            var objects = session.FindAllObjects(attrList);
                            foreach (var obj in objects)
                            {
                                if (obj.ObjectId != CK.CK_INVALID_HANDLE)
                                {
                                    var        objectHandle = Factories.ObjectHandleFactory.Create(obj.ObjectId);
                                    List <CKA> attributes   = new List <CKA>();
                                    attributes.Add(CKA.CKA_LABEL);
                                    List <IObjectAttribute> objectAttributes = session.GetAttributeValue(objectHandle, attributes);
                                    certsNode.Children.Add(new Node()
                                    {
                                        Header = objectAttributes[0].GetValueAsString(), IconURI = "resm:PKCS11Explorer.Assets.baseline_list_alt_green_18dp.png"
                                    });
                                    Console.WriteLine("Found: " + objectAttributes[0].GetValueAsString());
                                }
                            }
                            session.CloseSession();
                        }
                        Token.Children.Add(certsNode);


                        // Show list of mechanisms (algorithms) supported by the token
                        Node SupportedMechanisms = new Node()
                        {
                            Header = "Supported mechanisms", IconURI = "resm:PKCS11Explorer.Assets.baseline_memory_grey_18dp.png"
                        };
                        foreach (CKM mechanism in slot.GetMechanismList())
                        {
                            SupportedMechanisms.Children.Add(new Node()
                            {
                                Header = mechanism.ToString(), IconURI = "resm:PKCS11Explorer.Assets.baseline_check_circle_green_18dp.png"
                            });
                        }
                        Token.Children.Add(SupportedMechanisms);
                        Slot.Children.Add(Token);
                    }
                    Assert.AssertTrue(slot.GetTokenInfo().RwSessionCount == 0);
                    Assert.AssertTrue(slot.GetTokenInfo().SessionCount == 0);
                    Tree.Children.Add(Slot);
                }
                ListForTreeviewFinished?.Invoke(Tree, new ListForTreeviewEventArgs()
                {
                    MainNode = Tree, Success = true
                });
            }
            catch (Net.Pkcs11Interop.Common.UnmanagedException exception)
            {
                ListForTreeviewFinished?.Invoke(exception, new ListForTreeviewEventArgs()
                {
                    UnmanagedException = exception, Success = false
                });
            }
            catch (Net.Pkcs11Interop.Common.Pkcs11Exception exception)
            {
                ListForTreeviewFinished?.Invoke(exception, new ListForTreeviewEventArgs()
                {
                    Pkcs11Exception = exception, Success = false
                });
            }
            return;
        }
Beispiel #19
0
 public void NotifySlotOld(ISlotInfo previous)
 {
 }
Beispiel #20
0
 public int GetViewIndex(ISlotInfo slot) => - 1;
 /// <summary>
 /// Verifies that the attribute is being used correctly.
 /// </summary>
 /// <param name="containingScope">The containing scope.</param>
 /// <param name="slot">The slot.</param>
 /// <exception cref="PatternUsageErrorException">Thrown if the attribute is being used incorrectly.</exception>
 protected virtual void Validate(IPatternScope containingScope, ISlotInfo slot)
 {
     if (!containingScope.CanAddTestParameter || slot == null)
         ThrowUsageErrorException("This attribute can only be used on a test parameter.");
 }
Beispiel #22
0
    public string SignWithCMS(String serializedJson)
    {
        byte[] data = Encoding.UTF8.GetBytes(serializedJson);
        Pkcs11InteropFactories factories = new Pkcs11InteropFactories();

        using (IPkcs11Library pkcs11Library = factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, DllLibPath, AppType.MultiThreaded))
        {
            ISlot slot = pkcs11Library.GetSlotList(SlotsType.WithTokenPresent).FirstOrDefault();

            if (slot is null)
            {
                return("No slots found");
            }

            ITokenInfo tokenInfo = slot.GetTokenInfo();

            ISlotInfo slotInfo = slot.GetSlotInfo();


            using (var session = slot.OpenSession(SessionType.ReadWrite))
            {
                session.Login(CKU.CKU_USER, Encoding.UTF8.GetBytes(TokenPin));

                var certificateSearchAttributes = new List <IObjectAttribute>()
                {
                    session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_CERTIFICATE),
                    session.Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true),
                    session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CERTIFICATE_TYPE, CKC.CKC_X_509)
                };

                IObjectHandle certificate = session.FindAllObjects(certificateSearchAttributes).FirstOrDefault();

                if (certificate is null)
                {
                    return("Certificate not found");
                }

                X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                store.Open(OpenFlags.MaxAllowed);

                // find cert by thumbprint
                var foundCerts = store.Certificates.Find(X509FindType.FindByIssuerName, TokenCertificate, false);

                //var foundCerts = store.Certificates.Find(X509FindType.FindBySerialNumber, "2b1cdda84ace68813284519b5fb540c2", true);



                if (foundCerts.Count == 0)
                {
                    return("no device detected");
                }

                var certForSigning = foundCerts[0];
                store.Close();


                ContentInfo content = new ContentInfo(new Oid("1.2.840.113549.1.7.5"), data);


                SignedCms cms = new SignedCms(content, true);

                EssCertIDv2 bouncyCertificate = new EssCertIDv2(new Org.BouncyCastle.Asn1.X509.AlgorithmIdentifier(new DerObjectIdentifier("1.2.840.113549.1.9.16.2.47")), this.HashBytes(certForSigning.RawData));

                SigningCertificateV2 signerCertificateV2 = new SigningCertificateV2(new EssCertIDv2[] { bouncyCertificate });


                CmsSigner signer = new CmsSigner(certForSigning);

                signer.DigestAlgorithm = new Oid("2.16.840.1.101.3.4.2.1");



                signer.SignedAttributes.Add(new Pkcs9SigningTime(DateTime.UtcNow));
                signer.SignedAttributes.Add(new AsnEncodedData(new Oid("1.2.840.113549.1.9.16.2.47"), signerCertificateV2.GetEncoded()));


                cms.ComputeSignature(signer);

                var output = cms.Encode();

                return(Convert.ToBase64String(output));
            }
        }
    }
Beispiel #23
0
        /// <inheritdoc />
        protected override void DecorateTestParameter(IPatternScope slotScope, ISlotInfo slot)
        {
            var binding = new DataBinding(index, path);

            slotScope.TestParameterBuilder.Binder = new ScalarDataBinder(binding, Source ?? @"");
        }
Beispiel #24
0
 public int GetViewIndex(ISlotInfo info) => SlotOffsets.FindIndex(info.Equals);
        /// <summary>
        /// Initializes a test parameter after it has been added to the containing test.
        /// </summary>
        /// <param name="testParameterScope">The test parameter scope.</param>
        /// <param name="slot">The slot.</param>
        protected virtual void InitializeTestParameter(IPatternScope testParameterScope, ISlotInfo slot)
        {
            int index     = slot.Position;
            var parameter = slot as IParameterInfo;

            if (parameter != null)
            {
                // For generic methods, we offset the position of the parameter
                // by the number of generic method parameters.  That way
                // we can assign each parameter in the method a unique index
                // by reading all parameters left to right, starting with the
                // generic parameters and moving onwards to the method parameters.
                IMethodInfo method = parameter.Member as IMethodInfo;
                if (method != null && method.IsGenericMethodDefinition)
                {
                    index += method.GenericArguments.Count;
                }
            }
            testParameterScope.TestDataContextBuilder.ImplicitDataBindingIndexOffset = index;

            string xmlDocumentation = slot.GetXmlDocumentation();

            if (xmlDocumentation != null)
            {
                testParameterScope.TestParameterBuilder.AddMetadata(MetadataKeys.XmlDocumentation, xmlDocumentation);
            }

            testParameterScope.TestParameterBuilder.TestParameterActions.BindTestParameterChain.After((state, value) =>
            {
                state.SlotValues.Add(slot, value);
            });

            testParameterScope.Process(slot);
        }
 /// <inheritdoc />
 public bool Equals(ISlotInfo other)
 {
     return(Equals((object)other));
 }
Beispiel #27
0
 /// <inheritdoc />
 protected override void DecorateTestParameter(IPatternScope slotScope, ISlotInfo slot)
 {
     var binding = new DataBinding(index, path);
     slotScope.TestParameterBuilder.Binder = new ScalarDataBinder(binding, Source ?? @"");
 }
Beispiel #28
0
 public bool Equals(ISlotInfo other) => other is SlotInfoBox b && Equals(b);
 /// <inheritdoc />
 public bool Equals(ISlotInfo other)
 {
     return Equals((object)other);
 }
Beispiel #30
0
 public bool Equals(ISlotInfo other) => other is SlotInfoMisc p && Equals(p);
 /// <summary>
 /// Applies decorations to a <see cref="PatternTestParameter" />.
 /// </summary>
 /// <remarks>
 /// <para>
 /// A typical use of this method is to augment the test parameter with additional metadata
 /// or to add additional behaviors to the test parameter.
 /// </para>
 /// </remarks>
 /// <param name="slotScope">The slot scope.</param>
 /// <param name="slot">The slot.</param>
 protected virtual void DecorateTestParameter(IPatternScope slotScope, ISlotInfo slot)
 {
 }