Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/x509/certificate_transparency.py: 100%

33 statements  

« prev     ^ index     » next       coverage.py v7.0.1, created at 2022-12-25 06:11 +0000

1# This file is dual licensed under the terms of the Apache License, Version 

2# 2.0, and the BSD License. See the LICENSE file in the root of this repository 

3# for complete details. 

4 

5 

6import abc 

7import datetime 

8 

9from cryptography import utils 

10from cryptography.hazmat.bindings._rust import x509 as rust_x509 

11from cryptography.hazmat.primitives.hashes import HashAlgorithm 

12 

13 

14class LogEntryType(utils.Enum): 

15 X509_CERTIFICATE = 0 

16 PRE_CERTIFICATE = 1 

17 

18 

19class Version(utils.Enum): 

20 v1 = 0 

21 

22 

23class SignatureAlgorithm(utils.Enum): 

24 """ 

25 Signature algorithms that are valid for SCTs. 

26 

27 These are exactly the same as SignatureAlgorithm in RFC 5246 (TLS 1.2). 

28 

29 See: <https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.4.1> 

30 """ 

31 

32 ANONYMOUS = 0 

33 RSA = 1 

34 DSA = 2 

35 ECDSA = 3 

36 

37 

38class SignedCertificateTimestamp(metaclass=abc.ABCMeta): 

39 @abc.abstractproperty 

40 def version(self) -> Version: 

41 """ 

42 Returns the SCT version. 

43 """ 

44 

45 @abc.abstractproperty 

46 def log_id(self) -> bytes: 

47 """ 

48 Returns an identifier indicating which log this SCT is for. 

49 """ 

50 

51 @abc.abstractproperty 

52 def timestamp(self) -> datetime.datetime: 

53 """ 

54 Returns the timestamp for this SCT. 

55 """ 

56 

57 @abc.abstractproperty 

58 def entry_type(self) -> LogEntryType: 

59 """ 

60 Returns whether this is an SCT for a certificate or pre-certificate. 

61 """ 

62 

63 @abc.abstractproperty 

64 def signature_hash_algorithm(self) -> HashAlgorithm: 

65 """ 

66 Returns the hash algorithm used for the SCT's signature. 

67 """ 

68 

69 @abc.abstractproperty 

70 def signature_algorithm(self) -> SignatureAlgorithm: 

71 """ 

72 Returns the signing algorithm used for the SCT's signature. 

73 """ 

74 

75 @abc.abstractproperty 

76 def signature(self) -> bytes: 

77 """ 

78 Returns the signature for this SCT. 

79 """ 

80 

81 @abc.abstractproperty 

82 def extension_bytes(self) -> bytes: 

83 """ 

84 Returns the raw bytes of any extensions for this SCT. 

85 """ 

86 

87 

88SignedCertificateTimestamp.register(rust_x509.Sct)