-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SPDX-FileCopyrightText: 2024 Tim Cocks | ||
# SPDX-License-Identifier: MIT | ||
""" | ||
This script can be used to generate a new key pair and output them as JSON. | ||
You can copy the JSON from serial console and paste it into a new file | ||
on the device and then use it with the rsa_json_keys.py example. | ||
""" | ||
import json | ||
import adafruit_rsa | ||
|
||
|
||
# Create a keypair | ||
print("Generating keypair...") | ||
(public_key, private_key) = adafruit_rsa.newkeys(512) | ||
|
||
|
||
print("public json:") | ||
print("-------------------------------") | ||
public_obj = {"public_key_arguments": [public_key.n, public_key.e]} | ||
print(json.dumps(public_obj)) | ||
print("-------------------------------") | ||
|
||
|
||
print("private json:") | ||
print("-------------------------------") | ||
private_obj = { | ||
"private_key_arguments": [ | ||
private_key.n, | ||
private_key.e, | ||
private_key.d, | ||
private_key.p, | ||
private_key.q, | ||
] | ||
} | ||
print(json.dumps(private_obj)) | ||
print("-------------------------------") |