chore: import MCTF services

- Added all seven issued service trees without omissions.
- Preserved the supplied runtime configuration, binaries, and assets.
This commit is contained in:
TakuyaYagam1 committed 2026-11-29 12:25:29 +03:00
commit 13f936bee9
1222 files changed
+21280

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import base64
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import ec, padding, rsa
class UnsupportedKeyType(ValueError):
pass
def parse_public_key(pem):
if not isinstance(pem, str):
raise ValueError("PEM must be a string")
try:
key = serialization.load_pem_public_key(pem.encode("utf-8"))
except (ValueError, UnsupportedAlgorithm):
raise ValueError("Invalid PEM public key") from None
if isinstance(key, rsa.RSAPublicKey) and key.key_size >= 2048:
return key
if isinstance(key, ec.EllipticCurvePublicKey) and isinstance(key.curve, ec.SECP256R1):
return key
raise UnsupportedKeyType("Unsupported public key type")
def verify_implant_signature(public_key, signature, nonce):
try:
signed = base64.b64decode(signature, validate=True)
if isinstance(public_key, ec.EllipticCurvePublicKey):
public_key.verify(signed, nonce.encode("ascii"), ec.ECDSA(hashes.SHA256()))
else:
public_key.verify(signed, nonce.encode("ascii"), padding.PKCS1v15(), hashes.SHA256())
except (InvalidSignature, ValueError):
return False
return True