示例#1
0
        /// <summary>
        ///     Generates the manifest based on passed parameters and <c>saves manifest to file system</c>
        /// </summary>
        /// <remarks>
        ///     Performs the signing of the manifest file.
        /// </remarks>
        /// <returns>The newly created manifest.</returns>
        public ModuleManifest CreateAndPublish()
        {
            // perform creation
            ModuleManifest manifest = Create();

            byte[] manifestSerialized = XmlSerializerHelper.Serialize(manifest);

            //  sign the manifest
            string manifestPath = string.Format("{0}{1}", GetAssemblyPath(),
                                                ModuleManifest.ManifestFileNameSuffix);

            File.WriteAllBytes(manifestPath, manifestSerialized);
            File.WriteAllBytes(manifestPath + ModuleManifest.ManifestSignatureFileNameSuffix,
                               _signatureAlgorithm.Sign(File.ReadAllBytes(manifestPath)));

            return(manifest);
        }
        public IEnumerable<SignedFile> GetSignedFiles(string directory,
            ISignatureAlgorithm signatureAlgorithm)
        {
            string[] files = Directory.GetFiles(directory, "*",
                                                SearchOption.AllDirectories);

            IEnumerable<SignedFile> signedFiles = from file in files
                                                  select
                                                      new SignedFile
                                                          {
                                                              FilePath =
                                                                  file.Substring(
                                                                      directory.
                                                                          Length),
                                                              Signature =
                                                                  signatureAlgorithm.Sign(
                                                                      File.ReadAllBytes(file))
                                                          };
            return signedFiles;
        }
        public IEnumerable <SignedFile> GetSignedFiles(string directory,
                                                       ISignatureAlgorithm signatureAlgorithm)
        {
            string[] files = Directory.GetFiles(directory, "*",
                                                SearchOption.AllDirectories);

            IEnumerable <SignedFile> signedFiles = from file in files
                                                   select
                                                   new SignedFile
            {
                FilePath =
                    file.Substring(
                        directory.
                        Length),
                Signature =
                    signatureAlgorithm.Sign(
                        File.ReadAllBytes(file))
            };

            return(signedFiles);
        }
示例#4
0
 public void can_decrypt_using_verifier()
 {
     byte[] signature = _signer.Sign(_data);
     Assert.AreEqual(true, _verifier.Verify(_data, signature));
 }