entropy-protocol 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. entropy_protocol/__init__.py +11 -0
  2. entropy_protocol/_unicode14.py +120 -0
  3. entropy_protocol/attest.py +62 -0
  4. entropy_protocol/attested/__init__.py +6 -0
  5. entropy_protocol/attested/amd.py +221 -0
  6. entropy_protocol/attested/appraise.py +325 -0
  7. entropy_protocol/attested/attester.py +58 -0
  8. entropy_protocol/attested/authority.py +239 -0
  9. entropy_protocol/attested/azure_cgpu.py +186 -0
  10. entropy_protocol/attested/binding.py +71 -0
  11. entropy_protocol/attested/capture.py +109 -0
  12. entropy_protocol/attested/ear.py +94 -0
  13. entropy_protocol/attested/enroll.py +119 -0
  14. entropy_protocol/attested/evidence.py +106 -0
  15. entropy_protocol/attested/hcl.py +109 -0
  16. entropy_protocol/attested/nvidia.py +168 -0
  17. entropy_protocol/attested/ocsp.py +90 -0
  18. entropy_protocol/attested/pki.py +121 -0
  19. entropy_protocol/attested/rim.py +130 -0
  20. entropy_protocol/attested/service.py +242 -0
  21. entropy_protocol/attested/tpm.py +259 -0
  22. entropy_protocol/backend_hf.py +439 -0
  23. entropy_protocol/batch.py +537 -0
  24. entropy_protocol/calibrate.py +99 -0
  25. entropy_protocol/canon.py +321 -0
  26. entropy_protocol/canongen.py +325 -0
  27. entropy_protocol/cli.py +493 -0
  28. entropy_protocol/cose.py +260 -0
  29. entropy_protocol/crypto.py +140 -0
  30. entropy_protocol/delivery.py +31 -0
  31. entropy_protocol/detect.py +246 -0
  32. entropy_protocol/gateway.py +370 -0
  33. entropy_protocol/hpke.py +105 -0
  34. entropy_protocol/mcp.py +159 -0
  35. entropy_protocol/pack.py +217 -0
  36. entropy_protocol/plain.py +122 -0
  37. entropy_protocol/predicates.py +37 -0
  38. entropy_protocol/profiles.py +45 -0
  39. entropy_protocol/record.py +116 -0
  40. entropy_protocol/scrapi.py +203 -0
  41. entropy_protocol/seal.py +232 -0
  42. entropy_protocol/statements.py +148 -0
  43. entropy_protocol/stats.py +20 -0
  44. entropy_protocol/tlog.py +147 -0
  45. entropy_protocol/ts3161.py +205 -0
  46. entropy_protocol/typography.py +73 -0
  47. entropy_protocol/verify.py +232 -0
  48. entropy_protocol-0.1.0.dist-info/METADATA +255 -0
  49. entropy_protocol-0.1.0.dist-info/RECORD +54 -0
  50. entropy_protocol-0.1.0.dist-info/WHEEL +5 -0
  51. entropy_protocol-0.1.0.dist-info/entry_points.txt +2 -0
  52. entropy_protocol-0.1.0.dist-info/licenses/LICENSE +201 -0
  53. entropy_protocol-0.1.0.dist-info/licenses/NOTICE +4 -0
  54. entropy_protocol-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,11 @@
1
+ """Entropy Protocol — reference implementation (ep1).
2
+
3
+ Seal AI-generated text at the moment of generation; verify it anywhere, without revealing it.
4
+ Verdicts are determinations, not probabilities: VERIFIED, MODIFIED (with character ranges),
5
+ INDETERMINATE, or NOT_VERIFIABLE.
6
+
7
+ Apache-2.0; see LICENSE, NOTICE and PATENTS.md.
8
+ """
9
+
10
+ __version__ = "0.1.0"
11
+ ENGINE = f"entropy-protocol/{__version__}"
@@ -0,0 +1,120 @@
1
+ """Code points assigned in Unicode 14.0, from DerivedAge-17.0.0.txt (sha256
2
+ f8ecdf768bdc210f201abd271d9bc587825618a86a7046a8146cc816393f1998), by spec/make_unicode14.py: 706 ranges. Generated
3
+ - do not edit."""
4
+ from __future__ import annotations
5
+
6
+ from bisect import bisect_right
7
+
8
+ STARTS = (0x0, 0x37A, 0x384, 0x38C, 0x38E, 0x3A3, 0x531, 0x559, 0x58D, 0x591, 0x5D0, 0x5EF, 0x600, 0x70F, 0x74D, 0x7C0,
9
+ 0x7FD, 0x830, 0x840, 0x85E, 0x860, 0x870, 0x890, 0x898, 0x985, 0x98F, 0x993, 0x9AA, 0x9B2, 0x9B6, 0x9BC, 0x9C7,
10
+ 0x9C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0, 0x13F8, 0x1400, 0x16A0, 0x1700, 0x171F, 0x1740,
20
+ 0x1760, 0x176E, 0x1772, 0x1780, 0x17E0, 0x17F0, 0x1800, 0x1820, 0x1880, 0x18B0, 0x1900, 0x1920, 0x1930, 0x1940,
21
+ 0x1944, 0x1970, 0x1980, 0x19B0, 0x19D0, 0x19DE, 0x1A1E, 0x1A60, 0x1A7F, 0x1A90, 0x1AA0, 0x1AB0, 0x1B00, 0x1B50,
22
+ 0x1B80, 0x1BFC, 0x1C3B, 0x1C4D, 0x1C90, 0x1CBD, 0x1CD0, 0x1D00, 0x1F18, 0x1F20, 0x1F48, 0x1F50, 0x1F59, 0x1F5B,
23
+ 0x1F5D, 0x1F5F, 0x1F80, 0x1FB6, 0x1FC6, 0x1FD6, 0x1FDD, 0x1FF2, 0x1FF6, 0x2000, 0x2066, 0x2074, 0x2090, 0x20A0,
24
+ 0x20D0, 0x2100, 0x2190, 0x2440, 0x2460, 0x2B76, 0x2B97, 0x2CF9, 0x2D27, 0x2D2D, 0x2D30, 0x2D6F, 0x2D7F, 0x2DA0,
25
+ 0x2DA8, 0x2DB0, 0x2DB8, 0x2DC0, 0x2DC8, 0x2DD0, 0x2DD8, 0x2DE0, 0x2E80, 0x2E9B, 0x2F00, 0x2FF0, 0x3000, 0x3041,
26
+ 0x3099, 0x3105, 0x3131, 0x3190, 0x31F0, 0x3220, 0xA490, 0xA4D0, 0xA640, 0xA700, 0xA7D0, 0xA7D3, 0xA7D5, 0xA7F2,
27
+ 0xA830, 0xA840, 0xA880, 0xA8CE, 0xA8E0, 0xA95F, 0xA980, 0xA9CF, 0xA9DE, 0xAA00, 0xAA40, 0xAA50, 0xAA5C, 0xAADB,
28
+ 0xAB01, 0xAB09, 0xAB11, 0xAB20, 0xAB28, 0xAB30, 0xAB70, 0xABF0, 0xAC00, 0xD7B0, 0xD7CB, 0xD800, 0xFA70, 0xFB00,
29
+ 0xFB13, 0xFB1D, 0xFB38, 0xFB3E, 0xFB40, 0xFB43, 0xFB46, 0xFBD3, 0xFD92, 0xFDCF, 0xFE20, 0xFE54, 0xFE68, 0xFE70,
30
+ 0xFE76, 0xFEFF, 0xFF01, 0xFFC2, 0xFFCA, 0xFFD2, 0xFFDA, 0xFFE0, 0xFFE8, 0xFFF9, 0x1000D, 0x10028, 0x1003C, 0x1003F,
31
+ 0x10050, 0x10080, 0x10100, 0x10107, 0x10137, 0x10190, 0x101A0, 0x101D0, 0x10280, 0x102A0, 0x102E0, 0x10300,
32
+ 0x1032D, 0x10350, 0x10380, 0x1039F, 0x103C8, 0x10400, 0x104A0, 0x104B0, 0x104D8, 0x10500, 0x10530, 0x1056F,
33
+ 0x1057C, 0x1058C, 0x10594, 0x10597, 0x105A3, 0x105B3, 0x105BB, 0x10600, 0x10740, 0x10760, 0x10780, 0x10787,
34
+ 0x107B2, 0x10800, 0x10808, 0x1080A, 0x10837, 0x1083C, 0x1083F, 0x10857, 0x108A7, 0x108E0, 0x108F4, 0x108FB,
35
+ 0x1091F, 0x1093F, 0x10980, 0x109BC, 0x109D2, 0x10A05, 0x10A0C, 0x10A15, 0x10A19, 0x10A38, 0x10A3F, 0x10A50,
36
+ 0x10A60, 0x10AC0, 0x10AEB, 0x10B00, 0x10B39, 0x10B58, 0x10B78, 0x10B99, 0x10BA9, 0x10C00, 0x10C80, 0x10CC0,
37
+ 0x10CFA, 0x10D30, 0x10E60, 0x10E80, 0x10EAB, 0x10EB0, 0x10F00, 0x10F30, 0x10F70, 0x10FB0, 0x10FE0, 0x11000,
38
+ 0x11052, 0x1107F, 0x110CD, 0x110D0, 0x110F0, 0x11100, 0x11136, 0x11150, 0x11180, 0x111E1, 0x11200, 0x11213,
39
+ 0x11280, 0x11288, 0x1128A, 0x1128F, 0x1129F, 0x112B0, 0x112F0, 0x11300, 0x11305, 0x1130F, 0x11313, 0x1132A,
40
+ 0x11332, 0x11335, 0x1133B, 0x11347, 0x1134B, 0x11350, 0x11357, 0x1135D, 0x11366, 0x11370, 0x11400, 0x1145D,
41
+ 0x11480, 0x114D0, 0x11580, 0x115B8, 0x11600, 0x11650, 0x11660, 0x11680, 0x116C0, 0x11700, 0x1171D, 0x11730,
42
+ 0x11800, 0x118A0, 0x118FF, 0x11909, 0x1190C, 0x11915, 0x11918, 0x11937, 0x1193B, 0x11950, 0x119A0, 0x119AA,
43
+ 0x119DA, 0x11A00, 0x11A50, 0x11AB0, 0x11C00, 0x11C0A, 0x11C38, 0x11C50, 0x11C70, 0x11C92, 0x11CA9, 0x11D00,
44
+ 0x11D08, 0x11D0B, 0x11D3A, 0x11D3C, 0x11D3F, 0x11D50, 0x11D60, 0x11D67, 0x11D6A, 0x11D90, 0x11D93, 0x11DA0,
45
+ 0x11EE0, 0x11FB0, 0x11FC0, 0x11FFF, 0x12400, 0x12470, 0x12480, 0x12F90, 0x13000, 0x13430, 0x14400, 0x16800,
46
+ 0x16A40, 0x16A60, 0x16A6E, 0x16AC0, 0x16AD0, 0x16AF0, 0x16B00, 0x16B50, 0x16B5B, 0x16B63, 0x16B7D, 0x16E40,
47
+ 0x16F00, 0x16F4F, 0x16F8F, 0x16FE0, 0x16FF0, 0x17000, 0x18800, 0x18D00, 0x1AFF0, 0x1AFF5, 0x1AFFD, 0x1B000,
48
+ 0x1B150, 0x1B164, 0x1B170, 0x1BC00, 0x1BC70, 0x1BC80, 0x1BC90, 0x1BC9C, 0x1CF00, 0x1CF30, 0x1CF50, 0x1D000,
49
+ 0x1D100, 0x1D129, 0x1D200, 0x1D2E0, 0x1D300, 0x1D360, 0x1D400, 0x1D456, 0x1D49E, 0x1D4A2, 0x1D4A5, 0x1D4A9,
50
+ 0x1D4AE, 0x1D4BB, 0x1D4BD, 0x1D4C5, 0x1D507, 0x1D50D, 0x1D516, 0x1D51E, 0x1D53B, 0x1D540, 0x1D546, 0x1D54A,
51
+ 0x1D552, 0x1D6A8, 0x1D7CE, 0x1DA9B, 0x1DAA1, 0x1DF00, 0x1E000, 0x1E008, 0x1E01B, 0x1E023, 0x1E026, 0x1E100,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97, 0xFBC, 0xFCC, 0xFDA,
72
+ 0x10C5, 0x10C7, 0x10CD, 0x1248, 0x124D, 0x1256, 0x1258, 0x125D, 0x1288, 0x128D, 0x12B0, 0x12B5, 0x12BE, 0x12C0,
73
+ 0x12C5, 0x12D6, 0x1310, 0x1315, 0x135A, 0x137C, 0x1399, 0x13F5, 0x13FD, 0x169C, 0x16F8, 0x1715, 0x1736, 0x1753,
74
+ 0x176C, 0x1770, 0x1773, 0x17DD, 0x17E9, 0x17F9, 0x1819, 0x1878, 0x18AA, 0x18F5, 0x191E, 0x192B, 0x193B, 0x1940,
75
+ 0x196D, 0x1974, 0x19AB, 0x19C9, 0x19DA, 0x1A1B, 0x1A5E, 0x1A7C, 0x1A89, 0x1A99, 0x1AAD, 0x1ACE, 0x1B4C, 0x1B7E,
76
+ 0x1BF3, 0x1C37, 0x1C49, 0x1C88, 0x1CBA, 0x1CC7, 0x1CFA, 0x1F15, 0x1F1D, 0x1F45, 0x1F4D, 0x1F57, 0x1F59, 0x1F5B,
77
+ 0x1F5D, 0x1F7D, 0x1FB4, 0x1FC4, 0x1FD3, 0x1FDB, 0x1FEF, 0x1FF4, 0x1FFE, 0x2064, 0x2071, 0x208E, 0x209C, 0x20C0,
78
+ 0x20F0, 0x218B, 0x2426, 0x244A, 0x2B73, 0x2B95, 0x2CF3, 0x2D25, 0x2D27, 0x2D2D, 0x2D67, 0x2D70, 0x2D96, 0x2DA6,
79
+ 0x2DAE, 0x2DB6, 0x2DBE, 0x2DC6, 0x2DCE, 0x2DD6, 0x2DDE, 0x2E5D, 0x2E99, 0x2EF3, 0x2FD5, 0x2FFB, 0x303F, 0x3096,
80
+ 0x30FF, 0x312F, 0x318E, 0x31E3, 0x321E, 0xA48C, 0xA4C6, 0xA62B, 0xA6F7, 0xA7CA, 0xA7D1, 0xA7D3, 0xA7D9, 0xA82C,
81
+ 0xA839, 0xA877, 0xA8C5, 0xA8D9, 0xA953, 0xA97C, 0xA9CD, 0xA9D9, 0xA9FE, 0xAA36, 0xAA4D, 0xAA59, 0xAAC2, 0xAAF6,
82
+ 0xAB06, 0xAB0E, 0xAB16, 0xAB26, 0xAB2E, 0xAB6B, 0xABED, 0xABF9, 0xD7A3, 0xD7C6, 0xD7FB, 0xFA6D, 0xFAD9, 0xFB06,
83
+ 0xFB17, 0xFB36, 0xFB3C, 0xFB3E, 0xFB41, 0xFB44, 0xFBC2, 0xFD8F, 0xFDC7, 0xFE19, 0xFE52, 0xFE66, 0xFE6B, 0xFE74,
84
+ 0xFEFC, 0xFEFF, 0xFFBE, 0xFFC7, 0xFFCF, 0xFFD7, 0xFFDC, 0xFFE6, 0xFFEE, 0x1000B, 0x10026, 0x1003A, 0x1003D,
85
+ 0x1004D, 0x1005D, 0x100FA, 0x10102, 0x10133, 0x1018E, 0x1019C, 0x101A0, 0x101FD, 0x1029C, 0x102D0, 0x102FB,
86
+ 0x10323, 0x1034A, 0x1037A, 0x1039D, 0x103C3, 0x103D5, 0x1049D, 0x104A9, 0x104D3, 0x104FB, 0x10527, 0x10563,
87
+ 0x1057A, 0x1058A, 0x10592, 0x10595, 0x105A1, 0x105B1, 0x105B9, 0x105BC, 0x10736, 0x10755, 0x10767, 0x10785,
88
+ 0x107B0, 0x107BA, 0x10805, 0x10808, 0x10835, 0x10838, 0x1083C, 0x10855, 0x1089E, 0x108AF, 0x108F2, 0x108F5,
89
+ 0x1091B, 0x10939, 0x1093F, 0x109B7, 0x109CF, 0x10A03, 0x10A06, 0x10A13, 0x10A17, 0x10A35, 0x10A3A, 0x10A48,
90
+ 0x10A58, 0x10A9F, 0x10AE6, 0x10AF6, 0x10B35, 0x10B55, 0x10B72, 0x10B91, 0x10B9C, 0x10BAF, 0x10C48, 0x10CB2,
91
+ 0x10CF2, 0x10D27, 0x10D39, 0x10E7E, 0x10EA9, 0x10EAD, 0x10EB1, 0x10F27, 0x10F59, 0x10F89, 0x10FCB, 0x10FF6,
92
+ 0x1104D, 0x11075, 0x110C2, 0x110CD, 0x110E8, 0x110F9, 0x11134, 0x11147, 0x11176, 0x111DF, 0x111F4, 0x11211,
93
+ 0x1123E, 0x11286, 0x11288, 0x1128D, 0x1129D, 0x112A9, 0x112EA, 0x112F9, 0x11303, 0x1130C, 0x11310, 0x11328,
94
+ 0x11330, 0x11333, 0x11339, 0x11344, 0x11348, 0x1134D, 0x11350, 0x11357, 0x11363, 0x1136C, 0x11374, 0x1145B,
95
+ 0x11461, 0x114C7, 0x114D9, 0x115B5, 0x115DD, 0x11644, 0x11659, 0x1166C, 0x116B9, 0x116C9, 0x1171A, 0x1172B,
96
+ 0x11746, 0x1183B, 0x118F2, 0x11906, 0x11909, 0x11913, 0x11916, 0x11935, 0x11938, 0x11946, 0x11959, 0x119A7,
97
+ 0x119D7, 0x119E4, 0x11A47, 0x11AA2, 0x11AF8, 0x11C08, 0x11C36, 0x11C45, 0x11C6C, 0x11C8F, 0x11CA7, 0x11CB6,
98
+ 0x11D06, 0x11D09, 0x11D36, 0x11D3A, 0x11D3D, 0x11D47, 0x11D59, 0x11D65, 0x11D68, 0x11D8E, 0x11D91, 0x11D98,
99
+ 0x11DA9, 0x11EF8, 0x11FB0, 0x11FF1, 0x12399, 0x1246E, 0x12474, 0x12543, 0x12FF2, 0x1342E, 0x13438, 0x14646,
100
+ 0x16A38, 0x16A5E, 0x16A69, 0x16ABE, 0x16AC9, 0x16AED, 0x16AF5, 0x16B45, 0x16B59, 0x16B61, 0x16B77, 0x16B8F,
101
+ 0x16E9A, 0x16F4A, 0x16F87, 0x16F9F, 0x16FE4, 0x16FF1, 0x187F7, 0x18CD5, 0x18D08, 0x1AFF3, 0x1AFFB, 0x1AFFE,
102
+ 0x1B122, 0x1B152, 0x1B167, 0x1B2FB, 0x1BC6A, 0x1BC7C, 0x1BC88, 0x1BC99, 0x1BCA3, 0x1CF2D, 0x1CF46, 0x1CFC3,
103
+ 0x1D0F5, 0x1D126, 0x1D1EA, 0x1D245, 0x1D2F3, 0x1D356, 0x1D378, 0x1D454, 0x1D49C, 0x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1FBF9, 0x2A6DF, 0x2B738, 0x2B81D, 0x2CEA1, 0x2EBE0,
114
+ 0x2FA1D, 0x3134A, 0x3FFFF, 0x4FFFF, 0x5FFFF, 0x6FFFF, 0x7FFFF, 0x8FFFF, 0x9FFFF, 0xAFFFF, 0xBFFFF, 0xCFFFF,
115
+ 0xDFFFF, 0xE0001, 0xE007F, 0xE01EF, 0x10FFFF,)
116
+
117
+
118
+ def assigned(cp: int) -> bool:
119
+ i = bisect_right(STARTS, cp) - 1
120
+ return i >= 0 and cp <= ENDS[i]
@@ -0,0 +1,62 @@
1
+ """A signed verification attestation in its minimal form: Ed25519 over canonical JSON.
2
+
3
+ The pack carries the verdict, counts, divergence ranges, the model/tokenizer identity and the
4
+ decoding configuration, the verifier nonce and a digest of the log token — never the text.
5
+ Signed with Ed25519 over canonical JSON; checkable by anyone with the verifier's public key.
6
+ Signed COSE statements, the transparency log, RFC 3161 time stamps and the CBOR evidence package that supersede
7
+ it for publication: statements.py, tlog.py, ts3161.py, pack.py.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import base64
12
+ import hashlib
13
+ import json
14
+ import time
15
+
16
+ from cryptography.exceptions import InvalidSignature
17
+ from cryptography.hazmat.primitives import serialization
18
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
19
+
20
+ from . import ENGINE, crypto
21
+
22
+ _PACK_FIELDS = ("verdict", "reason", "score", "matched", "divergent", "indeterminate", "entries", "model_evidence",
23
+ "divergence_ranges", "changed_ranges", "deletion_points", "digest_match", "model", "weights_digest",
24
+ "tokenizer_digest", "decoding", "nonce", "doc_id", "candidate_digest")
25
+
26
+
27
+ def canonical_json(obj) -> bytes:
28
+ return json.dumps(obj, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()
29
+
30
+
31
+ def new_signing_key() -> Ed25519PrivateKey:
32
+ return Ed25519PrivateKey.generate()
33
+
34
+
35
+ def public_bytes(key: Ed25519PublicKey) -> bytes:
36
+ return key.public_bytes(serialization.Encoding.Raw, serialization.PublicFormat.Raw)
37
+
38
+
39
+ def key_id(key: Ed25519PublicKey) -> str:
40
+ return hashlib.sha256(public_bytes(key)).hexdigest()[:16]
41
+
42
+
43
+ def evidence_pack(result, verifier_id: str, token: str) -> dict:
44
+ pack = {f: getattr(result, f) for f in _PACK_FIELDS}
45
+ pack.update({"type": "ep1/evidence-pack", "engine": ENGINE, "verifier": verifier_id,
46
+ "log_token_digest": crypto.sha256_hex(token), "time": int(time.time())})
47
+ return pack
48
+
49
+
50
+ def sign(pack: dict, key: Ed25519PrivateKey) -> dict:
51
+ sig = key.sign(canonical_json(pack))
52
+ return {"pack": pack, "alg": "Ed25519", "kid": key_id(key.public_key()),
53
+ "sig": base64.urlsafe_b64encode(sig).decode().rstrip("=")}
54
+
55
+
56
+ def verify_signed(signed: dict, key: Ed25519PublicKey) -> bool:
57
+ try:
58
+ sig = signed["sig"]
59
+ key.verify(base64.urlsafe_b64decode(sig + "=" * (-len(sig) % 4)), canonical_json(signed["pack"]))
60
+ return signed.get("kid") == key_id(key)
61
+ except (InvalidSignature, KeyError, ValueError):
62
+ return False
@@ -0,0 +1,6 @@
1
+ """Attested sealing and attested detection (ARCHITECTURE §7d).
2
+
3
+ The keys, the model and the sealing code run in a confidential VM with a confidential GPU; a credential authority
4
+ appraises the hardware evidence, which carries a binding value over the statement key, the model and the code, and
5
+ only then certifies the statement key. Attester side: `azure_cgpu` (evidence from inside the guest), `binding`.
6
+ """
@@ -0,0 +1,221 @@
1
+ """AMD SEV-SNP: the attestation report and its certificate chain, checked from the specifications.
2
+
3
+ Report (SEV-SNP Firmware ABI, AMD 56860; offsets also in our library, attestation/platforms.md): 1184 octets, signed
4
+ body [0x000:0x2A0], ECDSA P-384 with SHA-384, r and s little-endian in 72-octet slots at 0x2A0 and 0x2E8.
5
+ Chain: VCEK (or VLEK) <- ASK (or ASVK) <- ARK, all RSASSA-PSS with SHA-384. The certificates encode the PSS trailer
6
+ field at its default value, which DER forbids: cryptography 42.0.8 refuses to load them, 43.0.3 and later load and
7
+ verify them (checked 27.10.2026 against AMD KDS's Genoa chain; hence the dependency floor). ARKs are pinned by SHA-256
8
+ of their DER, taken from AMD KDS (snapshot archived 30.09.2026 in the library; ARK-Milan matches the fingerprint
9
+ recorded there).
10
+ VCEK extensions (AMD 57230 rev 1.05, tables 10-11): structVersion .1.1, productName .1.2, TCB_VERSION elements
11
+ .1.3.x (blSPL 1, teeSPL 2, snpSPL 3, ucodeSPL 8, fmcSPL 9), hwID .1.4 (64 octets on Milan/Genoa, 8 from Turin).
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import datetime as dt
16
+ import hashlib
17
+ from dataclasses import dataclass
18
+
19
+ from cryptography import x509
20
+ from cryptography.exceptions import InvalidSignature
21
+ from cryptography.hazmat.primitives import hashes
22
+ from cryptography.hazmat.primitives.asymmetric import ec
23
+ from cryptography.hazmat.primitives.asymmetric.utils import encode_dss_signature
24
+
25
+ from .pki import UNREADABLE
26
+
27
+ ARK_SHA256 = {
28
+ "Milan": "69d063b45344d26a2e94e1f4210de49ef555308287d4c174445c95639a540bcd",
29
+ "Genoa": "4c6598d19c18719c5dfd4a7d335f674e5bfe1d8f800cea2cf270c10d103db2f1",
30
+ "Turin": "1f084161a44bb6d93778a904877d4819cafa5d05ef4193b2ded9dd9c73dd3f6a",
31
+ "Venice": "46ef2eb7664175c7e9d3923ea0d275e572366d755556a30e229634592dce5903",
32
+ }
33
+ OID_RSASSA_PSS = "1.2.840.113549.1.1.10"
34
+ OID_ECDSA_SHA384 = "1.2.840.10045.4.3.3"
35
+ VCEK_OID = "1.3.6.1.4.1.3704.1."
36
+ REPORT_SIZE = 0x4A0
37
+ SIGNED = 0x2A0
38
+
39
+
40
+ class SNPError(ValueError):
41
+ """The report or its chain does not hold."""
42
+
43
+
44
+ def verify_chain(leaf_der: bytes, ask_der: bytes, ark_der: bytes, product: str, at: dt.datetime) -> dict:
45
+ """The leaf (VCEK or VLEK) to the pinned ARK of ``product``. Returns the leaf's AMD extensions; SNPError otherwise."""
46
+ pin = ARK_SHA256.get(product)
47
+ if pin is None:
48
+ raise SNPError(f"no pinned ARK for {product}")
49
+ if hashlib.sha256(ark_der).hexdigest() != pin:
50
+ raise SNPError(f"ARK is not AMD's pinned ARK-{product}")
51
+ try:
52
+ leaf, ask, ark = (x509.load_der_x509_certificate(x) for x in (leaf_der, ask_der, ark_der))
53
+ except UNREADABLE as exc:
54
+ raise SNPError(f"not a DER certificate: {exc}") from exc
55
+ for child, parent in ((ark, ark), (ask, ark), (leaf, ask)):
56
+ if child.signature_algorithm_oid.dotted_string != OID_RSASSA_PSS:
57
+ raise SNPError(f"unexpected signature algorithm {child.signature_algorithm_oid.dotted_string}")
58
+ try:
59
+ child.verify_directly_issued_by(parent)
60
+ except (*UNREADABLE, InvalidSignature) as exc: # an unreadable key included
61
+ raise SNPError(f"{child.subject.rfc4514_string()} is not signed by its issuer") from exc
62
+ for c in (leaf, ask, ark):
63
+ if not c.not_valid_before_utc <= at <= c.not_valid_after_utc:
64
+ raise SNPError(f"certificate not valid at {at.isoformat()}")
65
+ return vcek_extensions(leaf)
66
+
67
+
68
+ def _der_value(raw: bytes) -> tuple[int, bytes]:
69
+ """(tag, contents) of one short DER element - the INTEGER, IA5String or OCTET STRING inside an AMD extension."""
70
+ tag, ln, off = raw[0], raw[1], 2
71
+ if ln & 0x80:
72
+ n = ln & 0x7F
73
+ ln, off = int.from_bytes(raw[2:2 + n], "big"), 2 + n
74
+ return tag, raw[off:off + ln]
75
+
76
+
77
+ def vcek_extensions(leaf: x509.Certificate) -> dict:
78
+ out: dict = {}
79
+ names = {"1": "structVersion", "3.1": "blSPL", "3.2": "teeSPL", "3.3": "snpSPL", "3.8": "ucodeSPL",
80
+ "3.9": "fmcSPL"}
81
+ for ext in leaf.extensions:
82
+ oid = ext.oid.dotted_string
83
+ if not oid.startswith(VCEK_OID) or not isinstance(ext.value, x509.UnrecognizedExtension):
84
+ continue
85
+ tail = oid[len(VCEK_OID):]
86
+ tag, val = _der_value(ext.value.value)
87
+ if tail in names and tag == 0x02:
88
+ out[names[tail]] = int.from_bytes(val, "big", signed=True)
89
+ elif tail == "2" and tag == 0x16:
90
+ out["productName"] = val.decode("ascii")
91
+ elif tail == "4":
92
+ out["hwID"] = val if tag == 0x04 else ext.value.value
93
+ return out
94
+
95
+
96
+ @dataclass
97
+ class Report:
98
+ raw: bytes
99
+ version: int
100
+ guest_svn: int
101
+ policy: int
102
+ vmpl: int
103
+ signature_algo: int
104
+ current_tcb: int
105
+ platform_info: int
106
+ flags: int
107
+ report_data: bytes
108
+ measurement: bytes
109
+ host_data: bytes
110
+ id_key_digest: bytes
111
+ report_id: bytes
112
+ reported_tcb: int
113
+ chip_id: bytes
114
+ committed_tcb: int
115
+ launch_tcb: int
116
+ family_id: bytes # from the ID block, when one was given at launch
117
+ image_id: bytes
118
+ author_key_digest: bytes
119
+ launch_mit_vector: int # report version 5: 0x1F8
120
+ current_mit_vector: int # report version 5: 0x200
121
+ r: int
122
+ s: int
123
+
124
+ @property
125
+ def id_block(self) -> bool:
126
+ """An ID block was given at launch: the firmware then refused to launch unless the block's expected launch
127
+ digest equalled the measurement and the block's signature verified under the ID key whose SHA-384 digest the
128
+ report carries (AMD 56860 rev. 1.59 §8.19.2, SNP_LAUNCH_FINISH)."""
129
+ return any(self.id_key_digest)
130
+
131
+ @property
132
+ def alias_check_complete(self) -> bool:
133
+ """PLATFORM_INFO bit 5: the platform checked DIMM aliasing (the BadRAM fix, AMD-SB-3015)."""
134
+ return bool(self.platform_info >> 5 & 1)
135
+
136
+ @property
137
+ def debug(self) -> bool:
138
+ return bool(self.policy >> 19 & 1)
139
+
140
+ @property
141
+ def signing_key(self) -> str:
142
+ return {0: "vcek", 1: "vlek", 7: "none"}.get(self.flags >> 2 & 7, "reserved")
143
+
144
+
145
+ def _u(b: bytes, off: int, n: int) -> int:
146
+ return int.from_bytes(b[off:off + n], "little")
147
+
148
+
149
+ def parse_report(raw: bytes) -> Report:
150
+ if len(raw) < REPORT_SIZE:
151
+ raise SNPError(f"report is {len(raw)} octets, expected {REPORT_SIZE}")
152
+ raw = raw[:REPORT_SIZE]
153
+ return Report(raw=raw, version=_u(raw, 0, 4), guest_svn=_u(raw, 4, 4), policy=_u(raw, 8, 8), vmpl=_u(raw, 0x30, 4),
154
+ signature_algo=_u(raw, 0x34, 4), current_tcb=_u(raw, 0x38, 8), platform_info=_u(raw, 0x40, 8),
155
+ flags=_u(raw, 0x48, 4), report_data=raw[0x50:0x90], measurement=raw[0x90:0xC0],
156
+ host_data=raw[0xC0:0xE0], id_key_digest=raw[0xE0:0x110], report_id=raw[0x140:0x160],
157
+ reported_tcb=_u(raw, 0x180, 8), chip_id=raw[0x1A0:0x1E0], committed_tcb=_u(raw, 0x1E0, 8),
158
+ launch_tcb=_u(raw, 0x1F0, 8), family_id=raw[0x10:0x20], image_id=raw[0x20:0x30],
159
+ author_key_digest=raw[0x110:0x140], launch_mit_vector=_u(raw, 0x1F8, 8) if _u(raw, 0, 4) >= 5 else 0,
160
+ current_mit_vector=_u(raw, 0x200, 8) if _u(raw, 0, 4) >= 5 else 0,
161
+ r=_u(raw, 0x2A0, 72), s=_u(raw, 0x2E8, 72))
162
+
163
+
164
+ def verify_report(rep: Report, leaf_der: bytes) -> None:
165
+ """ECDSA P-384 / SHA-384 over the signed body, under the VCEK or VLEK."""
166
+ if rep.signature_algo != 1:
167
+ raise SNPError(f"signature algorithm {rep.signature_algo}, expected 1 (ECDSA P-384 with SHA-384)")
168
+ try:
169
+ key = x509.load_der_x509_certificate(leaf_der).public_key()
170
+ except UNREADABLE as exc:
171
+ raise SNPError(f"the report key cannot be read: {exc}") from exc
172
+ if not isinstance(key, ec.EllipticCurvePublicKey) or key.curve.name != "secp384r1":
173
+ raise SNPError("the report key is not ECDSA P-384")
174
+ try:
175
+ key.verify(encode_dss_signature(rep.r, rep.s), rep.raw[:SIGNED], ec.ECDSA(hashes.SHA384()))
176
+ except InvalidSignature as exc:
177
+ raise SNPError("report signature does not verify") from exc
178
+
179
+
180
+ def tcb_parts(tcb: int, product: str) -> dict:
181
+ """TCB_VERSION decomposed by product layout (Milan/Genoa vs Turin and later)."""
182
+ if product in ("Milan", "Genoa"):
183
+ return {"blSPL": tcb & 0xFF, "teeSPL": tcb >> 8 & 0xFF, "snpSPL": tcb >> 48 & 0xFF, "ucodeSPL": tcb >> 56 & 0xFF}
184
+ return {"fmcSPL": tcb & 0xFF, "blSPL": tcb >> 8 & 0xFF, "teeSPL": tcb >> 16 & 0xFF, "snpSPL": tcb >> 24 & 0xFF,
185
+ "ucodeSPL": tcb >> 56 & 0xFF}
186
+
187
+
188
+ def tcb_at_least(tcb: dict, minimum: dict) -> bool:
189
+ """Every component at or above the minimum: TCB components are compared one by one, never as one integer."""
190
+ return all(tcb.get(k, -1) >= v for k, v in minimum.items())
191
+
192
+
193
+ KDS = "https://kdsintf.amd.com"
194
+
195
+
196
+ def crl_url(product: str, signer: str = "vcek") -> str:
197
+ return f"{KDS}/{signer}/v1/{product}/crl"
198
+
199
+
200
+ def fetch_crl(product: str, signer: str = "vcek", timeout: int = 20) -> bytes:
201
+ """AMD's CRL for the product's ASK (or ASVK), signed by the ARK. KDS rate-limits: fetch once per appraisal."""
202
+ import urllib.request
203
+ with urllib.request.urlopen(crl_url(product, signer), timeout=timeout) as r: # noqa: S310 - fixed https URL
204
+ return r.read()
205
+
206
+
207
+ def check_crl(crl_der: bytes, ask_der: bytes, ark_der: bytes, at: dt.datetime,
208
+ skew: dt.timedelta = dt.timedelta(minutes=5)) -> None:
209
+ """The CRL is the ARK's, current at ``at``, and does not list the ASK; SNPError otherwise."""
210
+ try:
211
+ crl = x509.load_der_x509_crl(crl_der)
212
+ ask, ark = x509.load_der_x509_certificate(ask_der), x509.load_der_x509_certificate(ark_der)
213
+ signed = crl.issuer == ark.subject and crl.is_signature_valid(ark.public_key())
214
+ except UNREADABLE as exc:
215
+ raise SNPError(f"CRL or certificates cannot be read: {exc}") from exc
216
+ if not signed:
217
+ raise SNPError("CRL not signed by the ARK")
218
+ if crl.last_update_utc > at + skew or (crl.next_update_utc is not None and at > crl.next_update_utc + skew):
219
+ raise SNPError(f"CRL not current at {at.isoformat()}")
220
+ if crl.get_revoked_certificate_by_serial_number(ask.serial_number) is not None:
221
+ raise SNPError("the ASK is revoked")