
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
pyattest provides a common interface that helps you verify attestations from either Google or Apple. The package works standalone but if you use django and need a full implementation with key generation and storage then django-dreiattest could be of interest for you.
pyattest is available on PyPI and can be installed via $ python -m pip install pyattest
In it's most basic form you can create either a GoogleConfig
, GooglePlayIntegrityApiConfig
or AppleConfig
instance, create an Attestation
and verify it.
The following parameters are important:
decryption_key
: A Base64 encoded AES key secret as described hereverification_key
: A Base64 encoded public key as described hereapk_package_name
: Name of your apkallow_non_play_distribution
: Set to true if you want to verify apps distributed via other means than Google Play (you need to set verify_code_signature_hex
) Note: should not be used for dev builds set production
to False
in that case instead.verify_code_signature_hex
: The sha256 hash of the signing identity you use for distributing your app. This can be obtained using ./gradlew signingReport
in your Android project.required_device_verdict
: If you want to require stronger integrity guarantees pass the corresponding key here.attest
: The jwt object string representing the attestation, which is a jws nested in a jwe objectnonce
: The nonce used to create the attestationconfig = GooglePlayIntegrityApiConfig(
decryption_key=[decryption_key],
verification_key=[decryption_key],
apk_package_name='ch.dreipol.demo',
production=True,
allow_non_play_distribution=True,
verify_code_signature_hex=["00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"],
required_device_verdict="MEETS_STRONG_INTEGRITY"
)
attestation = Attestation(attest, nonce, config)
try:
attestation.verify()
except PyAttestException as exception:
# Do your thing
pass
The following parameters are important:
key_id
: A Base64 encoded SHA-256 hash of your apps certificateapk_package_name
: Name of your apkproduction
: Ignores basic integrity and cts profile check if False
attest
: The jws object string representing the attestationnonce
: The nonce used to create the attestationconfig = GoogleConfig(key_ids=[key_id], apk_package_name='ch.dreipol.demo', production=True)
attestation = Attestation(attest, nonce, config)
try:
attestation.verify()
except PyAttestException as exception:
# Do your thing
pass
The following parameters are important:
key_id
: SHA-256 hash of the public key form the cert you got back from the attestationapp_id
: Your app’s App ID, which is the concatenation of your 10-digit team identifier, a period, and your app’s CFBundleIdentifier valueproduction
: Checks for the appropriate aaguid
attest
: The apple attestation as binarynonce
: The nonce used to create the attestationconfig = AppleConfig(key_id=key_id, app_id='1234ABCDEF.ch.dreipol.demo', production=True)
attestation = Attestation(attest, nonce, config)
try:
attestation.verify()
except PyAttestException as exception:
# Do your thing
pass
Once you verified and obtained a public key, you can use it to assert
further requests. For a full implementation on how to get to the public key check out django-dreiattest. To check if an assertion
is valid we check if it was signed with given pem_key
.
assertion
: Raw bytes of the assertion you want to testexpected_hash
: The hash we want to compare the signature againstpem_key
: The public key to verify the signatureconfig
: A AppleConfig
or GoogleConfig
instanceassertion = Assertion(assertion, expected_hash, pem_key, config)
assertion.verify()
FAQs
Unknown package
We found that pyattest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.