sigstore._internal.timestamp

Utilities to deal with sources of signed time.

 1# Copyright 2022 The Sigstore Authors
 2#
 3# Licensed under the Apache License, Version 2.0 (the "License");
 4# you may not use this file except in compliance with the License.
 5# You may obtain a copy of the License at
 6#
 7#      http://www.apache.org/licenses/LICENSE-2.0
 8#
 9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""
16Utilities to deal with sources of signed time.
17"""
18
19import enum
20from dataclasses import dataclass
21from datetime import datetime
22
23
24class TimestampSource(enum.Enum):
25    """Represents the source of a timestamp."""
26
27    TIMESTAMP_AUTHORITY = enum.auto()
28    TRANSPARENCY_SERVICE = enum.auto()
29
30
31@dataclass
32class TimestampVerificationResult:
33    """Represents a timestamp used by the Verifier.
34
35    A Timestamp either comes from a Timestamping Service (RFC3161) or the Transparency
36    Service.
37    """
38
39    source: TimestampSource
40    time: datetime
class TimestampSource(enum.Enum):
25class TimestampSource(enum.Enum):
26    """Represents the source of a timestamp."""
27
28    TIMESTAMP_AUTHORITY = enum.auto()
29    TRANSPARENCY_SERVICE = enum.auto()

Represents the source of a timestamp.

TIMESTAMP_AUTHORITY = <TimestampSource.TIMESTAMP_AUTHORITY: 1>
TRANSPARENCY_SERVICE = <TimestampSource.TRANSPARENCY_SERVICE: 2>
@dataclass
class TimestampVerificationResult:
32@dataclass
33class TimestampVerificationResult:
34    """Represents a timestamp used by the Verifier.
35
36    A Timestamp either comes from a Timestamping Service (RFC3161) or the Transparency
37    Service.
38    """
39
40    source: TimestampSource
41    time: datetime

Represents a timestamp used by the Verifier.

A Timestamp either comes from a Timestamping Service (RFC3161) or the Transparency Service.

TimestampVerificationResult( source: TimestampSource, time: datetime.datetime)
source: TimestampSource
time: datetime.datetime