예제 #1
0
        /// <summary>
        /// Verifies input in attached format.
        /// </summary>
        /// <param name="fileNames">The file names to check. Should be two entries, first for the signature, second for the data.</param>
        internal static void VerifyDetached(IReadOnlyList <string> fileNames)
        {
            var signatureBytes = FileSystemStreamHelper.ReadFileStreamFully(fileNames[0]);

            var signedDataBytes = FileSystemStreamHelper.ReadFileStreamFully(fileNames[1]);

            VerifyDetached(signatureBytes, signedDataBytes);
        }
예제 #2
0
        /// <summary>
        /// Performs the sign action.
        /// </summary>
        /// <param name="fileName">The file name to sign. If null will be stdin.</param>
        /// <param name="localUser">The email address or certificate id of the certificate to sign against.</param>
        /// <param name="timeStampAuthority">A uri to the timestamp authority.</param>
        /// <param name="isDetached">If the signing operation should be detached and produce separate signature.</param>
        /// <param name="useArmor">If we should produce data in the PEM encoded format.</param>
        /// <param name="includeOption">The certificate include options, if we should just include end certificates, or intermediate/root certificates as well.</param>
        /// <returns>0 if the operation was successful, 1 otherwise.</returns>
        public static Task <int> Do(string fileName, string localUser, Uri timeStampAuthority, bool isDetached, bool useArmor, X509IncludeOption includeOption)
        {
            if (localUser == null)
            {
                throw new ArgumentNullException(nameof(localUser), Resources.InvalidCertificateId);
            }

            var certificate = CertificateHelper.FindUserCertificate(localUser);

            if (certificate == null)
            {
                throw new ArgumentException("Failed to get identity certificate with identity: " + localUser, nameof(localUser));
            }

            var bytes = FileSystemStreamHelper.ReadFileStreamFully(fileName);

            return(PerformSign(certificate, bytes, timeStampAuthority, isDetached, useArmor, includeOption));
        }
예제 #3
0
        /// <summary>
        /// Verifies a file with attached signature.
        /// </summary>
        /// <param name="fileName">The file name to check.</param>
        internal static void VerifyAttached(string fileName)
        {
            var bytes = FileSystemStreamHelper.ReadFileStreamFully(fileName);

            VerifyAttached(bytes);
        }