-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
200 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,24 @@ | ||
class MessageImprint: | ||
"""Represents a Message Imprint (per RFC 3161).""" | ||
@property | ||
def hash_algorithm(self) -> ObjectIdentifier: | ||
"""Returns the Object Identifier of the Hash algorithm used.""" | ||
... | ||
from sigstore_tsp.tsp import TimeStampRequest, TimeStampResponse | ||
|
||
@property | ||
def message(self) -> bytes: | ||
"""Return the hashed message.""" | ||
... | ||
class PyMessageImprint: ... | ||
|
||
class TimeStampReq: ... | ||
|
||
class TimeStampRequest: | ||
"""Represents a Timestamp Request (per RFC 3161).""" | ||
class TimeStampResp: ... | ||
|
||
@property | ||
def version(self) -> int: | ||
"""Returns the version of the Timestamp Request.""" | ||
... | ||
class ObjectIdentifier: ... | ||
|
||
@property | ||
def nonce(self) -> int: | ||
"""Returns the nonce generated for this request.""" | ||
... | ||
class SignedData: ... | ||
|
||
@property | ||
def policy(self) -> ObjectIdentifier: | ||
"""Returns the request policy OID.""" | ||
... | ||
|
||
@property | ||
def cert_req(self) -> bool: | ||
"""Is the certificate request present.""" | ||
... | ||
|
||
@property | ||
def message_imprint(self) -> MessageImprint: | ||
"""Returns the Timestamp Request Message Imprint.""" | ||
... | ||
|
||
def as_bytes(self) -> bytes: | ||
"""Returns the Timestamp Request as bytes.""" | ||
... | ||
|
||
class PyTSTInfo: ... | ||
|
||
class Accuracy: ... | ||
|
||
def create_timestamp_request( | ||
data: bytes, | ||
) -> TimeStampRequest: ... | ||
|
||
|
||
class TimeStampResponse: | ||
@property | ||
def status(self) -> int: ... | ||
|
||
@property | ||
def tst_info_version(self) -> int: ... | ||
|
||
@property | ||
def tst_info_nonce(self) -> int: ... | ||
|
||
@property | ||
def tst_info_policy(self) -> ObjectIdentifier: ... | ||
|
||
def parse_timestamp_response( | ||
data: bytes, | ||
) -> TimeStampResponse: ... | ||
|
||
class ObjectIdentifier: | ||
@property | ||
def dotted_string(self) -> str:... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
from __future__ import annotations | ||
|
||
import abc | ||
import datetime | ||
import enum | ||
|
||
import cryptography.x509 | ||
|
||
from sigstore_tsp import _rust | ||
|
||
|
||
class ObjectIdentifier(metaclass=abc.ABCMeta): | ||
@property | ||
@abc.abstractmethod | ||
def dotted_string(self) -> str: | ||
"""Returns the dotted string of the OID.""" | ||
|
||
ObjectIdentifier.register(_rust.ObjectIdentifier) | ||
|
||
|
||
class MessageImprint(metaclass=abc.ABCMeta): | ||
"""Represents a Message Imprint (per RFC 3161).""" | ||
@property | ||
@abc.abstractmethod | ||
def hash_algorithm(self) -> ObjectIdentifier: | ||
"""Returns the Object Identifier of the Hash algorithm used.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def message(self) -> bytes: | ||
"""Return the hashed message.""" | ||
|
||
MessageImprint.register(_rust.PyMessageImprint) | ||
|
||
class TimeStampRequest(metaclass=abc.ABCMeta): | ||
"""Represents a Timestamp Request (per RFC 3161).""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def version(self) -> int: | ||
"""Returns the version of the Timestamp Request.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def nonce(self) -> int: | ||
"""Returns the nonce generated for this request.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def policy(self) -> ObjectIdentifier: | ||
"""Returns the request policy OID.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def cert_req(self) -> bool: | ||
"""Is the certificate request present.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def message_imprint(self) -> MessageImprint: | ||
"""Returns the Timestamp Request Message Imprint.""" | ||
|
||
@abc.abstractmethod | ||
def as_bytes(self) -> bytes: | ||
"""Returns the Timestamp Request as bytes.""" | ||
|
||
|
||
TimeStampRequest.register(_rust.TimeStampReq) | ||
|
||
class PKIStatus(enum.IntEnum): | ||
GRANTED = 0 | ||
GRANTED_WITH_MODS = 1 | ||
REJECTION = 2 | ||
WAITING = 3 | ||
REVOCATION_WARNING = 4 | ||
REVOCATION_NOTIFICATION = 5 | ||
|
||
|
||
class TimeStampResponse(metaclass=abc.ABCMeta): | ||
|
||
@property | ||
@abc.abstractmethod | ||
def status(self) -> int: | ||
"""Returns the status of the Timestamp Response.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def status_string(self) -> list[str]: | ||
"""Returns the status string.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def tst_info(self) -> TimeStampTokenInfo: | ||
"""Returns the Timestamp Token Info.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def signed_data(self) -> SignedData: | ||
"""Returns the Signed Data.""" | ||
|
||
TimeStampResponse.register(_rust.TimeStampResp) | ||
|
||
|
||
class Accuracy(metaclass=abc.ABCMeta): | ||
|
||
@property | ||
@abc.abstractmethod | ||
def seconds(self) -> int: | ||
"""Returns the seconds.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def millis(self) -> int | None: | ||
"""Returns the seconds.""" | ||
|
||
|
||
@property | ||
@abc.abstractmethod | ||
def micros(self) -> int | None: | ||
"""Returns the seconds.""" | ||
|
||
Accuracy.register(_rust.Accuracy) | ||
|
||
|
||
class TimeStampTokenInfo(metaclass=abc.ABCMeta): | ||
@property | ||
@abc.abstractmethod | ||
def version(self) -> int: | ||
"""Returns the version.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def policy(self) -> ObjectIdentifier: | ||
"""Returns the policy OID.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def serial_number(self) -> int: | ||
"""Returns the Serial Number.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def gen_time(self) -> datetime.datetime: | ||
"""Returns the policy OID.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def accuracy(self) -> Accuracy: | ||
"""Returns the Accuracy.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def ordering(self) -> bool: | ||
"""Returns the ordering.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def nonce(self) -> bytes: | ||
"""Returns the nonce.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def name(self) -> cryptography.x509.Name: | ||
"""Returns the name.""" | ||
|
||
|
||
TimeStampTokenInfo.register(_rust.PyTSTInfo) | ||
|
||
|
||
class SignedData(metaclass=abc.ABCMeta): | ||
|
||
@property | ||
@abc.abstractmethod | ||
def version(self) -> int: | ||
"""Returns the version.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def digest_algorithms(self) -> set[ObjectIdentifier]: | ||
"""Returns the set of digest algorithms.""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def certificates(self) -> set[bytes]: | ||
"""Returns the set of certificates. | ||
Warning: they are returned as a byte array and should be loaded. | ||
""" | ||
|
||
SignedData.register(_rust.SignedData) |