|
1 | 1 | # Sources |
2 | | -Original repo : https://github.com/keygen-sh/example-python-cryptographic-machine-files |
3 | | - |
4 | | -# Example Python Cryptographic Machine Files |
5 | | - |
6 | | -This is an example of how to verify and decrypt [cryptographic machine files](https://keygen.sh/docs/api/cryptography/#cryptographic-lic) |
7 | | -in Python, using Ed25519 signing and AES-256-GCM encryption. This example |
8 | | -verifies the `aes-256-gcm+ed25519` algorithm. |
9 | | - |
10 | | -## Running the example |
11 | | - |
12 | | -First up, add an environment variable containing your Ed25519 public key: |
13 | | -```bash |
14 | | -export KEYGEN_PUBLIC_KEY='799efc7752286e6c3815b13358d98fc0f0b566764458adcb48f1be2c10a55906' |
15 | | -``` |
16 | | - |
17 | | -You can either run each line above within your terminal session before |
18 | | -starting the app, or you can add the above contents to your `~/.bashrc` |
19 | | -file and then run `source ~/.bashrc` after saving the file. |
20 | | - |
21 | | -Next, install dependencies with [`pip`](https://packaging.python.org/): |
22 | | - |
23 | | -``` |
24 | | -python3 -m pip install -r requirements.txt |
25 | | -``` |
26 | | - |
27 | | -Then run the script, passing in a `path` to a machine file, and a `license` |
28 | | -key as arguments: |
29 | | - |
30 | | -```bash |
31 | | -python3 main.py --license 'A_LICENSE_KEY' \ |
32 | | - --path /etc/keygen/machine.lic |
33 | | -``` |
34 | | - |
35 | | -Or run one of the pre-defined examples: |
36 | | - |
37 | | -```bash |
38 | | -KEYGEN_PUBLIC_KEY='e8601e48b69383ba520245fd07971e983d06d22c4257cfd82304601479cee788' python3 main.py \ |
39 | | - --fingerprint '198e9fe586114844f6a4eaca5069b41a7ed43fb5a2df84892b69826d64573e39' \ |
40 | | - --license 'B10760-1B177D-656D1F-C03298-9AF89E-V3' \ |
41 | | - --path examples/machine.lic |
42 | | -``` |
43 | | - |
44 | | -The following will happen: |
45 | | - |
46 | | -1. The current device will be fingerprinted, using a SHA256-HMAC digest of the |
47 | | - device's [machineid](https://github.com/keygen-sh/py-machineid). You may |
48 | | - want to look into alternative fingerprinting, depending on your expected |
49 | | - run environment. |
50 | | -1. The machine file's authenticity will be verified using Ed25519, by verifing |
51 | | - its signature using the public key. |
52 | | -1. The machine file will be decrypted using the license key and fingerprint |
53 | | - as the decryption key. |
54 | | - |
55 | | -If everything checks out, the script will print the decrypted contents of |
56 | | -the machine file — the machine object, with any included data. If it |
57 | | -fails, check your inputs. |
58 | | - |
59 | | -## Questions? |
60 | | - |
61 | | -Reach out at [support@keygen.sh](mailto:support@keygen.sh) if you have any |
62 | | -questions or concerns! |
| 2 | +Original repo : https://github.com/keygen-sh/example-python-cryptographic-machine-files |
0 commit comments