@@ -17,6 +17,7 @@ import (
1717 "context"
1818 "crypto/x509"
1919 "errors"
20+ "fmt"
2021 "time"
2122
2223 "github.com/notaryproject/tspclient-go"
@@ -197,17 +198,21 @@ func (signerInfo *SignerInfo) ExtendedAttribute(key string) (Attribute, error) {
197198 return Attribute {}, errors .New ("key not in ExtendedAttributes" )
198199}
199200
200- // AuthenticSigningTime returns the authentic signing time
201+ // AuthenticSigningTime returns the authentic signing time under signing scheme
202+ // notary.x509.signingAuthority.
203+ // For signing scheme notary.x509, since it only supports authentic timestamp,
204+ // an error is returned.
205+ //
206+ // Reference: https://github.com/notaryproject/specifications/blob/3b0743cd9bb99faee60600dc31d706149775fd49/specs/signature-specification.md#signing-time--authentic-signing-time
201207func (signerInfo * SignerInfo ) AuthenticSigningTime () (time.Time , error ) {
202- switch signerInfo .SignedAttributes .SigningScheme {
208+ switch signingScheme := signerInfo .SignedAttributes .SigningScheme ; signingScheme {
203209 case SigningSchemeX509SigningAuthority :
204- return signerInfo .SignedAttributes .SigningTime , nil
205- case SigningSchemeX509 :
206- if len (signerInfo .UnsignedAttributes .TimestampSignature ) > 0 {
207- // TODO: Add TSA support for AutheticSigningTime
208- // https://github.com/notaryproject/notation-core-go/issues/38
209- return time.Time {}, errors .New ("TSA checking has not been implemented" )
210+ signingTime := signerInfo .SignedAttributes .SigningTime
211+ if signingTime .IsZero () {
212+ return time.Time {}, fmt .Errorf ("authentic signing time must be present under signing scheme %q" , signingScheme )
210213 }
214+ return signingTime , nil
215+ default :
216+ return time.Time {}, fmt .Errorf ("authentic signing time not supported under signing scheme %q" , signingScheme )
211217 }
212- return time.Time {}, errors .New ("authenticSigningTime not found" )
213218}
0 commit comments