| 1 | // |
| 2 | // Copyright (c) SAS Institute Inc. |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
| 16 | |
| 17 | package authenticodescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/ |
| 18 | |
| 19 | import ( |
| 20 | "contextscip-go gomod github.com/golang/go/src go1.18 context/" |
| 21 | "cryptoscip-go gomod github.com/golang/go/src go1.18 crypto/" |
| 22 | |
| 23 | "github.com/sassoftware/relic/v7/lib/certloaderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/certloader`/" |
| 24 | "github.com/sassoftware/relic/v7/lib/comdocscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/comdoc`/" |
| 25 | "github.com/sassoftware/relic/v7/lib/pkcs9scip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/pkcs9`/" |
| 26 | ) |
| 27 | |
| 28 | // Create the Authenticode structure for a MSI file signature using a previously-calculated digest (imprint). |
| 29 | func SignMSIImprintscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/SignMSIImprint().(ctx contextscip-go gomod github.com/golang/go/src go1.18 context/.Contextscip-go gomod github.com/golang/go/src go1.18 context/Context#, digest []byte, hash cryptoscip-go gomod github.com/golang/go/src go1.18 crypto/.Hashscip-go gomod github.com/golang/go/src go1.18 crypto/Hash#, cert *certloaderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/certloader`/.Certificatescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/certloader`/Certificate#, params *OpusParamsscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/OpusParams#) (*pkcs9scip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/pkcs9`/.TimestampedSignaturescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/pkcs9`/TimestampedSignature#, error) { |
| 30 | return SignSipscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/SignSip().(ctx, digest, hash, msiSipInfoscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/msiSipInfo., cert, params) |
| 31 | } |
| 32 | |
| 33 | // Add a signature blob to an open MSI file. The extended signature blob is |
| 34 | // added or updated if provided, or deleted if nil. |
| 35 | func InsertMSISignaturescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/InsertMSISignature().(cdf *comdocscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/comdoc`/.ComDocscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/comdoc`/ComDoc#, pkcs, exsig []byte) error { |
| 36 | if len(exsig) > 0 { |
| 37 | if err := cdf.AddFilescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/comdoc`/ComDoc#AddFile().(msiDigitalSignatureExscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/msiDigitalSignatureEx., exsig); err != nil { |
| 38 | return err |
| 39 | } |
| 40 | } else { |
| 41 | if err := cdf.DeleteFilescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/comdoc`/ComDoc#DeleteFile().(msiDigitalSignatureExscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/msiDigitalSignatureEx.); err != nil { |
| 42 | return err |
| 43 | } |
| 44 | } |
| 45 | return cdf.AddFilescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/comdoc`/ComDoc#AddFile().(msiDigitalSignaturescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/authenticode`/msiDigitalSignature., pkcs) |
| 46 | } |