public Context( int packageKey, Stream packageStream, ISignedPackage packageReader, SignatureValidationMessage message, CancellationToken cancellationToken) { PackageKey = packageKey; PackageStream = packageStream ?? throw new ArgumentNullException(nameof(packageStream)); PackageReader = packageReader ?? throw new ArgumentNullException(nameof(packageReader)); Message = message ?? throw new ArgumentNullException(nameof(message)); CancellationToken = cancellationToken; }
private SignTest(Signer signer, ISignedPackage package, ISignatureProvider signatureProvider, SignPackageRequest request, MemoryStream readStream, MemoryStream writeStream) { Signer = signer; Package = package; SignatureProvider = signatureProvider; Request = request; _readStream = readStream; _writeStream = writeStream; }
private static async Task AddRepositoryCountersignatureToSignedPackageAsync(ISignedPackage package, RepositorySignPackageRequest request, ILogger logger) { #if IS_DESKTOP var primarySignature = await package.GetPrimarySignatureAsync(CancellationToken.None); if (primarySignature != null) { var testSignatureProvider = new X509SignatureProvider(timestampProvider: null); var signature = await testSignatureProvider.CreateRepositoryCountersignatureAsync(request, primarySignature, logger, CancellationToken.None); using (var stream = new MemoryStream(signature.GetBytes())) { await package.AddSignatureAsync(stream, CancellationToken.None); } } #endif }
private static async Task AddSignatureToPackageAsync(ISignedPackage package, SignPackageRequest request, ILogger logger) { var testSignatureProvider = new X509SignatureProvider(timestampProvider: null); var zipArchiveHash = await package.GetArchiveHashAsync(request.SignatureHashAlgorithm, CancellationToken.None); var base64ZipArchiveHash = Convert.ToBase64String(zipArchiveHash); var signatureContent = new SignatureContent(SigningSpecifications.V1, request.SignatureHashAlgorithm, base64ZipArchiveHash); var signature = await testSignatureProvider.CreatePrimarySignatureAsync(request, signatureContent, logger, CancellationToken.None); using (var stream = new MemoryStream(signature.GetBytes())) { #if IS_DESKTOP await package.AddSignatureAsync(stream, CancellationToken.None); #endif } }
/// <summary> /// Creates a signer for a specific package. /// </summary> /// <param name="package">Package to sign or modify.</param> public Signer(ISignedPackage package, ISignatureProvider signatureProvider) { _package = package ?? throw new ArgumentNullException(nameof(package)); _signatureProvider = signatureProvider ?? throw new ArgumentNullException(nameof(signatureProvider)); }